~ubuntu-branches/ubuntu/karmic/libnotify/karmic

« back to all changes in this revision

Viewing changes to debian/patches/02_support-for-notification-spec-0.10.patch

  • Committer: Bazaar Package Importer
  • Author(s): Aurélien Gâteau
  • Date: 2009-08-04 17:56:34 UTC
  • Revision ID: james.westby@ubuntu.com-20090804175634-2uvyj1vv3bvzges6
Tags: 0.4.5-1ubuntu1
Add support for v0.10 of the notification spec. (lp: #408940)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From c6f46e8a757e40773f7767ec2d645032b9442569 Mon Sep 17 00:00:00 2001
 
2
From: =?utf-8?q?Aur=C3=A9lien=20G=C3=A2teau?= <agateau@kde.org>
 
3
Date: Mon, 22 Jun 2009 10:57:31 +0200
 
4
Subject: [PATCH] Support for image_data hint
 
5
 
 
6
---
 
7
 libnotify/internal.h     |    1 +
 
8
 libnotify/notification.c |    4 +++-
 
9
 libnotify/notify.c       |   30 ++++++++++++++++++++++++++++++
 
10
 3 files changed, 34 insertions(+), 1 deletions(-)
 
11
 
 
12
diff --git a/libnotify/internal.h b/libnotify/internal.h
 
13
index 697f64a..e0a689d 100644
 
14
--- a/libnotify/internal.h
 
15
+++ b/libnotify/internal.h
 
16
@@ -46,6 +46,7 @@ void _notify_cache_remove_notification(NotifyNotification *n);
 
17
 gint _notify_notification_get_timeout(const NotifyNotification *n);
 
18
 gboolean _notify_notification_has_nondefault_actions(
 
19
        const NotifyNotification *n);
 
20
+gboolean _notify_check_spec_version(int major, int minor);
 
21
 
 
22
 G_END_DECLS
 
23
 
 
24
diff --git a/libnotify/notification.c b/libnotify/notification.c
 
25
index 0a5051d..9341941 100644
 
26
--- a/libnotify/notification.c
 
27
+++ b/libnotify/notification.c
 
28
@@ -1011,8 +1011,10 @@ notify_notification_set_icon_from_pixbuf(NotifyNotification *notification,
 
29
        g_value_init(value, G_TYPE_VALUE_ARRAY);
 
30
        g_value_set_boxed_take_ownership(value, image_struct);
 
31
 
 
32
+       char *hint_name = _notify_check_spec_version(0, 10)
 
33
+                         ? "image_data" : "icon_data";
 
34
        g_hash_table_insert(notification->priv->hints,
 
35
-                                               g_strdup("icon_data"), value);
 
36
+                                               g_strdup(hint_name), value);
 
37
 #else /* D-BUS < 0.60 */
 
38
        g_warning("Raw images and pixbufs require D-BUS >= 0.60");
 
39
 #endif
 
40
diff --git a/libnotify/notify.c b/libnotify/notify.c
 
41
index c0c7b21..7dd74d5 100644
 
42
--- a/libnotify/notify.c
 
43
+++ b/libnotify/notify.c
 
44
@@ -32,6 +32,30 @@ static gchar *_app_name = NULL;
 
45
 static DBusGProxy *_proxy = NULL;
 
46
 static DBusGConnection *_dbus_gconn = NULL;
 
47
 static GList *_active_notifications = NULL;
 
48
+static int _spec_version_major = 0;
 
49
+static int _spec_version_minor = 0;
 
50
+
 
51
+gboolean
 
52
+_notify_check_spec_version(int major, int minor)
 
53
+{
 
54
+       if (_spec_version_major > major)
 
55
+               return TRUE;
 
56
+       if (_spec_version_major < major)
 
57
+               return FALSE;
 
58
+       return _spec_version_minor >= minor;
 
59
+}
 
60
+
 
61
+static gboolean
 
62
+_notify_update_spec_version(void)
 
63
+{
 
64
+       char* spec_version;
 
65
+       if (!notify_get_server_info(NULL, NULL, NULL, &spec_version))
 
66
+               return FALSE;
 
67
+
 
68
+       sscanf(spec_version, "%d.%d", &_spec_version_major, &_spec_version_minor);
 
69
+       g_free(spec_version);
 
70
+       return TRUE;
 
71
+}
 
72
 
 
73
 /**
 
74
  * notify_init:
 
75
@@ -89,6 +113,12 @@ notify_init(const char *app_name)
 
76
                                                        G_TYPE_UINT, G_TYPE_STRING,
 
77
                                                        G_TYPE_INVALID);
 
78
 
 
79
+       if (!_notify_update_spec_version())
 
80
+       {
 
81
+               g_message("Error getting spec version");
 
82
+               return FALSE;
 
83
+       }
 
84
+
 
85
        _initted = TRUE;
 
86
 
 
87
        return TRUE;
 
88
-- 
 
89
1.6.0.4
 
90