Introduce a convenience module for initialization
Common code for retrieving translations and GSettings schemas has been factored out into lib/convenience.js, which is part of every extension installation. Since that code relies on renames done at zip file creation time, extensions can no longer be installed with "make install". Instead, one should create the zip file and install it with the tweak-tool. There is also a bash script, local-install.sh, that will install everything in zip-files. Also, since the GSettingsSchemaSource code is not yet in a stable GLib release, extensions using GSettings have seen their stable shell version removed.
This commit is contained in:
@@ -2,6 +2,8 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
|
||||
|
||||
SUBDIRS = extensions po
|
||||
|
||||
EXTRA_DIST = lib/convenience.js
|
||||
|
||||
DISTCHECK_CONFIGURE_FLAGS = --enable-extensions=all
|
||||
|
||||
include include.mk
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
include $(top_srcdir)/include.mk
|
||||
|
||||
dist_extension_DATA = extension.js stylesheet.css
|
||||
nodist_extension_DATA = metadata.json $(EXTRA_EXTENSION)
|
||||
nodist_extension_DATA = metadata.json $(top_srcdir)/lib/convenience.js $(EXTRA_EXTENSION)
|
||||
|
||||
EXTRA_DIST = metadata.json.in
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ const Gettext = imports.gettext.domain('gnome-shell-extensions');
|
||||
const _ = Gettext.gettext;
|
||||
const N_ = function(e) { return e };
|
||||
|
||||
let settings;
|
||||
|
||||
const POPUP_DELAY_TIMEOUT = 150; // milliseconds
|
||||
|
||||
const SETTINGS_SCHEMA = 'org.gnome.shell.extensions.alternate-tab';
|
||||
@@ -328,9 +330,8 @@ AltTabSettingsDialog.prototype = {
|
||||
},
|
||||
|
||||
setBehaviour: function(behaviour) {
|
||||
this._settings = new Gio.Settings({ schema: SETTINGS_SCHEMA });
|
||||
this._settings.set_string(SETTINGS_BEHAVIOUR_KEY, behaviour);
|
||||
this._settings.set_boolean(SETTINGS_FIRST_TIME_KEY, false);
|
||||
settings.set_string(SETTINGS_BEHAVIOUR_KEY, behaviour);
|
||||
settings.set_boolean(SETTINGS_FIRST_TIME_KEY, false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -595,13 +596,12 @@ WindowList.prototype = {
|
||||
};
|
||||
|
||||
function init(metadata) {
|
||||
imports.gettext.bindtextdomain('gnome-shell-extensions', metadata.localedir);
|
||||
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
|
||||
me.convenience.initTranslations(metadata);
|
||||
settings = me.convenience.getSettings(metadata, 'alternate-tab');
|
||||
}
|
||||
|
||||
function doAltTab(shellwm, binding, mask, window, backwards) {
|
||||
let settings = new Gio.Settings({ schema: SETTINGS_SCHEMA });
|
||||
|
||||
|
||||
if(settings.get_boolean(SETTINGS_FIRST_TIME_KEY)) {
|
||||
new AltTabSettingsDialog().open();
|
||||
} else {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"name": "AlternateTab",
|
||||
"description": "A replacement for Alt-Tab, allows to cycle between windows and does not group by application",
|
||||
"original-authors": [ "jw@bargsten.org", "thomas.bouffon@gmail.com" ],
|
||||
"shell-version": [ "@shell_current@", "3.2" ],
|
||||
"shell-version": [ "@shell_current@" ],
|
||||
"localedir": "@LOCALEDIR@",
|
||||
"url": "@url@"
|
||||
}
|
||||
|
||||
@@ -99,7 +99,8 @@ function createSubMenu() {
|
||||
|
||||
// Put your extension initialization code here
|
||||
function init(metadata) {
|
||||
imports.gettext.bindtextdomain('gnome-shell-extensions', metadata.localedir);
|
||||
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
|
||||
me.convenience.initTranslations(metadata);
|
||||
}
|
||||
|
||||
function reset(statusMenu) {
|
||||
|
||||
@@ -14,13 +14,15 @@ const Main = imports.ui.main;
|
||||
const SETTINGS_SCHEMA = 'org.gnome.shell.extensions.auto-move-windows';
|
||||
const SETTINGS_KEY = 'application-list';
|
||||
|
||||
let settings;
|
||||
|
||||
function WindowMover() {
|
||||
this._init();
|
||||
}
|
||||
|
||||
WindowMover.prototype = {
|
||||
_init: function() {
|
||||
this._settings = new Gio.Settings({ schema: SETTINGS_SCHEMA });
|
||||
this._settings = settings;
|
||||
this._windowTracker = Shell.WindowTracker.get_default();
|
||||
|
||||
let display = global.screen.get_display();
|
||||
@@ -79,8 +81,10 @@ WindowMover.prototype = {
|
||||
let prevCheckWorkspaces;
|
||||
let winMover;
|
||||
|
||||
function init(extensionMeta) {
|
||||
// do nothing here
|
||||
function init(metadata) {
|
||||
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
|
||||
me.convenience.initTranslations(metadata);
|
||||
settings = me.convenience.getSettings(metadata, 'auto-move-windows');
|
||||
}
|
||||
|
||||
function enable() {
|
||||
@@ -159,4 +163,4 @@ function enable() {
|
||||
function disable() {
|
||||
Main._checkWorkspaces = prevCheckWorkspaces;
|
||||
winMover.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"uuid": "@uuid@",
|
||||
"name": "Auto Move Windows",
|
||||
"description": "Move applications to specific workspaces when they create windows",
|
||||
"shell-version": [ "@shell_current@", "3.2" ],
|
||||
"shell-version": [ "@shell_current@" ],
|
||||
"localedir": "@LOCALEDIR@",
|
||||
"original-authors": [ "alessandro.crismani@gmail.com", "thomas.bouffon@gmail.com" ],
|
||||
"url": "@url@"
|
||||
|
||||
@@ -33,6 +33,7 @@ const DOCK_HIDE_KEY = 'autohide';
|
||||
const DOCK_EFFECTHIDE_KEY = 'hide-effect';
|
||||
const DOCK_AUTOHIDE_ANIMATION_TIME_KEY = 'hide-effect-duration';
|
||||
|
||||
let _me, _metadata;
|
||||
|
||||
//hide
|
||||
//const autohide_animation_time = 0.3;
|
||||
@@ -340,7 +341,7 @@ Dock.prototype = {
|
||||
this._favorites = [];
|
||||
|
||||
// Load Settings
|
||||
this._settings = new Gio.Settings({ schema: DOCK_SETTINGS_SCHEMA });
|
||||
this._settings = _me.convenience.getSettings(_metadata, 'dock');
|
||||
position = this._settings.get_enum(DOCK_POSITION_KEY);
|
||||
dockicon_size = this._settings.get_int(DOCK_SIZE_KEY);
|
||||
hideDock = hideable = this._settings.get_boolean(DOCK_HIDE_KEY);
|
||||
@@ -934,8 +935,10 @@ DockIconMenu.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
function init(extensionMeta) {
|
||||
imports.gettext.bindtextdomain('gnome-shell-extensions', extensionMeta.localedir);
|
||||
function init(metadata) {
|
||||
_metadata = metadata;
|
||||
_me = imports.ui.extensionSystem.extensions[metadata.uuid];
|
||||
_me.convenience.initTranslations(metadata);
|
||||
}
|
||||
|
||||
let dock;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"name": "Dock",
|
||||
"description": "A dock for the GNOME Shell -- displays favorite and running applications",
|
||||
"original-author": "tclaesson@gmail.com",
|
||||
"shell-version": [ "@shell_current@", "3.2" ],
|
||||
"shell-version": [ "@shell_current@" ],
|
||||
"localedir": "@LOCALEDIR@",
|
||||
"url": "@url@"
|
||||
}
|
||||
|
||||
@@ -91,7 +91,8 @@ DriveMenu.prototype = {
|
||||
|
||||
// Put your extension initialization code here
|
||||
function init(metadata) {
|
||||
imports.gettext.bindtextdomain('gnome-shell-extensions', metadata.localedir);
|
||||
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
|
||||
me.convenience.initTranslations(metadata);
|
||||
}
|
||||
|
||||
let _indicator;
|
||||
|
||||
@@ -19,7 +19,8 @@ function _showHello() {
|
||||
function init(metadata) {
|
||||
log ('Example extension initalized');
|
||||
|
||||
imports.gettext.bindtextdomain('gnome-shell-extensions', metadata.localedir);
|
||||
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
|
||||
me.convenience.initTranslations(metadata);
|
||||
}
|
||||
|
||||
let signalId;
|
||||
@@ -38,4 +39,4 @@ function disable() {
|
||||
Main.panel.actor.disconnect(signalId);
|
||||
signalId = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ const WindowPlacementStrategy = {
|
||||
GRID: 1,
|
||||
};
|
||||
|
||||
let _me, _metadata;
|
||||
|
||||
// testing settings for natural window placement strategy:
|
||||
const WINDOW_PLACEMENT_NATURAL_FILLGAPS = true; // enlarge windows at the end to fill gaps // not implemented yet
|
||||
const WINDOW_PLACEMENT_NATURAL_GRID_FALLBACK = true; // fallback to grid mode if all windows have the same size and positions. // not implemented yet
|
||||
@@ -117,7 +119,7 @@ function resetState() {
|
||||
function enable() {
|
||||
resetState();
|
||||
|
||||
let settings = new Gio.Settings({ schema: 'org.gnome.shell.extensions.native-window-placement' });
|
||||
let settings = _me.convenience.getSettings(_metadata, 'native-window-placement');
|
||||
let placementStrategy = settings.get_enum('strategy');
|
||||
let signalId = settings.connect('changed::strategy', function() {
|
||||
placementStrategy = settings.get_enum('strategy');
|
||||
@@ -527,6 +529,7 @@ function disable() {
|
||||
resetState();
|
||||
}
|
||||
|
||||
function init() {
|
||||
/* do nothing */
|
||||
}
|
||||
function init(metadata) {
|
||||
_metadata = metadata;
|
||||
_me = imports.ui.extensionSystem.extensions[metadata.uuid];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"uuid": "@uuid@",
|
||||
"name": "Native Window Placement",
|
||||
"description": "Arrange windows in overview in a more native way",
|
||||
"shell-version": [ "@shell_current@", "3.2" ],
|
||||
"shell-version": [ "@shell_current@" ],
|
||||
"localedir": "@LOCALEDIR@",
|
||||
"url": "@url@",
|
||||
"original-authors": [ "wepmaschda@gmx.de" ]
|
||||
|
||||
@@ -114,7 +114,8 @@ PlacesMenu.prototype = {
|
||||
|
||||
|
||||
function init(metadata) {
|
||||
imports.gettext.bindtextdomain('gnome-shell-extensions', metadata.localedir);
|
||||
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
|
||||
me.convenience.initTranslations(metadata);
|
||||
}
|
||||
|
||||
let _indicator;
|
||||
|
||||
@@ -10,15 +10,16 @@ const SETTINGS_SCHEMA = 'org.gnome.shell.extensions.user-theme';
|
||||
const SETTINGS_KEY = 'name';
|
||||
|
||||
function ThemeManager() {
|
||||
this._init();
|
||||
this._init.apply(this, arguments);
|
||||
}
|
||||
|
||||
ThemeManager.prototype = {
|
||||
_init: function() {
|
||||
_init: function(metadata) {
|
||||
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
|
||||
this._settings = me.convenience.getSettings(metadata, 'user-theme');
|
||||
},
|
||||
|
||||
enable: function() {
|
||||
this._settings = new Gio.Settings({ schema: SETTINGS_SCHEMA });
|
||||
this._changedId = this._settings.connect('changed::'+SETTINGS_KEY, Lang.bind(this, this._changeTheme));
|
||||
this._changeTheme();
|
||||
},
|
||||
@@ -68,5 +69,5 @@ ThemeManager.prototype = {
|
||||
|
||||
|
||||
function init(metadata) {
|
||||
return new ThemeManager();
|
||||
return new ThemeManager(metadata);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"uuid": "@uuid@",
|
||||
"name": "User Themes",
|
||||
"description": "Load shell themes from user directory",
|
||||
"shell-version": [ "@shell_current@", "3.2" ],
|
||||
"shell-version": [ "@shell_current@" ],
|
||||
"localedir": "@LOCALEDIR@",
|
||||
"original-authors": [ "john.stowers@gmail.com" ],
|
||||
"url": "@url@"
|
||||
|
||||
@@ -137,7 +137,8 @@ Indicator.prototype = {
|
||||
|
||||
|
||||
function init(metadata) {
|
||||
imports.gettext.bindtextdomain('gnome-shell-extensions', metadata.localedir);
|
||||
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
|
||||
me.convenience.initTranslations(metadata);
|
||||
}
|
||||
|
||||
let _indicator;
|
||||
@@ -149,4 +150,4 @@ function enable() {
|
||||
|
||||
function disable() {
|
||||
_indicator.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
const Gettext = imports.gettext;
|
||||
const Gio = imports.gi.Gio;
|
||||
|
||||
function initTranslations(metadata) {
|
||||
let localeDir = metadata.dir.get_child('locale').get_path();
|
||||
Gettext.bindtextdomain('gnome-shell-extensions', localeDir);
|
||||
}
|
||||
|
||||
function getSettings(metadata, extension_id) {
|
||||
let schemaDir = metadata.dir.get_child('schemas').get_path();
|
||||
let schemaSource = Gio.SettingsSchemaSource.new_from_directory(schemaDir,
|
||||
Gio.SettingsSchemaSource.get_default(),
|
||||
false);
|
||||
let schema = schemaSource.lookup('org.gnome.shell.extensions.' + extension_id, false);
|
||||
return new Gio.Settings({ settings_schema: schema });
|
||||
}
|
||||
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
extensionbase=~/.local/share/gnome-shell/extensions
|
||||
|
||||
for i in zip-files/*; do
|
||||
zip_file=`pwd`/$i;
|
||||
uuid=`basename $i | sed -e "s/.shell-extension.zip//"`;
|
||||
if [ -d $extensionbase/$uuid ]; then
|
||||
rm -fR $extensionbase/$uuid;
|
||||
fi
|
||||
mkdir $extensionbase/$uuid;
|
||||
(cd $extensionbase/$uuid;
|
||||
unzip -q $zip_file;
|
||||
);
|
||||
done
|
||||
Reference in New Issue
Block a user