[gnome-shell-extensions] auto-move-windows: make the suspend and hibernate items configurable
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] auto-move-windows: make the suspend and hibernate items configurable
- Date: Sun, 29 Apr 2012 21:28:35 +0000 (UTC)
commit 31ff2d4c974fd09667082ca4e2d490f865a48e6b
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Sun Apr 29 23:23:45 2012 +0200
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.
extensions/alternative-status-menu/Makefile.am | 1 +
extensions/alternative-status-menu/extension.js | 17 +++++++++++++++--
...tensions.alternative-status-menu.gschema.xml.in | 14 ++++++++++++++
po/POTFILES.in | 1 +
4 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/extensions/alternative-status-menu/Makefile.am b/extensions/alternative-status-menu/Makefile.am
index 4f95d47..8823849 100644
--- a/extensions/alternative-status-menu/Makefile.am
+++ b/extensions/alternative-status-menu/Makefile.am
@@ -1,3 +1,4 @@
EXTENSION_ID = alternative-status-menu
include ../../extension.mk
+include ../../settings.mk
diff --git a/extensions/alternative-status-menu/extension.js b/extensions/alternative-status-menu/extension.js
index fbc6585..94d35a4 100644
--- a/extensions/alternative-status-menu/extension.js
+++ b/extensions/alternative-status-menu/extension.js
@@ -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();
diff --git a/extensions/alternative-status-menu/org.gnome.shell.extensions.alternative-status-menu.gschema.xml.in b/extensions/alternative-status-menu/org.gnome.shell.extensions.alternative-status-menu.gschema.xml.in
new file mode 100644
index 0000000..77ec320
--- /dev/null
+++ b/extensions/alternative-status-menu/org.gnome.shell.extensions.alternative-status-menu.gschema.xml.in
@@ -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>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9c3d6a4..7ddd177 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]