Commit 064a4c58 authored by Giovanni Campagna's avatar Giovanni Campagna
Browse files

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.
parent c828d095
......@@ -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
......
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)
EXTENSION_ID = alternative-status-menu
include ../../extension.mk
/* -*- 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);
}
{
"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@"
}
.popup-alternating-menu-item:alternate {
font-weight: normal !important;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment