StIcon: add support for GIcon

Add a "gicon" property so that a GIcon can be used instead of an
icon name, while still getting icon recoloring from the theme.
Also include a compatibility wrapper in libshell until GJS has
support for interface static methods.

https://bugzilla.gnome.org/show_bug.cgi?id=622451
This commit is contained in:
Giovanni Campagna
2010-09-26 17:18:26 +02:00
committed by Giovanni Campagna
parent 0c5d87d79b
commit 21ac225981
11 changed files with 157 additions and 42 deletions

View File

@ -72,18 +72,19 @@ SystemStatusButton.prototype = {
_init: function(iconName,tooltipText) {
Button.prototype._init.call(this, St.Align.START);
this._iconActor = null;
this.setIcon(iconName);
this._iconActor = new St.Icon({ icon_name: iconName,
icon_type: St.IconType.SYMBOLIC,
style_class: 'system-status-icon' });
this.actor.set_child(this._iconActor);
this.setTooltip(tooltipText);
},
setIcon: function(iconName) {
this._iconName = iconName;
if (this._iconActor)
this._iconActor.destroy();
this._iconActor = new St.Icon({ icon_name: this._iconName,
style_class: 'system-status-icon' });
this.actor.set_child(this._iconActor);
this._iconActor.icon_name = iconName;
},
setGIcon: function(gicon) {
this._iconActor.gicon = gicon;
},
setTooltip: function(text) {
@ -96,4 +97,4 @@ SystemStatusButton.prototype = {
this.tooltip = null;
}
}
};
};