Add API for system status indicators
Add a container in the panel for holding them, a fast method for loading and a simple base class to be subclassed by specific implementations. https://bugzilla.gnome.org/show_bug.cgi?id=621705
This commit is contained in:

committed by
Dan Winship

parent
6eb90434f0
commit
73ecdbd6da
@ -35,4 +35,44 @@ Button.prototype = {
|
||||
else
|
||||
this.actor.remove_style_pseudo_class('pressed');
|
||||
}
|
||||
};
|
||||
|
||||
/* SystemStatusButton:
|
||||
*
|
||||
* This class manages one System Status indicator (network, keyboard,
|
||||
* 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,
|
||||
|
||||
_init: function(iconName,tooltipText) {
|
||||
Button.prototype._init.call(this, St.Align.START);
|
||||
this._iconActor = null;
|
||||
this.setIcon(iconName);
|
||||
this.setTooltip(tooltipText);
|
||||
},
|
||||
|
||||
setIcon: function(iconName) {
|
||||
this._iconName = iconName;
|
||||
if (this._iconActor)
|
||||
this._iconActor.destroy();
|
||||
this._iconActor = St.TextureCache.get_default().load_icon_name(this._iconName, 24);
|
||||
this.actor.set_child(this._iconActor);
|
||||
},
|
||||
|
||||
setTooltip: function(text) {
|
||||
if (text != null) {
|
||||
this.tooltip = text;
|
||||
this.actor.has_tooltip = true;
|
||||
this.actor.tooltip_text = text;
|
||||
} else {
|
||||
this.actor.has_tooltip = false;
|
||||
this.tooltip = null;
|
||||
}
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user