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
This commit is contained in:
parent
c217377114
commit
86efdc906a
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user