updated on Thu Jan 19 20:01:47 UTC 2012
[aur-mirror.git] / liferea-unity / libindicate.patch
blob1e47d51308f9b77f4fb04d980a6d256258b52506
1 Index: liferea-ubuntu/configure.ac
2 ===================================================================
3 --- liferea-ubuntu.orig/configure.ac 2011-08-10 23:11:11.654309000 -0400
4 +++ liferea-ubuntu/configure.ac 2011-08-10 23:18:16.625899496 -0400
5 @@ -28,6 +28,7 @@
6 AC_ARG_ENABLE(dbus, AS_HELP_STRING([--disable-dbus],[compile without DBUS support]),,enable_dbus=yes)
7 AC_ARG_ENABLE(nm, AS_HELP_STRING([--disable-nm],[compile without NetworkManager support]),,enable_nm=yes)
8 AC_ARG_ENABLE(libnotify, AS_HELP_STRING([--disable-libnotify],[don't compile the libnotify plugin]),,enable_libnotify=yes)
9 +AC_ARG_ENABLE(libindicate, AS_HELP_STRING([--disable-libindicate],[compile without libindicate support]),,enable_libindicate=yes)
10 AC_ARG_ENABLE(lua, AS_HELP_STRING([--disable-lua],[don't compile with LUA scripting support]),,enable_lua=yes)
11 dnl AC_ARG_ENABLE(avahi, AS_HELP_STRING([--disable-avahi],[don't compile with AVAHI support]),,enable_avahi=yes)
13 @@ -100,6 +101,24 @@
15 AM_CONDITIONAL(WITH_LUA, test "x$enable_lua" = "xyes")
17 +dnl *********
18 +dnl libindicate
19 +dnl *********
21 +if test "x$enable_libindicate" = "xyes"; then
22 + PKG_CHECK_MODULES([LIBINDICATE], indicate-0.6 indicate-gtk-0.6,enable_libindicate=yes,enable_libindicate=no)
23 + AC_SUBST(LIBINDICATE_CFLAGS)
24 + AC_SUBST(LIBINDICATE_LIBS)
25 +else
26 + enable_libindicate=no
27 +fi
29 +if test "x$enable_libindicate" = "xyes"; then
30 + AC_DEFINE(HAVE_LIBINDICATE, 1, [Define if libindicate support is enabled])
31 +fi
33 +AM_CONDITIONAL(WITH_LIBINDICATE, test "x$enable_libindicate" = "xyes")
35 dnl *****
36 dnl AVAHI
37 dnl *****
38 @@ -240,6 +259,7 @@
39 echo "Use X Session Management........ : $enable_sm"
40 echo "Use DBUS........................ : $enable_dbus"
41 echo "Use NetworkManager.............. : $enable_nm"
42 +echo "Use libindicate................. : $enable_libindicate"
43 dnl echo "AVAHI Support................... : $enable_avahi"
44 echo
45 eval eval echo Liferea will be installed in $bindir.
46 Index: liferea-ubuntu/src/Makefile.am
47 ===================================================================
48 --- liferea-ubuntu.orig/src/Makefile.am 2011-08-10 23:11:11.654309000 -0400
49 +++ liferea-ubuntu/src/Makefile.am 2011-08-10 23:17:29.495830366 -0400
50 @@ -91,3 +91,9 @@
51 liferea_LDFLAGS = -Wl,--export-all-symbols,--out-implib,liferea.a
53 endif
55 +if WITH_LIBINDICATE
57 +liferea_LDADD += $(LIBINDICATE_LIBS)
59 +endif
60 Index: liferea-ubuntu/src/ui/liferea_shell.c
61 ===================================================================
62 --- liferea-ubuntu.orig/src/ui/liferea_shell.c 2011-08-10 23:11:11.654309000 -0400
63 +++ liferea-ubuntu/src/ui/liferea_shell.c 2011-08-10 23:17:29.585830499 -0400
64 @@ -46,6 +46,7 @@
65 #include "ui/liferea_dialog.h"
66 #include "ui/ui_common.h"
67 #include "ui/ui_feedlist.h"
68 +#include "ui/ui_indicator.h"
69 #include "ui/ui_itemlist.h"
70 #include "ui/ui_prefs.h"
71 #include "ui/ui_script.h"
72 @@ -489,7 +490,7 @@
73 static gboolean
74 on_close (GtkWidget *widget, GdkEvent *event, gpointer user_data)
76 - if ((ui_tray_get_count() == 0) || (conf_get_bool_value (DONT_MINIMIZE_TO_TRAY))) {
77 + if (!ui_indicator_is_visible () && (ui_tray_get_count() == 0 || (conf_get_bool_value (DONT_MINIMIZE_TO_TRAY)))) {
78 liferea_shutdown ();
79 return TRUE;
81 @@ -1264,6 +1265,8 @@
82 shell->priv->feedlist = feedlist_create ();
84 ui_tray_enable (conf_get_bool_value (SHOW_TRAY_ICON)); /* init tray icon */
86 + ui_indicator_init ();
88 liferea_shell_restore_state ();
90 @@ -1329,6 +1332,7 @@
92 ui_feedlist_select (NULL);
93 liferea_shell_save_position ();
94 + ui_indicator_destroy ();
95 ui_tray_enable (FALSE);
96 notification_enable (FALSE);
97 g_object_unref (shell->priv->tabs);
98 @@ -1346,6 +1350,7 @@
99 liferea_shell_restore_position ();
101 gtk_window_present (shell->priv->window);
102 + gdk_window_raise (gtk_widget_get_window (mainwindow));
105 void
106 Index: liferea-ubuntu/src/ui/Makefile.am
107 ===================================================================
108 --- liferea-ubuntu.orig/src/ui/Makefile.am 2011-08-10 23:11:11.654309000 -0400
109 +++ liferea-ubuntu/src/ui/Makefile.am 2011-08-10 23:17:29.515830403 -0400
110 @@ -8,7 +8,7 @@
112 noinst_LIBRARIES = libliui.a
114 -libliui_a_CFLAGS = $(PACKAGE_CFLAGS) $(DBUS_CFLAGS)
115 +libliui_a_CFLAGS = $(PACKAGE_CFLAGS) $(DBUS_CFLAGS) $(LIBINDICATE_CFLAGS)
116 libliui_a_SOURCES = \
117 auth_dialog.c auth_dialog.h \
118 browser_tabs.c browser_tabs.h \
119 @@ -25,6 +25,7 @@
120 ui_dnd.c ui_dnd.h \
121 ui_feedlist.c ui_feedlist.h \
122 ui_folder.c ui_folder.h \
123 + ui_indicator.c ui_indicator.h \
124 ui_itemlist.c ui_itemlist.h \
125 ui_node.c ui_node.h \
126 ui_popup.c ui_popup.h \
127 Index: liferea-ubuntu/src/ui/ui_indicator.c
128 ===================================================================
129 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
130 +++ liferea-ubuntu/src/ui/ui_indicator.c 2011-08-10 23:11:11.654309000 -0400
131 @@ -0,0 +1,195 @@
133 + * @file ui_indicator.c libindicate support
135 + * Copyright (C) 2010 Maia Kozheva <sikon@ubuntu.com>
137 + * This program is free software; you can redistribute it and/or modify
138 + * it under the terms of the GNU General Public License as published by
139 + * the Free Software Foundation; either version 2 of the License, or
140 + * (at your option) any later version.
141 + *
142 + * This program is distributed in the hope that it will be useful,
143 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
144 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
145 + * GNU Library General Public License for more details.
146 + *
147 + * You should have received a copy of the GNU General Public License
148 + * along with this program; if not, write to the Free Software
149 + * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
150 + */
152 +#include "ui_indicator.h"
154 +#ifdef HAVE_LIBINDICATE
156 +#include <gtk/gtk.h>
157 +#include <libindicate/server.h>
158 +#include <libindicate/indicator.h>
159 +#include <libindicate-gtk/indicator.h>
160 +#include <libindicate/interests.h>
161 +#include "ui_tray.h"
162 +#include "feedlist.h"
163 +#include "vfolder.h"
165 +#define MAX_INDICATORS 6
166 +#define SET_DRAW_ATTENTION FALSE
168 +static struct indicator_priv {
169 + IndicateServer *server;
170 + gboolean visible;
171 + GPtrArray *indicators;
172 +} *indicator_priv = NULL;
174 +static const char *DESKTOP_FILE = PACKAGE_DATA_DIR G_DIR_SEPARATOR_S "applications" G_DIR_SEPARATOR_S "liferea.desktop";
176 +static void
177 +remove_all_indicators () {
178 + g_ptr_array_set_size (indicator_priv->indicators, 0);
181 +static void
182 +on_indicator_server_clicked (IndicateServer *server, gchar *type, gpointer user_data)
184 + liferea_shell_present ();
185 + remove_all_indicators ();
188 +static void
189 +on_indicator_interest_added (IndicateServer *server, guint interest, gpointer user_data)
191 + if (interest != INDICATE_INTEREST_SERVER_SIGNAL)
192 + return;
194 + indicator_priv->visible = TRUE;
195 + ui_tray_update ();
198 +static void
199 +on_indicator_interest_removed (IndicateServer *server, guint interest, gpointer user_data)
201 + if (interest != INDICATE_INTEREST_SERVER_SIGNAL)
202 + return;
204 + indicator_priv->visible = FALSE;
205 + ui_tray_update ();
208 +static void
209 +on_indicator_clicked (IndicateIndicator *indicator, guint timestamp, gpointer user_data)
211 + ui_feedlist_select ((nodePtr) user_data);
212 + liferea_shell_present ();
213 + remove_all_indicators ();
216 +static void
217 +destroy_indicator (gpointer indicator)
219 + if (indicator_priv->server == NULL || indicator == NULL)
220 + return;
222 + indicate_server_remove_indicator (indicator_priv->server, INDICATE_INDICATOR(indicator));
223 + g_object_unref (G_OBJECT (indicator));
226 +void
227 +ui_indicator_init ()
229 + g_assert (!indicator_priv);
230 + indicator_priv = g_new0 (struct indicator_priv, 1);
231 + indicator_priv->visible = FALSE;
232 + indicator_priv->indicators = g_ptr_array_new_with_free_func (destroy_indicator);
234 + indicator_priv->server = indicate_server_ref_default();
235 + indicate_server_set_type (indicator_priv->server, "message.im");
236 + indicate_server_set_desktop_file (indicator_priv->server, DESKTOP_FILE);
238 + g_signal_connect (G_OBJECT (indicator_priv->server), "server-display", G_CALLBACK (on_indicator_server_clicked), NULL);
239 + g_signal_connect (G_OBJECT (indicator_priv->server), "interest-added", G_CALLBACK (on_indicator_interest_added), NULL);
240 + g_signal_connect (G_OBJECT (indicator_priv->server), "interest-removed", G_CALLBACK (on_indicator_interest_removed), NULL);
242 + indicate_server_show (indicator_priv->server);
243 + ui_indicator_update ();
246 +void
247 +ui_indicator_destroy ()
249 + remove_all_indicators ();
250 + g_object_unref (indicator_priv->server);
251 + indicator_priv->server = NULL;
252 + g_ptr_array_free (indicator_priv->indicators, TRUE);
253 + g_free (indicator_priv);
254 + indicator_priv = NULL;
257 +static void
258 +add_node_indicator (nodePtr node)
260 + IndicateIndicator *indicator;
261 + GdkPixbuf *pixbuf;
262 + gchar count[10];
264 + if (indicator_priv->indicators->len >= MAX_INDICATORS)
265 + return;
267 + if (IS_VFOLDER(node) || g_slist_length (node->children) > 0) {
268 + // Not a feed - walk children and do nothing more
269 + node_foreach_child (node, add_node_indicator);
270 + return;
273 + if (!node->unreadCount)
274 + return;
276 + indicator = indicate_indicator_new_with_server (indicator_priv->server);
277 + g_signal_connect (indicator, "user-display", G_CALLBACK (on_indicator_clicked), node);
279 + // load favicon
280 + pixbuf = gdk_pixbuf_new_from_file (node->iconFile, NULL);
282 + // display favicon
283 + indicate_gtk_indicator_set_property_icon (indicator, "icon", pixbuf);
284 + gdk_pixbuf_unref (pixbuf);
286 + sprintf (count, "%u", node->unreadCount);
287 + indicate_indicator_set_property (indicator, "name", node->title);
288 + indicate_indicator_set_property (indicator, "count", count);
289 +#if SET_DRAW_ATTENTION
290 + indicate_indicator_set_property_bool (indicator, "draw-attention", TRUE);
291 +#endif
292 + g_ptr_array_add (indicator_priv->indicators, indicator);
295 +void
296 +ui_indicator_update ()
298 + guint index;
300 + if (!indicator_priv || gtk_window_is_active (GTK_WINDOW (liferea_shell_get_window ())))
301 + return;
303 + // Remove all previous indicators from the menu
304 + remove_all_indicators ();
305 + // ...then walk the tree and add an indicator for each unread feed
306 + feedlist_foreach (add_node_indicator);
308 + // revert order of items
309 + for (index = indicator_priv->indicators->len; index > 0; index--)
310 + indicate_indicator_show (g_ptr_array_index (indicator_priv->indicators, index - 1));
313 +gboolean
314 +ui_indicator_is_visible ()
316 + return indicator_priv && indicator_priv->visible;
319 +#else
321 +void ui_indicator_init () {}
322 +void ui_indicator_destroy () {}
323 +void ui_indicator_update () {}
324 +gboolean ui_indicator_is_visible () { return FALSE; }
326 +#endif /* HAVE_LIBINDICATE */
327 Index: liferea-ubuntu/src/ui/ui_indicator.h
328 ===================================================================
329 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
330 +++ liferea-ubuntu/src/ui/ui_indicator.h 2011-08-10 23:11:11.654309000 -0400
331 @@ -0,0 +1,35 @@
333 + * @file ui_indicator.h libindicate support
335 + * Copyright (C) 2010 Maia Kozheva <sikon@ubuntu.com>
337 + * This program is free software; you can redistribute it and/or modify
338 + * it under the terms of the GNU General Public License as published by
339 + * the Free Software Foundation; either version 2 of the License, or
340 + * (at your option) any later version.
341 + *
342 + * This program is distributed in the hope that it will be useful,
343 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
344 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
345 + * GNU Library General Public License for more details.
346 + *
347 + * You should have received a copy of the GNU General Public License
348 + * along with this program; if not, write to the Free Software
349 + * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
350 + */
352 +#ifndef _UI_INDICATOR_H
353 +#define _UI_INDICATOR_H
355 +#ifdef HAVE_CONFIG_H
356 + #include <config.h>
357 +#endif
359 +#include <glib.h>
361 +void ui_indicator_init ();
362 +void ui_indicator_destroy ();
363 +void ui_indicator_update ();
364 +gboolean ui_indicator_is_visible ();
366 +#endif /* _UI_INDICATOR_H */
367 Index: liferea-ubuntu/src/ui/ui_prefs.c
368 ===================================================================
369 --- liferea-ubuntu.orig/src/ui/ui_prefs.c 2011-08-10 23:11:11.654309000 -0400
370 +++ liferea-ubuntu/src/ui/ui_prefs.c 2011-08-10 23:11:11.654309000 -0400
371 @@ -767,9 +767,15 @@
372 widget = liferea_dialog_lookup (prefdialog, "popupwindowsoptionbtn");
373 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), conf_get_bool_value (SHOW_POPUP_WINDOWS));
375 + // If we have an indicator, we always act as if the tray icon is shown (but it's actually hidden)
376 + if (ui_indicator_is_visible ())
377 + conf_set_bool_value (SHOW_TRAY_ICON, TRUE);
379 widget = liferea_dialog_lookup (prefdialog, "trayiconoptionbtn");
380 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), conf_get_bool_value (SHOW_TRAY_ICON));
382 + gtk_widget_set_visible (gtk_widget_get_parent (widget), !ui_indicator_is_visible ());
384 widget = liferea_dialog_lookup (prefdialog, "newcountintraybtn");
385 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), conf_get_bool_value (SHOW_NEW_COUNT_IN_TRAY));
386 gtk_widget_set_sensitive (liferea_dialog_lookup (prefdialog, "newcountintraybtn"), conf_get_bool_value (SHOW_TRAY_ICON));
387 @@ -782,6 +788,14 @@
388 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), conf_get_bool_value (START_IN_TRAY));
389 gtk_widget_set_sensitive (liferea_dialog_lookup (prefdialog, "startintraybtn"), conf_get_bool_value (SHOW_TRAY_ICON));
391 + if (ui_indicator_is_visible ()) {
392 + gtk_widget_reparent (liferea_dialog_lookup (prefdialog, "startintraybtn"),
393 + gtk_widget_get_parent (liferea_dialog_lookup (prefdialog, "popupwindowsoptionbtn")));
395 + gtk_button_set_label (liferea_dialog_lookup (prefdialog, "startintraybtn"),
396 + _("Start minimized to the messaging menu"));
399 /* tool bar settings */
400 widget = liferea_dialog_lookup (prefdialog, "hidetoolbarbtn");
401 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), conf_get_bool_value(DISABLE_TOOLBAR));
402 Index: liferea-ubuntu/src/ui/ui_tray.c
403 ===================================================================
404 --- liferea-ubuntu.orig/src/ui/ui_tray.c 2011-08-10 23:11:11.654309000 -0400
405 +++ liferea-ubuntu/src/ui/ui_tray.c 2011-08-10 23:17:29.545830446 -0400
406 @@ -35,6 +35,7 @@
407 #include "net.h"
408 #include "ui/liferea_shell.h"
409 #include "ui/ui_common.h"
410 +#include "ui/ui_indicator.h"
411 #include "ui/ui_popup.h"
412 #include "ui/ui_tray.h"
414 @@ -185,10 +186,19 @@
416 gint newItems, unreadItems;
417 gchar *msg, *tmp;
420 + ui_indicator_update ();
422 if (!trayIcon_priv)
423 return;
425 + if (ui_indicator_is_visible ()) {
426 + gtk_status_icon_set_visible (trayIcon_priv->status_icon, FALSE);
427 + return;
428 + } else {
429 + gtk_status_icon_set_visible (trayIcon_priv->status_icon, TRUE);
432 newItems = feedlist_get_new_item_count ();
433 unreadItems = feedlist_get_unread_item_count ();