[gnome-shell] Port PanelMenu to new class framework



commit 566bdb50c2786aef5f7840a3cf95e53a7c37c7bc
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sun Nov 20 15:38:48 2011 +0100

    Port PanelMenu to new class framework
    
    Second patch in the class framework, now it's the turn of
    PanelMenu (buttons, menus and status indicators).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=664436

 js/gdm/powerMenu.js           |   13 +++++--------
 js/ui/dateMenu.js             |   13 +++++--------
 js/ui/panel.js                |   26 ++++++++++----------------
 js/ui/panelMenu.js            |   39 ++++++++++++++++-----------------------
 js/ui/status/accessibility.js |   14 +++++---------
 js/ui/status/bluetooth.js     |   13 +++++--------
 js/ui/status/keyboard.js      |   13 +++++--------
 js/ui/status/network.js       |   12 +++++-------
 js/ui/status/power.js         |   14 ++++++--------
 js/ui/status/volume.js        |   13 +++++--------
 js/ui/userMenu.js             |   14 ++++++--------
 11 files changed, 73 insertions(+), 111 deletions(-)
---
diff --git a/js/gdm/powerMenu.js b/js/gdm/powerMenu.js
index b590d75..efe1a8f 100644
--- a/js/gdm/powerMenu.js
+++ b/js/gdm/powerMenu.js
@@ -25,15 +25,12 @@ const ConsoleKit = imports.gdm.consoleKit;
 const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
 
-function PowerMenuButton() {
-    this._init();
-}
-
-PowerMenuButton.prototype = {
-    __proto__: PanelMenu.SystemStatusButton.prototype,
+const PowerMenuButton = new Lang.Class({
+    Name: 'PowerMenuButton',
+    Extends: PanelMenu.SystemStatusButton,
 
     _init: function() {
-        PanelMenu.SystemStatusButton.prototype._init.call(this, 'system-shutdown', null);
+        this.parent('system-shutdown', null);
         this._consoleKitManager = new ConsoleKit.ConsoleKitManager();
         this._upClient = new UPowerGlib.Client();
 
@@ -143,4 +140,4 @@ PowerMenuButton.prototype = {
         if (this._haveShutdown)
             this._consoleKitManager.StopRemote();
     }
-};
+});
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index 224d2bc..d3b2309 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -40,12 +40,9 @@ function _onVertSepRepaint (area)
     cr.stroke();
 };
 
