Merge lp:~ted/libappindicator/lp875770 into lp:libappindicator/0.5

Proposed by Ted Gould
Status: Merged
Approved by: Charles Kerr
Approved revision: 230
Merged at revision: 230
Proposed branch: lp:~ted/libappindicator/lp875770
Merge into: lp:libappindicator/0.5
Diff against target: 107 lines (+43/-43)
1 file modified
src/app-indicator.c (+43/-43)
To merge this branch: bzr merge lp:~ted/libappindicator/lp875770
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Review via email: mp+95685@code.launchpad.net

Description of the change

Making it so that the fallback can handle icons that are specified with full paths

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) wrote :

Looks fine.

FWIW, you don't need to test "if (foo != NULL)" before calling g_free (foo). g_free() handles NULLs fine, and that's one less branch in the code to lower coverage stats :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app-indicator.c'
2--- src/app-indicator.c 2012-01-31 04:51:10 +0000
3+++ src/app-indicator.c 2012-03-02 22:37:18 +0000
4@@ -1582,60 +1582,60 @@
5 status_icon_changes (AppIndicator * self, gpointer data)
6 {
7 GtkStatusIcon * icon = GTK_STATUS_ICON(data);
8- gchar *longname = NULL;
9-
10- /* add the icon_theme_path once if needed */
11- GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
12- if (self->priv->icon_theme_path != NULL)
13- {
14- gchar **path;
15- gint n_elements, i;
16- gboolean found=FALSE;
17- gtk_icon_theme_get_search_path(icon_theme, &path, &n_elements);
18- for (i=0; i< n_elements || path[i] == NULL; i++)
19- {
20- if(g_strcmp0(path[i], self->priv->icon_theme_path) == 0)
21- {
22- found=TRUE;
23- break;
24- }
25- }
26- if(!found)
27- gtk_icon_theme_append_search_path(icon_theme, self->priv->icon_theme_path);
28- g_strfreev (path);
29- }
30-
31+
32+ /* add the icon_theme_path once if needed */
33+ GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
34+ if (self->priv->icon_theme_path != NULL) {
35+ gchar **path;
36+ gint n_elements, i;
37+ gboolean found=FALSE;
38+ gtk_icon_theme_get_search_path(icon_theme, &path, &n_elements);
39+ for (i=0; i< n_elements || path[i] == NULL; i++) {
40+ if(g_strcmp0(path[i], self->priv->icon_theme_path) == 0) {
41+ found=TRUE;
42+ break;
43+ }
44+ }
45+ if(!found) {
46+ gtk_icon_theme_append_search_path(icon_theme, self->priv->icon_theme_path);
47+ }
48+ g_strfreev (path);
49+ }
50+
51+ const gchar * icon_name = NULL;
52 switch (app_indicator_get_status(self)) {
53 case APP_INDICATOR_STATUS_PASSIVE:
54- /* hide first to avoid that the change is visible to the user */
55- gtk_status_icon_set_visible(icon, FALSE);
56- longname = append_panel_icon_suffix(app_indicator_get_icon(self));
57- if (gtk_icon_theme_has_icon (icon_theme, longname))
58- gtk_status_icon_set_from_icon_name(icon, longname);
59- else
60- gtk_status_icon_set_from_icon_name(icon, app_indicator_get_icon(self));
61+ /* hide first to avoid that the change is visible to the user */
62+ gtk_status_icon_set_visible(icon, FALSE);
63+ icon_name = app_indicator_get_icon(self);
64 break;
65 case APP_INDICATOR_STATUS_ACTIVE:
66- longname = append_panel_icon_suffix(app_indicator_get_icon(self));
67- if (gtk_icon_theme_has_icon (icon_theme, longname))
68- gtk_status_icon_set_from_icon_name(icon, longname);
69- else
70- gtk_status_icon_set_from_icon_name(icon, app_indicator_get_icon(self));
71+ icon_name = app_indicator_get_icon(self);
72 gtk_status_icon_set_visible(icon, TRUE);
73 break;
74 case APP_INDICATOR_STATUS_ATTENTION:
75- /* get the _attention_ icon here */
76- longname = append_panel_icon_suffix(app_indicator_get_attention_icon(self));
77- if (gtk_icon_theme_has_icon (icon_theme, longname))
78- gtk_status_icon_set_from_icon_name(icon, longname);
79- else
80- gtk_status_icon_set_from_icon_name(icon, app_indicator_get_icon(self));
81+ /* get the _attention_ icon here */
82+ icon_name = app_indicator_get_attention_icon(self);
83 gtk_status_icon_set_visible(icon, TRUE);
84 break;
85 };
86
87- if (longname) {
88- g_free(longname);
89+ if (icon_name != NULL) {
90+ if (g_file_test(icon_name, G_FILE_TEST_EXISTS)) {
91+ gtk_status_icon_set_from_file(icon, icon_name);
92+ } else {
93+ gchar *longname = append_panel_icon_suffix(icon_name);
94+
95+ if (longname != NULL && gtk_icon_theme_has_icon (icon_theme, longname)) {
96+ gtk_status_icon_set_from_icon_name(icon, longname);
97+ } else {
98+ gtk_status_icon_set_from_icon_name(icon, icon_name);
99+ }
100+
101+ if (longname) {
102+ g_free(longname);
103+ }
104+ }
105 }
106
107 return;

Subscribers

People subscribed via source and target branches