[Galago-commits] r2458 - in trunk/libnotify: . libnotify

galago-commits at freedesktop.org galago-commits at freedesktop.org
Sun Jan 22 13:22:31 PST 2006


Author: chipx86
Date: 2006-01-22 13:22:27 -0800 (Sun, 22 Jan 2006)
New Revision: 2458

Modified:
   trunk/libnotify/ChangeLog
   trunk/libnotify/libnotify/notification.c
Log:
Raw images are broken in D-BUS versions less than 0.60. Don't crash under this case, and warn the user.


Modified: trunk/libnotify/ChangeLog
===================================================================
--- trunk/libnotify/ChangeLog	2006-01-21 08:38:35 UTC (rev 2457)
+++ trunk/libnotify/ChangeLog	2006-01-22 21:22:27 UTC (rev 2458)
@@ -1,3 +1,9 @@
+Sun Jan 22 13:21:52 PST 2006  Christian Hammond <chipx86 at 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 at chipx86.com>
 
 	* libnotify/internal.h:

Modified: trunk/libnotify/libnotify/notification.c
===================================================================
--- trunk/libnotify/libnotify/notification.c	2006-01-21 08:38:35 UTC (rev 2457)
+++ trunk/libnotify/libnotify/notification.c	2006-01-22 21:22:27 UTC (rev 2458)
@@ -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_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 @@
 
 	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 @@
 	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 @@
 	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 @@
 
 	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



More information about the galago-commits mailing list