[gnome-shell] [panel] PanelImageMenuItem should follow gtk-menu-show-images
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] [panel] PanelImageMenuItem should follow gtk-menu-show-images
- Date: Wed, 12 May 2010 21:25:19 +0000 (UTC)
commit e835cd2c2d604e291b7b3ece47dc0e80ffa7e49a
Author: Colin Walters <walters verbum org>
Date: Wed May 12 11:45:58 2010 -0400
[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
js/ui/panel.js | 45 +++++++++++++++++++++++++++++++++++++++++----
js/ui/statusMenu.js | 6 +++---
2 files changed, 44 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/panel.js b/js/ui/panel.js
index b046c22..8a28641 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -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);
+ }
}
}
diff --git a/js/ui/statusMenu.js b/js/ui/statusMenu.js
index cf64f6a..2b12444 100644
--- a/js/ui/statusMenu.js
+++ b/js/ui/statusMenu.js
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]