auto-move-windows: make the suspend and hibernate items configurable

Desktop users rarely use suspend, and in general hibernate is
more trouble than it's worth to show at all times, so make their
visibility configurable in GSettings.
Supend defaults to true (since that's the GNOME 3 message anyway),
while hibernate is normally false. No UI is provided, since it's
unlikely that changing this is necessary.
This commit is contained in:
Giovanni Campagna
2012-04-29 23:26:07 +02:00
parent d355424f22
commit 31ff2d4c97
4 changed files with 31 additions and 2 deletions
@@ -1,3 +1,4 @@
EXTENSION_ID = alternative-status-menu
include ../../extension.mk
include ../../settings.mk
@@ -15,13 +15,15 @@ let suspend_item = null;
let hibernate_item = null;
let poweroff_item = null;
let suspend_signal_id = 0, hibernate_signal_id = 0;
let settings = null;
let setting_changed_id = 0;
function updateSuspend(object, pspec, item) {
item.actor.visible = object.get_can_suspend();
item.actor.visible = object.get_can_suspend() && settings.get_boolean('allow-suspend');
}
function updateHibernate(object, pspec, item) {
item.actor.visible = object.get_can_hibernate();
item.actor.visible = object.get_can_hibernate() && settings.get_boolean('allow-hibernate');
}
function onSuspendActivate(item) {
@@ -48,6 +50,8 @@ function init(metadata) {
function enable() {
let statusMenu = Main.panel._statusArea.userMenu;
settings = Convenience.getSettings();
let children = statusMenu.menu._getMenuItems();
let index = children.length;
@@ -85,6 +89,11 @@ function enable() {
// clear out this to avoid criticals (we don't mess with
// updateSuspendOrPowerOff)
statusMenu._suspendOrPowerOffItem = null;
setting_changed_id = settings.connect('changed', function() {
updateSuspend(statusMenu._upClient, null, suspend_item);
updateHibernate(statusMenu._upClient, null, hibernate_item);
});
}
function disable() {
@@ -106,6 +115,10 @@ function disable() {
statusMenu._upClient.disconnect(hibernate_signal_id);
suspend_signal_id = hibernate_signal_id = 0;
settings.disconnect(setting_changed_id);
setting_changed_id = 0;
settings = null;
/* destroy the entries we had created */
suspend_item.destroy();
hibernate_item.destroy();
@@ -0,0 +1,14 @@
<schemalist gettext-domain="gnome-shell-extensions">
<schema id="org.gnome.shell.extensions.alternative-status-menu" path="/org/gnome/shell/extensions/alternative-status-menu/">
<key name="allow-suspend" type="b">
<default>true</default>
<_summary>Enable suspending</_summary>
<_description>Control the visibility of the Suspend menu item</_description>
</key>
<key name="allow-hibernate" type="b">
<default>false</default>
<_summary>Enable hibernating</_summary>
<_description>Control the visibility of the Hibernate menu item</_description>
</key>
</schema>
</schemalist>
+1
View File
@@ -2,6 +2,7 @@ extensions/alternate-tab/extension.js
extensions/alternate-tab/org.gnome.shell.extensions.alternate-tab.gschema.xml.in
extensions/alternate-tab/prefs.js
extensions/alternative-status-menu/extension.js
extensions/alternative-status-menu/org.gnome.shell.extensions.alternative-status-menu.gschema.xml.in
extensions/apps-menu/extension.js
extensions/auto-move-windows/extension.js
extensions/auto-move-windows/org.gnome.shell.extensions.auto-move-windows.gschema.xml.in