summarylogtreecommitdiffstats
path: root/pidgin-libnotify-notify-osd.patch
blob: 4d9cc408437ff85a1f02969a9d13f59d9a196d49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
diff -aur pidgin-libnotify-0.14/src/pidgin-libnotify.c pidgin-libnotify-0.14.new/src/pidgin-libnotify.c
--- pidgin-libnotify-0.14/src/pidgin-libnotify.c	2008-12-14 18:45:51.000000000 +0100
+++ pidgin-libnotify-0.14.new/src/pidgin-libnotify.c	2011-03-17 17:02:59.000000000 +0100
@@ -254,6 +254,32 @@
 	return purple_status_is_online (status) && purple_status_is_available (status);
 }
 
+static gboolean
+notify_supports_actions ()
+{
+	GList *caps;
+	gint i = 0;
+	
+	caps = notify_get_server_caps ();
+	
+	do
+	{
+		if (g_strcmp0 (caps->data, "actions") == 0)
+		{
+			g_list_free (caps);
+			return TRUE;
+		}
+		
+		if (caps->next != NULL)
+			caps = g_list_next (caps);
+
+	} while (caps->next != NULL);
+	
+	g_list_free (caps);
+	
+	return FALSE;
+}
+
 static void
 notify (const gchar *title,
 		const gchar *body,
@@ -286,7 +312,7 @@
 		g_free (tr_body);
 		return;
 	}
-	notification = notify_notification_new (title, tr_body, NULL, NULL);
+	notification = notify_notification_new (title, tr_body, NULL);
 	purple_debug_info (PLUGIN_ID, "notify(), new: "
 					 "title: '%s', body: '%s', buddy: '%s'\n",
 					 title, tr_body, best_name (buddy));
@@ -316,8 +342,12 @@
 	g_signal_connect (notification, "closed", G_CALLBACK(closed_cb), NULL);
 
 	notify_notification_set_urgency (notification, NOTIFY_URGENCY_NORMAL);
-
-	notify_notification_add_action (notification, "show", _("Show"), action_cb, NULL, NULL);
+	
+	/* Check if notification server can use actions */
+	if (notify_supports_actions ())
+	{
+		notify_notification_add_action (notification, "show", _("Show"), action_cb, NULL, NULL);
+	}
 
 	if (!notify_notification_show (notification, NULL)) {
 		purple_debug_error (PLUGIN_ID, "notify(), failed to send notification\n");
@@ -329,7 +359,7 @@
 notify_buddy_signon_cb (PurpleBuddy *buddy,
 						gpointer data)
 {
-	gchar *tr_name, *title;
+	gchar *tr_name;
 	gboolean blocked;
 
 	g_return_if_fail (buddy);
@@ -349,19 +379,16 @@
 
 	tr_name = truncate_escape_string (best_name (buddy), 25);
 
-	title = g_strdup_printf (_("%s signed on"), tr_name);
-
-	notify (title, NULL, buddy);
+	notify (tr_name, "Signed on", buddy);
 
 	g_free (tr_name);
-	g_free (title);
 }
 
 static void
 notify_buddy_signoff_cb (PurpleBuddy *buddy,
 						 gpointer data)
 {
-	gchar *tr_name, *title;
+	gchar *tr_name;
 	gboolean blocked;
 
 	g_return_if_fail (buddy);
@@ -381,12 +408,9 @@
 
 	tr_name = truncate_escape_string (best_name (buddy), 25);
 
-	title = g_strdup_printf (_("%s signed off"), tr_name);
-
-	notify (title, NULL, buddy);
+	notify (tr_name, "Signed off", buddy);
 
 	g_free (tr_name);
-	g_free (title);
 }
 
 static void