Make icon set via rules take priority over raw icons
When a notification contains both a raw icon and an icon path according to the GNOME notification specification the raw icon should take priority over anything else. If, however, a user uses the new_icon rule to set a custom icon on a notification, that rule overwrote the icon path and not the raw icon and as a result the raw icon was displayed in place of the user specified one. As a simple fix, a new icon_overridden boolean was added to the notification struct indicating if a custom icon has been set. If so, the icon path should take priority over the raw icon. Fixes #339
This commit is contained in:
		
							parent
							
								
									b06475b4aa
								
							
						
					
					
						commit
						86cbc1d34b
					
				@ -2,6 +2,9 @@
 | 
			
		||||
 | 
			
		||||
## Unreleased
 | 
			
		||||
 | 
			
		||||
### Fixed
 | 
			
		||||
- `new_icon` rule being ignored on notifications that had a raw icon
 | 
			
		||||
 | 
			
		||||
## 1.2.0 - 2017-07-12
 | 
			
		||||
 | 
			
		||||
### Added
 | 
			
		||||
 | 
			
		||||
@ -34,6 +34,7 @@ typedef struct _notification {
 | 
			
		||||
        char *appname;
 | 
			
		||||
        char *summary;
 | 
			
		||||
        char *body;
 | 
			
		||||
        bool icon_overridden;
 | 
			
		||||
        char *icon;
 | 
			
		||||
        RawImage *raw_icon;
 | 
			
		||||
        char *msg;            /* formatted message */
 | 
			
		||||
 | 
			
		||||
@ -24,6 +24,7 @@ void rule_apply(rule_t * r, notification * n)
 | 
			
		||||
                if(n->icon)
 | 
			
		||||
                        g_free(n->icon);
 | 
			
		||||
                n->icon = g_strdup(r->new_icon);
 | 
			
		||||
                n->icon_overridden = true;
 | 
			
		||||
        }
 | 
			
		||||
        if (r->fg)
 | 
			
		||||
                n->color_strings[ColFG] = r->fg;
 | 
			
		||||
 | 
			
		||||
@ -408,8 +408,11 @@ static colored_layout *r_init_shared(cairo_t *c, notification *n)
 | 
			
		||||
 | 
			
		||||
        GdkPixbuf *pixbuf = NULL;
 | 
			
		||||
 | 
			
		||||
        if (n->raw_icon && settings.icon_position != icons_off) {
 | 
			
		||||
        if (n->raw_icon && !n->icon_overridden &&
 | 
			
		||||
            settings.icon_position != icons_off) {
 | 
			
		||||
 | 
			
		||||
                pixbuf = get_pixbuf_from_raw_image(n->raw_icon);
 | 
			
		||||
 | 
			
		||||
        } else if (n->icon && settings.icon_position != icons_off) {
 | 
			
		||||
                pixbuf = get_pixbuf_from_path(n->icon);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user