diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index cb17c021a..934d35446 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -372,64 +372,34 @@ PopupSwitchMenuItem.prototype = { } -function PopupImageMenuItem(text, iconName, alwaysShowImage) { - this._init(text, iconName, alwaysShowImage); +function PopupImageMenuItem(text, iconName) { + this._init(text, iconName); } -// We need to instantiate a GtkImageMenuItem so it -// hooks up its properties on the GtkSettings -var _gtkImageMenuItemCreated = false; - PopupImageMenuItem.prototype = { __proto__: PopupBaseMenuItem.prototype, - _init: function (text, iconName, alwaysShowImage) { + _init: function (text, iconName) { PopupBaseMenuItem.prototype._init.call(this); - if (!_gtkImageMenuItemCreated) { - let menuItem = new Gtk.ImageMenuItem(); - menuItem.destroy(); - _gtkImageMenuItemCreated = true; - } - - this._alwaysShowImage = alwaysShowImage; - this._iconName = iconName; this._size = 16; let box = new St.BoxLayout({ style_class: 'popup-image-menu-item' }); this.actor.set_child(box); - this._imageBin = new St.Bin({ width: this._size, height: this._size }); - box.add(this._imageBin, { y_fill: false }); this.label = new St.Label({ text: text }); box.add(this.label, { expand: true }); + this._imageBin = new St.Bin({ width: this._size, height: this._size }); + box.add(this._imageBin, { y_fill: false }); - if (!alwaysShowImage) { - let settings = Gtk.Settings.get_default(); - settings.connect('notify::gtk-menu-images', Lang.bind(this, this._onMenuImagesChanged)); - } - this._onMenuImagesChanged(); + this.setIcon(iconName); }, - _onMenuImagesChanged: function() { - let show; - if (this._alwaysShowImage) { - show = true; - } else { - let settings = Gtk.Settings.get_default(); - show = settings.gtk_menu_images; - } - if (!show) { - this._imageBin.hide(); - } else { - let img = St.TextureCache.get_default().load_icon_name(this._iconName, St.IconType.SYMBOLIC, this._size); - this._imageBin.set_child(img); - this._imageBin.show(); - } - }, - setIcon: function(name) { - this._iconName = name; - this._onMenuImagesChanged(); + if (this._imageBin.child) + this._imageBin.child.destroy(); + + let img = St.TextureCache.get_default().load_icon_name(name, St.IconType.SYMBOLIC, this._size); + this._imageBin.set_child(img); } }; diff --git a/js/ui/statusMenu.js b/js/ui/statusMenu.js index 9aae26cb4..1979668e1 100644 --- a/js/ui/statusMenu.js +++ b/js/ui/statusMenu.js @@ -109,31 +109,31 @@ StatusMenuButton.prototype = { item = new PopupMenu.PopupSeparatorMenuItem(); this.menu.addMenuItem(item); - item = new PopupMenu.PopupImageMenuItem(_("Account Information..."), 'user-info'); + item = new PopupMenu.PopupMenuItem(_("Account Information...")); item.connect('activate', Lang.bind(this, this._onAccountInformationActivate)); this.menu.addMenuItem(item); - item = new PopupMenu.PopupImageMenuItem(_("System Settings..."), 'preferences-desktop'); + item = new PopupMenu.PopupMenuItem(_("System Settings...")); item.connect('activate', Lang.bind(this, this._onPreferencesActivate)); this.menu.addMenuItem(item); item = new PopupMenu.PopupSeparatorMenuItem(); this.menu.addMenuItem(item); - item = new PopupMenu.PopupImageMenuItem(_("Lock Screen"), 'system-lock-screen'); + item = new PopupMenu.PopupMenuItem(_("Lock Screen")); item.connect('activate', Lang.bind(this, this._onLockScreenActivate)); this.menu.addMenuItem(item); - item = new PopupMenu.PopupImageMenuItem(_("Switch User"), 'system-users'); + item = new PopupMenu.PopupMenuItem(_("Switch User")); item.connect('activate', Lang.bind(this, this._onLoginScreenActivate)); this.menu.addMenuItem(item); this._loginScreenItem = item; - item = new PopupMenu.PopupImageMenuItem(_("Log Out..."), 'system-log-out'); + item = new PopupMenu.PopupMenuItem(_("Log Out...")); item.connect('activate', Lang.bind(this, this._onQuitSessionActivate)); this.menu.addMenuItem(item); - item = new PopupMenu.PopupImageMenuItem(_("Shut Down..."), 'system-shutdown'); + item = new PopupMenu.PopupMenuItem(_("Shut Down...")); item.connect('activate', Lang.bind(this, this._onShutDownActivate)); this.menu.addMenuItem(item); },