From fb8754f048176039d268157a22da3745773bd15b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 12:25:58 -0600 Subject: Adding in a handler and renderer for the restart required item --- src/indicator-session.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index a815e40..fab3463 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -69,6 +69,7 @@ static GtkImage * get_icon (IndicatorObject * io); static GtkMenu * get_menu (IndicatorObject * io); static gboolean build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); +static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static void indicator_session_class_init (IndicatorSessionClass *klass); static void indicator_session_init (IndicatorSession *self); @@ -108,6 +109,7 @@ indicator_session_init (IndicatorSession *self) DbusmenuClient * client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(self->menu)); dbusmenu_client_add_type_handler(client, MENU_SWITCH_TYPE, build_menu_switch); dbusmenu_client_add_type_handler(client, USER_ITEM_TYPE, new_user_item); + dbusmenu_client_add_type_handler(client, RESTART_ITEM_TYPE, build_restart_item); return; } @@ -253,6 +255,60 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, const G static const gchar * dbusmenu_item_data = "dbusmenu-item"; +/* IF the label or icon changes we need to grab that and update + the menu item */ +static void +restart_property_change (DbusmenuMenuitem * item, const gchar * property, const GValue * value, gpointer user_data) +{ + DbusmenuGtkClient * client = DBUSMENU_GTKCLIENT(user_data); + GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(client, item); + + if (g_strcmp0(property, RESTART_ITEM_LABEL) == 0) { + gtk_menu_item_set_label(gmi, g_value_get_string(value)); + } else if (g_strcmp0(property, RESTART_ITEM_ICON) == 0) { + GtkWidget * image = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(gmi)); + + if (image == NULL) { + image = gtk_image_new_from_icon_name(g_value_get_string(value), GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), image); + } else { + gtk_image_set_from_icon_name(GTK_IMAGE(image), g_value_get_string(value), GTK_ICON_SIZE_MENU); + } + } + + return; +} + +/* Builds the restart item which is a more traditional GTK image + menu item that puts the graphic into the gutter. */ +static gboolean +build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +{ + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new()); + if (gmi == NULL) { + return FALSE; + } + + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + + g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(restart_property_change), client); + + /* Grab the inital values and put them into the item */ + const GValue * value; + value = dbusmenu_menuitem_property_get_value(newitem, RESTART_ITEM_LABEL); + if (value != NULL) { + restart_property_change(newitem, RESTART_ITEM_LABEL, value, client); + } + + value = dbusmenu_menuitem_property_get_value(newitem, RESTART_ITEM_ICON); + if (value != NULL) { + restart_property_change(newitem, RESTART_ITEM_ICON, value, client); + } + + return TRUE; +} + + /* Callback for when the style changes so we can reevaluate the size of the user name with the potentially new font. */ static void @@ -265,7 +321,6 @@ switch_style_set (GtkWidget * widget, GtkStyle * prev_style, gpointer user_data) return; } - /* This function checks to see if the user name is short enough to not need ellipsing itself, or if, it will get ellipsed by the standard label processor. */ -- cgit v1.2.3 From 535a2e63fd4e605ef63c933797abedcc28a55861 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 13:04:22 -0600 Subject: Setting up the indicator to use library translations so they'll be grabbed from the right domain. --- src/indicator-session.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index a815e40..54431ee 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -20,9 +20,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include -#include +#include #include #include -- cgit v1.2.3 From fced2aaae755846922b46fa55a6444f0e0406c8d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 15:08:25 -0600 Subject: Building us a proxy! Now we are dangerous. --- src/indicator-session.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index a815e40..0b8d77e 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -55,6 +55,7 @@ struct _IndicatorSession { IndicatorServiceManager * service; GtkImage * status_image; DbusmenuGtkMenu * menu; + DBusGProxy * service_proxy; }; GType indicator_session_get_type (void); @@ -109,6 +110,12 @@ indicator_session_init (IndicatorSession *self) dbusmenu_client_add_type_handler(client, MENU_SWITCH_TYPE, build_menu_switch); dbusmenu_client_add_type_handler(client, USER_ITEM_TYPE, new_user_item); + DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + self->service_proxy = dbus_g_proxy_new_for_name(session_bus, + INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_SERVICE_DBUS_OBJECT, + INDICATOR_SESSION_SERVICE_DBUS_IFACE); + return; } @@ -122,6 +129,11 @@ indicator_session_dispose (GObject *object) self->service = NULL; } + if (self->service_proxy != NULL) { + g_object_unref(self->service_proxy); + self->service_proxy = NULL; + } + G_OBJECT_CLASS (indicator_session_parent_class)->dispose (object); return; } -- cgit v1.2.3 From 10ab858ea1a244f92b57d3e8c96c76045e02e93b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 15:26:50 -0600 Subject: Icon name changing signal for updating the image. --- src/indicator-session.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index 0b8d77e..c23cd0b 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -70,6 +70,7 @@ static GtkImage * get_icon (IndicatorObject * io); static GtkMenu * get_menu (IndicatorObject * io); static gboolean build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); +static void icon_changed (DBusGProxy * proxy, gchar * icon_name, gpointer user_data); static void indicator_session_class_init (IndicatorSessionClass *klass); static void indicator_session_init (IndicatorSession *self); @@ -116,6 +117,14 @@ indicator_session_init (IndicatorSession *self) INDICATOR_SESSION_SERVICE_DBUS_OBJECT, INDICATOR_SESSION_SERVICE_DBUS_IFACE); + dbus_g_proxy_add_signal(self->service_proxy, "IconUpdated", + G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal(self->service_proxy, + "IconUpdated", + G_CALLBACK(icon_changed), + self, + NULL); + return; } @@ -152,6 +161,14 @@ get_label (IndicatorObject * io) return NULL; } +static void +icon_changed (DBusGProxy * proxy, gchar * icon_name, gpointer user_data) +{ + IndicatorSession * session = INDICATOR_SESSION(user_data); + gtk_image_set_from_icon_name(session->status_image, icon_name, GTK_ICON_SIZE_MENU); + return; +} + static GtkImage * get_icon (IndicatorObject * io) { -- cgit v1.2.3 From 746636765323cb223ef84af13920a9620176eb4f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 15:47:33 -0600 Subject: Getting the icon, but only when we're connected. --- src/indicator-session.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index c23cd0b..6e259dc 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -35,6 +35,7 @@ with this program. If not, see . #include "dbus-shared-names.h" #include "dbusmenu-shared.h" +#include "session-dbus-client.h" #define INDICATOR_SESSION_TYPE (indicator_session_get_type ()) #define INDICATOR_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_SESSION_TYPE, IndicatorSession)) @@ -71,6 +72,7 @@ static GtkMenu * get_menu (IndicatorObject * io); static gboolean build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static void icon_changed (DBusGProxy * proxy, gchar * icon_name, gpointer user_data); +static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); static void indicator_session_class_init (IndicatorSessionClass *klass); static void indicator_session_init (IndicatorSession *self); @@ -103,6 +105,7 @@ indicator_session_init (IndicatorSession *self) /* Now let's fire these guys up. */ self->service = indicator_service_manager_new_version(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_VERSION); + g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(service_connection_cb), self); self->status_image = GTK_IMAGE(gtk_image_new_from_icon_name("system-shutdown-panel", GTK_ICON_SIZE_MENU)); self->menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT); @@ -155,6 +158,28 @@ indicator_session_finalize (GObject *object) return; } +static void +icon_name_get_cb (DBusGProxy *proxy, char * OUT_name, GError *error, gpointer userdata) +{ + IndicatorSession * self = INDICATOR_SESSION(userdata); + gtk_image_set_from_icon_name(self->status_image, OUT_name, GTK_ICON_SIZE_MENU); + return; +} + +static void +service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) +{ + IndicatorSession * self = INDICATOR_SESSION(user_data); + + if (connected) { + org_ayatana_indicator_session_service_get_icon_async(self->service_proxy, icon_name_get_cb, user_data); + } else { + gtk_image_set_from_icon_name(self->status_image, "system-shutdown-panel", GTK_ICON_SIZE_MENU); + } + + return; +} + static GtkLabel * get_label (IndicatorObject * io) { -- cgit v1.2.3 From 2dd05e216cdc0e7ab9318a410758eade2d3e68a4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 15:49:52 -0600 Subject: Moving the icon names into the shared header files --- src/indicator-session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index 6e259dc..de18bb3 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -107,7 +107,7 @@ indicator_session_init (IndicatorSession *self) self->service = indicator_service_manager_new_version(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_VERSION); g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(service_connection_cb), self); - self->status_image = GTK_IMAGE(gtk_image_new_from_icon_name("system-shutdown-panel", GTK_ICON_SIZE_MENU)); + self->status_image = GTK_IMAGE(gtk_image_new_from_icon_name(ICON_DEFAULT, GTK_ICON_SIZE_MENU)); self->menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT); DbusmenuClient * client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(self->menu)); @@ -174,7 +174,7 @@ service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointe if (connected) { org_ayatana_indicator_session_service_get_icon_async(self->service_proxy, icon_name_get_cb, user_data); } else { - gtk_image_set_from_icon_name(self->status_image, "system-shutdown-panel", GTK_ICON_SIZE_MENU); + gtk_image_set_from_icon_name(self->status_image, ICON_DEFAULT, GTK_ICON_SIZE_MENU); } return; -- cgit v1.2.3 From b419d049e7fe398e52739183f26cd486b7d9c421 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 16:33:33 -0600 Subject: Using the libindicator helpers so we get things like fallbacks! \o/ --- src/indicator-session.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index de18bb3..0282616 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -32,6 +32,7 @@ with this program. If not, see . #include #include #include +#include #include "dbus-shared-names.h" #include "dbusmenu-shared.h" @@ -107,7 +108,7 @@ indicator_session_init (IndicatorSession *self) self->service = indicator_service_manager_new_version(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_VERSION); g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(service_connection_cb), self); - self->status_image = GTK_IMAGE(gtk_image_new_from_icon_name(ICON_DEFAULT, GTK_ICON_SIZE_MENU)); + self->status_image = indicator_image_helper(ICON_DEFAULT); self->menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT); DbusmenuClient * client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(self->menu)); @@ -162,7 +163,7 @@ static void icon_name_get_cb (DBusGProxy *proxy, char * OUT_name, GError *error, gpointer userdata) { IndicatorSession * self = INDICATOR_SESSION(userdata); - gtk_image_set_from_icon_name(self->status_image, OUT_name, GTK_ICON_SIZE_MENU); + indicator_image_helper_update(self->status_image, OUT_name); return; } @@ -174,7 +175,7 @@ service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointe if (connected) { org_ayatana_indicator_session_service_get_icon_async(self->service_proxy, icon_name_get_cb, user_data); } else { - gtk_image_set_from_icon_name(self->status_image, ICON_DEFAULT, GTK_ICON_SIZE_MENU); + indicator_image_helper_update(self->status_image, ICON_DEFAULT); } return; @@ -190,7 +191,7 @@ static void icon_changed (DBusGProxy * proxy, gchar * icon_name, gpointer user_data) { IndicatorSession * session = INDICATOR_SESSION(user_data); - gtk_image_set_from_icon_name(session->status_image, icon_name, GTK_ICON_SIZE_MENU); + indicator_image_helper_update(session->status_image, icon_name); return; } -- cgit v1.2.3 From 4045ff049580248fdffa58a3b8c40bf4bef07682 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 21:08:15 -0600 Subject: Switching to building with GIcon so that we don't have to add an icon, we can use fallbacks. --- src/indicator-session.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index 3349886..184a335 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -326,12 +326,14 @@ restart_property_change (DbusmenuMenuitem * item, const gchar * property, const } else if (g_strcmp0(property, RESTART_ITEM_ICON) == 0) { GtkWidget * image = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(gmi)); + GIcon * gicon = g_themed_icon_new_with_default_fallbacks(g_value_get_string(value)); if (image == NULL) { - image = gtk_image_new_from_icon_name(g_value_get_string(value), GTK_ICON_SIZE_MENU); + image = gtk_image_new_from_gicon(gicon, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), image); } else { - gtk_image_set_from_icon_name(GTK_IMAGE(image), g_value_get_string(value), GTK_ICON_SIZE_MENU); + gtk_image_set_from_gicon(GTK_IMAGE(image), gicon, GTK_ICON_SIZE_MENU); } + g_object_unref(G_OBJECT(gicon)); } return; -- cgit v1.2.3 From 70a0dc7cf431dd2c7d4faa7081cbd7ea637a825f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Mar 2010 21:23:35 -0600 Subject: Making sure that if we can't get the icon, we leave it alone. --- src/indicator-session.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index 184a335..55579b9 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -167,6 +167,14 @@ indicator_session_finalize (GObject *object) static void icon_name_get_cb (DBusGProxy *proxy, char * OUT_name, GError *error, gpointer userdata) { + if (error != NULL) { + return; + } + + if (OUT_name == NULL || OUT_name[0] == '\0') { + return; + } + IndicatorSession * self = INDICATOR_SESSION(userdata); gtk_image_set_from_icon_name(self->status_image, OUT_name, GTK_ICON_SIZE_MENU); return; -- cgit v1.2.3 From 6233fb618821692cf103a52ae1a068c1e5c5a108 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 10:47:09 -0500 Subject: Fix capitalization of 'Switch From' --- src/indicator-session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index c21579a..eb7d53f 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -298,7 +298,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 { -- cgit v1.2.3 From 6a3728388fdf6454d2029c3d6ae0b1c71ad6222e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 15:28:46 -0500 Subject: Watch for the logged in property changing and hide or show the logged in widget depending on it. --- src/indicator-session.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index c21579a..9cf58a5 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -216,6 +216,19 @@ get_icon (IndicatorObject * io) return INDICATOR_SESSION(io)->status_image; } +static void +user_property_change (DbusmenuMenuitem * item, const gchar * property, const GValue * value, gpointer user_data) +{ + if (g_strcmp0(property, USER_ITEM_PROP_LOGGED_IN) == 0) { + if (g_value_get_boolean(value)) { + gtk_widget_show(GTK_WIDGET(user_data)); + } else { + gtk_widget_hide(GTK_WIDGET(user_data)); + } + } + return; +} + /* Builds an item with a hip little logged in icon. */ static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) @@ -242,6 +255,8 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(user_property_change), icon); + return TRUE; } -- cgit v1.2.3 From 23b8dc273347c6782667869e3de8f1dff059937d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 16:24:00 -0500 Subject: Building an icon based on teh icon props --- src/indicator-session.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index c21579a..e3444c0 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -28,6 +28,7 @@ with this program. If not, see . #include #include #include +#include #include #include @@ -223,6 +224,23 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); GtkWidget * hbox = gtk_hbox_new(FALSE, 0); + GtkWidget * usericon = NULL; + const gchar * icon_name = dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_ICON); + if (icon_name != NULL && icon_name[0] != '\0') { + if (g_strcmp0(icon_name, USER_ITEM_ICON_DEFAULT) == 0) { + GIcon * gicon = g_themed_icon_new_with_default_fallbacks("stock-user-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); gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); -- cgit v1.2.3 From 2f000c8501f73eed31b2441e83a434f6f4564c18 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 16:33:05 -0500 Subject: Using proper icon. --- src/indicator-session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index e3444c0..11231cd 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -228,7 +228,7 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl const gchar * icon_name = dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_ICON); if (icon_name != NULL && icon_name[0] != '\0') { if (g_strcmp0(icon_name, USER_ITEM_ICON_DEFAULT) == 0) { - GIcon * gicon = g_themed_icon_new_with_default_fallbacks("stock-user-panel"); + 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 { -- cgit v1.2.3 From 4e4246d795baea9a286914e870eca7690e3aa5de Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 16:36:53 -0500 Subject: Nice debugging message. --- src/indicator-session.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index 11231cd..2ffc2e3 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -232,6 +232,7 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl usericon = gtk_image_new_from_gicon(gicon, GTK_ICON_SIZE_MENU); g_object_unref(gicon); } else { + g_debug("Using user icon for '%s' from file: %s", dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME), icon_name); usericon = gtk_image_new_from_file(icon_name); } } -- cgit v1.2.3 From e94cf5b18ec45024d70a71096fd5e8aeaee6d988 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 16:38:31 -0500 Subject: Check to ensure the file exists. --- src/indicator-session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index 2ffc2e3..2be1e12 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -227,7 +227,7 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl GtkWidget * usericon = NULL; const gchar * icon_name = dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_ICON); if (icon_name != NULL && icon_name[0] != '\0') { - if (g_strcmp0(icon_name, USER_ITEM_ICON_DEFAULT) == 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); -- cgit v1.2.3 From d2e52c5334e119b40e12c9f3c03593737ef7bac8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 16:50:13 -0500 Subject: Moving debug message --- src/indicator-session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index 2be1e12..4e42567 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -226,13 +226,13 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl 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 { - g_debug("Using user icon for '%s' from file: %s", dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME), icon_name); usericon = gtk_image_new_from_file(icon_name); } } -- cgit v1.2.3 From c3d3a6b0a90dc9b34ea34951174a4171c1b4fd09 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Mar 2010 16:55:44 -0500 Subject: Getting the horizontal padding for a nice spacing between widgets. --- src/indicator-session.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/indicator-session.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index 4e42567..3c141c4 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -222,7 +222,9 @@ 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); -- cgit v1.2.3