Skip to content

Commit

Permalink
Make icon set via rules take priority over raw icons
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tsipinakis committed Jul 19, 2017
1 parent b06475b commit 86cbc1d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions src/rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/x11/x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 86cbc1d

Please sign in to comment.