found 636323 0.7.2-1
tags 636323 patch
thanks

This patch against 0.7.2-1 seems to fix the problem. What it does is
check the type of the incoming hint and use the appropriate
g_variant_get_* function.

It also applies the same fix for the "resident" and "action-icons"
hints.
--- a/src/nd-notification.c
+++ b/src/nd-notification.c
@@ -224,54 +224,53 @@
 }
 
 gboolean
-nd_notification_get_is_transient (NdNotification *notification)
+nd_notification_get_bool (NdNotification *notification, const char *name)
 {
         gboolean  ret;
         GVariant *value;
-
         ret = FALSE;
         g_return_val_if_fail (ND_IS_NOTIFICATION (notification), FALSE);
 
-        value = g_hash_table_lookup (notification->hints, "transient");
+        value = g_hash_table_lookup (notification->hints, name);
         if (value != NULL) {
-                ret = g_variant_get_boolean (value);
+                if (g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) {
+                        ret = g_variant_get_boolean (value);
+                } else if (g_variant_is_of_type (value, G_VARIANT_TYPE_BYTE)) {
+                        ret = (g_variant_get_byte (value) != 0);
+                } else if (g_variant_is_of_type (value, G_VARIANT_TYPE_INT16)) {
+                        ret = (g_variant_get_int16 (value) != 0);
+                } else if (g_variant_is_of_type (value, G_VARIANT_TYPE_UINT16)) {
+                        ret = (g_variant_get_uint16 (value) != 0);
+                } else if (g_variant_is_of_type (value, G_VARIANT_TYPE_INT32)) {
+                        ret = (g_variant_get_int32 (value) != 0);
+                } else if (g_variant_is_of_type (value, G_VARIANT_TYPE_UINT32)) {
+                        ret = (g_variant_get_uint32 (value) != 0);
+                } else if (g_variant_is_of_type (value, G_VARIANT_TYPE_INT64)) {
+                        ret = (g_variant_get_int64 (value) != 0);
+                } else if (g_variant_is_of_type (value, G_VARIANT_TYPE_UINT64)) {
+                        ret = (g_variant_get_uint64 (value) != 0);
+                }
         }
 
         return ret;
 }
 
 gboolean
-nd_notification_get_is_resident (NdNotification *notification)
+nd_notification_get_is_transient (NdNotification *notification)
 {
-        gboolean  ret;
-        GVariant *value;
-
-        ret = FALSE;
-        g_return_val_if_fail (ND_IS_NOTIFICATION (notification), FALSE);
-
-        value = g_hash_table_lookup (notification->hints, "resident");
-        if (value != NULL) {
-                ret = g_variant_get_boolean (value);
-        }
+        return nd_notification_get_bool (notification, "transient");
+}
 
-        return ret;
+gboolean
+nd_notification_get_is_resident (NdNotification *notification)
+{
+        return nd_notification_get_bool (notification, "resident");
 }
 
 gboolean
 nd_notification_get_action_icons (NdNotification *notification)
 {
-        gboolean  ret;
-        GVariant *value;
-
-        ret = FALSE;
-        g_return_val_if_fail (ND_IS_NOTIFICATION (notification), FALSE);
-
-        value = g_hash_table_lookup (notification->hints, "action-icons");
-        if (value != NULL) {
-                ret = g_variant_get_boolean (value);
-        }
-
-        return ret;
+        return nd_notification_get_bool (notification, "action-icons");
 }
 
 guint32

Reply via email to