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

Proposed by Karl Lattimer on 2010-08-09
Status: Merged
Approved by: David Barth on 2010-08-10
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 on 2010-08-10
Ubuntu branches 2010-08-09 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.
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).

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?

David Barth (dbarth) wrote :

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

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?

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
1=== modified file 'libindicator/indicator-image-helper.c'
2--- libindicator/indicator-image-helper.c 2010-07-06 14:47:12 +0000
3+++ libindicator/indicator-image-helper.c 2010-08-09 09:51:43 +0000
4@@ -30,6 +30,9 @@
5 refresh_image (GtkImage * image)
6 {
7 g_return_if_fail(GTK_IS_IMAGE(image));
8+ gchar * icon_filename = NULL;
9+ GtkIconInfo * icon_info = NULL;
10+ gint icon_size = 22;
11
12 GIcon * icon_names = (GIcon *)g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA);
13 g_return_if_fail(icon_names != NULL);
14@@ -38,23 +41,29 @@
15 GtkIconTheme * default_theme = gtk_icon_theme_get_default();
16 g_return_if_fail(default_theme != NULL);
17
18- gint icon_size = 22;
19-
20 /* Look through the themes for that icon */
21- GtkIconInfo * icon_info = gtk_icon_theme_lookup_by_gicon(default_theme, icon_names, icon_size, 0);
22+ icon_info = gtk_icon_theme_lookup_by_gicon(default_theme, icon_names, icon_size, 0);
23 if (icon_info == NULL) {
24- g_warning("Unable to find icon in theme.");
25- return;
26+ /* Try using the second item in the names, which should be the original filename supplied */
27+ const gchar * const * names = g_themed_icon_get_names(G_THEMED_ICON( icon_names ));
28+ if (names) {
29+ icon_filename = g_strdup(names[1]);
30+ } else {
31+ g_warning("Unable to find icon\n");
32+ return;
33+ }
34+ } else {
35+ /* Grab the filename */
36+ icon_filename = (gchar *)gtk_icon_info_get_filename(icon_info);
37 }
38-
39- /* Grab the filename */
40- const gchar * icon_filename = gtk_icon_info_get_filename(icon_info);
41- g_return_if_fail(icon_filename != NULL); /* An error because we shouldn't get info without a filename */
42+ g_return_if_fail(icon_filename != NULL); /* An error because we don't have a filename */
43
44 /* Build a pixbuf */
45 GError * error = NULL;
46 GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file(icon_filename, &error);
47- gtk_icon_info_free(icon_info);
48+
49+ if (icon_info != NULL)
50+ gtk_icon_info_free(icon_info);
51
52 if (pixbuf == NULL) {
53 g_error("Unable to load icon from file '%s' because: %s", icon_filename, error == NULL ? "I don't know" : error->message);
54@@ -126,15 +135,16 @@
55 g_return_if_fail(name != NULL);
56 g_return_if_fail(name[0] != '\0');
57 g_return_if_fail(image != NULL);
58+ gboolean seen_previously = FALSE;
59
60 /* Build us a GIcon */
61 GIcon * icon_names = g_themed_icon_new_with_default_fallbacks(name);
62+ g_warn_if_fail(icon_names != NULL);
63 g_return_if_fail(icon_names != NULL);
64
65- gboolean seen_previously = (g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA) != NULL);
66-
67 /* Attach our names to the image */
68 g_object_set_data_full(G_OBJECT(image), INDICATOR_NAMES_DATA, icon_names, g_object_unref);
69+ seen_previously = (g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA) != NULL);
70
71 /* Put the pixbuf in */
72 refresh_image(image);

Subscribers

People subscribed via source and target branches