[gnome-shell] PopupImageMenuItem: always show icon, on the right, not the left



commit 86efdc906aa94b5fcf5c398019567acc6ca0c0f3
Author: Dan Winship <danw gnome org>
Date:   Tue Oct 19 11:59:23 2010 -0400

    PopupImageMenuItem: always show icon, on the right, not the left
    
    In the new mockups, the user menu icons are on the right, not the
    left.
    
    Also, get rid of the idea of optional icons; the design doesn't have
    icons on those items, and there probably aren't going to be symbolic
    versions of some of those icons anyway. So if the caller specifies
    PopupImageMenuItem, then always show an icon, and just use regular
    PopupMenuItems for the items that don't have icons in the current
    design.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=631193

 js/ui/popupMenu.js  |   52 ++++++++++----------------------------------------
 js/ui/statusMenu.js |   12 +++++-----
 2 files changed, 17 insertions(+), 47 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index cb17c02..934d354 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 9aae26c..1979668 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);
     },



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]