Compare commits

...

8 Commits
3.3.4 ... 3.3.5

Author SHA1 Message Date
Giovanni Campagna
b6f4ed7013 Bump version to 3.3.5
To go along GNOME Shell 3.3.5
2012-02-10 15:21:01 +01:00
Giovanni Campagna
9b6374881d all: port to the new class framework
A long due update, since this was merged in gjs and core shell.
We no longer need to mess with __proto__ and prototype, and can
use decent syntax for true object oriented programming.
(This affects all except xrandr-indicator, since I want to port
that to GDBus too, using the new bindings right from the start)
2012-02-10 15:16:46 +01:00
Giovanni Campagna
2388b8738f dock: refactor and clean up code
Modified to avoid global settings variables, that were updated
unpredictably. Removed the inital show effect and placing the dock
at primary.y at startup (causing a big and often unexpected jump).
Ported to the new class framework, which should mean cleaner code.
2012-02-10 15:16:16 +01:00
Giovanni Campagna
775bd5a86a alternate-tab: shuffle and update code around a bit
Mode selection was cleaned up, settings dialog was moved to a
separate file (in preparation for GTK replacement), all classes
were moved to Lang.Class. No big code changes though.
2012-02-09 18:43:29 +01:00
Giovanni Campagna
3630228cac all: port to the new convienence module
Retrieve Convenience from the extension helper object (Me), and
pass no arguments to initTranslations and getSettings (since the
metadata has all that is required)
2012-02-09 18:43:28 +01:00
Giovanni Campagna
7517d8ab6a convenience: update for the new extension API
Extension helper and metadata are now different objects, so the
first needs be retrieved from ExtensionUtils.
Also, reduce the number of required arguments (by using the new
metadata keys) and make generic enough for usage by other extensions.
Includes documentation.
2012-02-09 18:43:25 +01:00
Giovanni Campagna
9ebfd1f495 build system: factor out setting schema generation
Introduce a common settings.mk file, which is included in extensions
that need GSettings, to ensure that conventions are respected, and
necessary fixes can be applied from one place.
2012-02-08 18:01:00 +01:00
Giovanni Campagna
dfca68062c build system: add additional automatic metadata
Add "gettext-domain", "extension-id" (containing the base part of the
UUID) and "gschemabase" (which, combined with "extension-id", gives
the GSettings schema) to metadata.json, autogenerated by the build
system.
2012-02-08 18:00:56 +01:00
40 changed files with 781 additions and 805 deletions

10
NEWS
View File

@@ -1,3 +1,13 @@
3.3.5
=====
* improvements to the build system and convenience module,
making it easier for other extensions to use, and bringing
it up to date with gnome-shell changes
* all extensions were ported to the Lang.Class framework
(except xrandr-indicator, which is pending GDBus merge)
* alternate-tab and dock were slightly refactored to clean up
some old code
3.3.4
=====
* improved styling of windowsNavigator tooltips

View File

