diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dbus-shared-names.h | 2 | ||||
-rw-r--r-- | src/gconf-helper.c | 27 | ||||
-rw-r--r-- | src/indicator-session.c | 25 | ||||
-rw-r--r-- | src/session-service.c | 5 |
4 files changed, 53 insertions, 6 deletions
diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index a6364b1..3ac14b3 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -44,6 +44,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #define USER_ITEM_TYPE "x-canonical-user-item" #define USER_ITEM_PROP_NAME "user-item-name" #define USER_ITEM_PROP_LOGGED_IN "user-item-logged-in" +#define USER_ITEM_PROP_ICON "user-item-icon-path" +#define USER_ITEM_ICON_DEFAULT "default-icon" #define RESTART_ITEM_TYPE "x-canonical-restart-item" #define RESTART_ITEM_LABEL "restart-label" diff --git a/src/gconf-helper.c b/src/gconf-helper.c index 588b11c..77fde1d 100644 --- a/src/gconf-helper.c +++ b/src/gconf-helper.c @@ -34,6 +34,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "gconf-helper.h" static GConfClient * gconf_client = NULL; +static guint confirmation_notify = 0; +static guint logout_notify = 0; gboolean supress_confirmations (void) { @@ -82,14 +84,31 @@ update_logout_callback (GConfClient *client, guint cnxn_id, GConfEntry *entry, void update_menu_entries(RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi, DbusmenuMenuitem * logoutitem) { + /* If we don't have a client, build one. */ if(!gconf_client) { gconf_client = gconf_client_get_default (); } - gconf_client_add_dir (gconf_client, GLOBAL_DIR, - GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - gconf_client_notify_add (gconf_client, SUPPRESS_KEY, + + /* If we've not gotten any notifications, then we need + to add the directory for notifications to come from. */ + if (confirmation_notify == 0 || logout_notify == 0) { + gconf_client_add_dir (gconf_client, GLOBAL_DIR, + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + } + + if (confirmation_notify != 0) { + gconf_client_notify_remove (gconf_client, confirmation_notify); + confirmation_notify = 0; + } + + if (logout_notify != 0) { + gconf_client_notify_remove (gconf_client, logout_notify); + logout_notify = 0; + } + + confirmation_notify = gconf_client_notify_add (gconf_client, SUPPRESS_KEY, update_menu_entries_callback, restart_shutdown_logout_mi, NULL, NULL); - gconf_client_notify_add (gconf_client, LOGOUT_KEY, + logout_notify = gconf_client_notify_add (gconf_client, LOGOUT_KEY, update_logout_callback, logoutitem, NULL, NULL); } diff --git a/src/indicator-session.c b/src/indicator-session.c index c21579a..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); @@ -298,7 +319,7 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, const G /* TODO: We need some way to remove the elipsis from appearing twice in the label. Not sure how to do that yet. */ - finalstring = g_strdup_printf(_("Switch from %s..."), username); + finalstring = g_strdup_printf(_("Switch From %s..."), username); if (ems >= 20.0f) { set_ellipsize = TRUE; } else { diff --git a/src/session-service.c b/src/session-service.c index b5fb42e..ee1a9af 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -590,6 +590,11 @@ rebuild_items (DbusmenuMenuitem *root, dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, user->real_name); } dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, user->sessions != NULL); + if (user->icon_url != NULL && user->icon_url[0] != '\0' && g_str_has_prefix(user->icon_url, "file://")) { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_url + strlen("file://")); + } else { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); + } dbusmenu_menuitem_child_append (root, mi); g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user); } |