Merge lp:~karl-qdh/ubuntu/maverick/libindicator/absfilename-ibus-bug564034 into lp:libindicator/0.4

Proposed by Karl Lattimer
Status: Merged
Approved by: David Barth
Approved revision: 370
Merged at revision: 370
Proposed branch: lp:~karl-qdh/ubuntu/maverick/libindicator/absfilename-ibus-bug564034
Merge into: lp:libindicator/0.4
Diff against target: 72 lines (+22/-12)
1 file modified
libindicator/indicator-image-helper.c (+22/-12)
To merge this branch: bzr merge lp:~karl-qdh/ubuntu/maverick/libindicator/absfilename-ibus-bug564034
Reviewer Review Type Date Requested Status
David Barth Approve
Ubuntu branches Pending
Review via email: mp+32077@code.launchpad.net

Description of the change

I think this is the correctly committed branch for merging into the correct branch.

Update to indicator-image-helper.c to fall back to using absolute filenames.

Half of the fix for; https://bugs.launchpad.net/bugs/564034

To post a comment you must log in.
Revision history for this message
David Barth (dbarth) wrote :

THe general logic looks right.
Style issue: g_return_if_fail shouldn't be used since it would catch a runtime error (as opposed to a programming error).

Revision history for this message
Karl Lattimer (karl-qdh) wrote :

@David, that line was also present in the existing branch and I tried to maintain the existing style.

Is this enough of an issue to block merging? if so what do you recommend we do instead?

Revision history for this message
David Barth (dbarth) wrote :

It may be something to fix in the rest of the branch then

Revision history for this message
Karl Lattimer (karl-qdh) wrote :

well, in that case can we approve the merge here and ask tedg what he'd like doing about the g_return_if_fail?

Revision history for this message
David Barth (dbarth) wrote :

Cody was fine with the g_return_if_fail actually. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libindicator/indicator-image-helper.c'
--- libindicator/indicator-image-helper.c 2010-07-06 14:47:12 +0000
+++ libindicator/indicator-image-helper.c 2010-08-09 09:51:43 +0000
@@ -30,6 +30,9 @@
30refresh_image (GtkImage * image)30refresh_image (GtkImage * image)
31{31{
32 g_return_if_fail(GTK_IS_IMAGE(image));32 g_return_if_fail(GTK_IS_IMAGE(image));
33 gchar * icon_filename = NULL;
34 GtkIconInfo * icon_info = NULL;
35 gint icon_size = 22;
3336
34 GIcon * icon_names = (GIcon *)g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA);37 GIcon * icon_names = (GIcon *)g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA);
35 g_return_if_fail(icon_names != NULL);38 g_return_if_fail(icon_names != NULL);
@@ -38,23 +41,29 @@
38 GtkIconTheme * default_theme = gtk_icon_theme_get_default();41 GtkIconTheme * default_theme = gtk_icon_theme_get_default();
39 g_return_if_fail(default_theme != NULL);42 g_return_if_fail(default_theme != NULL);
4043
41 gint icon_size = 22;
42
43 /* Look through the themes for that icon */44 /* Look through the themes for that icon */
44 GtkIconInfo * icon_info = gtk_icon_theme_lookup_by_gicon(default_theme, icon_names, icon_size, 0);45 icon_info = gtk_icon_theme_lookup_by_gicon(default_theme, icon_names, icon_size, 0);
45 if (icon_info == NULL) {46 if (icon_info == NULL) {
46 g_warning("Unable to find icon in theme.");47 /* Try using the second item in the names, which should be the original filename supplied */
47 return;48 const gchar * const * names = g_themed_icon_get_names(G_THEMED_ICON( icon_names ));
49 if (names) {
50 icon_filename = g_strdup(names[1]);
51 } else {
52 g_warning("Unable to find icon\n");
53 return;
54 }
55 } else {
56 /* Grab the filename */
57 icon_filename = (gchar *)gtk_icon_info_get_filename(icon_info);
48 }58 }
4959 g_return_if_fail(icon_filename != NULL); /* An error because we don't have a filename */
50 /* Grab the filename */
51 const gchar * icon_filename = gtk_icon_info_get_filename(icon_info);
52 g_return_if_fail(icon_filename != NULL); /* An error because we shouldn't get info without a filename */
5360
54 /* Build a pixbuf */61 /* Build a pixbuf */
55 GError * error = NULL;62 GError * error = NULL;
56 GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file(icon_filename, &error);63 GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file(icon_filename, &error);
57 gtk_icon_info_free(icon_info);64
65 if (icon_info != NULL)
66 gtk_icon_info_free(icon_info);
5867
59 if (pixbuf == NULL) {68 if (pixbuf == NULL) {
60 g_error("Unable to load icon from file '%s' because: %s", icon_filename, error == NULL ? "I don't know" : error->message);69 g_error("Unable to load icon from file '%s' because: %s", icon_filename, error == NULL ? "I don't know" : error->message);
@@ -126,15 +135,16 @@
126 g_return_if_fail(name != NULL);135 g_return_if_fail(name != NULL);
127 g_return_if_fail(name[0] != '\0');136 g_return_if_fail(name[0] != '\0');
128 g_return_if_fail(image != NULL);137 g_return_if_fail(image != NULL);
138 gboolean seen_previously = FALSE;
129139
130 /* Build us a GIcon */140 /* Build us a GIcon */
131 GIcon * icon_names = g_themed_icon_new_with_default_fallbacks(name);141 GIcon * icon_names = g_themed_icon_new_with_default_fallbacks(name);
142 g_warn_if_fail(icon_names != NULL);
132 g_return_if_fail(icon_names != NULL);143 g_return_if_fail(icon_names != NULL);
133144
134 gboolean seen_previously = (g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA) != NULL);
135
136 /* Attach our names to the image */145 /* Attach our names to the image */
137 g_object_set_data_full(G_OBJECT(image), INDICATOR_NAMES_DATA, icon_names, g_object_unref);146 g_object_set_data_full(G_OBJECT(image), INDICATOR_NAMES_DATA, icon_names, g_object_unref);
147 seen_previously = (g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA) != NULL);
138148
139 /* Put the pixbuf in */149 /* Put the pixbuf in */
140 refresh_image(image);150 refresh_image(image);

Subscribers

People subscribed via source and target branches