summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurélien Gâteau <aurelien.gateau@canonical.com>2010-01-29 05:50:49 -0500
committerWilliam Jon McCann <jmccann@redhat.com>2010-01-29 05:50:49 -0500
commit6c1231835d5e330271ee1a03e0c10deb704b9c39 (patch)
tree32192a883191313ce6579de62ddaa4b513d3a69f
parent86b806c71ec249b6a07482828d3179bfde2acf2f (diff)
downloadlibnotify-6c1231835d5e330271ee1a03e0c10deb704b9c39.tar.gz
Support for image_data hint
Add support for the image_data hint from version 1.1 of the spec.
-rw-r--r--libnotify/internal.h1
-rw-r--r--libnotify/notification.c10
-rw-r--r--libnotify/notify.c36
3 files changed, 46 insertions, 1 deletions
diff --git a/libnotify/internal.h b/libnotify/internal.h
index 5a167ac..9b46406 100644
--- a/libnotify/internal.h
+++ b/libnotify/internal.h
@@ -40,6 +40,7 @@ void _notify_cache_add_notification (NotifyNotification
void _notify_cache_remove_notification (NotifyNotification *n);
gint _notify_notification_get_timeout (const NotifyNotification *n);
gboolean _notify_notification_has_nondefault_actions (const NotifyNotification *n);
+gboolean _notify_check_spec_version (int major, int minor);
G_END_DECLS
diff --git a/libnotify/notification.c b/libnotify/notification.c
index c7bca3a..3afcd54 100644
--- a/libnotify/notification.c
+++ b/libnotify/notification.c
@@ -987,6 +987,7 @@ notify_notification_set_icon_from_pixbuf (NotifyNotification *notification,
gsize image_len;
GValueArray *image_struct;
GValue *value;
+ const char *hint_name;
#endif
g_return_if_fail (notification != NULL);
@@ -1018,8 +1019,15 @@ notify_notification_set_icon_from_pixbuf (NotifyNotification *notification,
g_value_init (value, G_TYPE_VALUE_ARRAY);
g_value_take_boxed (value, image_struct);
+ if (_notify_check_spec_version(1, 1)) {
+ hint_name = "image_data";
+ } else {
+ hint_name = "icon_data";
+ }
+
g_hash_table_insert (notification->priv->hints,
- g_strdup ("icon_data"), value);
+ g_strdup (hint_name),
+ value);
#else /* D-BUS < 0.60 */
g_warning ("Raw images and pixbufs require D-BUS >= 0.60");
#endif
diff --git a/libnotify/notify.c b/libnotify/notify.c
index 1de188f..d20355d 100644
--- a/libnotify/notify.c
+++ b/libnotify/notify.c
@@ -34,6 +34,37 @@ static char *_app_name = NULL;
static DBusGProxy *_proxy = NULL;
static DBusGConnection *_dbus_gconn = NULL;
static GList *_active_notifications = NULL;
+static int _spec_version_major = 0;
+static int _spec_version_minor = 0;
+
+gboolean
+_notify_check_spec_version (int major,
+ int minor)
+{
+ if (_spec_version_major > major)
+ return TRUE;
+ if (_spec_version_major < major)
+ return FALSE;
+ return _spec_version_minor >= minor;
+}
+
+static gboolean
+_notify_update_spec_version (void)
+{
+ char *spec_version;
+
+ if (!notify_get_server_info (NULL, NULL, NULL, &spec_version))
+ return FALSE;
+
+ sscanf (spec_version,
+ "%d.%d",
+ &_spec_version_major,
+ &_spec_version_minor);
+
+ g_free (spec_version);
+
+ return TRUE;
+}
/**
* notify_init:
@@ -94,6 +125,11 @@ notify_init (const char *app_name)
G_TYPE_STRING,
G_TYPE_INVALID);
+ if (!_notify_update_spec_version ()) {
+ g_message ("Error getting spec version");
+ return FALSE;
+ }
+
_initted = TRUE;
return TRUE;