updated on Sun Jan 15 08:01:04 UTC 2012
[aur-mirror.git] / liferea-ext4-indicate-svn / libindicate.patch
blob19bbe354882798b10e816034a1b0c14f5c768016
1 Index: liferea/src/Makefile.am
2 ===================================================================
3 --- liferea/src/Makefile.am (revision 5359)
4 +++ liferea/src/Makefile.am (working copy)
5 @@ -90,3 +90,9 @@
6 liferea_LDADD += notification/libnotify.a $(LIBNOTIFY_LIBS)
8 endif
10 +if WITH_LIBINDICATE
12 +liferea_LDADD += $(LIBINDICATE_LIBS)
14 +endif
15 Index: liferea/src/ui/ui_tray.c
16 ===================================================================
17 --- liferea/src/ui/ui_tray.c (revision 5359)
18 +++ liferea/src/ui/ui_tray.c (working copy)
19 @@ -31,6 +31,7 @@
20 #include "net_monitor.h"
21 #include "ui/liferea_shell.h"
22 #include "ui/icons.h"
23 +#include "ui/ui_indicator.h"
24 #include "ui/ui_popup.h"
25 #include "ui/ui_tray.h"
27 @@ -194,10 +195,19 @@
29 gint newItems, unreadItems;
30 gchar *msg, *tmp;
33 + ui_indicator_update ();
35 if (!trayIcon_priv)
36 return;
38 + if (ui_indicator_is_visible ()) {
39 + gtk_status_icon_set_visible (trayIcon_priv->status_icon, FALSE);
40 + return;
41 + } else {
42 + gtk_status_icon_set_visible (trayIcon_priv->status_icon, TRUE);
43 + }
45 newItems = feedlist_get_new_item_count ();
46 unreadItems = feedlist_get_unread_item_count ();
48 Index: liferea/src/ui/liferea_shell.c
49 ===================================================================
50 --- liferea/src/ui/liferea_shell.c (revision 5359)
51 +++ liferea/src/ui/liferea_shell.c (working copy)
52 @@ -45,6 +45,7 @@
53 #include "ui/liferea_dialog.h"
54 #include "ui/search_dialog.h"
55 #include "ui/ui_common.h"
56 +#include "ui/ui_indicator.h"
57 #include "ui/ui_prefs.h"
58 #include "ui/ui_session.h"
59 #include "ui/ui_tray.h"
60 @@ -502,7 +503,7 @@
62 conf_get_bool_value (DONT_MINIMIZE_TO_TRAY, &dont_maximize_to_tray);
64 - if ((ui_tray_get_count() == 0) || dont_maximize_to_tray) {
65 + if (!ui_indicator_is_visible () && (ui_tray_get_count() == 0 || dont_maximize_to_tray)) {
66 liferea_shutdown ();
67 return TRUE;
69 @@ -1196,6 +1197,8 @@
70 conf_get_bool_value (SHOW_TRAY_ICON, &show_tray_icon);
72 ui_tray_enable (show_tray_icon); /* init tray icon */
74 + ui_indicator_init ();
76 liferea_shell_restore_state ();
78 @@ -1268,6 +1271,7 @@
80 feed_list_view_select (NULL);
81 liferea_shell_save_position ();
82 + ui_indicator_destroy ();
83 ui_tray_enable (FALSE);
84 g_object_unref (shell->priv->tabs);
85 g_object_unref (shell->priv->feedlist);
86 Index: liferea/src/ui/ui_indicator.c
87 ===================================================================
88 --- liferea/src/ui/ui_indicator.c (revision 0)
89 +++ liferea/src/ui/ui_indicator.c (revision 0)
90 @@ -0,0 +1,159 @@
91 +/*
92 + * @file ui_indicator.c libindicate support
93 + *
94 + * Copyright (C) 2010 Maia Kozheva <sikon@ubuntu.com>
95 + *
96 + * This program is free software; you can redistribute it and/or modify
97 + * it under the terms of the GNU General Public License as published by
98 + * the Free Software Foundation; either version 2 of the License, or
99 + * (at your option) any later version.
100 + *
101 + * This program is distributed in the hope that it will be useful,
102 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
103 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
104 + * GNU Library General Public License for more details.
105 + *
106 + * You should have received a copy of the GNU General Public License
107 + * along with this program; if not, write to the Free Software
108 + * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
109 + */
111 +#include "ui_indicator.h"
113 +#ifdef HAVE_LIBINDICATE
115 +#include <gtk/gtk.h>
116 +#include <libindicate/server.h>
117 +#include <libindicate/indicator.h>
118 +#include "ui_tray.h"
119 +#include "feedlist.h"
120 +#include "vfolder.h"
122 +static struct indicator_priv {
123 + IndicateServer *server;
124 + gboolean visible;
125 + GPtrArray *indicators;
126 +} *indicator_priv = NULL;
128 +static const char * DESKTOP_FILE = PACKAGE_DATA_DIR G_DIR_SEPARATOR_S "applications" G_DIR_SEPARATOR_S "liferea.desktop";
130 +static void
131 +on_indicator_server_clicked (IndicateServer *server, gchar *type, gpointer user_data)
133 + liferea_shell_present ();
136 +static void
137 +on_indicator_server_shown (IndicateServer *server, gchar *type, gpointer user_data)
139 + indicator_priv->visible = TRUE;
140 + ui_tray_update ();
143 +static void
144 +on_indicator_server_hidden (IndicateServer *server, gchar *type, gpointer user_data)
146 + indicator_priv->visible = FALSE;
147 + ui_tray_update ();
150 +static void
151 +on_indicator_clicked (IndicateIndicator *indicator, guint timestamp, gpointer user_data)
153 + indicate_indicator_set_property_bool (indicator, "draw-attention", FALSE);
154 + liferea_shell_present ();
155 + feed_list_view_select ((nodePtr) user_data);
158 +static void
159 +destroy_indicator (gpointer indicator)
161 + if (indicator_priv->server == NULL || indicator == NULL)
162 + return;
164 + indicate_server_remove_indicator (indicator_priv->server, INDICATE_INDICATOR(indicator));
165 + g_object_unref (G_OBJECT (indicator));
168 +void
169 +ui_indicator_init ()
171 + g_assert (!indicator_priv);
172 + indicator_priv = g_new0 (struct indicator_priv, 1);
173 + indicator_priv->visible = FALSE;
174 + indicator_priv->indicators = g_ptr_array_new_with_free_func (destroy_indicator);
176 + indicator_priv->server = indicate_server_ref_default();
177 + indicate_server_set_type (indicator_priv->server, "message.im");
178 + indicate_server_set_desktop_file (indicator_priv->server, DESKTOP_FILE);
180 + g_signal_connect (G_OBJECT (indicator_priv->server), "server-display", G_CALLBACK (on_indicator_server_clicked), NULL);
181 + g_signal_connect (G_OBJECT (indicator_priv->server), "server-show", G_CALLBACK (on_indicator_server_shown), NULL);
182 + g_signal_connect (G_OBJECT (indicator_priv->server), "server-hide", G_CALLBACK (on_indicator_server_hidden), NULL);
184 + indicate_server_show (indicator_priv->server);
185 + ui_indicator_update ();
188 +void
189 +ui_indicator_destroy ()
191 + g_ptr_array_set_size (indicator_priv->indicators, 0);
192 + g_object_unref (indicator_priv->server);
193 + indicator_priv->server = NULL;
194 + g_ptr_array_free (indicator_priv->indicators, TRUE);
195 + g_free (indicator_priv);
196 + indicator_priv = NULL;
199 +static void
200 +add_node_indicator (nodePtr node)
202 + IndicateIndicator *indicator;
203 + gchar count[10];
205 + if (IS_VFOLDER(node)) {
206 + // Not a feed - walk children and do nothing more
207 + node_foreach_child (node, add_node_indicator);
208 + return;
211 + if (!node->unreadCount)
212 + return;
214 + indicator = indicate_indicator_new_with_server (indicator_priv->server);
215 + g_signal_connect (indicator, "user-display", G_CALLBACK (on_indicator_clicked), node);
216 + sprintf (count, "%u", node->unreadCount);
217 + indicate_indicator_set_property (indicator, "name", node->title);
218 + indicate_indicator_set_property (indicator, "count", count);
219 + indicate_indicator_set_property_bool (indicator, "draw-attention", TRUE);
220 + indicate_indicator_show (indicator);
221 + g_ptr_array_add (indicator_priv->indicators, indicator);
224 +void
225 +ui_indicator_update ()
227 + if (!indicator_priv)
228 + return;
230 + // Remove all previous indicators from the menu
231 + g_ptr_array_set_size (indicator_priv->indicators, 0);
232 + // ...then walk the tree and add an indicator for each unread feed
233 + feedlist_foreach (add_node_indicator);
236 +gboolean
237 +ui_indicator_is_visible ()
239 + return indicator_priv && indicator_priv->visible;
242 +#else
244 +void ui_indicator_init () {}
245 +void ui_indicator_destroy () {}
246 +void ui_indicator_update () {}
247 +gboolean ui_indicator_is_visible () { return FALSE; }
249 +#endif /* HAVE_LIBINDICATE */
250 Index: liferea/src/ui/ui_prefs.c
251 ===================================================================
252 --- liferea/src/ui/ui_prefs.c (revision 5359)
253 +++ liferea/src/ui/ui_prefs.c (working copy)
254 @@ -643,13 +643,17 @@
255 conf_get_str_value (BROWSER_COMMAND, &browser_command);
256 entry = liferea_dialog_lookup(prefdialog, "browsercmd");
257 gtk_entry_set_text(GTK_ENTRY(entry), browser_command);
258 - g_free (browser_command);
259 + g_free (browser_command);
261 gtk_widget_set_sensitive(GTK_WIDGET(entry), tmp==manual);
262 gtk_widget_set_sensitive(liferea_dialog_lookup(prefdialog, "manuallabel"), tmp==manual);
264 /* ================== panel 4 "GUI" ================ */
266 + // If we have an indicator, we always act as if the tray icon is shown (but it's actually hidden)
267 + if (ui_indicator_is_visible ())
268 + conf_set_bool_value (SHOW_TRAY_ICON, TRUE);
270 conf_get_bool_value (SHOW_TRAY_ICON, &show_tray_icon);
272 widget = liferea_dialog_lookup (prefdialog, "popupwindowsoptionbtn");
273 @@ -659,6 +663,8 @@
274 widget = liferea_dialog_lookup (prefdialog, "trayiconoptionbtn");
275 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), show_tray_icon);
277 + gtk_widget_set_visible (gtk_widget_get_parent (widget), !ui_indicator_is_visible ());
279 widget = liferea_dialog_lookup (prefdialog, "newcountintraybtn");
280 conf_get_bool_value (SHOW_NEW_COUNT_IN_TRAY, &show_new_count_in_tray);
281 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), show_new_count_in_tray);
282 @@ -674,6 +680,10 @@
283 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), start_in_tray);
284 gtk_widget_set_sensitive (liferea_dialog_lookup (prefdialog, "startintraybtn"), show_tray_icon);
286 + if (ui_indicator_is_visible ()) {
287 + gtk_widget_reparent (widget, gtk_widget_get_parent (liferea_dialog_lookup (prefdialog, "popupwindowsoptionbtn")));
290 /* tool bar settings */
291 widget = liferea_dialog_lookup (prefdialog, "hidetoolbarbtn");
292 conf_get_bool_value(DISABLE_TOOLBAR, &disable_toolbar);
293 Index: liferea/src/ui/ui_indicator.h
294 ===================================================================
295 --- liferea/src/ui/ui_indicator.h (revision 0)
296 +++ liferea/src/ui/ui_indicator.h (revision 0)
297 @@ -0,0 +1,35 @@
299 + * @file ui_indicator.h libindicate support
301 + * Copyright (C) 2010 Maia Kozheva <sikon@ubuntu.com>
303 + * This program is free software; you can redistribute it and/or modify
304 + * it under the terms of the GNU General Public License as published by
305 + * the Free Software Foundation; either version 2 of the License, or
306 + * (at your option) any later version.
307 + *
308 + * This program is distributed in the hope that it will be useful,
309 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
310 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
311 + * GNU Library General Public License for more details.
312 + *
313 + * You should have received a copy of the GNU General Public License
314 + * along with this program; if not, write to the Free Software
315 + * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
316 + */
318 +#ifndef _UI_INDICATOR_H
319 +#define _UI_INDICATOR_H
321 +#ifdef HAVE_CONFIG_H
322 + #include <config.h>
323 +#endif
325 +#include <glib.h>
327 +void ui_indicator_init ();
328 +void ui_indicator_destroy ();
329 +void ui_indicator_update ();
330 +gboolean ui_indicator_is_visible ();
332 +#endif /* _UI_INDICATOR_H */
333 \ No newline at end of file
334 Index: liferea/src/ui/Makefile.am
335 ===================================================================
336 --- liferea/src/ui/Makefile.am (revision 5359)
337 +++ liferea/src/ui/Makefile.am (working copy)
338 @@ -8,7 +8,7 @@
340 noinst_LIBRARIES = libliui.a
342 -libliui_a_CFLAGS = $(PACKAGE_CFLAGS) $(DBUS_CFLAGS)
343 +libliui_a_CFLAGS = $(PACKAGE_CFLAGS) $(DBUS_CFLAGS) $(LIBINDICATE_CFLAGS)
344 libliui_a_SOURCES = \
345 auth_dialog.c auth_dialog.h \
346 browser_tabs.c browser_tabs.h \
347 @@ -27,6 +27,7 @@
348 ui_common.c ui_common.h \
349 ui_dnd.c ui_dnd.h \
350 ui_folder.c ui_folder.h \
351 + ui_indicator.c ui_indicator.h \
352 ui_node.c ui_node.h \
353 ui_popup.c ui_popup.h \
354 ui_prefs.c ui_prefs.h \
355 Index: liferea/configure.ac
356 ===================================================================
357 --- liferea/configure.ac (revision 5359)
358 +++ liferea/configure.ac (working copy)
359 @@ -24,6 +24,7 @@
360 AC_ARG_ENABLE(dbus, AS_HELP_STRING([--disable-dbus],[compile without DBUS support]),,enable_dbus=yes)
361 AC_ARG_ENABLE(nm, AS_HELP_STRING([--disable-nm],[compile without NetworkManager support]),,enable_nm=yes)
362 AC_ARG_ENABLE(libnotify, AS_HELP_STRING([--disable-libnotify],[compile without libnotify support]),,enable_libnotify=yes)
363 +AC_ARG_ENABLE(libindicate, AS_HELP_STRING([--disable-libindicate],[compile without libindicate support]),,enable_libindicate=yes)
364 dnl AC_ARG_ENABLE(avahi, AS_HELP_STRING([--disable-avahi],[compile without AVAHI support]),,enable_avahi=yes)
366 AC_CHECK_FUNCS([strsep])
367 @@ -56,6 +57,24 @@
369 AM_CONDITIONAL(WITH_LIBNOTIFY, test "x$enable_libnotify" = "xyes")
371 +dnl *********
372 +dnl libindicate
373 +dnl *********
375 +if test "x$enable_libindicate" = "xyes"; then
376 + PKG_CHECK_MODULES([LIBINDICATE], indicate,enable_libindicate=yes,enable_libindicate=no)
377 + AC_SUBST(LIBINDICATE_CFLAGS)
378 + AC_SUBST(LIBINDICATE_LIBS)
379 +else
380 + enable_libindicate=no
383 +if test "x$enable_libnotify" = "xyes"; then
384 + AC_DEFINE(HAVE_LIBINDICATE, 1, [Define if libindicate support is enabled])
387 +AM_CONDITIONAL(WITH_LIBINDICATE, test "x$enable_libindicate" = "xyes")
389 dnl *****
390 dnl AVAHI
391 dnl *****
392 @@ -192,6 +211,7 @@
393 echo "Use DBUS........................ : $enable_dbus"
394 echo "Use NetworkManager.............. : $enable_nm"
395 echo "Use libnotify................... : $enable_libnotify"
396 +echo "Use libindicate................. : $enable_libindicate"
397 dnl echo "AVAHI Support................... : $enable_avahi"
398 echo
399 eval eval echo Liferea will be installed in $bindir.