[gnome-shell/wip/aggregate-menu: 36/36] aggregate menu xxx



commit c6e9998a7ba6e080b5465e982161b48634c538e0
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Apr 23 18:13:38 2013 -0400

    aggregate menu xxx

 js/Makefile.am                 |    2 -
 js/gdm/powerMenu.js            |  129 ----------------------------------------
 js/ui/panel.js                 |   49 ++++++++++-----
 js/ui/panelMenu.js             |   31 ++++------
 js/ui/sessionMode.js           |   10 +--
 js/ui/status/accessibility.js  |    4 +-
 js/ui/status/bluetooth.js      |    4 +-
 js/ui/status/lockScreenMenu.js |   62 -------------------
 js/ui/status/network.js        |    6 +-
 js/ui/status/power.js          |    6 +-
 js/ui/status/system.js         |   12 +---
 js/ui/status/volume.js         |    8 +-
 12 files changed, 64 insertions(+), 259 deletions(-)
---
diff --git a/js/Makefile.am b/js/Makefile.am
index c388d26..c6f5dac 100644
--- a/js/Makefile.am
+++ b/js/Makefile.am
@@ -20,7 +20,6 @@ nobase_dist_js_DATA =         \
        gdm/batch.js            \
        gdm/fingerprint.js      \
        gdm/loginDialog.js      \
-       gdm/powerMenu.js        \
        gdm/realmd.js           \
        gdm/util.js             \
        extensionPrefs/main.js  \
@@ -90,7 +89,6 @@ nobase_dist_js_DATA =         \
        ui/status/accessibility.js      \
        ui/status/brightness.js \
        ui/status/keyboard.js   \
-       ui/status/lockScreenMenu.js     \
        ui/status/network.js    \
        ui/status/power.js      \
        ui/status/volume.js     \
diff --git a/js/ui/panel.js b/js/ui/panel.js
index dbd03fb..f8bca82 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -921,31 +921,48 @@ const PanelCorner = new Lang.Class({
     }
 });
 
+const AggregateMenu = new Lang.Class({
+    Name: 'AggregateMenu',
+    Extends: PanelMenu.Button,
+
+    _init: function() {
+        this.parent(0.0, _("Settings Menu"), false);
+
+        this._indicators = new St.BoxLayout({ style_class: 'panel-status-button-box' });
+        this.actor.add_child(this._indicators);
+
+        let network = new imports.ui.status.network.NMApplet();
+        let power = new imports.ui.status.power.Indicator();
+        let volume = new imports.ui.status.volume.Indicator();
+        let brightness = new imports.ui.status.brightness.Indicator();
+        let system = new imports.ui.status.system.Indicator();
+
+        this._indicators.add_child(network.indicators);
+        this._indicators.add_child(power.indicators);
+        this._indicators.add_child(volume.indicators);
+        this._indicators.add_child(system.indicators);
+        this._indicators.add_child(new St.Label({ text: '\u25BE' }));
+
+        this.menu.addMenuItem(volume.menu);
+        this.menu.addMenuItem(brightness.menu);
+        this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
+        this.menu.addMenuItem(network.menu);
+        this.menu.addMenuItem(power.menu);
+        this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
+        this.menu.addMenuItem(system.menu);
+    },
+});
+
 const PANEL_ITEM_IMPLEMENTATIONS = {
     'activities': ActivitiesButton,
+    'aggregateMenu': AggregateMenu,
     'appMenu': AppMenuButton,
     'dateMenu': imports.ui.dateMenu.DateMenuButton,
     'a11y': imports.ui.status.accessibility.ATIndicator,
     'a11yGreeter': imports.ui.status.accessibility.ATGreeterIndicator,
-    'volume': imports.ui.status.volume.Indicator,
-    'battery': imports.ui.status.power.Indicator,
-    'lockScreen': imports.ui.status.lockScreenMenu.Indicator,
     'keyboard': imports.ui.status.keyboard.InputSourceIndicator,
-    'powerMenu': imports.gdm.powerMenu.PowerMenuButton,
-    'system': imports.ui.status.system.Indicator,
 };
 
