From 8dad8a7e2d1aa2ff1bd7dd434c7ccb58575d47c6 Mon Sep 17 00:00:00 2001 From: Kyle Brenneman Date: Tue, 3 Sep 2019 20:56:50 -0600 Subject: Fix decoding the hints dictionary. g_variant_lookup works like g_variant_get, so using a format string of "v" only works if the type is actually a GVariant. Since none of the hints have GVariant values, that means every g_variant_get with a "v" format will fail. Fix all of the g_variant_lookup calls so that they either unpack a value directly, or use a "@" prefix when it's more convenient to fetch the value as a GVariant pointer. In addition, in cases where we do fetch a GVariant, make sure that we unreference it afterward. --- src/themes/standard/theme.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/themes/standard') diff --git a/src/themes/standard/theme.c b/src/themes/standard/theme.c index 91147c2..d36bda3 100644 --- a/src/themes/standard/theme.c +++ b/src/themes/standard/theme.c @@ -796,16 +796,14 @@ GtkWindow* create_notification(UrlClickedCb url_clicked) void set_notification_hints(GtkWindow *nw, GVariant *hints) { WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata"); - GVariant *value = NULL, *icon_value = NULL; + guint8 urgency; + gboolean action_icons; g_assert(windata != NULL); - g_variant_lookup(hints, "urgency", "v", &value); - g_variant_lookup(hints, "action-icons", "v", &icon_value); - - if (value != NULL && g_variant_get_type(value) == G_VARIANT_TYPE_BYTE) + if (g_variant_lookup(hints, "urgency", "y", &urgency)) { - windata->urgency = g_variant_get_byte(value); + windata->urgency = urgency; if (windata->urgency == URGENCY_CRITICAL) { gtk_window_set_title(GTK_WINDOW(nw), "Critical Notification"); @@ -815,9 +813,9 @@ void set_notification_hints(GtkWindow *nw, GVariant *hints) } /* Determine if action-icons have been requested */ - if (icon_value != NULL && g_variant_get_type(icon_value) == G_VARIANT_TYPE_BOOLEAN) + if (g_variant_lookup(hints, "action-icons", "b", &action_icons)) { - windata->action_icons = g_variant_get_boolean(icon_value); + windata->action_icons = action_icons; } } -- cgit v1.2.1