Merge lp:~phurley/indicator-session/lp-957563 into lp:indicator-session/13.04

Proposed by Peter Hurley
Status: Work in progress
Proposed branch: lp:~phurley/indicator-session/lp-957563
Merge into: lp:indicator-session/13.04
Diff against target: 44 lines (+18/-16)
1 file modified
src/indicator-session.c (+18/-16)
To merge this branch: bzr merge lp:~phurley/indicator-session/lp-957563
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre Needs Fixing
Review via email: mp+141480@code.launchpad.net

Description of the change

Use a list of icons to select appropriate system icon (LP: #975563)

To post a comment you must log in.
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Seems far more complex and prone to omissions/special cases that another merge fixing the same issue: https://code.launchpad.net/~ballogy/indicator-session/better-fallback-icon/+merge/141608 (which however doesn't take care of retaining the fix for bug 1048348).

I'm sure there's a way to simplify this to not require a list of icons hard-coded in indicator-session -- perhaps by using the g_themed_icon_with_default_fallbacks mechanisms, and checking if it results in a valid icon, and dealing with when it doesn't?

review: Needs Fixing
Revision history for this message
Peter Hurley (phurley) wrote :

I reworked this branch to use g_themed_icon_new_from_names(). This removes some of the patch complexity (related to the poorly designed GtkIconTheme api).

381. By Peter Hurley

Use an ordered list to choose the appropriate system icon.
   The list is ordered by the following rules:
   1) Most unique names come first (ie, names least likely to exist in other themes)
   2) Themes with multiple matches require the desired icon name higher in the list
      than other possible matches.
   Fixes: https://bugs.launchpad.net/indicator-session/+bug/975563

   Preserves existing behavior: if the system menu's icon is missing in the current theme,
   fall back to gtk-missing-icon instead of showing no icon at all.
   Fixes: https://bugs.launchpad.net/bugs/1048348.

Unmerged revisions

381. By Peter Hurley

Use an ordered list to choose the appropriate system icon.
   The list is ordered by the following rules:
   1) Most unique names come first (ie, names least likely to exist in other themes)
   2) Themes with multiple matches require the desired icon name higher in the list
      than other possible matches.
   Fixes: https://bugs.launchpad.net/indicator-session/+bug/975563

   Preserves existing behavior: if the system menu's icon is missing in the current theme,
   fall back to gtk-missing-icon instead of showing no icon at all.
   Fixes: https://bugs.launchpad.net/bugs/1048348.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator-session.c'
2--- src/indicator-session.c 2012-11-14 20:20:13 +0000
3+++ src/indicator-session.c 2013-01-10 14:26:22 +0000
4@@ -399,22 +399,24 @@
5 indicator_session_update_icon_from_disposition (IndicatorSession * indicator,
6 int disposition)
7 {
8- const gchar * icon;
9-
10- if (disposition == DISPOSITION_NORMAL)
11- icon = ICON_DEFAULT;
12- else if (disposition == DISPOSITION_INFO)
13- icon = ICON_INFO;
14- else
15- icon = ICON_ALERT;
16-
17- if (gtk_icon_theme_has_icon (indicator->icon_theme, icon) == FALSE)
18- icon = "gtk-missing-image";
19-
20- g_debug (G_STRLOC" setting icon to \"%s\"", icon);
21- gtk_image_set_from_icon_name (GTK_IMAGE(indicator->entry.image),
22- icon,
23- GTK_ICON_SIZE_BUTTON);
24+ GIcon * gicon;
25+ const char * icons[] = { ICON_DEFAULT, /* ubuntu-mono-* */
26+ "system", /* gnome & humanity */
27+ "emblem-system", /* HighContrast */
28+ "system-shutdown", /* others */
29+ "gtk-missing-image",
30+ NULL,
31+ };
32+
33+ if (disposition == DISPOSITION_INFO)
34+ icons[0] = ICON_INFO;
35+ else if (disposition != DISPOSITION_NORMAL)
36+ icons[0] = ICON_ALERT;
37+
38+ gicon = g_themed_icon_new_from_names ((char **) icons, -1);
39+ gtk_image_set_from_gicon (GTK_IMAGE(indicator->entry.image),
40+ gicon,
41+ GTK_ICON_SIZE_BUTTON);
42 }
43
44 static int

Subscribers

People subscribed via source and target branches