-if (Config.HAVE_BLUETOOTH)
-    PANEL_ITEM_IMPLEMENTATIONS['bluetooth'] =
-        imports.ui.status.bluetooth.Indicator;
-
-try {
-    PANEL_ITEM_IMPLEMENTATIONS['network'] =
-        imports.ui.status.network.NMApplet;
-} catch(e) {
-    log('NMApplet is not supported. It is possible that your NetworkManager version is too old');
-}
-
 const Panel = new Lang.Class({
     Name: 'Panel',
 
diff --git a/js/ui/panelMenu.js b/js/ui/panelMenu.js
index b73152e..40ce47c 100644
--- a/js/ui/panelMenu.js
+++ b/js/ui/panelMenu.js
@@ -224,37 +224,28 @@ const Button = new Lang.Class({
 });
 Signals.addSignalMethods(Button.prototype);
 
-/* SystemStatusButton:
+/* SystemIndicator:
  *
- * This class manages one System Status indicator (network, keyboard,
- * volume, bluetooth...), which is just a PanelMenuButton with an
- * icon.
+ * This class manages one system indicator, which are the icons
+ * that you see at the top right. A system indicator is composed
+ * of an icon and a menu section, which will be composed into the
+ * aggregate section.
  */
-const SystemStatusButton = new Lang.Class({
-    Name: 'SystemStatusButton',
-    Extends: Button,
+const SystemIndicator = new Lang.Class({
+    Name: 'SystemIndicator',
 
-    _init: function(iconName, nameText) {
-        this.parent(0.0, nameText);
-        this.actor.add_style_class_name('panel-status-button');
-
-        this._box = new St.BoxLayout({ style_class: 'panel-status-button-box' });
-        this.actor.add_actor(this._box);
+    _init: function(iconName) {
+        this.indicators = new St.BoxLayout({ style_class: 'panel-status-button-box' });
+        this.menu = new PopupMenu.PopupMenuSection();
 
         if (iconName)
             this.setIcon(iconName);
     },
 
-    get icons() {
-        return this._box.get_children();
-    },
-
     addIcon: function(gicon) {
         let icon = new St.Icon({ gicon: gicon,
                                  style_class: 'system-status-icon' });
-        this._box.add_actor(icon);
-
-        this.emit('icons-changed');
+        this.indicators.add_actor(icon);
 
         return icon;
     },
diff --git a/js/ui/sessionMode.js b/js/ui/sessionMode.js
index fb5147b..8a00c2f 100644
--- a/js/ui/sessionMode.js
+++ b/js/ui/sessionMode.js
@@ -47,8 +47,7 @@ const _modes = {
         panel: {
             left: [],
             center: ['dateMenu'],
-            right: ['a11yGreeter', 'display', 'keyboard',
-                    'volume', 'battery', 'powerMenu']
+            right: ['a11yGreeter', 'keyboard', 'aggregateMenu'],
         },
         panelStyle: 'login-screen'
     },
@@ -61,7 +60,7 @@ const _modes = {
         panel: {
             left: [],
             center: [],
-            right: ['lockScreen']
+            right: ['aggregateMenu']
         },
         panelStyle: 'lock-screen'
     },
@@ -73,7 +72,7 @@ const _modes = {
         panel: {
             left: [],
             center: [],
-            right: ['a11y', 'keyboard', 'lockScreen']
+            right: ['a11y', 'keyboard', 'aggregateMenu']
         },
         panelStyle: 'unlock-screen'
     },
@@ -95,8 +94,7 @@ const _modes = {
         panel: {
             left: ['activities', 'appMenu'],
             center: ['dateMenu'],
-            right: ['a11y', 'keyboard', 'volume', 'bluetooth',
-                    'network', 'battery', 'system']
+            right: ['a11y', 'keyboard', 'aggregateMenu']
         }
     }
 };
diff --git a/js/ui/status/accessibility.js b/js/ui/status/accessibility.js
index e6be115..1639c42 100644
--- a/js/ui/status/accessibility.js
+++ b/js/ui/status/accessibility.js
@@ -30,10 +30,10 @@ const HIGH_CONTRAST_THEME = 'HighContrast';
 
 const ATIndicator = new Lang.Class({
     Name: 'ATIndicator',
-    Extends: PanelMenu.SystemStatusButton,
+    Extends: PanelMenu.Button,
 
     _init: function() {
-        this.parent('preferences-desktop-accessibility-symbolic', _("Accessibility"));
+        this.parent('preferences-desktop-accessibility-symbolic');
 
         let highContrast = this._buildHCItem();
         this.menu.addMenuItem(highContrast);
diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js
index 903ef3e..1df5d6f 100644
--- a/js/ui/status/bluetooth.js
+++ b/js/ui/status/bluetooth.js
@@ -22,10 +22,10 @@ const ConnectionState = {
 
 const Indicator = new Lang.Class({
     Name: 'BTIndicator',
-    Extends: PanelMenu.SystemStatusButton,
+    Extends: PanelMenu.SystemIndicator,
 
     _init: function() {
-        this.parent('bluetooth-disabled-symbolic', _("Bluetooth"));
+        this.parent('bluetooth-disabled-symbolic');
 
         this._applet = new GnomeBluetoothApplet.Applet();
 
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 8db7b42..da09b90 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -1289,10 +1289,10 @@ const NMVPNSection = new Lang.Class({
 
 const NMApplet = new Lang.Class({
     Name: 'NMApplet',
-    Extends: PanelMenu.SystemStatusButton,
+    Extends: PanelMenu.SystemIndicator,
 
     _init: function() {
-        this.parent('network-offline-symbolic', _('Network'));
+        this.parent('network-offline-symbolic');
 
         this.secondaryIcon = this.addIcon(new Gio.ThemedIcon({ name: 'network-vpn-symbolic' }));
         this.secondaryIcon.hide();
@@ -1755,7 +1755,7 @@ const NMApplet = new Lang.Class({
 
     _syncNMState: function() {
         this.mainIcon.visible = this._client.manager_running;
-        this.actor.visible = this.mainIcon.visible;
+        this.indicators.visible = this.mainIcon.visible;
 
         if (!this._client.networking_enabled) {
             this.setIcon('network-offline-symbolic');
diff --git a/js/ui/status/power.js b/js/ui/status/power.js
index ec7739f..9f46e3e 100644
--- a/js/ui/status/power.js
+++ b/js/ui/status/power.js
@@ -25,10 +25,10 @@ const PowerManagerProxy = Gio.DBusProxy.makeProxyWrapper(PowerManagerInterface);
 
 const Indicator = new Lang.Class({
     Name: 'PowerIndicator',
-    Extends: PanelMenu.SystemStatusButton,
+    Extends: PanelMenu.SystemIndicator,
 
     _init: function() {
-        this.parent('battery-missing-symbolic', _("Battery"));
+        this.parent('battery-missing-symbolic');
 
         this._proxy = new PowerManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH,
                                             Lang.bind(this, function(proxy, error) {
@@ -111,7 +111,7 @@ const Indicator = new Lang.Class({
             hasIcon = true;
         }
         this.mainIcon.visible = hasIcon;
-        this.actor.visible = hasIcon;
+        this.indicators.visible = hasIcon;
     },
 
     _syncAirplaneMode: function() {
diff --git a/js/ui/status/system.js b/js/ui/status/system.js
index a1c2990..8bcf019 100644
--- a/js/ui/status/system.js
+++ b/js/ui/status/system.js
@@ -41,10 +41,10 @@ const SystemdLoginSession = Gio.DBusProxy.makeProxyWrapper(SystemdLoginSessionIf
 
 const Indicator = new Lang.Class({
     Name: 'SystemIndicator',
-    Extends: PanelMenu.SystemStatusButton,
+    Extends: PanelMenu.SystemIndicator,
 
     _init: function() {
-        this.parent('system-shutdown-symbolic', _("System"));
+        this.parent('system-shutdown-symbolic');
 
         this._screenSaverSettings = new Gio.Settings({ schema: SCREENSAVER_SCHEMA });
         this._lockdownSettings = new Gio.Settings({ schema: LOCKDOWN_SCHEMA });
@@ -97,14 +97,6 @@ const Indicator = new Lang.Class({
             }));
         this._lockdownSettings.connect('changed::' + DISABLE_LOG_OUT_KEY,
                                        Lang.bind(this, this._updateHaveShutdown));
-
-        Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
-        this._sessionUpdated();
-    },
-
-    _sessionUpdated: function() {
-        this.actor.visible = !Main.sessionMode.isGreeter;
-        this.setSensitive(!Main.sessionMode.isLocked);
     },
 
     _updateMultiUser: function() {
diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js
index 62114a1..d751a21 100644
--- a/js/ui/status/volume.js
+++ b/js/ui/status/volume.js
@@ -294,16 +294,16 @@ const VolumeMenu = new Lang.Class({
 
 const Indicator = new Lang.Class({
     Name: 'VolumeIndicator',
-    Extends: PanelMenu.SystemStatusButton,
+    Extends: PanelMenu.SystemIndicator,
 
     _init: function() {
-        this.parent('audio-volume-muted-symbolic', _("Volume"));
+        this.parent('audio-volume-muted-symbolic');
 
         this._control = getMixerControl();
         this._volumeMenu = new VolumeMenu(this._control);
         this._volumeMenu.connect('icon-changed', Lang.bind(this, function(menu) {
             let icon = this._volumeMenu.getIcon();
-            this.actor.visible = (icon != null);
+            this.indicators.visible = (icon != null);
             this.setIcon(icon);
         }));
         this._volumeMenu.connect('headphones-changed', Lang.bind(this, function(menu, value) {
@@ -315,7 +315,7 @@ const Indicator = new Lang.Class({
 
         this.menu.addMenuItem(this._volumeMenu);
 
-        this.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
+        this.indicators.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
     },
 
     _onScrollEvent: function(actor, event) {


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