status: Port to a new SystemIndicator framework

We can't silently replace the old behavior of separate status
icons into a new system. Replace SystemStatusButton with a new
SystemIndicator class which will allow for the flexibility we
need. For now, make it a subclass of Button so that it mostly
feels the same, but we'll soon be swapping it out with a dummy
implementation that the aggregate menu will use.

I think the code cleanup here is worth it.

https://bugzilla.gnome.org/show_bug.cgi?id=705845
This commit is contained in:
Jasper St. Pierre
2013-06-06 17:27:25 -04:00
parent a347f02545
commit 5cca26a565
9 changed files with 62 additions and 74 deletions

View File

@ -15,10 +15,12 @@ const PopupMenu = imports.ui.popupMenu;
const Indicator = new Lang.Class({
Name: 'BTIndicator',
Extends: PanelMenu.SystemStatusButton,
Extends: PanelMenu.SystemIndicator,
_init: function() {
this.parent('bluetooth-disabled-symbolic', _("Bluetooth"));
this.parent();
this._indicator = this.addIndicator(new Gio.ThemedIcon({ name: 'bluetooth-active-symbolic' }));
// The Bluetooth menu only appears when Bluetooth is in use,
// so just statically build it with a "Turn Off" menu item.
@ -47,8 +49,8 @@ const Indicator = new Lang.Class({
let nDevices = connectedDevices.length;
let on = nDevices > 0;
this.mainIcon.visible = on;
this.actor.visible = on;
this._indicator.visible = on;
this._item.actor.visible = on;
if (on)
this._item.status.text = ngettext("%d Connected Device", "%d Connected Devices").format(nDevices);