From 088907488cc329206d04e390bb48f0df49c2e2f6 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Fri, 28 Dec 2018 18:33:34 +0100 Subject: [PATCH] Rename icon field to iconname --- src/dbus.c | 6 +++--- src/icon.c | 4 ++-- src/notification.c | 20 ++++++++++---------- src/notification.h | 2 +- src/rules.c | 6 +++--- test/dbus.c | 2 +- test/notification.c | 10 +++++----- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/dbus.c b/src/dbus.c index 679a489..0ff6a2b 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -183,7 +183,7 @@ static struct notification *dbus_message_to_notification(const gchar *sender, GV g_variant_iter_next(&i, "s", &n->appname); g_variant_iter_next(&i, "u", &n->id); - g_variant_iter_next(&i, "s", &n->icon); + g_variant_iter_next(&i, "s", &n->iconname); g_variant_iter_next(&i, "s", &n->summary); g_variant_iter_next(&i, "s", &n->body); g_variant_iter_next(&i, "^a&s", &actions); @@ -230,8 +230,8 @@ static struct notification *dbus_message_to_notification(const gchar *sender, GV } if ((dict_value = g_variant_lookup_value(hints, "image-path", G_VARIANT_TYPE_STRING))) { - g_free(n->icon); - n->icon = g_variant_dup_string(dict_value, NULL); + g_free(n->iconname); + n->iconname = g_variant_dup_string(dict_value, NULL); g_variant_unref(dict_value); } diff --git a/src/icon.c b/src/icon.c index 7bf30aa..4fbb69b 100644 --- a/src/icon.c +++ b/src/icon.c @@ -228,8 +228,8 @@ cairo_surface_t *icon_get_for_notification(const struct notification *n) if (n->raw_icon) pixbuf = get_pixbuf_from_raw_image(n->raw_icon); - else if (n->icon) - pixbuf = get_pixbuf_from_icon(n->icon); + else if (n->iconname) + pixbuf = get_pixbuf_from_icon(n->iconname); else return NULL; diff --git a/src/notification.c b/src/notification.c index 968dd7b..5b224bd 100644 --- a/src/notification.c +++ b/src/notification.c @@ -52,7 +52,7 @@ void notification_print(const struct notification *n) printf("\tappname: '%s'\n", n->appname); printf("\tsummary: '%s'\n", n->summary); printf("\tbody: '%s'\n", n->body); - printf("\ticon: '%s'\n", n->icon); + printf("\ticon: '%s'\n", n->iconname); printf("\traw_icon set: %s\n", (n->raw_icon ? "true" : "false")); printf("\tcategory: %s\n", n->category); printf("\ttimeout: %ld\n", n->timeout/1000); @@ -103,7 +103,7 @@ void notification_run_script(struct notification *n) const char *appname = n->appname ? n->appname : ""; const char *summary = n->summary ? n->summary : ""; const char *body = n->body ? n->body : ""; - const char *icon = n->icon ? n->icon : ""; + const char *icon = n->iconname ? n->iconname : ""; const char *urgency = notification_urgency_to_string(n->urgency); @@ -183,7 +183,7 @@ int notification_is_duplicate(const struct notification *a, const struct notific return STR_EQ(a->appname, b->appname) && STR_EQ(a->summary, b->summary) && STR_EQ(a->body, b->body) - && (settings.icon_position != ICON_OFF ? STR_EQ(a->icon, b->icon) : 1) + && (settings.icon_position != ICON_OFF ? STR_EQ(a->iconname, b->iconname) : 1) && a->urgency == b->urgency; } @@ -227,7 +227,7 @@ void notification_unref(struct notification *n) g_free(n->appname); g_free(n->summary); g_free(n->body); - g_free(n->icon); + g_free(n->iconname); g_free(n->msg); g_free(n->dbus_client); g_free(n->category); @@ -328,10 +328,10 @@ void notification_init(struct notification *n) n->timeout = settings.timeouts[n->urgency]; /* Icon handling */ - if (STR_EMPTY(n->icon)) - g_clear_pointer(&n->icon, g_free); - if (!n->raw_icon && !n->icon) - n->icon = g_strdup(settings.icons[n->urgency]); + if (STR_EMPTY(n->iconname)) + g_clear_pointer(&n->iconname, g_free); + if (!n->raw_icon && !n->iconname) + n->iconname = g_strdup(settings.icons[n->urgency]); /* Color hints */ struct notification_colors defcolors; @@ -404,7 +404,7 @@ static void notification_format_message(struct notification *n) n->markup); break; case 'I': - icon_tmp = g_strdup(n->icon); + icon_tmp = g_strdup(n->iconname); notification_replace_single_field( &n->msg, &substr, @@ -416,7 +416,7 @@ static void notification_format_message(struct notification *n) notification_replace_single_field( &n->msg, &substr, - n->icon ? n->icon : "", + n->iconname ? n->iconname : "", MARKUP_NO); break; case 'p': diff --git a/src/notification.h b/src/notification.h index f8f23e8..fc69216 100644 --- a/src/notification.h +++ b/src/notification.h @@ -56,7 +56,7 @@ struct notification { char *category; enum urgency urgency; - char *icon; /**< plain icon information (may be a path or just a name) */ + char *iconname; /**< plain icon information (may be a path or just a name) */ struct raw_image *raw_icon; /**< passed icon data of notification, takes precedence over icon */ gint64 start; /**< begin of current display */ diff --git a/src/rules.c b/src/rules.c index d23c580..b1f1329 100644 --- a/src/rules.c +++ b/src/rules.c @@ -27,8 +27,8 @@ void rule_apply(struct rule *r, struct notification *n) if (r->markup != MARKUP_NULL) n->markup = r->markup; if (r->new_icon) { - g_free(n->icon); - n->icon = g_strdup(r->new_icon); + g_free(n->iconname); + n->iconname = g_strdup(r->new_icon); g_clear_pointer(&n->raw_icon, rawimage_free); } if (r->fg) { @@ -102,7 +102,7 @@ bool rule_matches_notification(struct rule *r, struct notification *n) return ( (!r->appname || (n->appname && !fnmatch(r->appname, n->appname, 0))) && (!r->summary || (n->summary && !fnmatch(r->summary, n->summary, 0))) && (!r->body || (n->body && !fnmatch(r->body, n->body, 0))) - && (!r->icon || (n->icon && !fnmatch(r->icon, n->icon, 0))) + && (!r->icon || (n->iconname && !fnmatch(r->icon, n->iconname,0))) && (!r->category || (n->category && !fnmatch(r->category, n->category, 0))) && (!r->stack_tag || (n->stack_tag && !fnmatch(r->stack_tag, n->stack_tag, 0))) && (r->match_transient == -1 || (r->match_transient == n->transient)) diff --git a/test/dbus.c b/test/dbus.c index 7102067..a98a9eb 100644 --- a/test/dbus.c +++ b/test/dbus.c @@ -511,7 +511,7 @@ TEST test_hint_icons(void) n = queues_debug_find_notification_by_id(id); - ASSERT_STR_EQ(iconname, n->icon); + ASSERT_STR_EQ(iconname, n->iconname); dbus_notification_free(n_dbus); diff --git a/test/notification.c b/test/notification.c index 1bf44e0..0e0e6e1 100644 --- a/test/notification.c +++ b/test/notification.c @@ -25,14 +25,14 @@ TEST test_notification_is_duplicate(void) a->appname = g_strdup("Test"); a->summary = g_strdup("Summary"); a->body = g_strdup("Body"); - a->icon = g_strdup("Icon"); + a->iconname = g_strdup("Icon"); a->urgency = URG_NORM; struct notification *b = notification_create(); b->appname = g_strdup("Test"); b->summary = g_strdup("Summary"); b->body = g_strdup("Body"); - b->icon = g_strdup("Icon"); + b->iconname = g_strdup("Icon"); b->urgency = URG_NORM; CHECK_CALL(test_notification_is_duplicate_field(&(b->appname), a, b)); @@ -52,13 +52,13 @@ TEST test_notification_is_duplicate(void) b->raw_icon = NULL; settings.icon_position = ICON_LEFT; - CHECK_CALL(test_notification_is_duplicate_field(&(b->icon), a, b)); + CHECK_CALL(test_notification_is_duplicate_field(&(b->iconname), a, b)); b->raw_icon = (struct raw_image*)0xff; ASSERT_FALSE(notification_is_duplicate(a, b)); b->raw_icon = NULL; settings.icon_position = ICON_RIGHT; - CHECK_CALL(test_notification_is_duplicate_field(&(b->icon), a, b)); + CHECK_CALL(test_notification_is_duplicate_field(&(b->iconname), a, b)); b->raw_icon = (struct raw_image*)0xff; ASSERT_FALSE(notification_is_duplicate(a, b)); b->raw_icon = NULL; @@ -173,7 +173,7 @@ SUITE(suite_notification) a->appname = g_strdup("MyApp"); a->summary = g_strdup("I've got a summary!"); a->body = g_strdup("Look at my shiny "); - a->icon = g_strdup("/this/is/my/icoknpath.png"); + a->iconname = g_strdup("/this/is/my/icoknpath.png"); a->progress = 95; const char *strings[] = {