@@ -1,5 +1,5 @@
AC_PREREQ(2.63)
AC_INIT([gnome-shell-extensions],[3.3.4],[https://bugzilla.gnome.org/enter_bug.cgi?product=gnome-shell&component=extensions])
AC_INIT([gnome-shell-extensions],[3.3.5],[https://bugzilla.gnome.org/enter_bug.cgi?product=gnome-shell&component=extensions])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([config])

View File

@@ -1,13 +1,18 @@
include $(top_srcdir)/include.mk
dist_extension_DATA = extension.js stylesheet.css
dist_extension_DATA = extension.js stylesheet.css $(EXTRA_MODULES)
nodist_extension_DATA = metadata.json $(top_srcdir)/lib/convenience.js $(EXTRA_EXTENSION)
EXTRA_DIST = metadata.json.in
metadata.json: metadata.json.in $(top_builddir)/config.status
$(AM_V_GEN) sed -e "s|[@]uuid@|$(uuid)|" \
$(AM_V_GEN) sed \
-e "s|[@]extension_id@|$(EXTENSION_ID)|" \
-e "s|[@]uuid@|$(uuid)|" \
-e "s|[@]gschemaname@|$(gschemaname)|" \
-e "s|[@]gettext_domain@|$(GETTEXT_PACKAGE)|" \
-e "s|[@]shell_current@|$(PACKAGE_VERSION)|" \
-e "s|[@]url@|$(extensionurl)|" $< > $@
-e "s|[@]url@|$(extensionurl)|" \
$< > $@
CLEANFILES = metadata.json

View File

@@ -1,14 +1,6 @@
EXTENSION_ID = alternate-tab
EXTRA_MODULES = settings.js
include ../../extension.mk
gschemas_in = $(gschemabase).alternate-tab.gschema.xml.in
@INTLTOOL_XML_NOMERGE_RULE@
gsettings_SCHEMAS = $(gschemas_in:.xml.in=.xml)
@GSETTINGS_RULES@
CLEANFILES += $(gschemas_in:.xml.in=.valid) $(gsettings_SCHEMAS)
EXTRA_DIST += $(gschemas_in)
include ../../settings.mk

View File

@@ -25,57 +25,21 @@ const Gettext = imports.gettext.domain('gnome-shell-extensions');
const _ = Gettext.gettext;
const N_ = function(e) { return e };
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const Settings = Me.imports.settings;
let settings;
const POPUP_DELAY_TIMEOUT = 150; // milliseconds
const SETTINGS_SCHEMA = 'org.gnome.shell.extensions.alternate-tab';
const SETTINGS_BEHAVIOUR_KEY = 'behaviour';
const SETTINGS_FIRST_TIME_KEY = 'first-time';
const MODES = {
all_thumbnails: function(display, binding, mask, window, backwards) {
let tabPopup = new AltTabPopup2();
if (!tabPopup.show(backwards, binding, mask))
tabPopup.destroy();
},
workspace_icons: function(display, binding, mask, window, backwards) {
if (Main.wm._workspaceSwitcherPopup)
Main.wm._workspaceSwitcherPopup.actor.hide();
let tabPopup = new AltTabPopupW();
if (!tabPopup.show(backwards, binding, mask))
tabPopup.destroy();
}
};
const MESSAGE = N_("This is the first time you use the Alternate Tab extension. \n\
Please choose your preferred behaviour:\n\
\n\
All & Thumbnails:\n\
This mode presents all applications from all workspaces in one selection \n\
list. Instead of using the application icon of every window, it uses small \n\
thumbnails resembling the window itself. \n\
\n\
Workspace & Icons:\n\
This mode let's you switch between the applications of your current \n\
workspace and gives you additionally the option to switch to the last used \n\
application of your previous workspace. This is always the last symbol in \n\
the list and is segregated by a separator/vertical line if available. \n\
Every window is represented by its application icon. \n\
\n\
If you whish to revert to the default behavior for the Alt-Tab switcher, just\n\
disable the extension from extensions.gnome.org or the Advanced Settings application.\
");
function AltTabPopupW() {
this._init();
}
AltTabPopupW.prototype = {
__proto__ : AltTab.AltTabPopup.prototype,
const AltTabPopupWorkspaceIcons = new Lang.Class({
Name: 'AlternateTab.AltTabPopupWorkspaceIcons',
Extends: AltTab.AltTabPopup,
_windowActivated : function(thumbnailList, n) { },
@@ -165,14 +129,11 @@ AltTabPopupW.prototype = {
this.destroy();
}
};
});
function AppIcon(app, window) {
this._init(app, window);
}
AppIcon.prototype = {
__proto__ : AltTab.AppIcon.prototype,
const AppIcon = new Lang.Class({
Name: 'AlternateTab.AppIcon',
Extends: AltTab.AppIcon,
_init: function(app, window) {
this.app = app;
@@ -199,16 +160,16 @@ AppIcon.prototype = {
this.actor.add(this.label, { x_fill: false });
}
}
};
});
function WindowSwitcher(apps, altTabPopup) {
this._init(apps, altTabPopup);
}
WindowSwitcher.prototype = {
__proto__ : AltTab.AppSwitcher.prototype,
const WindowSwitcher = new Lang.Class({
Name: 'AlternateTab.WindowSwitcher',
Extends: AltTab.AppSwitcher,
_init : function(apps, altTabPopup) {
// Horrible HACK!
// We inherit from AltTab.AppSwitcher, but only chain up to
// AltTab.SwitcherList._init, to bypass AltTab.AppSwitcher._init
AltTab.SwitcherList.prototype._init.call(this, true);
// Construct the AppIcons, sort by time, add to the popup
@@ -268,81 +229,11 @@ WindowSwitcher.prototype = {
if (t2 > t1) return 1;
else return -1;
}
};
});
function AltTabSettingsDialog() {
this._init();
}
AltTabSettingsDialog.prototype = {
__proto__: ModalDialog.ModalDialog.prototype,
_init : function() {
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: null });
let mainContentBox = new St.BoxLayout({ style_class: 'polkit-dialog-main-layout',
vertical: false });
this.contentLayout.add(mainContentBox,
{ x_fill: true,
y_fill: true });
let messageBox = new St.BoxLayout({ style_class: 'polkit-dialog-message-layout',
vertical: true });
mainContentBox.add(messageBox,
{ y_align: St.Align.START });
this._subjectLabel = new St.Label({ style_class: 'polkit-dialog-headline',
text: _("Alt Tab Behaviour") });
messageBox.add(this._subjectLabel,
{ y_fill: false,
y_align: St.Align.START });
this._descriptionLabel = new St.Label({ style_class: 'polkit-dialog-description',
text: Gettext.gettext(MESSAGE) });
messageBox.add(this._descriptionLabel,
{ y_fill: true,
y_align: St.Align.START });
this.setButtons([
{
label: _("All & Thumbnails"),
action: Lang.bind(this, function() {
this.setBehaviour('all_thumbnails');
this.close();
})
},
{
label: _("Workspace & Icons"),
action: Lang.bind(this, function() {
this.setBehaviour('workspace_icons');
this.close();
})
},
{
label: _("Cancel"),
action: Lang.bind(this, function() {
this.close();
}),
key: Clutter.Escape
}
]);
},
setBehaviour: function(behaviour) {
settings.set_string(SETTINGS_BEHAVIOUR_KEY, behaviour);
settings.set_boolean(SETTINGS_FIRST_TIME_KEY, false);
}
};
function AltTabPopup2() {
this._init();
}
AltTabPopup2.prototype = {
__proto__ : AltTab.AltTabPopup.prototype,
const AltTabPopupAllThumbnails = new Lang.Class({
Name: 'AlternateTab.AltTabPopup.AllThumbnails',
Extends: AltTab.AltTabPopup,
_init : function() {
this.actor = new Shell.GenericContainer({ name: 'altTabPopup',
@@ -465,54 +356,6 @@ AltTabPopup2.prototype = {
return true
},
/*
_keyPressEvent : function(actor, event) {
let keysym = event.get_key_symbol();
let shift = (Shell.get_event_state(event) & Clutter.ModifierType.SHIFT_MASK);
// X allows servers to represent Shift+Tab in two different ways
if (shift && keysym == Clutter.Tab)
keysym = Clutter.ISO_Left_Tab;
this._disableHover();
if (keysym == Clutter.grave)
this._select(this._currentApp, this._nextWindow());
else if (keysym == Clutter.asciitilde)
this._select(this._currentApp, this._previousWindow());
else if (keysym == Clutter.Escape)
this.destroy();
else if (this._thumbnailsFocused) {
if (keysym == Clutter.Tab) {
if (this._currentWindow == this._appIcons[this._currentApp].cachedWindows.length - 1)
this._select(this._nextApp());
else
this._select(this._currentApp, this._nextWindow());
} else if (keysym == Clutter.ISO_Left_Tab) {
if (this._currentWindow == 0 || this._currentWindow == -1)
this._select(this._previousApp());
else
this._select(this._currentApp, this._previousWindow());
} else if (keysym == Clutter.Left)
this._select(this._currentApp, this._previousWindow());
else if (keysym == Clutter.Right)
this._select(this._currentApp, this._nextWindow());
else if (keysym == Clutter.Up)
this._select(this._currentApp, null, true);
} else {
if (keysym == Clutter.Tab)
this._select(this._nextApp());
else if (keysym == Clutter.ISO_Left_Tab)
this._select(this._previousApp());
else if (keysym == Clutter.Left)
this._select(this._previousApp());
else if (keysym == Clutter.Right)
this._select(this._nextApp());
}
return true;
},
*/
_sortWindows : function(win1,win2) {
let t1 = win1.get_user_time();
let t2 = win2.get_user_time();
@@ -531,17 +374,14 @@ AltTabPopup2.prototype = {
Main.activateWindow(app.cachedWindows[0]);
this.destroy();
},
};
});
function WindowList(windows) {
this._init(windows);
}
WindowList.prototype = {
__proto__ : AltTab.SwitcherList.prototype,
const WindowList = new Lang.Class({
Name: 'AlternateTab.WindowList',
Extends: AltTab.SwitcherList,
_init : function(windows) {
AltTab.SwitcherList.prototype._init.call(this, true);
this.parent(true);
let activeWorkspace = global.screen.get_active_workspace();
this._labels = new Array();
@@ -595,25 +435,41 @@ WindowList.prototype = {
addSeparator: function () {
this._separator=null;
}
};
});
function init(metadata) {
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
me.convenience.initTranslations(metadata);
settings = me.convenience.getSettings(metadata, 'alternate-tab');
}
const MODES = {
all_thumbnails: AltTabPopupAllThumbnails,
workspace_icons: AltTabPopupWorkspaceIcons,
};
function doAltTab(display, screen, window, binding) {
if(settings.get_boolean(SETTINGS_FIRST_TIME_KEY)) {
new AltTabSettingsDialog().open();
} else {
let behaviour = settings.get_string(SETTINGS_BEHAVIOUR_KEY);
if(behaviour in MODES) {
let modifiers = binding.get_modifiers()
let backwards = modifiers & Meta.VirtualModifier.SHIFT_MASK;
MODES[behaviour](display, binding.get_name(), binding.get_mask(), window, backwards);
}
let dialog = new Settings.AltTabSettingsDialog(settings);
dialog.open();
return;
}
let behaviour = settings.get_string(SETTINGS_BEHAVIOUR_KEY);
// alt-tab having no effect is unexpected, even with wrong settings
if (!(behaviour in MODES))
behaviour = 'all_thumbnails';
if (Main.wm._workspaceSwitcherPopup)
Main.wm._workspaceSwitcherPopup.actor.hide();
let modifiers = binding.get_modifiers()
let backwards = modifiers & Meta.VirtualModifier.SHIFT_MASK;
let constructor = MODES[behaviour];
let popup = new constructor();
if (!popup.show(backwards, binding.get_name(), binding.get_mask()))
popup.destroy();
}
function init(metadata) {
Convenience.initTranslations();
settings = Convenience.getSettings();
}
function enable() {

View File

@@ -1,5 +1,8 @@
{
"extension-id": "@extension_id@",
"uuid": "@uuid@",
"settings-schema": "@gschemaname@",
"gettext-domain": "@gettext_domain@",
"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" ],

View File

@@ -0,0 +1,113 @@
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
/* most of the code is borrowed from
* > js/ui/altTab.js <
* of the gnome-shell source code
*/
const Clutter = imports.gi.Clutter;
const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
const AltTab = imports.ui.altTab;
const Main = imports.ui.main;
const ModalDialog = imports.ui.modalDialog;
const Tweener = imports.ui.tweener;
const WindowManager = imports.ui.windowManager;
const Gettext = imports.gettext.domain('gnome-shell-extensions');
const _ = Gettext.gettext;
const N_ = function(e) { return e };
const SETTINGS_BEHAVIOUR_KEY = 'behaviour';
const SETTINGS_FIRST_TIME_KEY = 'first-time';
const MESSAGE = N_("This is the first time you use the Alternate Tab extension. \n\
Please choose your preferred behaviour:\n\
\n\
All & Thumbnails:\n\
This mode presents all applications from all workspaces in one selection \n\
list. Instead of using the application icon of every window, it uses small \n\
thumbnails resembling the window itself. \n\
\n\
Workspace & Icons:\n\
This mode let's you switch between the applications of your current \n\
workspace and gives you additionally the option to switch to the last used \n\
application of your previous workspace. This is always the last symbol in \n\
the list and is segregated by a separator/vertical line if available. \n\
Every window is represented by its application icon. \n\
\n\
If you whish to revert to the default behavior for the Alt-Tab switcher, just\n\
disable the extension from extensions.gnome.org or the Advanced Settings application.\
");
const AltTabSettingsDialog = new Lang.Class({
Name: 'AlternateTab.Settings.AltTabSettingsDialog',
Extends: ModalDialog.ModalDialog,
_init : function(settings) {
this.settings = settings;
this.parent({ styleClass: null });
let mainContentBox = new St.BoxLayout({ style_class: 'polkit-dialog-main-layout',
vertical: false });
this.contentLayout.add(mainContentBox,
{ x_fill: true,
y_fill: true });
let messageBox = new St.BoxLayout({ style_class: 'polkit-dialog-message-layout',
vertical: true });
mainContentBox.add(messageBox,
{ y_align: St.Align.START });
this._subjectLabel = new St.Label({ style_class: 'polkit-dialog-headline',
text: _("Alt Tab Behaviour") });
messageBox.add(this._subjectLabel,
{ y_fill: false,
y_align: St.Align.START });
this._descriptionLabel = new St.Label({ style_class: 'polkit-dialog-description',
text: Gettext.gettext(MESSAGE) });
messageBox.add(this._descriptionLabel,
{ y_fill: true,
y_align: St.Align.START });
this.setButtons([
{
label: _("All & Thumbnails"),
action: Lang.bind(this, function() {
this.setBehaviour('all_thumbnails');
this.close();
})
},
{
label: _("Workspace & Icons"),
action: Lang.bind(this, function() {
this.setBehaviour('workspace_icons');
this.close();
})
},
{
label: _("Cancel"),
action: Lang.bind(this, function() {
this.close();
}),
key: Clutter.Escape
}
]);
},
setBehaviour: function(behaviour) {
this.settings.set_string(SETTINGS_BEHAVIOUR_KEY, behaviour);
this.settings.set_boolean(SETTINGS_FIRST_TIME_KEY, false);
}
});

View File

@@ -7,6 +7,10 @@ const PopupMenu = imports.ui.popupMenu;
const Gettext = imports.gettext.domain('gnome-shell-extensions');
const _ = Gettext.gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
let suspend_item = null;
let hibernate_item = null;
let poweroff_item = null;
@@ -36,17 +40,9 @@ function onHibernateActivate(item) {
}));
}
function createSubMenu() {
}
// Put your extension initialization code here
function init(metadata) {
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
me.convenience.initTranslations(metadata);
}
function resetMenu() {
Convenience.initTranslations();
}
function enable() {

View File

@@ -1,5 +1,8 @@
{
"extension-id": "@extension_id@",
"uuid": "@uuid@",
"settings-schema": "@gschemaname@",
"gettext-domain": "@gettext_domain@",
"name": "Alternative Status Menu",
"description": "Replaces GNOME Shell Status Menu with one showing Suspend/Hibernate and Power Off as separate items",
"shell-version": [ "@shell_current@" ],

View File

@@ -10,17 +10,13 @@ const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const ICON_SIZE = 28;
let appsys = Shell.AppSystem.get_default();
function AppMenuItem() {
this._init.apply(this, arguments);
}
AppMenuItem.prototype = {
__proto__: PopupMenu.PopupBaseMenuItem.prototype,
const AppMenuItem = new Lang.Class({
Name: 'AppsMenu.AppMenuItem',
Extends: PopupMenu.PopupBaseMenuItem,
_init: function (app, params) {
PopupMenu.PopupBaseMenuItem.prototype._init.call(this, params);
this.parent(params);
this._app = app;
this.label = new St.Label({ text: app.get_name() });
@@ -32,30 +28,36 @@ AppMenuItem.prototype = {
activate: function (event) {
this._app.activate_full(-1, event.get_time());
PopupMenu.PopupBaseMenuItem.prototype.activate.call(this, event);
this.parent(event);
}
};
});
function ApplicationsButton() {
this._init();
}
ApplicationsButton.prototype = {
__proto__: PanelMenu.SystemStatusButton.prototype,
const ApplicationsButton = new Lang.Class({
Name: 'AppsMenu.ApplicationsButton',
Extends: PanelMenu.SystemStatusButton,
_init: function() {
PanelMenu.SystemStatusButton.prototype._init.call(this, 'start-here');
this.parent('start-here');
this._appSys = Shell.AppSystem.get_default();
this._installedChangedId = this._appSys.connect('installed-changed', Lang.bind(this, this._refresh));
this._display();
appsys.connect('installed-changed', Lang.bind(this, this.reDisplay));
},
reDisplay : function() {
destroy: function() {
this._appSys.disconnect(this._installedChangedId);
this.parent();
},
_refresh: function() {
this._clearAll();
this._display();
},
_clearAll : function() {
_clearAll: function() {
this.menu.removeAll();
},
@@ -67,7 +69,7 @@ ApplicationsButton.prototype = {
while ((nextType = iter.next()) != GMenu.TreeItemType.INVALID) {
if (nextType == GMenu.TreeItemType.ENTRY) {
var entry = iter.get_entry();
var app = appsys.lookup_app_by_tree_entry(entry);
var app = this._appSys.lookup_app_by_tree_entry(entry);
if (!entry.get_app_info().get_nodisplay())
menu.addMenuItem(new AppMenuItem(app));
} else if (nextType == GMenu.TreeItemType.DIRECTORY) {
@@ -77,7 +79,7 @@ ApplicationsButton.prototype = {
},
_display : function() {
let tree = appsys.get_tree();
let tree = this._appSys.get_tree();
let root = tree.get_root_directory();
let iter = root.iter();
@@ -91,7 +93,7 @@ ApplicationsButton.prototype = {
}
}
}
};
});
let appsMenuButton;

View File

@@ -1,5 +1,8 @@
{
"extension-id": "@extension_id@",
"uuid": "@uuid@",
"settings-schema": "@gschemaname@",
"gettext-domain": "@gettext_domain@",
"name": "Applications Menu",
"description": "Add a gnome 2.x style menu for applications",
"shell-version": [ "@shell_current@" ],

View File

@@ -1,14 +1,5 @@
EXTENSION_ID = auto-move-windows
include ../../extension.mk
include ../../settings.mk
gschemas_in = $(gschemabase).auto-move-windows.gschema.xml.in
@INTLTOOL_XML_NOMERGE_RULE@
gsettings_SCHEMAS = $(gschemas_in:.xml.in=.xml)
@GSETTINGS_RULES@
CLEANFILES += $(gschemas_in:.xml.in=.valid) $(gsettings_SCHEMAS)
EXTRA_DIST += $(gschemas_in)

View File

@@ -11,16 +11,17 @@ const St = imports.gi.St;
const Main = imports.ui.main;
const SETTINGS_SCHEMA = 'org.gnome.shell.extensions.auto-move-windows';
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const SETTINGS_KEY = 'application-list';
let settings;
function WindowMover() {
this._init();
}
const WindowMover = new Lang.Class({
Name: 'AutoMoveWindows.WindowMover',
WindowMover.prototype = {
_init: function() {
this._settings = settings;
this._windowTracker = Shell.WindowTracker.get_default();
@@ -76,15 +77,14 @@ WindowMover.prototype = {
}
}
}
}
});
let prevCheckWorkspaces;
let winMover;
function init(metadata) {
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
me.convenience.initTranslations(metadata);
settings = me.convenience.getSettings(metadata, 'auto-move-windows');
function init() {
Convenience.initTranslations();
settings = Convenience.getSettings();
}
function enable() {

View File

@@ -1,5 +1,8 @@
{
"extension-id": "@extension_id@",
"uuid": "@uuid@",
"settings-schema": "@gschemaname@",
"gettext-domain": "@gettext_domain@",
"name": "Auto Move Windows",
"description": "Move applications to specific workspaces when they create windows",
"shell-version": [ "@shell_current@" ],

View File

@@ -1,14 +1,5 @@
EXTENSION_ID = dock
include ../../extension.mk
include ../../settings.mk
gschemas_in = $(gschemabase).dock.gschema.xml.in
@INTLTOOL_XML_NOMERGE_RULE@
gsettings_SCHEMAS = $(gschemas_in:.xml.in=.xml)
@GSETTINGS_RULES@
CLEANFILES += $(gschemas_in:.xml.in=.valid) $(gsettings_SCHEMAS)
EXTRA_DIST += $(gschemas_in)

View File

@@ -25,19 +25,17 @@ const AltTab = imports.ui.altTab;
const Gettext = imports.gettext.domain('gnome-shell-extensions');
const _ = Gettext.gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
// Settings
const DOCK_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.dock';
const DOCK_POSITION_KEY = 'position';
const DOCK_SIZE_KEY = 'size';
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;
// Keep enums in sync with GSettings schemas
const PositionMode = {
LEFT: 0,
@@ -50,268 +48,222 @@ const AutoHideEffect = {
MOVE: 2
};
let position = PositionMode.RIGHT;
let dockicon_size = 48;
let hideable = true;
let hideDock = true;
let hideEffect = AutoHideEffect.RESIZE;
let autohide_animation_time = 0.3;
const DND_RAISE_APP_TIMEOUT = 500;
/*************************************************************************************/
/**** start resize's Dock functions *****************/
/*************************************************************************************/
function hideDock_size () {
if (hideable){
let monitor = Main.layoutManager.primaryMonitor
let position_x = monitor.x;
let height = (this._nicons)*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
if (!this._hideable)
return;
Tweener.addTween(this,{
_item_size: 1,
time: autohide_animation_time,
transition: 'easeOutQuad',
onUpdate: function () {
height = (this._nicons)*(this._item_size + this._spacing) + 2*this._spacing;
width = this._item_size + 4*this._spacing;
switch (position) {
case PositionMode.LEFT:
position_x=monitor.x-2*this._spacing;
break;
case PositionMode.RIGHT:
default:
position_x = monitor.x + (monitor.width-1-this._item_size-2*this._spacing);
}
this.actor.set_position (position_x,monitor.y+(monitor.height-height)/2);
this.actor.set_size(width,height);
},
});
hideDock=true;
}
let monitor = Main.layoutManager.primaryMonitor
let position_x = monitor.x;
let height = (this._nicons)*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
Tweener.addTween(this, {
_item_size: 1,
time: this._settings.get_double(DOCK_AUTOHIDE_ANIMATION_TIME_KEY),
transition: 'easeOutQuad',
onUpdate: function () {
height = (this._nicons)*(this._item_size + this._spacing) + 2*this._spacing;
width = this._item_size + 4*this._spacing;
switch (this._settings.get_enum(DOCK_POSITION_KEY)) {
case PositionMode.LEFT:
position_x=monitor.x-2*this._spacing;
break;
case PositionMode.RIGHT:
default:
position_x = monitor.x + (monitor.width-1-this._item_size-2*this._spacing);
}
this.actor.set_position (position_x,monitor.y+(monitor.height-height)/2);
this.actor.set_size(width,height);
},
});
this._hidden = true;
}
function showDock_size () {
let monitor = Main.layoutManager.primaryMonitor;
let height = (this._nicons)*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
let position_x = monitor.x;
let monitor = Main.layoutManager.primaryMonitor;
let height = (this._nicons)*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
let position_x = monitor.x;
Tweener.addTween(this,{
_item_size: dockicon_size,
time: autohide_animation_time,
transition: 'easeOutQuad',
onUpdate: function () {
height = (this._nicons)*(this._item_size + this._spacing) + 2*this._spacing;
width = this._item_size + 4*this._spacing;
switch (position) {
case PositionMode.LEFT:
position_x=monitor.x-2*this._spacing;
break;
case PositionMode.RIGHT:
default:
position_x=monitor.x + (monitor.width-this._item_size-2*this._spacing);
}
this.actor.set_position (position_x, monitor.y+(monitor.height-height)/2);
this.actor.set_size(width,height);
}
});
hideDock=false;
}
Tweener.addTween(this, {
_item_size: this._settings.get_int(DOCK_SIZE_KEY),
time: this._settings.get_double(DOCK_AUTOHIDE_ANIMATION_TIME_KEY),
transition: 'easeOutQuad',
onUpdate: function () {
height = (this._nicons)*(this._item_size + this._spacing) + 2*this._spacing;
width = this._item_size + 4*this._spacing;
switch (this._settings.get_enum(DOCK_POSITION_KEY)) {
case PositionMode.LEFT:
position_x=monitor.x-2*this._spacing;
break;
case PositionMode.RIGHT:
default:
position_x=monitor.x + (monitor.width-this._item_size-2*this._spacing);
}
this.actor.set_position (position_x, monitor.y+(monitor.height-height)/2);
this.actor.set_size(width,height);
}
});
function initShowDock_size () {
this._item_size=1;
this._showDock();
this._hidden = false;
}
function showEffectAddItem_size () {
let primary = Main.layoutManager.primaryMonitor;
let height = (this._nicons)*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
let primary = Main.layoutManager.primaryMonitor;
let height = (this._nicons)*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
Tweener.addTween(this.actor, {
y: primary.y + (primary.height-height)/2,
height: height,
width: width,
time: autohide_animation_time,
transition: 'easeOutQuad'
});
Tweener.addTween(this.actor, {
y: primary.y + (primary.height-height)/2,
height: height,
width: width,
time: this._settings.get_double(DOCK_AUTOHIDE_ANIMATION_TIME_KEY),
transition: 'easeOutQuad'
});
}
/**************************************************************************************/
/**** start rescale's Dock functions *****************/
/**************************************************************************************/
function hideDock_scale () {
this._item_size = dockicon_size;
let monitor = Main.layoutManager.primaryMonitor;
let cornerX = 0;
let height = this._nicons*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
if (!this._hideable)
return;
switch (position) {
case PositionMode.LEFT:
cornerX=monitor.x;
break;
case PositionMode.RIGHT:
default:
cornerX = monitor.x + monitor.width-1;
}
this._item_size = this._settings.get_int(DOCK_SIZE_KEY);
let monitor = Main.layoutManager.primaryMonitor;
let cornerX = 0;
let height = this._nicons*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
if (hideable) {
Tweener.addTween(this.actor,{
y: monitor.y + (monitor.height-height)/2,
x: cornerX,
height:height,
width: width,
scale_x: 0.025,
time: autohide_animation_time,
transition: 'easeOutQuad'
});
hideDock=true;
}
switch (this._settings.get_enum(DOCK_POSITION_KEY)) {
case PositionMode.LEFT:
cornerX=monitor.x;
break;
case PositionMode.RIGHT:
default:
cornerX = monitor.x + monitor.width-1;
}
Tweener.addTween(this.actor,{
y: monitor.y + (monitor.height-height)/2,
x: cornerX,
height:height,
width: width,
scale_x: 0.025,
time: this._settings.get_double(DOCK_AUTOHIDE_ANIMATION_TIME_KEY),
transition: 'easeOutQuad'
});
this._hidden = true;
}
function showDock_scale () {
this._item_size = dockicon_size;
let monitor = Main.layoutManager.primaryMonitor;
let position_x = monitor.x;
let height = this._nicons*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
this._item_size = this._settings.get_int(DOCK_SIZE_KEY);
let monitor = Main.layoutManager.primaryMonitor;
let position_x = monitor.x;
let height = this._nicons*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
switch (position) {
case PositionMode.LEFT:
position_x=monitor.x-2*this._spacing;
break;
case PositionMode.RIGHT:
default:
position_x=monitor.x + (monitor.width-this._item_size-2*this._spacing);
}
Tweener.addTween(this.actor, {
y: monitor.y + (monitor.height-height)/2,
x: monitor.x + position_x,
height: height,
width: width,
scale_x: 1,
time: autohide_animation_time,
transition: 'easeOutQuad'
});
hideDock=false;
}
switch (this._settings.get_enum(DOCK_POSITION_KEY)) {
case PositionMode.LEFT:
position_x=monitor.x-2*this._spacing;
break;
case PositionMode.RIGHT:
default:
position_x=monitor.x + (monitor.width-this._item_size-2*this._spacing);
}
Tweener.addTween(this.actor, {
y: monitor.y + (monitor.height-height)/2,
x: monitor.x + position_x,
height: height,
width: width,
scale_x: 1,
time: this._settings.get_double(DOCK_AUTOHIDE_ANIMATION_TIME_KEY),
transition: 'easeOutQuad'
});
function initShowDock_scale () {
let primary = Main.layoutManager.primaryMonitor;
let height = this._nicons*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
this.actor.set_scale (0,0);
this.actor.set_size (width,height);
// set the position of the dock
switch (position) {
case PositionMode.LEFT:
this.actor.x = 0;
// effect of creation of the dock
Tweener.addTween(this.actor, {
x: primary.x-2*this._spacing,
y: primary.y + (primary.height-height)/2,
time: autohide_animation_time * 3,
transition: 'easeOutQuad'
});
break;
case PositionMode.RIGHT:
default:
this.actor.x = primary.width-1;
// effect of creation of the dock
Tweener.addTween(this.actor, {
x: primary.x + primary.width-this._item_size- 2*this._spacing,
y: primary.y + (primary.height-height)/2,
time: autohide_animation_time * 3,
transition: 'easeOutQuad'
});
}
Tweener.addTween(this.actor,{
scale_x: 1,
scale_y: 1,
time: autohide_animation_time * 3,
transition: 'easeOutQuad'
});
hideDock=false;
this._hidden = false;
}
function showEffectAddItem_scale () {
let monitor = Main.layoutManager.primaryMonitor;
let height = this._nicons*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
let monitor = Main.layoutManager.primaryMonitor;
let height = this._nicons*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
Tweener.addTween(this.actor, {
y: monitor.y + (monitor.height-height)/2,
height: height,
width: width,
time: autohide_animation_time,
transition: 'easeOutQuad'
});
Tweener.addTween(this.actor, {
y: monitor.y + (monitor.height-height)/2,
height: height,
width: width,
time: this._settings.get_double(DOCK_AUTOHIDE_ANIMATION_TIME_KEY),
transition: 'easeOutQuad'
});
}
/**************************************************************************************/
/**** start move Dock functions *****************/
/**************************************************************************************/
function hideDock_move () {
this._item_size = dockicon_size;
let monitor = Main.layoutManager.primaryMonitor;
let cornerX = 0;
let height = this._nicons*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
if (!this._hideable)
return;
switch (position) {
case PositionMode.LEFT:
cornerX= monitor.x - width + this._spacing;
break;
case PositionMode.RIGHT:
default:
cornerX = monitor.x + monitor.width - this._spacing;
}
this._item_size = this._settings.get_int(DOCK_SIZE_KEY);
let monitor = Main.layoutManager.primaryMonitor;
let cornerX = 0;
let height = this._nicons*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
if (hideable) {
Tweener.addTween(this.actor,{
x: cornerX,
y: monitor.y + (monitor.height - height)/2,
width: width,
height: height,
time: autohide_animation_time,
transition: 'easeOutQuad'
});
hideDock=true;
}
switch (this._settings.get_enum(DOCK_POSITION_KEY)) {
case PositionMode.LEFT:
cornerX= monitor.x - width + this._spacing;
break;
case PositionMode.RIGHT:
default:
cornerX = monitor.x + monitor.width - this._spacing;
}
Tweener.addTween(this.actor,{
x: cornerX,
y: monitor.y + (monitor.height - height)/2,
width: width,
height: height,
time: this._settings.get_double(DOCK_AUTOHIDE_ANIMATION_TIME_KEY),
transition: 'easeOutQuad'
});
this._hidden = true;
}
function showDock_move () {
this._item_size = dockicon_size;
let monitor = Main.layoutManager.primaryMonitor;
let position_x = monitor.x;
let height = this._nicons*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
this._item_size = this._settings.get_int(DOCK_SIZE_KEY);
let monitor = Main.layoutManager.primaryMonitor;
let position_x = monitor.x;
let height = this._nicons*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
switch (position) {
case PositionMode.LEFT:
position_x=monitor.x - 2*this._spacing;
break;
case PositionMode.RIGHT:
default:
position_x=monitor.x + (monitor.width-this._item_size-2*this._spacing);
}
Tweener.addTween(this.actor, {
x: position_x,
y: monitor.y + (monitor.height - height)/2,
width: width,
height: height,
time: autohide_animation_time,
transition: 'easeOutQuad'
});
hideDock=false;
}
switch (this._settings.get_enum(DOCK_POSITION_KEY)) {
case PositionMode.LEFT:
position_x=monitor.x - 2*this._spacing;
break;
case PositionMode.RIGHT:
default:
position_x=monitor.x + (monitor.width-this._item_size-2*this._spacing);
}
Tweener.addTween(this.actor, {
x: position_x,
y: monitor.y + (monitor.height - height)/2,
width: width,
height: height,
time: this._settings.get_double(DOCK_AUTOHIDE_ANIMATION_TIME_KEY),
transition: 'easeOutQuad'
});
function initShowDock_move () {
this._showDock();
this._hidden = false;
}
function showEffectAddItem_move () {
@@ -323,16 +275,14 @@ function showEffectAddItem_move () {
y: monitor.y + (monitor.height-height)/2,
height: height,
width: width,
time: autohide_animation_time,
time: this._settings.get_double(DOCK_AUTOHIDE_ANIMATION_TIME_KEY),
transition: 'easeOutQuad'
});
}
function Dock() {
this._init();
}
const Dock = new Lang.Class({
Name: 'Dock.Dock',
Dock.prototype = {
_init : function() {
this._placeholderText = null;
this._menus = [];
@@ -341,20 +291,14 @@ Dock.prototype = {
this._favorites = [];
// Load Settings
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);
hideEffect = this._settings.get_enum(DOCK_EFFECTHIDE_KEY);
autohide_animation_time = this._settings.get_double(DOCK_AUTOHIDE_ANIMATION_TIME_KEY);
//global.log("POSITION: " + position);
//global.log("dockicon_size: " + dockicon_size);
this._settings = Convenience.getSettings();
this._hidden = false;
this._hideable = this._settings.get_boolean(DOCK_HIDE_KEY);
this._spacing = 4;
this._item_size = dockicon_size;
this._item_size = this._settings.get_int(DOCK_SIZE_KEY);
this._nicons = 0;
this._selectFunctionsHide ();
this._selectEffectFunctions(this._settings.get_enum(DOCK_EFFECTHIDE_KEY));
this.actor = new St.BoxLayout({ name: 'dock', vertical: true, reactive: true });
@@ -385,58 +329,45 @@ Dock.prototype = {
{ affectsStruts: !this._settings.get_boolean(DOCK_HIDE_KEY) });
//hidden
this._settings.connect('changed::'+DOCK_POSITION_KEY, Lang.bind(this, function (){
let primary = Main.layoutManager.primaryMonitor;
position = this._settings.get_enum(DOCK_POSITION_KEY);
this.actor.y=primary.y;
this._redisplay();
}));
this._settings.connect('changed::'+DOCK_SIZE_KEY, Lang.bind(this, function (){
dockicon_size = this._settings.get_int(DOCK_SIZE_KEY);
this._redisplay();
}));
this._settings.connect('changed::'+DOCK_POSITION_KEY, Lang.bind(this, this._redisplay));
this._settings.connect('changed::'+DOCK_SIZE_KEY, Lang.bind(this, this._redisplay));
this._settings.connect('changed::'+DOCK_HIDE_KEY, Lang.bind(this, function (){
Main.layoutManager.removeChrome(this.actor);
Main.layoutManager.addChrome(this.actor,
{ affectsStruts: !this._settings.get_boolean(DOCK_HIDE_KEY) });
hideable = this._settings.get_boolean(DOCK_HIDE_KEY);
if (hideable){
hideDock=false;
this._hideable = this._settings.get_boolean(DOCK_HIDE_KEY);
if (this._hideable)
this._hideDock();
} else {
hideDock=true;
else
this._showDock();
}
}));
this._settings.connect('changed::'+DOCK_EFFECTHIDE_KEY, Lang.bind(this, function () {
hideEffect = this._settings.get_enum(DOCK_EFFECTHIDE_KEY);
this._settings.connect('changed::' + DOCK_EFFECTHIDE_KEY, Lang.bind(this, function () {
let hideEffect = this._settings.get_enum(DOCK_EFFECTHIDE_KEY);
switch (hideEffect) {
case AutoHideEffect.RESCALE:
this._item_size=dockicon_size;
break;
case AutoHideEffect.RESIZE:
this.actor.set_scale (1,1);
break;
case AutoHideEffect.MOVE:
;
}
this.actor.disconnect(this._leave_event);
this.actor.disconnect(this._enter_event);
// restore the effects of the other functions
switch (hideEffect) {
case AutoHideEffect.RESCALE:
this._item_size = this._settings.get_int(DOCK_SIZE_KEY);
break;
case AutoHideEffect.RESIZE:
this.actor.set_scale(1, 1);
break;
case AutoHideEffect.MOVE:
this.actor.set_scale(1, 1);
this._item_size = this._settings.get_int(DOCK_SIZE_KEY);
}
this._selectFunctionsHide ();
this.actor.disconnect(this._leave_event);
this.actor.disconnect(this._enter_event);
this._leave_event = this.actor.connect('leave-event', Lang.bind(this, this._hideDock));
this._enter_event = this.actor.connect('enter-event', Lang.bind(this, this._showDock));
this._redisplay();
}));
this._selectEffectFunctions(hideEffect);
this._settings.connect('changed::'+DOCK_AUTOHIDE_ANIMATION_TIME_KEY, Lang.bind(this,function (){
autohide_animation_time = this._settings.get_double(DOCK_AUTOHIDE_ANIMATION_TIME_KEY);
this._leave_event = this.actor.connect('leave-event', Lang.bind(this, this._hideDock));
this._enter_event = this.actor.connect('enter-event', Lang.bind(this, this._showDock));
this._redisplay();
}));
this._leave_event = this.actor.connect('leave-event', Lang.bind(this, this._hideDock));
@@ -481,33 +412,30 @@ Dock.prototype = {
},
// fuctions hide
_restoreHideDock: function(){
hideable = this._settings.get_boolean(DOCK_HIDE_KEY);
_restoreHideDock: function() {
this._hideable = this._settings.get_boolean(DOCK_HIDE_KEY);
},
_disableHideDock: function (){
hideable = false;
_disableHideDock: function() {
this._hideable = false;
},
_selectFunctionsHide: function () {
_selectEffectFunctions: function(hideEffect) {
switch (hideEffect) {
case AutoHideEffect.RESCALE:
this._hideDock = hideDock_scale;
this._showDock = showDock_scale;
this._initShowDock = initShowDock_scale;
this._showEffectAddItem = showEffectAddItem_scale;
break;
case AutoHideEffect.MOVE:
this._hideDock = hideDock_move;
this._showDock = showDock_move;
this._initShowDock = initShowDock_move;
this._showEffectAddItem = showEffectAddItem_move;
break;
case AutoHideEffect.RESIZE:
default:
this._hideDock = hideDock_size;
this._showDock = showDock_size;
this._initShowDock = initShowDock_size;
this._showEffectAddItem = showEffectAddItem_size;
}
},
@@ -566,21 +494,16 @@ Dock.prototype = {
let height = (icons)*(this._item_size + this._spacing) + 2*this._spacing;
let width = this._item_size + 4*this._spacing;
if (this.actor.y != primary.y) {
if (hideable && hideDock) {
this._hideDock();
} else {
if (dockicon_size == this._item_size) {
// only add/delete icon
this._showEffectAddItem ();
} else {
// change size icon
this._showDock ();
}
}
if (this._hideable && this._hidden) {
this._hideDock();
} else {
// effect of creation
this._initShowDock ();
if (this._settings.get_int(DOCK_SIZE_KEY) == this._item_size) {
// only add/delete icon
this._showEffectAddItem ();
} else {
// change size icon
this._showDock ();
}
}
},
@@ -602,7 +525,7 @@ Dock.prototype = {
let children = this._grid.get_children();
let x = box.x1 + this._spacing;
if (position == PositionMode.LEFT)
if (this._settings.get_enum(DOCK_POSITION_KEY) == PositionMode.LEFT)
x = box.x1 + 2*this._spacing;
let y = box.y1 + this._spacing;
@@ -638,15 +561,17 @@ Dock.prototype = {
addItem: function(actor) {
this._grid.add_actor(actor);
}
};
});
Signals.addSignalMethods(Dock.prototype);
function DockIcon(app, dock) {
this._init(app, dock);
}
const DockIcon = new Lang.Class({
Name: 'Dock.DockIcon',
DockIcon.prototype = {
_init : function(app, dock) {
this._dock = dock;
this._settings = dock._settings;
this.app = app;
this.actor = new St.Button({ style_class: 'app-well-app',
button_mask: St.ButtonMask.ONE | St.ButtonMask.TWO,
@@ -654,12 +579,11 @@ DockIcon.prototype = {
x_fill: true,
y_fill: true });
this.actor._delegate = this;
//this.actor.set_size(dockicon_size, dockicon_size);
this._icon = new AppDisplay.AppIcon(app, { setSizeManually: true,
showLabel: false });
this.actor.set_child(this._icon.actor);
this._icon.setIconSize(dockicon_size);
this._icon.setIconSize(this._settings.get_int(DOCK_SIZE_KEY));
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
@@ -679,7 +603,6 @@ DockIcon.prototype = {
this._stateChangedId = this.app.connect('notify::state',
Lang.bind(this, this._onStateChanged));
this._onStateChanged();
this._dock=dock;
},
_onDestroy: function() {
@@ -775,7 +698,8 @@ DockIcon.prototype = {
this._menuManager.addMenu(this._menu, true);
}
this._menu.popup();
this._menu.redisplay();
this._menu.open();
return false;
},
@@ -828,30 +752,25 @@ DockIcon.prototype = {
}
}
Main.overview.hide();
},
shellWorkspaceLaunch : function() {
this.app.open_new_window();
}
};
});
Signals.addSignalMethods(DockIcon.prototype);
function DockIconMenu(source) {
this._init(source);
}
DockIconMenu.prototype = {
__proto__: AppDisplay.AppIconMenu.prototype,
const DockIconMenu = new Lang.Class({
Name: 'Dock.DockIconMenu',
Extends: PopupMenu.PopupMenu,
_init: function(source) {
switch (position) {
case PositionMode.LEFT:
PopupMenu.PopupMenu.prototype._init.call(this, source.actor, St.Align.MIDDLE, St.Side.LEFT, 0);
break;
case PositionMode.RIGHT:
default:
PopupMenu.PopupMenu.prototype._init.call(this, source.actor, St.Align.MIDDLE, St.Side.RIGHT, 0);
let side;
switch (source._settings.get_enum(DOCK_POSITION_KEY)) {
case PositionMode.LEFT:
side = St.Side.LEFT;
break;
case PositionMode.RIGHT:
default:
side = St.Side.RIGHT;
}
this.parent(source.actor, 0.5, side);
this._source = source;
@@ -864,12 +783,12 @@ DockIconMenu.prototype = {
if (!source.actor.mapped)
this.close();
}));
source.actor.connect('destroy', Lang.bind(this, function () { this.actor.destroy(); }));
source.actor.connect('destroy', Lang.bind(this, function () { this.destroy(); }));
Main.layoutManager.addChrome(this.actor);
},
_redisplay: function() {
redisplay: function() {
this.removeAll();
let windows = this._source.app.get_windows();
@@ -906,6 +825,23 @@ DockIconMenu.prototype = {
this._highlightedItem = null;
},
_appendSeparator: function () {
let separator = new PopupMenu.PopupSeparatorMenuItem();
this.addMenuItem(separator);
},
_appendMenuItem: function(labelText) {
// FIXME: app-well-menu-item style
let item = new PopupMenu.PopupMenuItem(labelText);
this.addMenuItem(item);
return item;
},
popup: function(activatingButton) {
this._redisplay();
this.open();
},
_onActivate: function (actor, child) {
if (child._window) {
let metaWindow = child._window;
@@ -926,12 +862,10 @@ DockIconMenu.prototype = {
}
this.close();
}
}
});
function init(metadata) {
_metadata = metadata;
_me = imports.ui.extensionSystem.extensions[metadata.uuid];
_me.convenience.initTranslations(metadata);
function init() {
Convenience.initTranslations();
}
let dock;

View File

@@ -1,5 +1,8 @@
{
"extension-id": "@extension_id@",
"uuid": "@uuid@",
"settings-schema": "@gschemaname@",
"gettext-domain": "@gettext_domain@",
"name": "Dock",
"description": "A dock for the GNOME Shell -- displays favorite and running applications",
"original-author": "tclaesson@gmail.com",

View File

@@ -12,15 +12,16 @@ const Panel = imports.ui.panel;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
function DriveMenuItem(place) {
this._init(place);
}
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
DriveMenuItem.prototype = {
__proto__: PopupMenu.PopupBaseMenuItem.prototype,
const DriveMenuItem = new Lang.Class({
Name: 'DriveMenu.DriveMenuItem',
Extends: PopupMenu.PopupBaseMenuItem,
_init: function(place) {
PopupMenu.PopupBaseMenuItem.prototype._init.call(this);
this.parent();
this.place = place;
@@ -42,23 +43,19 @@ DriveMenuItem.prototype = {
activate: function(event) {
this.place.launch({ timestamp: event.get_time() });
PopupMenu.PopupBaseMenuItem.prototype.activate.call(this, event);
this.parent(event);
}
};
});
function DriveMenu() {
this._init();
}
DriveMenu.prototype = {
__proto__: PanelMenu.SystemStatusButton.prototype,
const DriveMenu = new Lang.Class({
Name: 'DriveMenu.DriveMenu',
Extends: PanelMenu.SystemStatusButton,
_init: function() {
// is 'media-eject' better?
PanelMenu.SystemStatusButton.prototype._init.call(this, 'media-eject');
this.parent('media-eject');
this._manager = Main.placesManager;
this._manager.connect('mounts-updated', Lang.bind(this, this._update));
this._updatedId = this._manager.connect('mounts-updated', Lang.bind(this, this._update));
this._contentSection = new PopupMenu.PopupMenuSection();
this.menu.addMenuItem(this._contentSection);
@@ -87,12 +84,16 @@ DriveMenu.prototype = {
this.actor.visible = any;
},
}
// Put your extension initialization code here
function init(metadata) {
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
me.convenience.initTranslations(metadata);
destroy: function() {
this._manager.disconnect(this._updatedId);
this.parent();
},
});
function init() {
Convenience.initTranslations();
}
let _indicator;

View File

@@ -1,5 +1,8 @@
{
"extension-id": "@extension_id@",
"uuid": "@uuid@",
"settings-schema": "@gschemaname@",
"gettext-domain": "@gettext_domain@",
"name": "Removable Drive Menu",
"description": "A status menu for accessing and unmounting removable devices",
"shell-version": [ "@shell_current@" ],

View File

@@ -7,6 +7,10 @@ const _ = Gettext.gettext;
const Main = imports.ui.main;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
function _showHello() {
let text = new St.Label({ style_class: 'helloworld-label', text: _("Hello, world!") });
let monitor = Main.layoutManager.primaryMonitor;
@@ -19,8 +23,7 @@ function _showHello() {
function init(metadata) {
log ('Example extension initalized');
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
me.convenience.initTranslations(metadata);
Convenience.initTranslations();
}
let signalId;

View File

@@ -1,5 +1,8 @@
{
"extension-id": "@extension_id@",
"uuid": "@uuid@",
"settings-schema": "@gschemaname@",
"gettext-domain": "@gettext_domain@",
"name": "Hello, World!",
"description": "An example extension to show how it works. Shows Hello, world when clicking on the top panel.",
"shell-version": [ "@shell_current@" ],

View File

@@ -1,5 +1,8 @@
{
"extension-id": "@extension_id@",
"uuid": "@uuid@",
"settings-schema": "@gschemaname@",
"gettext-domain": "@gettext_domain@",
"name": "Gajim IM integration",
"description": "Display Gajim incoming chats as notifications in the Shell message tray.",
"shell-version": [ "@shell_current@" ],

View File

@@ -1,14 +1,5 @@
EXTENSION_ID = native-window-placement
include ../../extension.mk
include ../../settings.mk
gschemas_in = $(gschemabase).native-window-placement.gschema.xml.in
@INTLTOOL_XML_NOMERGE_RULE@
gsettings_SCHEMAS = $(gschemas_in:.xml.in=.xml)
@GSETTINGS_RULES@
CLEANFILES += $(gschemas_in:.xml.in=.valid) $(gsettings_SCHEMAS)
EXTRA_DIST += $(gschemas_in)

View File

@@ -20,7 +20,9 @@ const Tweener = imports.ui.tweener;
const Workspace = imports.ui.workspace;
const WindowPositionFlags = Workspace.WindowPositionFlags;
let _me, _metadata;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
// testing settings for natural window placement strategy:
const WINDOW_PLACEMENT_NATURAL_FILLGAPS = true; // enlarge windows at the end to fill gaps // not implemented yet
@@ -46,15 +48,16 @@ function injectToFunction(parent, name, func) {
}
const WORKSPACE_BORDER_GAP = 10; // gap between the workspace area and the workspace selector
function Rect(x, y, width, height) {
[this.x, this.y, this.width, this.height] = arguments;
}
const Rect = new Lang.Class({
Name: 'NativeWindowPlacement.Rect',
_init: function(x, y, width, height) {
[this.x, this.y, this.width, this.height] = [x, y, width, height];
},
Rect.prototype = {
/**
* used in _calculateWindowTransformationsNatural to replace Meta.Rectangle that is too slow.
*/
copy: function() {
return new Rect(this.x, this.y, this.width, this.height);
},
@@ -103,7 +106,7 @@ Rect.prototype = {
this.x += dx;
this.y += dy;
}
};
});
let winInjections, workspaceInjections, connectedSignals;
@@ -116,7 +119,7 @@ function resetState() {
function enable() {
resetState();
let settings = _me.convenience.getSettings(_metadata, 'native-window-placement');
let settings = Convenience.getSettings();
let useMoreScreen = settings.get_boolean('use-more-screen');
signalId = settings.connect('changed::use-more-screen', function() {
useMoreScreen = settings.get_boolean('use-more-screen');
@@ -501,7 +504,6 @@ function disable() {
resetState();
}
function init(metadata) {
_metadata = metadata;
_me = imports.ui.extensionSystem.extensions[metadata.uuid];
function init() {
/* do nothing */
}

View File

@@ -1,5 +1,8 @@
{
"uuid": "@uuid@",
"extension-id": "@extension_id@",
"settings-schema": "@gschemaname@",
"gettext-domain": "@gettext_domain@",
"name": "Native Window Placement",
"description": "Arrange windows in overview in a more native way",
"shell-version": [ "@shell_current@" ],

View File

@@ -14,17 +14,18 @@ const Panel = imports.ui.panel;
const Gettext = imports.gettext.domain('gnome-shell-extensions');
const _ = Gettext.gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const PLACE_ICON_SIZE = 22;
function PlacesMenu() {
this._init.apply(this, arguments);
}
PlacesMenu.prototype = {
__proto__: PanelMenu.SystemStatusButton.prototype,
const PlacesMenu = new Lang.Class({
Name: 'PlacesMenu.PlacesMenu',
Extends: PanelMenu.SystemStatusButton,
_init: function() {
PanelMenu.SystemStatusButton.prototype._init.call(this, 'folder');
this.parent('folder');
this.defaultItems = [];
this.bookmarkItems = [];
@@ -36,8 +37,16 @@ PlacesMenu.prototype = {
this._devicesMenuItem = new PopupMenu.PopupSubMenuMenuItem(_("Removable Devices"));
this.menu.addMenuItem(this._devicesMenuItem);
this._createDevices();
Main.placesManager.connect('bookmarks-updated',Lang.bind(this,this._redisplayBookmarks));
Main.placesManager.connect('mounts-updated',Lang.bind(this,this._redisplayDevices));
this._bookmarksId = Main.placesManager.connect('bookmarks-updated',Lang.bind(this,this._redisplayBookmarks));
this._mountsId = Main.placesManager.connect('mounts-updated',Lang.bind(this,this._redisplayDevices));
},
destroy: function() {
Main.placesManager.disconnect(this._bookmarksId);
Main.placesManager.disconnect(this._mountsId);
this.parent();
},
_redisplayBookmarks: function(){
@@ -108,14 +117,12 @@ PlacesMenu.prototype = {
_clearDevices : function(){
this._devicesMenuItem.menu.removeAll();
this.DeviceItems = [];
this.deviceItems = [];
},
};
});
function init(metadata) {
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
me.convenience.initTranslations(metadata);
function init() {
Convenience.initTranslations();
}
let _indicator;

View File

@@ -1,5 +1,8 @@
{
"extension-id": "@extension_id@",
"uuid": "@uuid@",
"settings-schema": "@gschemaname@",
"gettext-domain": "@gettext_domain@",
"name": "Places Status Indicator",
"description": "Add a systems status menu for quickly navigating places in the system",
"shell-version": [ "@shell_current@" ],

View File

@@ -16,11 +16,9 @@ let _cpuIndicator;
let _memIndicator;
let _box;
function Indicator() {
this._init();
}
const Indicator = new Lang.Class({
Name: 'SystemMonitor.Indicator',
Indicator.prototype = {
_init: function() {
this._initValues();
this.drawing_area = new St.DrawingArea({ reactive: true });
@@ -44,6 +42,7 @@ Indicator.prototype = {
destroy: function() {
Mainloop.source_remove(this._timeout);
this.actor.destroy();
},
@@ -131,20 +130,16 @@ Indicator.prototype = {
cr.setDash([], 0);
cr.stroke();
}
}
});
};
function CpuIndicator() {
this._init();
}
CpuIndicator.prototype = {
__proto__: Indicator.prototype,
const CpuIndicator = new Lang.Class({
Name: 'SystemMonitor.CpuIndicator',
Extends: Indicator,
_init: function() {
Indicator.prototype._init.call(this);
this.parent();
this.gridColor = '-grid-color';
this.renderStats = [ 'cpu-user', 'cpu-sys', 'cpu-iowait' ];
@@ -187,17 +182,15 @@ CpuIndicator.prototype = {
this._prev = cpu;
}
};
});
function MemoryIndicator() {
this._init();
}
MemoryIndicator.prototype = {
__proto__: Indicator.prototype,
const MemoryIndicator = new Lang.Class({
Name: 'SystemMonitor.MemoryIndicator',
Extends: Indicator,
_init: function() {
Indicator.prototype._init.call(this);
this.parent();
this.gridColor = '-grid-color';
this.renderStats = [ 'mem-user', 'mem-other', 'mem-cached' ];
@@ -227,7 +220,7 @@ MemoryIndicator.prototype = {
t += this.mem.cached / this.mem.total;
this.stats['mem-cached'].values.push(t);
}
};
});
function init() {
// nothing to do here

View File

@@ -1,6 +1,9 @@
{
"shell-version": ["@shell_current@" ],
"uuid": "@uuid@",
"extension-id": "@extension_id@",
"settings-schema": "@gschemaname@",
"gettext-domain": "@gettext_domain@",
"original-author": "zaspire@rambler.ru",
"name": "SystemMonitor",
"description": "System Monitor",

View File

@@ -1,14 +1,5 @@
EXTENSION_ID = user-theme
include ../../extension.mk
include ../../settings.mk
gschemas_in = $(gschemabase).user-theme.gschema.xml.in
@INTLTOOL_XML_NOMERGE_RULE@
gsettings_SCHEMAS = $(gschemas_in:.xml.in=.xml)
@GSETTINGS_RULES@
CLEANFILES += $(gschemas_in:.xml.in=.valid) $(gsettings_SCHEMAS)
EXTRA_DIST += $(gschemas_in)

View File

@@ -6,17 +6,17 @@ const Gio = imports.gi.Gio;
const Lang = imports.lang;
const Main = imports.ui.main;
const SETTINGS_SCHEMA = 'org.gnome.shell.extensions.user-theme';
const SETTINGS_KEY = 'name';
function ThemeManager() {
this._init.apply(this, arguments);
}
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
ThemeManager.prototype = {
_init: function(metadata) {
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
this._settings = me.convenience.getSettings(metadata, 'user-theme');
const ThemeManager = new Lang.Class({
Name: 'UserTheme.ThemeManager',
_init: function() {
this._settings = Convenience.getSettings();
},
enable: function() {
@@ -63,9 +63,8 @@ ThemeManager.prototype = {
Main.setThemeStylesheet(_stylesheet);
Main.loadTheme();
}
}
});
function init(metadata) {
return new ThemeManager(metadata);
function init() {
return new ThemeManager();
}

View File

@@ -1,5 +1,8 @@
{
"uuid": "@uuid@",
"extension-id": "@extension_id@",
"settings-schema": "@gschemaname@",
"gettext-domain": "@gettext_domain@",
"name": "User Themes",
"description": "Load shell themes from user directory",
"shell-version": [ "@shell_current@" ],

View File

@@ -1,6 +1,9 @@
{
"shell-version": ["@shell_current@" ],
"extension-id": "@extension_id@",
"uuid": "@uuid@",
"settings-schema": "@gschemaname@",
"gettext-domain": "@gettext_domain@",
"original-author": "zaspire@rambler.ru",
"name": "windowNavigator",
"description": "Allow keyboard selection of windows and workspaces in overlay mode",

View File

@@ -7,103 +7,115 @@ const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const Panel = imports.ui.panel;
const Gettext = imports.gettext.domain('gnome-shell-extensions');
const _ = Gettext.gettext;
const Main = imports.ui.main;
function WorkspaceIndicator() {
this._init.apply(this, arguments);
}
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
WorkspaceIndicator.prototype = {
__proto__: PanelMenu.SystemStatusButton.prototype,
const WorkspaceIndicator = new Lang.Class({
Name: 'WorkspaceIndicator.WorkspaceIndicator',
Extends: PanelMenu.Button,
_init: function(){
PanelMenu.SystemStatusButton.prototype._init.call(this, 'folder');
_init: function(){
this.parent(0.0, _("Workspace Indicator"));
this._currentWorkspace = global.screen.get_active_workspace().index();
this.statusLabel = new St.Label({ text: this._labelText() });
this._currentWorkspace = global.screen.get_active_workspace().index();
this.statusLabel = new St.Label({ text: this._labelText() });
// destroy all previously created children, and add our statusLabel
this.actor.get_children().forEach(function(c) { c.destroy() });
this.actor.add_actor(this.statusLabel);
this.actor.add_actor(this.statusLabel);
this.workspacesItems = [];
this._workspaceSection = new PopupMenu.PopupMenuSection();
this.menu.addMenuItem(this._workspaceSection);
global.screen.connect_after('workspace-added', Lang.bind(this,this._createWorkspacesSection));
global.screen.connect_after('workspace-removed', Lang.bind(this,this._createWorkspacesSection));
global.screen.connect_after('workspace-switched', Lang.bind(this,this._updateIndicator));
this.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
this._createWorkspacesSection();
this.workspacesItems = [];
this._workspaceSection = new PopupMenu.PopupMenuSection();
this.menu.addMenuItem(this._workspaceSection);
//styling
this.menu.actor.add_style_class_name('workspace-indicator-shorter');
this.statusLabel.add_style_class_name('panel-workspace-indicator');
},
this._screenSignals = [];
this._screenSignals.push(global.screen.connect_after('workspace-added', Lang.bind(this,this._createWorkspacesSection)));
this._screenSignals.push(global.screen.connect_after('workspace-removed', Lang.bind(this,this._createWorkspacesSection)));
this._screenSignals.push(global.screen.connect_after('workspace-switched', Lang.bind(this,this._updateIndicator)));
_updateIndicator: function() {
this.workspacesItems[this._currentWorkspace].setShowDot(false);
this._currentWorkspace = global.screen.get_active_workspace().index();
this.workspacesItems[this._currentWorkspace].setShowDot(true);
this.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
this._createWorkspacesSection();
this.statusLabel.set_text(this._labelText());
},
//styling
this.menu.actor.add_style_class_name('workspace-indicator-shorter');
this.statusLabel.add_style_class_name('panel-workspace-indicator');
},
_labelText : function(workspaceIndex) {
if(workspaceIndex == undefined) {
workspaceIndex = this._currentWorkspace;
return (workspaceIndex + 1).toString();
}
return Meta.prefs_get_workspace_name(workspaceIndex);
},
destroy: function() {
for (let i = 0; i < this._screenSignals.length; i++)
global.screen.disconnect(this._screenSignals[i]);
_createWorkspacesSection : function() {
this._workspaceSection.removeAll();
this.workspacesItems = [];
this._currentWorkspace = global.screen.get_active_workspace().index();
this.parent();
},
let i = 0;
for(; i < global.screen.n_workspaces; i++) {
this.workspacesItems[i] = new PopupMenu.PopupMenuItem(this._labelText(i));
this._workspaceSection.addMenuItem(this.workspacesItems[i]);
this.workspacesItems[i].workspaceId = i;
this.workspacesItems[i].label_actor = this.statusLabel;
let self = this;
this.workspacesItems[i].connect('activate', Lang.bind(this, function(actor, event) {
this._activate(actor.workspaceId);
}));
_updateIndicator: function() {
this.workspacesItems[this._currentWorkspace].setShowDot(false);
this._currentWorkspace = global.screen.get_active_workspace().index();
this.workspacesItems[this._currentWorkspace].setShowDot(true);
if (i == this._currentWorkspace)
this.workspacesItems[i].setShowDot(true);
}
this.statusLabel.set_text(this._labelText());
},
this.statusLabel.set_text(this._labelText());
},
_labelText : function(workspaceIndex) {
if(workspaceIndex == undefined) {
workspaceIndex = this._currentWorkspace;
return (workspaceIndex + 1).toString();
}
return Meta.prefs_get_workspace_name(workspaceIndex);
},
_activate : function (index) {
if(index >= 0 && index < global.screen.n_workspaces) {
let metaWorkspace = global.screen.get_workspace_by_index(index);
metaWorkspace.activate(true);
}
},
_createWorkspacesSection : function() {
this._workspaceSection.removeAll();
this.workspacesItems = [];
this._currentWorkspace = global.screen.get_active_workspace().index();
_onScrollEvent : function(actor, event) {
let direction = event.get_scroll_direction();
let diff = 0;
if (direction == Clutter.ScrollDirection.DOWN) {
diff = 1;
} else if (direction == Clutter.ScrollDirection.UP) {
diff = -1;
} else {
return;
}
let i = 0;
for(; i < global.screen.n_workspaces; i++) {
this.workspacesItems[i] = new PopupMenu.PopupMenuItem(this._labelText(i));
this._workspaceSection.addMenuItem(this.workspacesItems[i]);
this.workspacesItems[i].workspaceId = i;
this.workspacesItems[i].label_actor = this.statusLabel;
let self = this;
this.workspacesItems[i].connect('activate', Lang.bind(this, function(actor, event) {
this._activate(actor.workspaceId);
}));
let newIndex = global.screen.get_active_workspace().index() + diff;
this._activate(newIndex);
},
}
if (i == this._currentWorkspace)
this.workspacesItems[i].setShowDot(true);
}
this.statusLabel.set_text(this._labelText());
},
_activate : function (index) {
if(index >= 0 && index < global.screen.n_workspaces) {
let metaWorkspace = global.screen.get_workspace_by_index(index);
metaWorkspace.activate(true);
}
},
_onScrollEvent : function(actor, event) {
let direction = event.get_scroll_direction();
let diff = 0;
if (direction == Clutter.ScrollDirection.DOWN) {
diff = 1;
} else if (direction == Clutter.ScrollDirection.UP) {
diff = -1;
} else {
return;
}
let newIndex = global.screen.get_active_workspace().index() + diff;
this._activate(newIndex);
},
});
function init(meta) {
// empty
Convenience.initTranslations();
}
let _indicator;

View File

@@ -1,5 +1,8 @@
{
"extension-id": "@extension_id@",
"uuid": "@uuid@",
"settings-schema": "@gschemaname@",
"gettext-domain": "@gettext_domain@",
"name": "Workspace Indicator",
"description": "Put an indicator on the panel signaling in which workspace you are, and give you the possibility of switching to another one",
"shell-version": [ "@shell_current@" ],

View File

@@ -17,6 +17,10 @@ const Gettext = imports.gettext.domain('gnome-shell-extensions');
const _ = Gettext.gettext;
const N_ = function(e) { return e };
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const possibleRotations = [ GnomeDesktop.RRRotation.ROTATION_0,
GnomeDesktop.RRRotation.ROTATION_90,
GnomeDesktop.RRRotation.ROTATION_180,
@@ -137,8 +141,7 @@ Indicator.prototype = {
function init(metadata) {
let me = imports.ui.extensionSystem.extensions[metadata.uuid];
me.convenience.initTranslations(metadata);
Convenience.initTranslations();
}
let _indicator;

View File

@@ -1,5 +1,8 @@
{
"extension-id": "@extension_id@",
"uuid": "@uuid@",
"settings-schema": "@gschemaname@",
"gettext-domain": "@gettext_domain@",
"name": "Monitor Status Indicator",
"description": "Add a systems status menu for rotating monitors (overrides what is currently provided by gnome-settings-daemon)",
"shell-version": [ "@shell_current@" ],

View File

@@ -7,5 +7,6 @@ extensionbase = @gnome-shell-extensions.gcampax.github.com
gschemabase = org.gnome.shell.extensions
uuid = $(EXTENSION_ID)$(extensionbase)
gschemaname = $(gschemabase).$(EXTENSION_ID)
extensiondir = $(topextensiondir)/$(uuid)

View File

@@ -1,17 +1,45 @@
/* -*- mode: js; js-basic-offset: 4; indent-tabs-mode: nil -*- */
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);
const ExtensionUtils = imports.misc.extensionUtils;
/**
* 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'];
let localeDir = extension.dir.get_child('locale').get_path();
Gettext.bindtextdomain(domain, localeDir);
}
function getSettings(metadata, extension_id) {
let schemaDir = metadata.dir.get_child('schemas').get_path();
/**
* 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'];
let schemaDir = extension.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 });
Gio.SettingsSchemaSource.get_default(),
false);
let schemaObj = schemaSource.lookup(schema, false);
return new Gio.Settings({ settings_schema: schemaObj });
}

10
settings.mk Normal file
View File

@@ -0,0 +1,10 @@
gschemas_in = $(gschemaname).gschema.xml.in
@INTLTOOL_XML_NOMERGE_RULE@
gsettings_SCHEMAS = $(gschemas_in:.xml.in=.xml)
@GSETTINGS_RULES@
CLEANFILES += $(gschemas_in:.xml.in=.valid) $(gsettings_SCHEMAS)
EXTRA_DIST += $(gschemas_in)