[gnome-shell-extensions] Add Alternative Status Menu extensions
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] Add Alternative Status Menu extensions
- Date: Sat, 12 Mar 2011 21:13:30 +0000 (UTC)
commit 064a4c5891b9a4674ece3c60fa5c472beb9d8769
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Sat Mar 12 21:59:56 2011 +0100
Add Alternative Status Menu extensions
For those who just cannot understand the design behind current
status menu, and want a power off item visible at all the time.
Adds the ability to hibernate as well.
configure.ac | 6 +-
extensions/Makefile.am | 2 +-
extensions/alternative-status-menu/Makefile.am | 3 +
extensions/alternative-status-menu/extension.js | 112 ++++++++++++++++++++
.../alternative-status-menu/metadata.json.in | 8 ++
extensions/alternative-status-menu/stylesheet.css | 3 +
6 files changed, 131 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b56830f..d769d5f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,8 @@ GLIB_GSETTINGS
ADDITIONAL_PACKAGES=
dnl keep this in sync with extensions/Makefile.am
-ALL_EXTENSIONS="example alternate-tab xrandr-indicator windowsNavigator auto-move-windows dock user-theme"
+ALL_EXTENSIONS="example alternate-tab xrandr-indicator windowsNavigator auto-move-windows
+dock user-theme alternative-status-menu"
AC_ARG_ENABLE([extensions],
[AS_HELP_STRING([--enable-extensions],[Space separated list of extensions to enable. Default is that all extensions are built.])],
[],
@@ -34,7 +35,7 @@ for e in $enable_extensions; do
ENABLED_EXTENSIONS="$ENABLED_EXTENSIONS $e"
ADDITIONAL_PACKAGES="gnome-desktop-3.0 >= 2.91.6"
;;
- alternate-tab|example|windowsNavigator|auto-move-windows|dock|user-theme)
+ alternate-tab|example|windowsNavigator|auto-move-windows|dock|user-theme|alternative-status-menu)
ENABLED_EXTENSIONS="$ENABLED_EXTENSIONS $e"
;;
*)
@@ -54,6 +55,7 @@ fi
dnl Please keep this sorted alphabetically
AC_CONFIG_FILES([
extensions/alternate-tab/Makefile
+ extensions/alternative-status-menu/Makefile
extensions/auto-move-windows/Makefile
extensions/dock/Makefile
extensions/example/Makefile
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
index 7a05e6d..8ef71ba 100644
--- a/extensions/Makefile.am
+++ b/extensions/Makefile.am
@@ -1,3 +1,3 @@
-DIST_SUBDIRS = example alternate-tab xrandr-indicator windowsNavigator auto-move-windows dock user-theme
+DIST_SUBDIRS = example alternate-tab xrandr-indicator windowsNavigator auto-move-windows dock user-theme alternative-status-menu
SUBDIRS = $(ENABLED_EXTENSIONS)
diff --git a/extensions/alternative-status-menu/Makefile.am b/extensions/alternative-status-menu/Makefile.am
new file mode 100644
index 0000000..4f95d47
--- /dev/null
+++ b/extensions/alternative-status-menu/Makefile.am
@@ -0,0 +1,3 @@
+EXTENSION_ID = alternative-status-menu
+
+include ../../extension.mk
diff --git a/extensions/alternative-status-menu/extension.js b/extensions/alternative-status-menu/extension.js
new file mode 100644
index 0000000..b9f9e07
--- /dev/null
+++ b/extensions/alternative-status-menu/extension.js
@@ -0,0 +1,112 @@
+/* -*- mode: js2 - indent-tabs-mode: nil - js2-basic-offset: 4 -*- */
+const Lang = imports.lang;
+const St = imports.gi.St;
+
+
+const Main = imports.ui.main;
+const PopupMenu = imports.ui.popupMenu;
+const GnomeSession = imports.misc.gnomeSession;
+
+const Gettext = imports.gettext.domain('gnome-shell');
+const _ = Gettext.gettext;
+
+function updateSuspendOrHibernate(object, pspec, item) {
+ let canSuspend = this._upClient.get_can_suspend();
+ let canHibernate = this._upClient.get_can_hibernate();
+
+ if (!canSuspend && !canHibernate) {
+ item.actor.hide();
+ return;
+ } else
+ item.actor.show();
+ if (!canSuspend && canHibernate) {
+ item.updateText(_("Hibernate"), null);
+ return;
+ }
+ let suspendText = _("Suspend");
+ let hibernateText = canHibernate ? _("Hibernate") : null;
+ item.updateText(suspendText, hibernateText);
+}
+
+function onSuspendOrHibernateActivate(item) {
+ Main.overview.hide();
+
+ let haveSuspend = this._upClient.get_can_suspend();
+ let haveHibernate = this._upClient.get_can_hibernate();
+
+ if (haveSuspend &&
+ item.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) {
+ this._screenSaverProxy.LockRemote(Lang.bind(this, function() {
+ this._upClient.suspend_sync(null);
+ }));
+ } else {
+ this._screenSaverProxy.LockRemote(Lang.bind(this, function() {
+ this._upClient.hibernate_sync(null);
+ }));
+ }
+}
+
+function createSubMenu() {
+ let item;
+
+ item = new PopupMenu.PopupImageMenuItem(_("Available"), 'user-available');
+ item.connect('activate', Lang.bind(this, this._setPresenceStatus, GnomeSession.PresenceStatus.AVAILABLE));
+ this.menu.addMenuItem(item);
+ this._presenceItems[GnomeSession.PresenceStatus.AVAILABLE] = item;
+
+ item = new PopupMenu.PopupImageMenuItem(_("Busy"), 'user-busy');
+ item.connect('activate', Lang.bind(this, this._setPresenceStatus, GnomeSession.PresenceStatus.BUSY));
+ this.menu.addMenuItem(item);
+ this._presenceItems[GnomeSession.PresenceStatus.BUSY] = item;
+
+ item = new PopupMenu.PopupSeparatorMenuItem();
+ this.menu.addMenuItem(item);
+
+ item = new PopupMenu.PopupMenuItem(_("My Account"));
+ item.connect('activate', Lang.bind(this, this._onMyAccountActivate));
+ this.menu.addMenuItem(item);
+
+ item = new PopupMenu.PopupMenuItem(_("System Settings"));
+ item.connect('activate', Lang.bind(this, this._onPreferencesActivate));
+ this.menu.addMenuItem(item);
+
+ item = new PopupMenu.PopupSeparatorMenuItem();
+ this.menu.addMenuItem(item);
+
+ item = new PopupMenu.PopupMenuItem(_("Lock Screen"));
+ item.connect('activate', Lang.bind(this, this._onLockScreenActivate));
+ this.menu.addMenuItem(item);
+
+ item = new PopupMenu.PopupMenuItem(_("Switch User"));
+ item.connect('activate', Lang.bind(this, this._onLoginScreenActivate));
+ this.menu.addMenuItem(item);
+ this._loginScreenItem = item;
+
+ item = new PopupMenu.PopupMenuItem(_("Log Out..."));
+ item.connect('activate', Lang.bind(this, this._onQuitSessionActivate));
+ this.menu.addMenuItem(item);
+
+ item = new PopupMenu.PopupSeparatorMenuItem();
+ this.menu.addMenuItem(item);
+
+ item = new PopupMenu.PopupAlternatingMenuItem(_("Suspend"),
+ _("Hibernate"));
+ this.menu.addMenuItem(item);
+ item.connect('activate', Lang.bind(this, onSuspendOrHibernateActivate));
+ this._upClient.connect('notify::can-suspend', Lang.bind(this, updateSuspendOrHibernate, item));
+ this._upClient.connect('notify::can-hibernate', Lang.bind(this, updateSuspendOrHibernate, item));
+ updateSuspendOrHibernate.call(this, null, null, item);
+
+ item = new PopupMenu.PopupMenuItem(_("Power off..."));
+ item.connect('activate', Lang.bind(this, function() {
+ this._session.ShutdownRemote();
+ }));
+ this.menu.addMenuItem(item);
+}
+
+// Put your extension initialization code here
+function main(metadata) {
+ let statusMenu = Main.panel._statusmenu;
+ statusMenu.menu.removeAll();
+ createSubMenu.call(statusMenu);
+}
diff --git a/extensions/alternative-status-menu/metadata.json.in b/extensions/alternative-status-menu/metadata.json.in
new file mode 100644
index 0000000..3c3c286
--- /dev/null
+++ b/extensions/alternative-status-menu/metadata.json.in
@@ -0,0 +1,8 @@
+{
+ "uuid": "@uuid@",
+ "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@" ],
+ "localedir": "@LOCALEDIR@",
+ "url": "@url@"
+}
diff --git a/extensions/alternative-status-menu/stylesheet.css b/extensions/alternative-status-menu/stylesheet.css
new file mode 100644
index 0000000..fd502bc
--- /dev/null
+++ b/extensions/alternative-status-menu/stylesheet.css
@@ -0,0 +1,3 @@
+.popup-alternating-menu-item:alternate {
+ font-weight: normal !important;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]