aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-session.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-03-18 13:48:42 -0500
committerTed Gould <ted@gould.cx>2010-03-18 13:48:42 -0500
commite6bf7bbff5e51b1c74a1e2f9c37c114d03b9c156 (patch)
tree91845d84ad73d6f0b4d2f567dc675d4a0f59ab0f /src/indicator-session.c
parente89ea26dff22aab414951f4a11c62848615ea74d (diff)
parenta4d38cd734039688c74db5244c7d751c0d4ec747 (diff)
downloadayatana-indicator-session-e6bf7bbff5e51b1c74a1e2f9c37c114d03b9c156.tar.gz
ayatana-indicator-session-e6bf7bbff5e51b1c74a1e2f9c37c114d03b9c156.tar.bz2
ayatana-indicator-session-e6bf7bbff5e51b1c74a1e2f9c37c114d03b9c156.zip
Using an icon for users or a stock item if they don't have an icon.
Diffstat (limited to 'src/indicator-session.c')
-rw-r--r--src/indicator-session.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/indicator-session.c b/src/indicator-session.c
index eb7d53f..e92c36b 100644
--- a/src/indicator-session.c
+++ b/src/indicator-session.c
@@ -28,6 +28,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
+#include <gio/gio.h>
#include <libdbusmenu-gtk/menu.h>
#include <dbus/dbus-glib.h>
@@ -221,7 +222,27 @@ static gboolean
new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
{
GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new());
- GtkWidget * hbox = gtk_hbox_new(FALSE, 0);
+ gint padding = 0;
+ gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL);
+ GtkWidget * hbox = gtk_hbox_new(FALSE, padding);
+
+ GtkWidget * usericon = NULL;
+ const gchar * icon_name = dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_ICON);
+ g_debug("Using user icon for '%s' from file: %s", dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME), icon_name);
+ if (icon_name != NULL && icon_name[0] != '\0') {
+ if (g_strcmp0(icon_name, USER_ITEM_ICON_DEFAULT) == 0 || !g_file_test(icon_name, G_FILE_TEST_EXISTS)) {
+ GIcon * gicon = g_themed_icon_new_with_default_fallbacks("stock_person-panel");
+ usericon = gtk_image_new_from_gicon(gicon, GTK_ICON_SIZE_MENU);
+ g_object_unref(gicon);
+ } else {
+ usericon = gtk_image_new_from_file(icon_name);
+ }
+ }
+ if (usericon != NULL) {
+ gtk_misc_set_alignment(GTK_MISC(usericon), 0.0, 0.5);
+ gtk_box_pack_start(GTK_BOX(hbox), usericon, FALSE, FALSE, 0);
+ gtk_widget_show(usericon);
+ }
GtkWidget * label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);