Support for image_data hint
Add support for the image_data hint from version 1.1 of the spec.
This commit is contained in:
parent
86b806c71e
commit
6c1231835d
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue