From b4ca4f6ff3d2176b42cad8ec5e5970452d83edb9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Mar 2010 10:22:17 -0600 Subject: Splitting things out into an update function and a buid function. --- libindicator/indicator-image-helper.c | 30 ++++++++++++++++-------------- libindicator/indicator-image-helper.h | 4 +++- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/libindicator/indicator-image-helper.c b/libindicator/indicator-image-helper.c index cbbad3d..2703208 100644 --- a/libindicator/indicator-image-helper.c +++ b/libindicator/indicator-image-helper.c @@ -112,21 +112,24 @@ image_destroyed_cb (GtkImage * image, gpointer user_data) GtkImage * indicator_image_helper (const gchar * name) { - g_return_val_if_fail(name != NULL, NULL); - g_return_val_if_fail(name[0] != '\0', NULL); - - /* Build us a GIcon */ - GIcon * icon_names = g_themed_icon_new_with_default_fallbacks(name); - g_return_val_if_fail(icon_names != NULL, NULL); - /* Build us an image */ GtkImage * image = GTK_IMAGE(gtk_image_new()); - if (image == NULL) { - g_error("Unable to create image from pixbuf on icon name '%s'", name); - g_object_unref(icon_names); - return NULL; - } + indicator_image_helper_update(image, name); + + return image; +} + +void +indicator_image_helper_update (GtkImage * image, const gchar * name) +{ + g_return_if_fail(name != NULL); + g_return_if_fail(name[0] != '\0'); + g_return_if_fail(image != NULL); + + /* Build us a GIcon */ + GIcon * icon_names = g_themed_icon_new_with_default_fallbacks(name); + g_return_if_fail(icon_names != NULL); /* Attach our names to the image */ g_object_set_data_full(G_OBJECT(image), INDICATOR_NAMES_DATA, icon_names, g_object_unref); @@ -138,6 +141,5 @@ indicator_image_helper (const gchar * name) g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), "changed", G_CALLBACK(theme_changed_cb), image); g_signal_connect(G_OBJECT(image), "destroy", G_CALLBACK(image_destroyed_cb), NULL); - /* Return our built image */ - return image; + return; } diff --git a/libindicator/indicator-image-helper.h b/libindicator/indicator-image-helper.h index fed02dc..77e2f0a 100644 --- a/libindicator/indicator-image-helper.h +++ b/libindicator/indicator-image-helper.h @@ -26,6 +26,8 @@ License along with this library. If not, see #include -GtkImage * indicator_image_helper (const gchar * name); +GtkImage * indicator_image_helper (const gchar * name); +void indicator_image_helper_update (GtkImage * image, + const gchar * name); #endif /* __INDICATOR_IMAGE_HELPER_H__ */ -- cgit v1.2.3 From e31a7de28b3a030186e49a4b0d88730604196539 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Mar 2010 10:35:14 -0600 Subject: Check to see if we've seen the image previously before adding signals in. --- libindicator/indicator-image-helper.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libindicator/indicator-image-helper.c b/libindicator/indicator-image-helper.c index 2703208..ae417c7 100644 --- a/libindicator/indicator-image-helper.c +++ b/libindicator/indicator-image-helper.c @@ -109,6 +109,8 @@ image_destroyed_cb (GtkImage * image, gpointer user_data) return; } +/* Builds an image with the name and fallbacks and all kinds of fun + stuff . */ GtkImage * indicator_image_helper (const gchar * name) { @@ -120,6 +122,7 @@ indicator_image_helper (const gchar * name) return image; } +/* Updates and image with all the fun stuff */ void indicator_image_helper_update (GtkImage * image, const gchar * name) { @@ -131,6 +134,8 @@ indicator_image_helper_update (GtkImage * image, const gchar * name) GIcon * icon_names = g_themed_icon_new_with_default_fallbacks(name); g_return_if_fail(icon_names != NULL); + gboolean seen_previously = (g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA) != NULL); + /* Attach our names to the image */ g_object_set_data_full(G_OBJECT(image), INDICATOR_NAMES_DATA, icon_names, g_object_unref); @@ -138,8 +143,10 @@ indicator_image_helper_update (GtkImage * image, const gchar * name) refresh_image(image); /* Connect to all changes */ - g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), "changed", G_CALLBACK(theme_changed_cb), image); - g_signal_connect(G_OBJECT(image), "destroy", G_CALLBACK(image_destroyed_cb), NULL); + if (!seen_previously) { + g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), "changed", G_CALLBACK(theme_changed_cb), image); + g_signal_connect(G_OBJECT(image), "destroy", G_CALLBACK(image_destroyed_cb), NULL); + } return; } -- cgit v1.2.3 From a6ecf4a5b44ae4179d17d1f78da80ced04209b32 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Mar 2010 10:51:17 -0600 Subject: Watching for style changes on the image. --- libindicator/indicator-image-helper.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libindicator/indicator-image-helper.c b/libindicator/indicator-image-helper.c index ae417c7..86d6c25 100644 --- a/libindicator/indicator-image-helper.c +++ b/libindicator/indicator-image-helper.c @@ -109,6 +109,15 @@ image_destroyed_cb (GtkImage * image, gpointer user_data) return; } +/* Catch the style changing on the image to make sure + we've got the latest. */ +static void +image_style_change_cb (GtkImage * image, GtkStyle * previous_style, gpointer user_data) +{ + refresh_image(image); + return; +} + /* Builds an image with the name and fallbacks and all kinds of fun stuff . */ GtkImage * @@ -146,6 +155,7 @@ indicator_image_helper_update (GtkImage * image, const gchar * name) if (!seen_previously) { g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), "changed", G_CALLBACK(theme_changed_cb), image); g_signal_connect(G_OBJECT(image), "destroy", G_CALLBACK(image_destroyed_cb), NULL); + g_signal_connect(G_OBJECT(image), "style-set", G_CALLBACK(image_style_change_cb), NULL); } return; -- cgit v1.2.3 From bb8b7032dfd93cd0cdad55967b973dd4de7ca044 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Mar 2010 14:20:02 -0600 Subject: 0.3.5 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 2601ea5..b3f3d78 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_INIT(libindicator, 0.3.4, ted@canonical.com) +AC_INIT(libindicator, 0.3.5, ted@canonical.com) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libindicator, 0.3.4) +AM_INIT_AUTOMAKE(libindicator, 0.3.5) AM_MAINTAINER_MODE m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES]) -- cgit v1.2.3