# HG changeset patch # User Guido Berhoerster # Date 1566991763 -7200 # Node ID 811df672633d543273b62fcd77fd57dee38513fb # Parent 9fc3e0c1a54bb59c27e32efa89a81769ee778f5e Add fallback icons for KDE-based themes diff -r 9fc3e0c1a54b -r 811df672633d pui-application.c --- a/pui-application.c Wed Jul 24 16:28:17 2019 +0200 +++ b/pui-application.c Wed Aug 28 13:29:23 2019 +0200 @@ -62,14 +62,19 @@ static GParamSpec *properties[PROP_LAST] = { NULL }; -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 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 GOptionEntry cmd_options[] = { @@ -196,6 +201,9 @@ 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; @@ -301,8 +309,18 @@ APP_INDICATOR_STATUS_ACTIVE); break; } - app_indicator_set_icon_full(self->indicator, icon_names[self->state], - title); + + /* 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); /* notification */ switch (self->state) { @@ -338,7 +356,7 @@ } g_debug("indicator icon: %s, notification title: \"%s\", " - "notification body: \"%s\"", icon_names[self->state], title, body); + "notification body: \"%s\"", icon_name, title, body); g_free(body); g_free(title); @@ -475,7 +493,7 @@ /* load icons */ for (i = 0; i < G_N_ELEMENTS(self->icons); i++) { - self->icons[i] = g_themed_icon_new(icon_names[i]); + self->icons[i] = g_themed_icon_new_from_names(icon_names[i], 2); } /* create settings */