[gnome-shell/T27795: 29/138] bottomPanel: Add a shutdown button to the login screen



commit ab44f98f65a1854afc6b21ccb59c51346565c82e
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Mon Jan 29 18:36:27 2018 +0000

    bottomPanel: Add a shutdown button to the login screen
    
    The new design guidelines remove the shutdown related buttons from the
    panel's system indicator menu and move it to the user's menu. Since we
    do not have the user menu in the login screen we need to provide a way
    for shutting the machine down.
    
    This patch adds a new button to the panel that opens the shutdown dialog
    when clicked. It has a slight margin to the left in order to be visually
    ungrouped from the rest of the indicators.
    
    https://phabricator.endlessm.com/T17241

 data/theme/gnome-shell-sass/_endless.scss |  4 ++++
 js/ui/panel.js                            | 28 ++++++++++++++++++++++++++++
 js/ui/sessionMode.js                      |  2 +-
 3 files changed, 33 insertions(+), 1 deletion(-)
---
diff --git a/data/theme/gnome-shell-sass/_endless.scss b/data/theme/gnome-shell-sass/_endless.scss
index 63a5e0335c..939310d20b 100644
--- a/data/theme/gnome-shell-sass/_endless.scss
+++ b/data/theme/gnome-shell-sass/_endless.scss
@@ -63,6 +63,10 @@
         font-size: 14px;
         font-weight: bold;
     }
+
+    .powermenu {
+        margin-left: 16px;
+    }
 }
 
 .popup-menu {
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 8df104d757..08beeb301e 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -8,6 +8,7 @@ const Animation = imports.ui.animation;
 const Config = imports.misc.config;
 const CtrlAltTab = imports.ui.ctrlAltTab;
 const DND = imports.ui.dnd;
+const GnomeSession = imports.misc.gnomeSession;
 const Overview = imports.ui.overview;
 const PopupMenu = imports.ui.popupMenu;
 const PanelMenu = imports.ui.panelMenu;
@@ -776,6 +777,32 @@ class AggregateMenu extends PanelMenu.Button {
     }
 });
 
+var PowerMenu = GObject.registerClass(
+class PopoverMenu extends PanelMenu.SingleIconButton {
+    _init() {
+        super._init(0.0, C_("Power menu", "Power"), false);
+
+        this.accessible_role = Atk.Role.PUSH_BUTTON;
+
+        this._session = new GnomeSession.SessionManager();
+
+        let icon = new Gio.ThemedIcon({ name: 'system-shutdown-symbolic' });
+        this.setIcon(icon, PANEL_ICON_SIZE);
+
+        this.add_style_class_name('powermenu');
+    }
+
+    _onEvent(actor, event) {
+        if (this.menu &&
+            (event.type() == Clutter.EventType.TOUCH_BEGIN ||
+             event.type() == Clutter.EventType.BUTTON_PRESS)) {
+            this._session.ShutdownRemote(0);
+        }
+
+        return Clutter.EVENT_PROPAGATE;
+    }
+});
+
 const PANEL_ITEM_IMPLEMENTATIONS = {
     'activities': ActivitiesButton,
     'aggregateMenu': AggregateMenu,
@@ -784,6 +811,7 @@ const PANEL_ITEM_IMPLEMENTATIONS = {
     'a11y': imports.ui.status.accessibility.ATIndicator,
     'keyboard': imports.ui.status.keyboard.InputSourceIndicator,
     'dwellClick': imports.ui.status.dwellClick.DwellClickIndicator,
+    'powerMenu': PowerMenu,
 };
 
 var Panel = GObject.registerClass(
diff --git a/js/ui/sessionMode.js b/js/ui/sessionMode.js
index 99c521be4b..28fd3292e6 100644
--- a/js/ui/sessionMode.js
+++ b/js/ui/sessionMode.js
@@ -48,7 +48,7 @@ const _modes = {
         panel: {
             left: [],
             center: [],
-            right: ['dwellClick', 'a11y', 'keyboard', 'aggregateMenu']
+            right: ['dwellClick', 'a11y', 'keyboard', 'aggregateMenu', 'powerMenu']
         },
         panelStyle: 'login-screen'
     },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]