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