projects/package-update-indicator

changeset 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 Sep 06 13:49:54 2019 +0200 (9 months ago)
parents cf7c73dfdac0
children 47f93d8de713
files pui-application.c
line diff
     1.1 --- a/pui-application.c	Fri Aug 30 13:34:00 2019 +0200
     1.2 +++ b/pui-application.c	Fri Sep 06 13:49:54 2019 +0200
     1.3 @@ -62,19 +62,14 @@
     1.4  
     1.5  static GParamSpec *properties[PROP_LAST] = { NULL };
     1.6  
     1.7 -static gchar *icon_names[PUI_STATE_LAST][2] = {
     1.8 -    [PUI_STATE_INITIAL] = { "system-software-update", "update-none" },
     1.9 -    [PUI_STATE_UP_TO_DATE] = { "system-software-update", "update-none" },
    1.10 -    [PUI_STATE_NORMAL_UPDATES_AVAILABLE] = { "software-update-available",
    1.11 -        "update-medium" },
    1.12 -    [PUI_STATE_IMPORTANT_UPDATES_AVAILABLE] = { "software-update-urgent",
    1.13 -        "update-high" },
    1.14 -    [PUI_STATE_SESSION_RESTART_REQUIRED] = { "system-log-out",
    1.15 -        "system-log-out" },
    1.16 -    [PUI_STATE_SYSTEM_RESTART_REQUIRED] = { "system-reboot",
    1.17 -        "system-reboot" },
    1.18 -    [PUI_STATE_ERROR] = { "dialog-warning",
    1.19 -        "dialog-warning" }
    1.20 +static const gchar *icon_names[PUI_STATE_LAST] = {
    1.21 +    [PUI_STATE_INITIAL] = "system-software-update",
    1.22 +    [PUI_STATE_UP_TO_DATE] = "system-software-update",
    1.23 +    [PUI_STATE_NORMAL_UPDATES_AVAILABLE] = "software-update-available",
    1.24 +    [PUI_STATE_IMPORTANT_UPDATES_AVAILABLE] = "software-update-urgent",
    1.25 +    [PUI_STATE_SESSION_RESTART_REQUIRED] = "system-log-out",
    1.26 +    [PUI_STATE_SYSTEM_RESTART_REQUIRED] = "system-reboot",
    1.27 +    [PUI_STATE_ERROR] = "dialog-warning"
    1.28  };
    1.29  
    1.30  static const GOptionEntry cmd_options[] = {
    1.31 @@ -201,9 +196,6 @@
    1.32  	guint		normal_updates = 0;
    1.33  	gchar		*title = NULL;
    1.34  	gchar		*body = NULL;
    1.35 -	GtkIconTheme	*icon_theme;
    1.36 -	const gchar	* const *icon_namep;
    1.37 -	const gchar	*icon_name;
    1.38  	GApplication	*application = G_APPLICATION(self);
    1.39  	GNotification	*notification = NULL;
    1.40  
    1.41 @@ -309,18 +301,8 @@
    1.42  		    APP_INDICATOR_STATUS_ACTIVE);
    1.43  		break;
    1.44  	}
    1.45 -
    1.46 -	/* determine icon name using fallbacks if necessary */
    1.47 -	icon_theme = gtk_icon_theme_get_default();
    1.48 -	for (icon_namep =
    1.49 -	    g_themed_icon_get_names(G_THEMED_ICON(self->icons[self->state])),
    1.50 -	    icon_name = *icon_namep; *icon_namep != NULL; icon_namep++) {
    1.51 -		if (gtk_icon_theme_has_icon(icon_theme, *icon_namep)) {
    1.52 -			icon_name = *icon_namep;
    1.53 -			break;
    1.54 -		}
    1.55 -	}
    1.56 -	app_indicator_set_icon_full(self->indicator, icon_name, title);
    1.57 +	app_indicator_set_icon_full(self->indicator, icon_names[self->state],
    1.58 +	    title);
    1.59  
    1.60  	/* notification */
    1.61  	switch (self->state) {
    1.62 @@ -356,7 +338,7 @@
    1.63  	}
    1.64  
    1.65  	g_debug("indicator icon: %s, notification title: \"%s\", "
    1.66 -	    "notification body: \"%s\"", icon_name, title, body);
    1.67 +	    "notification body: \"%s\"", icon_names[self->state], title, body);
    1.68  
    1.69  	g_free(body);
    1.70  	g_free(title);
    1.71 @@ -493,7 +475,7 @@
    1.72  
    1.73  	/* load icons */
    1.74  	for (i = 0; i < G_N_ELEMENTS(self->icons); i++) {
    1.75 -		self->icons[i] = g_themed_icon_new_from_names(icon_names[i], 2);
    1.76 +		self->icons[i] = g_themed_icon_new(icon_names[i]);
    1.77  	}
    1.78  
    1.79  	/* create settings */