From 4f535763d9e05e41c81b1a8fbf262aea1246f616 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 7 Jul 2011 17:46:00 +0100 Subject: icon updates for the user menu panel --- src/dbus-shared-names.h | 2 +- src/indicator-session.c | 119 ++++++++++++++++++++++++------------------------ src/session-service.c | 5 +- 3 files changed, 63 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index fd19e5f..b69c6ad 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -40,7 +40,7 @@ with this program. If not, see . #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 USER_ITEM_ICON_DEFAULT "user-offline" #define RESTART_ITEM_TYPE "x-canonical-restart-item" #define RESTART_ITEM_LABEL "restart-label" diff --git a/src/indicator-session.c b/src/indicator-session.c index 729b838..23d7f37 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -362,7 +362,6 @@ user_property_change (DbusmenuMenuitem * item, return; } - static void icon_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) { @@ -396,10 +395,11 @@ service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointe g_dbus_proxy_call(self->service_proxy, "GetIcon", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, icon_name_get_cb, user_data); - } else { - indicator_image_helper_update(self->users.image, ICON_DEFAULT); } - + else { + indicator_image_helper_update (self->users.image, + USER_ITEM_ICON_DEFAULT); + } return; } @@ -412,8 +412,11 @@ icon_changed (IndicatorSession * session, const gchar * icon_name) /* Receives all signals from the service, routed to the appropriate functions */ static void -receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, - GVariant * parameters, gpointer user_data) +receive_signal (GDBusProxy * proxy, + gchar * sender_name, + gchar * signal_name, + GVariant * parameters, + gpointer user_data) { IndicatorSession * self = INDICATOR_SESSION(user_data); @@ -422,83 +425,81 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, g_variant_get (parameters, "(&s)", &name); icon_changed(self, name); } - return; } - static void switch_property_change (DbusmenuMenuitem * item, const gchar * property, GVariant * variant, gpointer user_data) { - if (g_strcmp0(property, MENU_SWITCH_USER) != 0) { - return; - } + if (g_strcmp0 (property, MENU_SWITCH_USER) != 0) { + return; + } - GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(DBUSMENU_GTKCLIENT(user_data), item); - gchar * finalstring = NULL; - gboolean set_ellipsize = FALSE; - gboolean no_name_in_lang = FALSE; - - const gchar * translate = C_("session_menu:switchfrom", "1"); - if (g_strcmp0(translate, "1") != 0) { - no_name_in_lang = TRUE; - } + GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(DBUSMENU_GTKCLIENT(user_data), item); + gchar * finalstring = NULL; + gboolean set_ellipsize = FALSE; + gboolean no_name_in_lang = FALSE; + + const gchar * translate = C_("session_menu:switchfrom", "1"); + if (g_strcmp0(translate, "1") != 0) { + no_name_in_lang = TRUE; + } - if (variant == NULL || g_variant_get_string(variant, NULL) == NULL || g_variant_get_string(variant, NULL)[0] == '\0' || no_name_in_lang) { - finalstring = _("Switch User..."); - set_ellipsize = FALSE; + if (variant == NULL || g_variant_get_string(variant, NULL) == NULL || g_variant_get_string(variant, NULL)[0] == '\0' || no_name_in_lang) { + finalstring = _("Switch User..."); + set_ellipsize = FALSE; indicator_session_update_users_label (INDICATOR_SESSION (user_data), NULL); - } + } else{ indicator_session_update_users_label (INDICATOR_SESSION (user_data), variant); } - if (finalstring == NULL) { - const gchar * username = g_variant_get_string(variant, NULL); - GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(gmi)); + if (finalstring == NULL) { + const gchar * username = g_variant_get_string(variant, NULL); + GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(gmi)); - PangoLayout * layout = pango_layout_new(gtk_widget_get_pango_context(GTK_WIDGET(gmi))); - pango_layout_set_text(layout, username, -1); - pango_layout_set_font_description(layout, style->font_desc); + PangoLayout * layout = pango_layout_new(gtk_widget_get_pango_context(GTK_WIDGET(gmi))); + pango_layout_set_text (layout, username, -1); + pango_layout_set_font_description(layout, style->font_desc); - gint width; - pango_layout_get_pixel_size(layout, &width, NULL); - g_object_unref(layout); - g_debug("Username width %dpx", width); + gint width; + pango_layout_get_pixel_size(layout, &width, NULL); + g_object_unref(layout); + g_debug("Username width %dpx", width); - gint point = pango_font_description_get_size(style->font_desc); - g_debug("Font size %f pt", (gfloat)point / PANGO_SCALE); + gint point = pango_font_description_get_size(style->font_desc); + g_debug("Font size %f pt", (gfloat)point / PANGO_SCALE); - gdouble dpi = gdk_screen_get_resolution(gdk_screen_get_default()); - g_debug("Screen DPI %f", dpi); + gdouble dpi = gdk_screen_get_resolution(gdk_screen_get_default()); + g_debug("Screen DPI %f", dpi); - gdouble pixels_per_em = ((point * dpi) / 72.0f) / PANGO_SCALE; - gdouble ems = width / pixels_per_em; - g_debug("Username width %fem", ems); + gdouble pixels_per_em = ((point * dpi) / 72.0f) / PANGO_SCALE; + gdouble ems = width / pixels_per_em; + g_debug("Username width %fem", ems); - finalstring = g_strdup_printf(_("Switch From %s..."), username); - if (ems >= 20.0f) { - set_ellipsize = TRUE; - } else { - set_ellipsize = FALSE; - } + finalstring = g_strdup_printf(_("Switch From %s..."), username); + if (ems >= 20.0f) { + set_ellipsize = TRUE; + } else { + set_ellipsize = FALSE; + } - } - gtk_menu_item_set_label(gmi, finalstring); - - GtkLabel * label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(gmi))); - if (label != NULL) { - if (set_ellipsize) { - gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_END); - } else { - gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_NONE); - } - } + } + gtk_menu_item_set_label(gmi, finalstring); + + GtkLabel * label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(gmi))); + if (label != NULL) { + if (set_ellipsize) { + gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_END); + } else { + gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_NONE); + } + } return; } @@ -628,7 +629,7 @@ indicator_session_update_users_label (IndicatorSession* self, // Just in case protect again. if (username != NULL) { - g_debug ("Updating username label"); + g_debug ("Updating username label "); gtk_label_set_text (self->users.label, username); gtk_widget_show(GTK_WIDGET(self->users.label)); } diff --git a/src/session-service.c b/src/session-service.c index ed95080..9cd7800 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -627,10 +627,9 @@ rebuild_user_items (DbusmenuMenuitem *root, if (check_new_session ()) { - switch_menuitem = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_TYPE, MENU_SWITCH_TYPE); - dbusmenu_menuitem_property_set (switch_menuitem, MENU_SWITCH_USER, g_get_user_name()); + dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_TYPE, MENU_SWITCH_TYPE); + dbusmenu_menuitem_property_set (switch_menuitem, MENU_SWITCH_USER, g_get_user_name()); dbusmenu_menuitem_child_append (root, switch_menuitem); g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL); } -- cgit v1.2.3