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
This commit is contained in:
Giovanni Campagna 2011-11-20 15:38:48 +01:00
parent 2b57603271
commit 566bdb50c2
11 changed files with 73 additions and 111 deletions

View File

@ -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();
}
};
});

View File

@ -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 = {
}
}
}
};
});

View File

@ -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);

View File

@ -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,17 +90,14 @@ 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,
this.parent({ reactive: true,
can_focus: true,
track_hover: true });
@ -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;
}
}
};
});

View File

@ -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);
});

View File

@ -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);

View File

@ -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);
}
};
});

View File

@ -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();

View File

@ -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',

View File

@ -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));
}
};
});

View File

@ -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();
}
}
};
});