-function DateMenuButton() {
-    this._init.apply(this, arguments);
-}
-
-DateMenuButton.prototype = {
-    __proto__: PanelMenu.Button.prototype,
+const DateMenuButton = new Lang.Class({
+    Name: 'DateMenuButton',
+    Extends: PanelMenu.Button,
 
     _init: function(params) {
         params = Params.parse(params, { showEvents: true });
@@ -57,7 +54,7 @@ DateMenuButton.prototype = {
         let menuAlignment = 0.25;
         if (St.Widget.get_default_direction() == St.TextDirection.RTL)
             menuAlignment = 1.0 - menuAlignment;
-        PanelMenu.Button.prototype._init.call(this, menuAlignment);
+        this.parent(menuAlignment);
 
         this._clock = new St.Label();
         this.actor.add_actor(this._clock);
@@ -239,4 +236,4 @@ DateMenuButton.prototype = {
             }
         }
     }
-};
+});
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 2f78db9..db53776 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -235,15 +235,12 @@ TextShadower.prototype = {
  * this menu also handles startup notification for it.  So when we
  * have an active startup notification, we switch modes to display that.
  */
-function AppMenuButton() {
-    this._init();
-}
-
-AppMenuButton.prototype = {
-    __proto__: PanelMenu.Button.prototype,
+const AppMenuButton = new Lang.Class({
+    Name: 'AppMenuButton',
+    Extends: PanelMenu.Button,
 
     _init: function() {
-        PanelMenu.Button.prototype._init.call(this, 0.0);
+        this.parent(0.0);
         this._startingApps = [];
 
         this._targetApp = null;
@@ -546,22 +543,19 @@ AppMenuButton.prototype = {
 
         this.emit('changed');
     }
-};
+});
 
 Signals.addSignalMethods(AppMenuButton.prototype);
 
 // Activities button. Because everything else in the top bar is a
 // PanelMenu.Button, it simplifies some things to make this be one too.
 // We just hack it up to not actually have a menu attached to it.
-function ActivitiesButton() {
-    this._init.apply(this, arguments);
-}
-
-ActivitiesButton.prototype = {
-    __proto__: PanelMenu.Button.prototype,
+const ActivitiesButton = new Lang.Class({
+    Name: 'ActivitiesButton',
+    Extends: PanelMenu.Button,
 
     _init: function() {
-        PanelMenu.Button.prototype._init.call(this, 0.0);
+        this.parent(0.0);
 
         let container = new Shell.GenericContainer();
         container.connect('get-preferred-width', Lang.bind(this, this._containerGetPreferredWidth));
@@ -698,7 +692,7 @@ ActivitiesButton.prototype = {
         Mainloop.source_remove(this._xdndTimeOut);
         this._xdndTimeOut = 0;
     }
-};
+})
 
 function PanelCorner(panel, side) {
     this._init(panel, side);
diff --git a/js/ui/panelMenu.js b/js/ui/panelMenu.js
index 1f7b87e..927311b 100644
--- a/js/ui/panelMenu.js
+++ b/js/ui/panelMenu.js
@@ -11,11 +11,9 @@ const Main = imports.ui.main;
 const Params = imports.misc.params;
 const PopupMenu = imports.ui.popupMenu;
 
-function ButtonBox(params) {
-    this._init.apply(this, arguments);
-};
+const ButtonBox = new Lang.Class({
+    Name: 'ButtonBox',
 
-ButtonBox.prototype = {
     _init: function(params) {
         params = Params.parse(params, { style_class: 'panel-button' }, true);
         this.actor = new Shell.GenericContainer(params);
@@ -92,19 +90,16 @@ ButtonBox.prototype = {
 
         child.allocate(childBox, flags);
     },
-}
+});
 
-function Button(menuAlignment) {
-    this._init(menuAlignment);
-}
-
-Button.prototype = {
-    __proto__: ButtonBox.prototype,
+const Button = new Lang.Class({
+    Name: 'PanelMenuButton',
+    Extends: ButtonBox,
 
     _init: function(menuAlignment) {
-        ButtonBox.prototype._init.call(this, { reactive: true,
-                                               can_focus: true,
-                                               track_hover: true });
+        this.parent({ reactive: true,
+                      can_focus: true,
+                      track_hover: true });
 
         this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));
         this.actor.connect('key-press-event', Lang.bind(this, this._onSourceKeyPress));
@@ -175,7 +170,7 @@ Button.prototype = {
 
         this.emit('destroy');
     }
-};
+});
 Signals.addSignalMethods(Button.prototype);
 
 /* SystemStatusButton:
@@ -184,15 +179,13 @@ Signals.addSignalMethods(Button.prototype);
  * volume, bluetooth...), which is just a PanelMenuButton with an
  * icon and a tooltip
  */
-function SystemStatusButton() {
-    this._init.apply(this, arguments);
-}
-
-SystemStatusButton.prototype = {
-    __proto__: Button.prototype,
+const SystemStatusButton = new Lang.Class({
+    Name: 'SystemStatusButton',
+    Extends: Button,
 
     _init: function(iconName,tooltipText) {
-        Button.prototype._init.call(this, 0.0);
+        this.parent(0.0);
+
         this._iconActor = new St.Icon({ icon_name: iconName,
                                         icon_type: St.IconType.SYMBOLIC,
                                         style_class: 'system-status-icon' });
@@ -219,4 +212,4 @@ SystemStatusButton.prototype = {
             this.tooltip = null;
         }
     }
-};
+});
diff --git a/js/ui/status/accessibility.js b/js/ui/status/accessibility.js
index 77c5141..2804da3 100644
--- a/js/ui/status/accessibility.js
+++ b/js/ui/status/accessibility.js
@@ -40,15 +40,12 @@ const KEY_TEXT_SCALING_FACTOR = 'text-scaling-factor';
 
 const HIGH_CONTRAST_THEME = 'HighContrast';
 
-function ATIndicator() {
-    this._init.apply(this, arguments);
-}
-
-ATIndicator.prototype = {
-    __proto__: PanelMenu.SystemStatusButton.prototype,
+const ATIndicator = new Lang.Class({
+    Name: 'ATIndicator',
+    Extends: PanelMenu.SystemStatusButton,
 
     _init: function() {
-        PanelMenu.SystemStatusButton.prototype._init.call(this, 'preferences-desktop-accessibility', null);
+        this.parent('preferences-desktop-accessibility', null);
 
         let highContrast = this._buildHCItem();
         this.menu.addMenuItem(highContrast);
@@ -172,5 +169,4 @@ ATIndicator.prototype = {
         });
         return widget;
     }
-};
-Signals.addSignalMethods(ATIndicator.prototype);
+});
diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js
index 9118c6f..13d1b4a 100644
--- a/js/ui/status/bluetooth.js
+++ b/js/ui/status/bluetooth.js
@@ -23,15 +23,12 @@ const ConnectionState = {
     CONNECTING: 3
 }
 
-function Indicator() {
-    this._init.apply(this, arguments);
-}
-
-Indicator.prototype = {
-    __proto__: PanelMenu.SystemStatusButton.prototype,
+const Indicator = new Lang.Class({
+    Name: 'BTIndicator',
+    Extends: PanelMenu.SystemStatusButton,
 
     _init: function() {
-        PanelMenu.SystemStatusButton.prototype._init.call(this, 'bluetooth-disabled', null);
+        this.parent('bluetooth-disabled', null);
 
         GLib.spawn_command_line_sync ('pkill -f "^bluetooth-applet$"');
         this._applet = new GnomeBluetoothApplet.Applet();
@@ -335,7 +332,7 @@ Indicator.prototype = {
     _cancelRequest: function() {
         this._source.destroy();
     }
-}
+});
 
 function Source() {
     this._init.apply(this, arguments);
diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js
index f6f2d45..cffb608 100644
--- a/js/ui/status/keyboard.js
+++ b/js/ui/status/keyboard.js
@@ -36,15 +36,12 @@ const LayoutMenuItem = new Lang.Class({
     }
 });
 
-function XKBIndicator() {
-    this._init.call(this);
-}
-
-XKBIndicator.prototype = {
-    __proto__: PanelMenu.Button.prototype,
+const XKBIndicator = new Lang.Class({
+    Name: 'XKBIndicator',
+    Extends: PanelMenu.Button,
 
     _init: function() {
-        PanelMenu.Button.prototype._init.call(this, St.Align.START);
+        this.parent(0.0);
 
         this._container = new Shell.GenericContainer();
         this._container.connect('get-preferred-width', Lang.bind(this, this._containerGetPreferredWidth));
@@ -219,4 +216,4 @@ XKBIndicator.prototype = {
         for (let i = 0; i < this._labelActors.length; i++)
             this._labelActors[i].allocate_align_fill(box, 0.5, 0, false, false, flags);
     }
-};
+});
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 57edc9c..9fd157d 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -1548,14 +1548,12 @@ NMDeviceWireless.prototype = {
     },
 };
 
-function NMApplet() {
-    this._init.apply(this, arguments);
-}
-NMApplet.prototype = {
-    __proto__: PanelMenu.SystemStatusButton.prototype,
+const NMApplet = new Lang.Class({
+    Name: 'NMApplet',
+    Extends: PanelMenu.SystemStatusButton,
 
     _init: function() {
-        PanelMenu.SystemStatusButton.prototype._init.call(this, 'network-error');
+        this.parent('network-error', null);
 
         this._client = NMClient.Client.new();
 
@@ -2121,7 +2119,7 @@ NMApplet.prototype = {
             this._mobileUpdateId = 0;
         }
     }
-};
+});
 
 function NMMessageTraySource() {
     this._init();
diff --git a/js/ui/status/power.js b/js/ui/status/power.js
index 836b010..a393215 100644
--- a/js/ui/status/power.js
+++ b/js/ui/status/power.js
@@ -52,15 +52,13 @@ const PowerManagerInterface = <interface name="org.gnome.SettingsDaemon.Power">
 
 const PowerManagerProxy = Gio.DBusProxy.makeProxyWrapper(PowerManagerInterface);
 
-function Indicator() {
-    this._init.apply(this, arguments);
-}
-
-Indicator.prototype = {
-    __proto__: PanelMenu.SystemStatusButton.prototype,
+const Indicator = new Lang.Class({
+    Name: 'PowerIndicator',
+    Extends: PanelMenu.SystemStatusButton,
 
     _init: function() {
-        PanelMenu.SystemStatusButton.prototype._init.call(this, 'battery-missing');
+        this.parent('battery-missing', null);
+
         this._proxy = new PowerManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH);
 
         this._deviceItems = [ ];
@@ -163,7 +161,7 @@ Indicator.prototype = {
         this._readPrimaryDevice();
         this._readOtherDevices();
     }
-};
+});
 
 const DeviceItem = new Lang.Class({
     Name: 'DeviceItem',
diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js
index 3caa816..fcaa069 100644
--- a/js/ui/status/volume.js
+++ b/js/ui/status/volume.js
@@ -17,15 +17,12 @@ const VOLUME_ADJUSTMENT_STEP = 0.05; /* Volume adjustment step in % */
 
 const VOLUME_NOTIFY_ID = 1;
 
-function Indicator() {
-    this._init.apply(this, arguments);
-}
-
-Indicator.prototype = {
-    __proto__: PanelMenu.SystemStatusButton.prototype,
+const Indicator = new Lang.Class({
+    Name: 'VolumeIndicator',
+    Extends: PanelMenu.SystemStatusButton,
 
     _init: function() {
-        PanelMenu.SystemStatusButton.prototype._init.call(this, 'audio-volume-muted', null);
+        this.parent('audio-volume-muted', null);
 
         this._control = new Gvc.MixerControl({ name: 'GNOME Shell Volume Control' });
         this._control.connect('state-changed', Lang.bind(this, this._onControlStateChanged));
@@ -214,4 +211,4 @@ Indicator.prototype = {
         if (property == '_output' && !this._output.is_muted)
             this.setIcon(this._volumeToIcon(this._output.volume));
     }
-};
+});
diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js
index c934020..fdac848 100644
--- a/js/ui/userMenu.js
+++ b/js/ui/userMenu.js
@@ -414,15 +414,13 @@ const IMStatusChooserItem = new Lang.Class({
 });
 
 
-function UserMenuButton() {
-    this._init();
-}
-
-UserMenuButton.prototype = {
-    __proto__: PanelMenu.Button.prototype,
+const UserMenuButton = new Lang.Class({
+    Name: 'UserMenuButton',
+    Extends: PanelMenu.Button,
 
     _init: function() {
-        PanelMenu.Button.prototype._init.call(this, 0.0);
+        this.parent(0.0);
+
         let box = new St.BoxLayout({ name: 'panelUserMenu' });
         this.actor.add_actor(box);
 
@@ -725,4 +723,4 @@ UserMenuButton.prototype = {
             this._session.ShutdownRemote();
         }
     }
-};
+});



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