[PATCH] Support for image_data hint
Aurélien Gâteau
agateau at kde.org
Mon Jun 22 01:57:31 PDT 2009
---
libnotify/notification.c | 4 +++-
libnotify/notify.c | 26 ++++++++++++++++++++++++++
libnotify/notify.h | 8 ++++++++
3 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/libnotify/notification.c b/libnotify/notification.c
index 0a5051d..1d7ea11 100644
--- a/libnotify/notification.c
+++ b/libnotify/notification.c
@@ -1011,8 +1011,10 @@ notify_notification_set_icon_from_pixbuf(NotifyNotification *notification,
g_value_init(value, G_TYPE_VALUE_ARRAY);
g_value_set_boxed_take_ownership(value, image_struct);
+ char *hint_name = notify_get_spec_version() >= 0x00a
+ ? "image_data" : "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 c0c7b21..c988c51 100644
--- a/libnotify/notify.c
+++ b/libnotify/notify.c
@@ -32,6 +32,7 @@ static gchar *_app_name = NULL;
static DBusGProxy *_proxy = NULL;
static DBusGConnection *_dbus_gconn = NULL;
static GList *_active_notifications = NULL;
+static int _spec_version = 0;
/**
* notify_init:
@@ -94,6 +95,31 @@ notify_init(const char *app_name)
return TRUE;
}
+
+int
+notify_get_spec_version(void)
+{
+ if (_spec_version != 0)
+ return _spec_version;
+
+ char* name;
+ char* vendor;
+ char* version;
+ char* spec_version;
+ if (notify_get_server_info(&name, &vendor, &version, &spec_version))
+ {
+ int major, minor;
+ sscanf(spec_version, "%d.%d", &major, &minor);
+ _spec_version = (major << 8) | minor;
+ free(name);
+ free(vendor);
+ free(version);
+ free(spec_version);
+ }
+
+ return _spec_version;
+}
+
/**
* notify_get_app_name:
*
diff --git a/libnotify/notify.h b/libnotify/notify.h
index 0e1cad8..decb9e1 100644
--- a/libnotify/notify.h
+++ b/libnotify/notify.h
@@ -54,6 +54,14 @@ void notify_uninit(void);
gboolean notify_is_initted(void);
/**
+ * Gets the version of the spec implemented by the server.
+ *
+ * Returns: the spec version as a 2 byte integer, most significant byte is
+ * major, less significant is minor
+ */
+int notify_get_spec_version(void);
+
+/**
* Returns the name of the application set when notify_init() was called.
*
* @return The name of the application.
--
1.6.0.4
--------------020803090804020302060405
Content-Type: text/x-diff;
name="notification-daemon-Support-for-image_data-and-image_path-hints.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename*0="notification-daemon-Support-for-image_data-and-image_path-hi";
filename*1="nts.patch"
More information about the xdg
mailing list