[gnome-shell] lockScreenMenu: Construct actual panel icons much more accurately
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] lockScreenMenu: Construct actual panel icons much more accurately
- Date: Fri, 21 Dec 2012 18:26:02 +0000 (UTC)
commit 1d136cacfbf551950b30613144a4adcc833eeb95
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Dec 20 20:25:54 2012 -0500
lockScreenMenu: Construct actual panel icons much more accurately
Instead of faking it by adding a bunch of main icons and secondary
icons to our own box, try and recreate the original button box
with the original icons.
https://bugzilla.gnome.org/show_bug.cgi?id=690589
js/ui/panelMenu.js | 6 +++
js/ui/status/lockScreenMenu.js | 70 +++++++++++++++++++++-------------------
2 files changed, 43 insertions(+), 33 deletions(-)
---
diff --git a/js/ui/panelMenu.js b/js/ui/panelMenu.js
index bde3f03..ad3600f 100644
--- a/js/ui/panelMenu.js
+++ b/js/ui/panelMenu.js
@@ -244,11 +244,17 @@ const SystemStatusButton = new Lang.Class({
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');
+
return icon;
},
diff --git a/js/ui/status/lockScreenMenu.js b/js/ui/status/lockScreenMenu.js
index 2e07874..e9ee6fd 100644
--- a/js/ui/status/lockScreenMenu.js
+++ b/js/ui/status/lockScreenMenu.js
@@ -10,6 +10,31 @@ const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const VolumeMenu = imports.ui.status.volume;
+const FakeStatusIcon = new Lang.Class({
+ Name: 'FakeStatusIcon',
+
+ _init: function(button) {
+ this.actor = new St.BoxLayout({ style_class: 'panel-status-button-box' });
+ this._button = button;
+ this._button.connect('icons-updated', Lang.bind(this, this._reconstructIcons));
+ this._button.actor.bind_property('visible', this.actor, 'visible',
+ GObject.BindingFlags.SYNC_CREATE);
+ this._reconstructIcons();
+ },
+
+ _reconstructIcons: function() {
+ this.actor.destroy_all_children();
+ this._button.icons.forEach(Lang.bind(this, function(icon) {
+ let newIcon = new St.Icon({ style_class: 'system-status-icon' });
+ icon.bind_property('gicon', newIcon, 'gicon',
+ GObject.BindingFlags.SYNC_CREATE);
+ icon.bind_property('visible', newIcon, 'visible',
+ GObject.BindingFlags.SYNC_CREATE);
+ this.actor.add_actor(newIcon);
+ }));
+ }
+});
+
const Indicator = new Lang.Class({
Name: 'LockScreenMenuIndicator',
Extends: PanelMenu.SystemStatusButton,
@@ -18,41 +43,20 @@ const Indicator = new Lang.Class({
this.parent(null, _("Volume, network, battery"));
this._box.style_class = 'lock-screen-status-button-box';
- this._volume = Main.panel.statusArea.volume;
- if (this._volume) {
- this._volumeIcon = this.addIcon(null);
- this._volume.mainIcon.bind_property('gicon', this._volumeIcon, 'gicon',
- GObject.BindingFlags.SYNC_CREATE);
- this._volume.mainIcon.bind_property('visible', this._volumeIcon, 'visible',
- GObject.BindingFlags.SYNC_CREATE);
-
- this._volumeControl = VolumeMenu.getMixerControl();
- this._volumeMenu = new VolumeMenu.VolumeMenu(this._volumeControl);
- this.menu.addMenuItem(this._volumeMenu);
- }
+ this._volumeControl = VolumeMenu.getMixerControl();
+ this._volumeMenu = new VolumeMenu.VolumeMenu(this._volumeControl);
+ this.menu.addMenuItem(this._volumeMenu);
- this._network = Main.panel.statusArea.network;
- if (this._network) {
- this._networkIcon = this.addIcon(null);
- this._network.mainIcon.bind_property('gicon', this._networkIcon, 'gicon',
- GObject.BindingFlags.SYNC_CREATE);
- this._network.mainIcon.bind_property('visible', this._networkIcon, 'visible',
- GObject.BindingFlags.SYNC_CREATE);
-
- this._networkSecondaryIcon = this.addIcon(null);
- this._network.secondaryIcon.bind_property('gicon', this._networkSecondaryIcon, 'gicon',
- GObject.BindingFlags.SYNC_CREATE);
- this._network.secondaryIcon.bind_property('visible', this._networkSecondaryIcon, 'visible',
- GObject.BindingFlags.SYNC_CREATE);
- }
+ this._volume = new FakeStatusIcon(Main.panel.statusArea.volume);
+ this._box.add_child(this._volume.actor);
- this._battery = Main.panel.statusArea.battery;
- if (this._battery) {
- this._batteryIcon = this.addIcon(null);
- this._battery.mainIcon.bind_property('gicon', this._batteryIcon, 'gicon',
- GObject.BindingFlags.SYNC_CREATE);
- this._battery.mainIcon.bind_property('visible', this._batteryIcon, 'visible',
- GObject.BindingFlags.SYNC_CREATE);
+ // Network may not exist if the user doesn't have NetworkManager
+ if (Main.panel.statusArea.network) {
+ this._network = new FakeStatusIcon(Main.panel.statusArea.network);
+ this._box.add_child(this._network.actor);
}
+
+ this._battery = new FakeStatusIcon(Main.panel.statusArea.battery);
+ this._box.add_child(this._battery.actor);
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]