Mercurial > projects > package-update-indicator
diff pui-application.c @ 35:c4b8785d0b75
Back out fallback icon support which does not work as intended
The fallback icon support does not work as intended since it depends on
gtk_icon_theme_has_icon() in order to determine whether an icon exists in the
current icon theme. Contrary to the documentation GtkIconTheme not only falls
back to the "hicolor" theme but also to the "Adwaita" and "gnome" themes when
looking for icons. The Adwaita theme provides the "system-software-update",
"software-update-available", and "software-update-urgent" icons so the fallback
will never be used even if the current theme does not provide these icons. SNI
host implementations such as the one in KDE Plasma Shell will only look for
icon names in the current theme and do not fall back to the "Adwaita" and
"gnome" themes.
author | Guido Berhoerster <guido+pui@berhoerster.name> |
---|---|
date | Fri, 06 Sep 2019 13:49:54 +0200 |
parents | 811df672633d |
children | 24cba399757f |
line wrap: on
line diff
--- a/pui-application.c Fri Aug 30 13:34:00 2019 +0200 +++ b/pui-application.c Fri Sep 06 13:49:54 2019 +0200 @@ -62,19 +62,14 @@ static GParamSpec *properties[PROP_LAST] = { NULL }; -static gchar *icon_names[PUI_STATE_LAST][2] = { - [PUI_STATE_INITIAL] = { "system-software-update", "update-none" }, - [PUI_STATE_UP_TO_DATE] = { "system-software-update", "update-none" }, - [PUI_STATE_NORMAL_UPDATES_AVAILABLE] = { "software-update-available", - "update-medium" }, - [PUI_STATE_IMPORTANT_UPDATES_AVAILABLE] = { "software-update-urgent", - "update-high" }, - [PUI_STATE_SESSION_RESTART_REQUIRED] = { "system-log-out", - "system-log-out" }, - [PUI_STATE_SYSTEM_RESTART_REQUIRED] = { "system-reboot", - "system-reboot" }, - [PUI_STATE_ERROR] = { "dialog-warning", - "dialog-warning" } +static const gchar *icon_names[PUI_STATE_LAST] = { + [PUI_STATE_INITIAL] = "system-software-update", + [PUI_STATE_UP_TO_DATE] = "system-software-update", + [PUI_STATE_NORMAL_UPDATES_AVAILABLE] = "software-update-available", + [PUI_STATE_IMPORTANT_UPDATES_AVAILABLE] = "software-update-urgent", + [PUI_STATE_SESSION_RESTART_REQUIRED] = "system-log-out", + [PUI_STATE_SYSTEM_RESTART_REQUIRED] = "system-reboot", + [PUI_STATE_ERROR] = "dialog-warning" }; static const GOptionEntry cmd_options[] = { @@ -201,9 +196,6 @@ guint normal_updates = 0; gchar *title = NULL; gchar *body = NULL; - GtkIconTheme *icon_theme; - const gchar * const *icon_namep; - const gchar *icon_name; GApplication *application = G_APPLICATION(self); GNotification *notification = NULL; @@ -309,18 +301,8 @@ APP_INDICATOR_STATUS_ACTIVE); break; } - - /* determine icon name using fallbacks if necessary */ - icon_theme = gtk_icon_theme_get_default(); - for (icon_namep = - g_themed_icon_get_names(G_THEMED_ICON(self->icons[self->state])), - icon_name = *icon_namep; *icon_namep != NULL; icon_namep++) { - if (gtk_icon_theme_has_icon(icon_theme, *icon_namep)) { - icon_name = *icon_namep; - break; - } - } - app_indicator_set_icon_full(self->indicator, icon_name, title); + app_indicator_set_icon_full(self->indicator, icon_names[self->state], + title); /* notification */ switch (self->state) { @@ -356,7 +338,7 @@ } g_debug("indicator icon: %s, notification title: \"%s\", " - "notification body: \"%s\"", icon_name, title, body); + "notification body: \"%s\"", icon_names[self->state], title, body); g_free(body); g_free(title); @@ -493,7 +475,7 @@ /* load icons */ for (i = 0; i < G_N_ELEMENTS(self->icons); i++) { - self->icons[i] = g_themed_icon_new_from_names(icon_names[i], 2); + self->icons[i] = g_themed_icon_new(icon_names[i]); } /* create settings */