summaryrefslogtreecommitdiff
path: root/debian/patches/40_unity_launcher_count.patch
blob: d2e2e3193d56dcdabd73171a4d7249a748674257 (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
=== modified file 'configure.ac'
--- old/configure.ac	2011-02-24 17:06:45 +0000
+++ new/configure.ac	2011-02-24 17:09:26 +0000
@@ -58,6 +58,7 @@
 GNOME_CONTROL_CENTER_GTK3_REQUIRED=2.31.4
 INDICATE_REQUIRED=0.4.91
 INDICATE_GTK_REQUIRED=0.4.91
+UNITY_REQUIRED=3.4.0
 
 # telepathy-yell
 prev_top_build_prefix=$ac_top_build_prefix
@@ -506,12 +507,41 @@
 fi
 
 if test "x$enable_libindicate" = "xyes" -a "x$have_libindicate" != "xyes"; then
-   AC_MSG_ERROR([Couldn't find libindicate.])
+   AC_MSG_ERROR([Could not find libindicate.])
 fi
 
 AM_CONDITIONAL(HAVE_LIBINDICATE, test "x$have_libindicate" = "xyes")
 
 # -----------------------------------------------------------
+# libunity
+# -----------------------------------------------------------
+AC_ARG_ENABLE(libunity,
+		AS_HELP_STRING([--enable-libunity=@<:@no/yes/auto@:>@],
+			[build libunity support]), ,
+			enable_libunity=auto)
+
+if test "x$enable_unity" != "xno"; then
+   PKG_CHECK_MODULES(UNITY,
+   [
+     unity >= $UNITY_REQUIRED
+   ], have_unity="yes", have_unity="no")
+
+   if test "x$have_unity" = "xyes"; then
+      AC_DEFINE(HAVE_UNITY, 1, [Define if you have unity])
+   fi
+else
+   have_unity=no
+fi
+
+if test "x$enable_unity" = "xyes" -a "x$have_unity" != "xyes"; then
+   AC_MSG_ERROR([Could not find libunity.])
+fi
+
+AM_CONDITIONAL(HAVE_UNITY, test "x$have_unity" = "xyes")
+AC_SUBST([UNITY_CFLAGS])
+AC_SUBST([UNITY_LIBS])
+
+# -----------------------------------------------------------
 # nautilus-sendto
 # -----------------------------------------------------------
 AC_ARG_ENABLE(nautilus-sendto,
@@ -614,6 +644,7 @@
 
     Features:
 	Message indicator support (libindicate):  ${have_libindicate}
+	Unity panel support (unity).:  ${have_unity}
 	Spell checking (enchant)....:  ${have_enchant}
 	Display maps (libchamplain).:  ${have_libchamplain}
 	Location awareness (Geoclue):  ${have_geoclue}

=== modified file 'src/Makefile.am'
--- old/src/Makefile.am	2011-02-24 17:04:31 +0000
+++ new/src/Makefile.am	2011-02-24 17:09:26 +0000
@@ -19,6 +19,7 @@
 	$(CPPFLAGS_COMMON)				\
 	$(LIBNOTIFY_CFLAGS)				\
 	$(INDICATE_CFLAGS)				\
+	$(UNITY_CFLAGS)					\
 	$(UNIQUE_CFLAGS) \
 	$(LIBCHAMPLAIN_CFLAGS)				\
 	$(WEBKIT_CFLAGS)				\
@@ -30,6 +31,7 @@
 	$(top_builddir)/extensions/libemp-extensions.la		\
 	$(LIBNOTIFY_LIBS)					\
 	$(INDICATE_LIBS)					\
+	$(UNITY_LIBS)						\
 	$(UNIQUE_LIBS)						\
 	$(EMPATHY_LIBS)						\
 	$(GTK_LIBS)						\
@@ -203,6 +205,7 @@
         $(UNIQUE_LIBS)						\
         $(EMPATHY_LIBS)							\
 	$(INDICATE_LIBS)						\
+	$(UNITY_LIBS)							\
         $(LIBCHAMPLAIN_LIBS)						\
         $(WEBKIT_LIBS)							\
 	$(NULL)

=== modified file 'src/empathy-chat-window.c'
--- old/src/empathy-chat-window.c	2011-02-24 17:04:31 +0000
+++ new/src/empathy-chat-window.c	2011-02-24 17:09:26 +0000
@@ -71,6 +71,10 @@
 #define DEBUG_FLAG EMPATHY_DEBUG_CHAT
 #include <libempathy/empathy-debug.h>
 
+#ifdef HAVE_UNITY
+#include <unity.h>
+#endif
+
 /* Macro to compare guint32 X timestamps, while accounting for wrapping around
  */
 #define X_EARLIER_OR_EQL(t1, t2) \
@@ -96,6 +100,9 @@
 	/* EmpathyChat -> EmpathyIndicator for that chat, if any */
 	GHashTable  *indicators;
 #endif
+#ifdef HAVE_UNITY
+	UnityLauncherEntry *launcher;
+#endif
 	GtkTargetList *contact_targets;
 	GtkTargetList *file_targets;
 
@@ -1308,8 +1315,19 @@
 			sender, body);
 		g_signal_connect (indicator, "activate",
 				  G_CALLBACK (chat_window_indicator_activate_cb), chat);
-
 		g_hash_table_insert (priv->indicators, chat, indicator);
+#ifdef HAVE_UNITY
+		if (priv->launcher != NULL)
+		{
+			gint count = g_hash_table_size (priv->indicators);
+			DEBUG ("unity launcher: count is now %d", count);
+			if (count > 0)
+			{
+				unity_launcher_entry_set_count (priv->launcher, count);
+				unity_launcher_entry_set_count_visible (priv->launcher, TRUE);
+			}
+		}
+#endif
 	}
 	empathy_indicator_show (indicator);
 }
@@ -1326,6 +1344,25 @@
 		DEBUG ("indicator is %p", indicator);
 		empathy_indicator_hide (indicator);
 		g_hash_table_remove (priv->indicators, chat);
+#ifdef HAVE_UNITY
+        if (priv->launcher != NULL)
+        {
+	        gint count = g_hash_table_size (priv->indicators);
+        	DEBUG ("unity launcher: count is %d", count);
+        	if (count > 0)
+        	{
+                	DEBUG ("unity launcher: setting count to %d", count);
+                	unity_launcher_entry_set_count (priv->launcher, count);
+                	unity_launcher_entry_set_count_visible (priv->launcher, TRUE);
+        	} else {
+                	unity_launcher_entry_set_count (priv->launcher, count);
+                	DEBUG ("unity launcher: hiding count");
+                	unity_launcher_entry_set_count_visible (priv->launcher, FALSE);
+        	}
+	}
+#endif
+
+
 	} else {
 		DEBUG ("indicator is NULL, nothing to remove");
 	}
