[gnome-shell] popupMenu: Accept either an icon name or a GIcon on PopupImageMenuItem
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] popupMenu: Accept either an icon name or a GIcon on PopupImageMenuItem
- Date: Tue, 9 May 2017 17:34:26 +0000 (UTC)
commit 28ca96064bcb95fb3b3461f3eb9959c2aef7eee6
Author: Mario Sanchez Prada <mario endlessm com>
Date: Mon May 8 11:36:35 2017 +0100
popupMenu: Accept either an icon name or a GIcon on PopupImageMenuItem
Add an extra check to setIcon() so that either a GIcon or an string
with the icon's name is handlded, so that we can create menu items
in different ways (e.g. by passing a GIcon created from a resource).
https://bugzilla.gnome.org/show_bug.cgi?id=782166
js/ui/popupMenu.js | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index d326ea8..53ab7c1 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -2,6 +2,8 @@
const Clutter = imports.gi.Clutter;
const Gtk = imports.gi.Gtk;
+const Gio = imports.gi.Gio;
+const GObject = imports.gi.GObject;
const Lang = imports.lang;
const Shell = imports.gi.Shell;
const Signals = imports.signals;
@@ -389,7 +391,7 @@ const PopupImageMenuItem = new Lang.Class({
Name: 'PopupImageMenuItem',
Extends: PopupBaseMenuItem,
- _init: function (text, iconName, params) {
+ _init: function (text, icon, params) {
this.parent(params);
this.label = new St.Label({ text: text });
@@ -398,11 +400,15 @@ const PopupImageMenuItem = new Lang.Class({
this.actor.add_child(this._icon, { align: St.Align.END });
this.actor.label_actor = this.label;
- this.setIcon(iconName);
+ this.setIcon(icon);
},
- setIcon: function(name) {
- this._icon.icon_name = name;
+ setIcon: function(icon) {
+ // The 'icon' parameter can be either a Gio.Icon or a string.
+ if (GObject.type_is_a(icon, Gio.Icon))
+ this._icon.gicon = icon;
+ else
+ this._icon.icon_name = icon;
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]