Skip to content

Commit

Permalink
Fix not being able to override raw icons with new_icon
Browse files Browse the repository at this point in the history
This fixes a regression in ea9c7f1. It
could be implemented more efficiently, but this works well enough for
now.

Fixes #1009
  • Loading branch information
fwsmit committed Feb 7, 2022
1 parent a63d523 commit d4f492b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/dbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,6 @@ static struct notification *dbus_message_to_notification(const gchar *sender, GV
g_variant_unref(dict_value);
}

// All attributes that have to be set before initializations are set,
// so we can initialize the notification. This applies all rules that
// are defined and applies the formatting to the message.
notification_init(n);


// Set raw icon data only after initializing the notification, so the
// desired icon size is known. This way the buffer can be immediately
// rescaled. If at some point you might want to match by if a
Expand All @@ -610,6 +604,11 @@ static struct notification *dbus_message_to_notification(const gchar *sender, GV
g_variant_unref(dict_value);
}

// All attributes that have to be set before initializations are set,
// so we can initialize the notification. This applies all rules that
// are defined and applies the formatting to the message.
notification_init(n);

// Modify these values after the notification is initialized and all rules are applied.
if ((dict_value = g_variant_lookup_value(hints, "fgcolor", G_VARIANT_TYPE_STRING))) {
g_free(n->colors.fg);
Expand Down
7 changes: 5 additions & 2 deletions src/rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ void rule_apply(struct rule *r, struct notification *n)
n->default_icon_name = g_strdup(r->default_icon);
}
if (r->new_icon) {
g_free(n->iconname);
n->iconname = g_strdup(r->new_icon);
// FIXME This is not efficient when the icon is replaced
// multiple times for the same notification. To fix this, a
// separate variable is needed to track if the icon is
// replaced, like in 86cbc1d34bb0f551461dbd466cd9e4860ae01817.
notification_icon_replace_path(n, r->new_icon);
}
if (r->script){
n->scripts = g_renew(const char*,n->scripts,n->script_count + 1);
Expand Down

0 comments on commit d4f492b

Please sign in to comment.