@@ -1959,6 +1996,11 @@
 		priv->chat_manager = NULL;
 	}
 
+	if (priv->launcher) {
+		g_object_unref (priv->launcher);
+		priv->launcher = NULL;
+	}
+
 	chat_windows = g_list_remove (chat_windows, window);
 	gtk_widget_destroy (priv->dialog);
 
@@ -2057,6 +2099,9 @@
 	priv->indicators = g_hash_table_new_full (g_direct_hash, g_direct_equal,
 			      NULL, g_object_unref);
 #endif
+#ifdef HAVE_UNITY
+	priv->launcher = unity_launcher_entry_get_for_desktop_id ("empathy.desktop");
+#endif
 
 	priv->notebook = gtk_notebook_new ();
 	gtk_notebook_set_group (GTK_NOTEBOOK (priv->notebook), "EmpathyChatWindow");

=== modified file 'src/empathy-indicator-manager.c'
--- old/src/empathy-indicator-manager.c	2011-02-24 17:06:45 +0000
+++ new/src/empathy-indicator-manager.c	2011-02-24 17:09:26 +0000
@@ -45,6 +45,10 @@
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
 #include <libempathy/empathy-debug.h>
 
+#ifdef HAVE_UNITY
+#include <unity.h>
+#endif
+
 #define INDICATOR_LOGIN_TIMEOUT 15
 #define EMPATHY_DESKTOP_PATH DESKTOPDIR "/empathy.desktop"
 
@@ -62,6 +66,9 @@
   IndicateServer      *indicate_server;
   GSList              *indicator_events;
   GHashTable          *login_timeouts;
+#ifdef HAVE_UNITY
+  UnityLauncherEntry  *launcher;
+#endif
 } EmpathyIndicatorManagerPriv;
 
 typedef struct {
@@ -172,6 +179,20 @@
   g_object_unref (indicator);
   priv->indicator_events = g_slist_prepend (priv->indicator_events,
       indicator_event);
+#ifdef HAVE_UNITY
+  if (priv->launcher == NULL)
+  {
+          return;
+  }
+  gint count = g_slist_length (priv->indicator_events);
+  DEBUG ("unity launcher: count is %d", count);
+  if (count > 0)
+  {
+          unity_launcher_entry_set_count (priv->launcher, count);
+          unity_launcher_entry_set_count_visible (priv->launcher, TRUE);
+  }
+#endif
+
 }
 
 static void
@@ -195,6 +216,26 @@
       priv->indicator_events = g_slist_remove (priv->indicator_events,
           indicator_event);
       empathy_indicator_hide (indicator_event->indicator);
+#ifdef HAVE_UNITY
+        if (priv->launcher == NULL)
+        {
+                DEBUG ("unity launcher: launcher is NULL");
+                return;
+        }
+
+        gint count = g_slist_length (priv->indicator_events);
+        DEBUG ("unity launcher: count is %d", count);
+        if (count > 0)
+        {
+                DEBUG ("unity launcher: setting count to %d", count);
+                unity_launcher_entry_set_count (priv->launcher, count);
+                unity_launcher_entry_set_count_visible (priv->launcher, TRUE);
+        } else {
+                unity_launcher_entry_set_count (priv->launcher, count);
+                DEBUG ("unity launcher: hiding count");
+                unity_launcher_entry_set_count_visible (priv->launcher, FALSE);
+        }
+#endif
       return;
     }
   }
@@ -211,6 +252,8 @@
 
   priv = GET_PRIV (manager);
 
+  DEBUG ("Event updated");
+
   for (l = priv->indicator_events; l; l = l->next)
   {
     IndicatorEvent *indicator_event;
@@ -305,6 +348,10 @@
     g_object_unref (priv->indicate_server);
     priv->indicate_server = NULL;
   }
+  if (priv->launcher) {
+    g_object_unref (priv->launcher);
+    priv->launcher = NULL;
+  }
   if (priv->login_timeouts) {
     g_hash_table_unref (priv->login_timeouts);
     priv->login_timeouts = NULL;
@@ -379,6 +426,10 @@
       G_CALLBACK (indicate_server_activate),
       manager);
 
+#ifdef HAVE_UNITY
+  priv->launcher = unity_launcher_entry_get_for_desktop_id ("empathy.desktop");
+#endif
+
   g_signal_connect (priv->event_manager, "event-added",
       G_CALLBACK (indicator_manager_event_added_cb),
       manager);