summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hammond <chipx86@chipx86.com>2006-01-22 21:22:27 +0000
committerChristian Hammond <chipx86@chipx86.com>2006-01-22 21:22:27 +0000
commit85d5df3cbd90f7a186ddc746ec80949c41c2ce88 (patch)
tree02ac8a2a98fcf1057d5c6c5f73a617e7e9667377
parentc587295cdd360e98359aadef86f3fe6cbaa45b4e (diff)
downloadlibnotify-85d5df3cbd90f7a186ddc746ec80949c41c2ce88.tar.gz
Raw images are broken in D-BUS versions less than 0.60. Don't crash under this case, and warn the user.
-rw-r--r--ChangeLog6
-rw-r--r--libnotify/notification.c24
2 files changed, 24 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 2b50c4e..d25ee05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sun Jan 22 13:21:52 PST 2006 Christian Hammond <chipx86@chipx86.com>
+
+ * libnotify/notification.c:
+ - Raw images are broken in D-BUS versions less than 0.60. Don't crash
+ under this case, and warn the user.
+
Sat Jan 21 00:37:03 PST 2006 Christian Hammond <chipx86@chipx86.com>
* libnotify/internal.h:
diff --git a/libnotify/notification.c b/libnotify/notification.c
index 4fa182b..f5db0c9 100644
--- a/libnotify/notification.c
+++ b/libnotify/notification.c
@@ -26,6 +26,10 @@
#include <libnotify/notify.h>
#include <libnotify/internal.h>
+#define CHECK_DBUS_VERSION(major, minor) \
+ (DBUS_MAJOR_VER > (major) || \
+ (DBUS_MAJOR_VER == (major) && DBUS_MINOR_VER >= (minor)))
+
static void notify_notification_class_init(NotifyNotificationClass *klass);
static void notify_notification_init(NotifyNotification *sp);
static void notify_notification_finalize(GObject *object);
@@ -453,6 +457,7 @@ notify_notification_set_urgency(NotifyNotification *notification,
notify_notification_set_hint_byte(notification, "urgency", (guchar)l);
}
+#if CHECK_DBUS_VERSION(0, 60)
static gboolean
_gvalue_array_append_int(GValueArray *array, gint i)
{
@@ -508,11 +513,13 @@ _gvalue_array_append_byte_array(GValueArray *array, guchar *bytes, gsize len)
return TRUE;
}
+#endif /* D-BUS >= 0.60 */
void
notify_notification_set_icon_from_pixbuf(NotifyNotification *notification,
GdkPixbuf *icon)
{
+#if CHECK_DBUS_VERSION(0, 60)
gint width;
gint height;
gint rowstride;
@@ -522,10 +529,12 @@ notify_notification_set_icon_from_pixbuf(NotifyNotification *notification,
gsize image_len;
GValueArray *image_struct;
GValue *value;
+#endif
g_return_if_fail(notification != NULL);
g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification));
+#if CHECK_DBUS_VERSION(0, 60)
width = gdk_pixbuf_get_width(icon);
height = gdk_pixbuf_get_height(icon);
rowstride = gdk_pixbuf_get_rowstride(icon);
@@ -539,12 +548,12 @@ notify_notification_set_icon_from_pixbuf(NotifyNotification *notification,
image_struct = g_value_array_new(1);
_gvalue_array_append_int(image_struct, width);
-// _gvalue_array_append_int(image_struct, height);
-// _gvalue_array_append_int(image_struct, rowstride);
-// _gvalue_array_append_bool(image_struct, gdk_pixbuf_get_has_alpha(icon));
-// _gvalue_array_append_int(image_struct, bits_per_sample);
-// _gvalue_array_append_int(image_struct, n_channels);
-// _gvalue_array_append_byte_array(image_struct, image, image_len);
+ _gvalue_array_append_int(image_struct, height);
+ _gvalue_array_append_int(image_struct, rowstride);
+ _gvalue_array_append_bool(image_struct, gdk_pixbuf_get_has_alpha(icon));
+ _gvalue_array_append_int(image_struct, bits_per_sample);
+ _gvalue_array_append_int(image_struct, n_channels);
+ _gvalue_array_append_byte_array(image_struct, image, image_len);
value = g_new0(GValue, 1);
g_value_init(value, G_TYPE_VALUE_ARRAY);
@@ -552,6 +561,9 @@ notify_notification_set_icon_from_pixbuf(NotifyNotification *notification,
g_hash_table_insert(notification->priv->hints,
g_strdup("icon_data"), value);
+#else /* D-BUS < 0.60 */
+ g_warning("Raw images and pixbufs require D-BUS >= 0.60");
+#endif
}
void