mirror of
https://github.com/morgan9e/dash-to-panel
synced 2026-04-14 00:04:17 +09:00
Drop convenience functions
This commit is contained in:
2
Makefile
2
Makefile
@@ -2,7 +2,7 @@
|
||||
|
||||
UUID = dash-to-panel@jderose9.github.com
|
||||
BASE_MODULES = extension.js stylesheet.css metadata.json COPYING README.md
|
||||
EXTRA_MODULES = appIcons.js convenience.js panel.js panelManager.js proximity.js intellihide.js progress.js panelPositions.js panelSettings.js panelStyle.js overview.js taskbar.js transparency.js windowPreview.js prefs.js utils.js Settings.ui
|
||||
EXTRA_MODULES = appIcons.js panel.js panelManager.js proximity.js intellihide.js progress.js panelPositions.js panelSettings.js panelStyle.js overview.js taskbar.js transparency.js windowPreview.js prefs.js utils.js Settings.ui
|
||||
EXTRA_IMAGES = highlight_stacked_bg.svg highlight_stacked_bg_2.svg highlight_stacked_bg_3.svg
|
||||
|
||||
TOLOCALIZE = prefs.js appIcons.js
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Dash-To-Panel extension for Gnome 3
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
* Credits:
|
||||
* This file is based on code from the Dash to Dock extension by micheleg
|
||||
* and code from the Taskbar extension by Zorin OS
|
||||
* Some code was also adapted from the upstream Gnome Shell source code.
|
||||
*/
|
||||
|
||||
const Config = imports.misc.config;
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
const Gettext = imports.gettext;
|
||||
const Gio = imports.gi.Gio;
|
||||
|
||||
/**
|
||||
* initTranslations:
|
||||
* @domain: (optional): the gettext domain to use
|
||||
*
|
||||
* Initialize Gettext to load translations from extensionsdir/locale.
|
||||
* If @domain is not provided, it will be taken from metadata['gettext-domain']
|
||||
*/
|
||||
function initTranslations(domain) {
|
||||
let extension = ExtensionUtils.getCurrentExtension();
|
||||
|
||||
domain = domain || extension.metadata['gettext-domain'];
|
||||
|
||||
// Check if this extension was built with "make zip-file", and thus
|
||||
// has the locale files in a subfolder
|
||||
// otherwise assume that extension has been installed in the
|
||||
// same prefix as gnome-shell
|
||||
let localeDir = extension.dir.get_child('locale');
|
||||
if (localeDir.query_exists(null))
|
||||
Gettext.bindtextdomain(domain, localeDir.get_path());
|
||||
else
|
||||
Gettext.bindtextdomain(domain, Config.LOCALEDIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* getSettings:
|
||||
* @schema: (optional): the GSettings schema id
|
||||
*
|
||||
* Builds and return a GSettings schema for @schema, using schema files
|
||||
* in extensionsdir/schemas. If @schema is not provided, it is taken from
|
||||
* metadata['settings-schema'].
|
||||
*/
|
||||
function getSettings(schema) {
|
||||
let extension = ExtensionUtils.getCurrentExtension();
|
||||
|
||||
schema = schema || extension.metadata['settings-schema'];
|
||||
|
||||
const GioSSS = Gio.SettingsSchemaSource;
|
||||
|
||||
// Check if this extension was built with "make zip-file", and thus
|
||||
// has the schema files in a subfolder
|
||||
// otherwise assume that extension has been installed in the
|
||||
// same prefix as gnome-shell (and therefore schemas are available
|
||||
// in the standard folders)
|
||||
let schemaDir = extension.dir.get_child('schemas');
|
||||
let schemaSource;
|
||||
if (schemaDir.query_exists(null))
|
||||
schemaSource = GioSSS.new_from_directory(schemaDir.get_path(),
|
||||
GioSSS.get_default(),
|
||||
false);
|
||||
else
|
||||
schemaSource = GioSSS.get_default();
|
||||
|
||||
let schemaObj = schemaSource.lookup(schema, true);
|
||||
if (!schemaObj)
|
||||
throw new Error('Schema ' + schema + ' could not be found for extension '
|
||||
+ extension.metadata.uuid + '. Please check your installation.');
|
||||
|
||||
return new Gio.Settings({
|
||||
settings_schema: schemaObj
|
||||
});
|
||||
}
|
||||
@@ -30,7 +30,6 @@ const Mainloop = imports.mainloop;
|
||||
const Signals = imports.signals;
|
||||
|
||||
const Me = ExtensionUtils.getCurrentExtension();
|
||||
const Convenience = Me.imports.convenience;
|
||||
const { PanelManager } = Me.imports.panelManager;
|
||||
const Utils = Me.imports.utils;
|
||||
const AppIcons = Me.imports.appIcons;
|
||||
@@ -45,7 +44,7 @@ let extensionSystem = (Main.extensionManager || imports.ui.extensionSystem);
|
||||
function init() {
|
||||
this._realHasOverview = Main.sessionMode.hasOverview;
|
||||
|
||||
Convenience.initTranslations(Utils.TRANSLATION_DOMAIN);
|
||||
ExtensionUtils.initTranslations(Utils.TRANSLATION_DOMAIN);
|
||||
|
||||
//create an object that persists until gnome-shell is restarted, even if the extension is disabled
|
||||
Me.persistentStorage = {};
|
||||
@@ -89,8 +88,8 @@ function _enable() {
|
||||
|
||||
if (panelManager) return; //already initialized
|
||||
|
||||
Me.settings = Convenience.getSettings('org.gnome.shell.extensions.dash-to-panel');
|
||||
Me.desktopSettings = Convenience.getSettings('org.gnome.desktop.interface');
|
||||
Me.settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.dash-to-panel');
|
||||
Me.desktopSettings = ExtensionUtils.getSettings('org.gnome.desktop.interface');
|
||||
|
||||
Main.layoutManager.startInOverview = !Me.settings.get_boolean('hide-overview-on-startup');
|
||||
|
||||
|
||||
6
prefs.js
6
prefs.js
@@ -29,7 +29,7 @@ const Gdk = imports.gi.Gdk;
|
||||
const Mainloop = imports.mainloop;
|
||||
|
||||
const Me = imports.misc.extensionUtils.getCurrentExtension();
|
||||
const Convenience = Me.imports.convenience;
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']);
|
||||
const _ = Gettext.gettext;
|
||||
const N_ = function(e) { return e };
|
||||
@@ -158,7 +158,7 @@ function mergeObjects(main, bck) {
|
||||
const Preferences = class {
|
||||
|
||||
constructor() {
|
||||
this._settings = Convenience.getSettings('org.gnome.shell.extensions.dash-to-panel');
|
||||
this._settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.dash-to-panel');
|
||||
this._rtl = (Gtk.Widget.get_default_direction() == Gtk.TextDirection.RTL);
|
||||
this._builder = new Gtk.Builder();
|
||||
this._builder.set_scope(new BuilderScope(this));
|
||||
@@ -2455,7 +2455,7 @@ const BuilderScope = GObject.registerClass({
|
||||
});
|
||||
|
||||
function init() {
|
||||
Convenience.initTranslations();
|
||||
ExtensionUtils.initTranslations();
|
||||
}
|
||||
|
||||
function fillPreferencesWindow(window) {
|
||||
|
||||
Reference in New Issue
Block a user