[panel] PanelImageMenuItem should follow gtk-menu-show-images
Update statusMenu to always show images for the presence items only. https://bugzilla.gnome.org/show_bug.cgi?id=618438
This commit is contained in:
parent
6098dca0f8
commit
e835cd2c2d
@ -156,20 +156,57 @@ PanelSeparatorMenuItem.prototype = {
|
||||
}
|
||||
Signals.addSignalMethods(PanelSeparatorMenuItem.prototype);
|
||||
|
||||
function PanelImageMenuItem(text, iconName) {
|
||||
this._init(text, iconName);
|
||||
function PanelImageMenuItem(text, iconName, alwaysShowImage) {
|
||||
this._init(text, iconName, alwaysShowImage);
|
||||
}
|
||||
|
||||
// We need to instantiate a GtkImageMenuItem so it
|
||||
// hooks up its properties on the GtkSettings
|
||||
var _gtkImageMenuItemCreated = false;
|
||||
|
||||
PanelImageMenuItem.prototype = {
|
||||
_init: function (text, iconName) {
|
||||
_init: function (text, iconName, alwaysShowImage) {
|
||||
|
||||
if (!_gtkImageMenuItemCreated) {
|
||||
let menuItem = new Gtk.ImageMenuItem();
|
||||
menuItem.destroy();
|
||||
_gtkImageMenuItemCreated = true;
|
||||
}
|
||||
this._alwaysShowImage = alwaysShowImage;
|
||||
this.actor = new St.BoxLayout({ style_class: 'panel-menu-item panel-image-menu-item',
|
||||
reactive: true,
|
||||
track_hover: true });
|
||||
this.actor.add(St.TextureCache.get_default().load_icon_name(iconName, 16), { y_fill: false });
|
||||
this._iconName = iconName;
|
||||
this._size = 16;
|
||||
this._imageBin = new St.Bin({ width: this._size, height: this._size });
|
||||
this.actor.add(this._imageBin, { y_fill: false });
|
||||
this.actor.add(new St.Label({ text: text }), { expand: true });
|
||||
this.actor.connect('button-release-event', Lang.bind(this, function (actor, event) {
|
||||
this.emit('activate', event);
|
||||
}));
|
||||
if (!alwaysShowImage) {
|
||||
let settings = Gtk.Settings.get_default();
|
||||
settings.connect('notify::gtk-menu-images', Lang.bind(this, this._onMenuImagesChanged));
|
||||
}
|
||||
this._onMenuImagesChanged();
|
||||
},
|
||||
|
||||
_onMenuImagesChanged: function() {
|
||||
let show;
|
||||
if (this._alwaysShowImage) {
|
||||
show = true;
|
||||
} else {
|
||||
let settings = Gtk.Settings.get_default();
|
||||
show = settings.gtk_menu_images;
|
||||
}
|
||||
if (!show) {
|
||||
let child = this._imageBin.get_child();
|
||||
if (child)
|
||||
child.destroy();
|
||||
} else {
|
||||
let img = St.TextureCache.get_default().load_icon_name(this._iconName, this._size);
|
||||
this._imageBin.set_child(img);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,15 +87,15 @@ StatusMenuButton.prototype = {
|
||||
_createSubMenu: function() {
|
||||
let item;
|
||||
|
||||
item = new Panel.PanelImageMenuItem(_("Available"), 'gtk-yes');
|
||||
item = new Panel.PanelImageMenuItem(_("Available"), 'gtk-yes', true);
|
||||
item.connect('activate', Lang.bind(this, this._setPresenceStatus, GnomeSession.PresenceStatus.AVAILABLE));
|
||||
this.menu.addMenuItem(item);
|
||||
|
||||
item = new Panel.PanelImageMenuItem(_("Busy"), 'gtk-no');
|
||||
item = new Panel.PanelImageMenuItem(_("Busy"), 'gtk-no', true);
|
||||
item.connect('activate', Lang.bind(this, this._setPresenceStatus, GnomeSession.PresenceStatus.BUSY));
|
||||
this.menu.addMenuItem(item);
|
||||
|
||||
item = new Panel.PanelImageMenuItem(_("Invisible"), 'gtk-close');
|
||||
item = new Panel.PanelImageMenuItem(_("Invisible"), 'gtk-close', true);
|
||||
item.connect('activate', Lang.bind(this, this._setPresenceStatus, GnomeSession.PresenceStatus.INVISIBLE));
|
||||
this.menu.addMenuItem(item);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user