Support setting the image after construction
This patch allows the icon in PopupImageMenuItems to be changed at any time, while preserving the item and all other properties (style, signals) attached and without rebuilding the whole menu. This is useful for images reflecting a dynamic status (e.g. cellular strength indicator or battery level) https://bugzilla.gnome.org/show_bug.cgi?id=623652
This commit is contained in:
parent
2adfca0582
commit
b5ee89459a
@ -221,7 +221,8 @@ PopupImageMenuItem.prototype = {
|
|||||||
this.actor.set_child(box);
|
this.actor.set_child(box);
|
||||||
this._imageBin = new St.Bin({ width: this._size, height: this._size });
|
this._imageBin = new St.Bin({ width: this._size, height: this._size });
|
||||||
box.add(this._imageBin, { y_fill: false });
|
box.add(this._imageBin, { y_fill: false });
|
||||||
box.add(new St.Label({ text: text }), { expand: true });
|
this.label = new St.Label({ text: text });
|
||||||
|
box.add(this.label, { expand: true });
|
||||||
|
|
||||||
if (!alwaysShowImage) {
|
if (!alwaysShowImage) {
|
||||||
let settings = Gtk.Settings.get_default();
|
let settings = Gtk.Settings.get_default();
|
||||||
@ -245,6 +246,11 @@ PopupImageMenuItem.prototype = {
|
|||||||
this._imageBin.set_child(img);
|
this._imageBin.set_child(img);
|
||||||
this._imageBin.show();
|
this._imageBin.show();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setIcon: function(name) {
|
||||||
|
this._iconName = name;
|
||||||
|
this._onMenuImagesChanged();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user