[gnome-shell/eos3.8: 20/255] bottomPanel: Add a shutdown button to the login screen



commit fa2e6e007ae7cc3928e24eeb5a52f86cd161c76d
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 09596f0b2b..4fe9a4b3b0 100644
--- a/data/theme/gnome-shell-sass/_endless.scss
+++ b/data/theme/gnome-shell-sass/_endless.scss
@@ -66,6 +66,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 e90ea4cb6f..3bbf771c82 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;
@@ -787,6 +788,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,
@@ -795,6 +822,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 5974b3edd7..f6994e5f41 100644
--- a/js/ui/sessionMode.js
+++ b/js/ui/sessionMode.js
@@ -49,7 +49,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]