2
# Description: Integrate Empathy into the messaging menu
3
# Ubuntu: https://bugs.edge.launchpad.net/ubuntu/+source/empathy/+bug/340180
4
# Upstream: https://bugzilla.gnome.org/show_bug.cgi?id=574744
7
=== modified file 'configure.ac'
8
--- configure.ac 2009-09-18 18:41:05 +0000
9
+++ configure.ac 2009-09-18 18:41:20 +0000
13
NETWORK_MANAGER_REQUIRED=0.7.0
14
+INDICATE_REQUIRED=0.2.0
15
+INDICATE_GTK_REQUIRED=0.2.0
17
# Use --enable-maintainer-mode to disabled deprecated symbols
18
GNOME_MAINTAINER_MODE_DEFINES
20
AM_CONDITIONAL(HAVE_NOTHERE, test "x$have_nothere" = "xyes")
22
# -----------------------------------------------------------
24
+# -----------------------------------------------------------
25
+AC_ARG_ENABLE(libindicate,
26
+ AS_HELP_STRING([--enable-libindicate=@<:@no/yes/auto@:>@],
27
+ [build libindicate support]), ,
28
+ enable_libindicate=auto)
30
+if test "x$enable_libindicate" != "xno"; then
31
+ PKG_CHECK_MODULES(INDICATE,
33
+ indicate >= $INDICATE_REQUIRED,
34
+ indicate-gtk >= $INDICATE_GTK_REQUIRED
35
+ ], have_libindicate="yes", have_libindicate="no")
37
+ if test "x$have_libindicate" = "xyes"; then
38
+ AC_DEFINE(HAVE_LIBINDICATE, 1, [Define if you have libindicate])
44
+if test "x$enable_libindicate" = "xyes" -a "x$have_libindicate" != "xyes"; then
45
+ AC_MSG_ERROR([Couldn't find libindicate.])
48
+AM_CONDITIONAL(HAVE_LIBINDICATE, test "x$have_libindicate" = "xyes")
50
+# -----------------------------------------------------------
52
# -----------------------------------------------------------
58
- Compiler....................: ${CC}
59
- Compiler Flags..............: ${CFLAGS}
60
- Prefix......................: ${prefix}
61
- Shaved build................: ${enable_shave}
62
- Tests.......................: ${have_check}
63
- Coding style checks.........: ${ENABLE_CODING_STYLE_CHECKS}
64
+ Compiler...............................: ${CC}
65
+ Compiler Flags.........................: ${CFLAGS}
66
+ Prefix.................................: ${prefix}
67
+ Shaved build...........................: ${enable_shave}
68
+ Tests..................................: ${have_check}
69
+ Coding style checks....................: ${ENABLE_CODING_STYLE_CHECKS}
72
- Spell checking (enchant)....: ${have_enchant}
73
- Display maps (libchamplain).: ${have_libchamplain}
74
- Location awareness (Geoclue): ${have_geoclue}
75
- Adium themes (Webkit).......: ${have_webkit}
76
+ Spell checking (enchant)...............: ${have_enchant}
77
+ Display maps (libchamplain)............: ${have_libchamplain}
78
+ Location awareness (Geoclue)...........: ${have_geoclue}
79
+ Adium themes (Webkit)..................: ${have_webkit}
80
+ Message indicator support (libindicate): ${have_libindicate}
83
- NetworkManager integration..: ${have_nm}
84
- ConnMan integration.........: ${have_connman}
85
+ NetworkManager integration.............: ${have_nm}
86
+ ConnMan integration....................: ${have_connman}
89
- Documentation...............: ${enable_gtk_doc}
90
- Python bindings.............: ${have_python}
91
- Megaphone applet............: ${have_megaphone}
92
- Nothere applet..............: ${have_nothere}
93
+ Documentation..........................: ${enable_gtk_doc}
94
+ Python bindings........................: ${have_python}
95
+ Megaphone applet.......................: ${have_megaphone}
96
+ Nothere applet.........................: ${have_nothere}
99
=== modified file 'data/empathy.schemas.in'
100
--- data/empathy.schemas.in 2009-09-18 18:41:05 +0000
101
+++ data/empathy.schemas.in 2009-09-18 18:41:20 +0000
106
+ <key>/schemas/apps/empathy/notifications/use_libindicate</key>
107
+ <applyto>/apps/empathy/notifications/use_libindicate</applyto>
108
+ <owner>empathy</owner>
110
+ <default>true</default>
112
+ <short>Use the messaging indicator</short>
114
+ Whether or not to use the messaging indicator, if false
115
+ the icon in the notification area will be displayed.
121
<key>/schemas/apps/empathy/ui/separate_chat_windows</key>
122
<applyto>/apps/empathy/ui/separate_chat_windows</applyto>
123
<owner>empathy</owner>
125
=== modified file 'libempathy-gtk/empathy-conf.h'
126
--- libempathy-gtk/empathy-conf.h 2009-09-18 18:41:05 +0000
127
+++ libempathy-gtk/empathy-conf.h 2009-09-18 18:41:20 +0000
129
#define EMPATHY_PREFS_UI_AVATAR_DIRECTORY EMPATHY_PREFS_PATH "/ui/avatar_directory"
130
#define EMPATHY_PREFS_UI_SHOW_AVATARS EMPATHY_PREFS_PATH "/ui/show_avatars"
131
#define EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST EMPATHY_PREFS_PATH "/ui/compact_contact_list"
132
+#define EMPATHY_PREFS_UI_USE_LIBINDICATE EMPATHY_PREFS_PATH "/notifications/use_libindicate"
133
#define EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE EMPATHY_PREFS_PATH "/contacts/show_offline"
134
#define EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM EMPATHY_PREFS_PATH "/contacts/sort_criterium"
135
#define EMPATHY_PREFS_HINTS_CLOSE_MAIN_WINDOW EMPATHY_PREFS_PATH "/hints/close_main_window"
137
=== modified file 'libempathy-gtk/empathy-ui-utils.c'
138
--- libempathy-gtk/empathy-ui-utils.c 2009-09-18 18:41:05 +0000
139
+++ libempathy-gtk/empathy-ui-utils.c 2009-09-18 18:41:20 +0000
140
@@ -1269,24 +1269,35 @@
142
GdkWindow *gdk_window;
144
- gtk_status_icon_get_geometry (status_icon, NULL, &icon_location, NULL);
145
- gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
146
- dpy = gdk_x11_drawable_get_xdisplay (gdk_window);
148
- data[0] = icon_location.x;
149
- data[1] = icon_location.y;
150
- data[2] = icon_location.width;
151
- data[3] = icon_location.height;
153
- XChangeProperty (dpy,
154
- GDK_WINDOW_XID (gdk_window),
155
- gdk_x11_get_xatom_by_name_for_display (gdk_drawable_get_display (gdk_window),
156
- "_NET_WM_ICON_GEOMETRY"),
157
- XA_CARDINAL, 32, PropModeReplace,
158
- (guchar *)&data, 4);
159
+ // If the status icon isn't visible (because indicators are used) then
160
+ // attempting to change the properties of the status icon doesn't work.
161
+ if (gtk_status_icon_get_visible (status_icon)) {
162
+ gtk_status_icon_get_geometry (status_icon, NULL, &icon_location, NULL);
163
+ gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
164
+ dpy = gdk_x11_drawable_get_xdisplay (gdk_window);
166
+ data[0] = icon_location.x;
167
+ data[1] = icon_location.y;
168
+ data[2] = icon_location.width;
169
+ data[3] = icon_location.height;
171
+ XChangeProperty (dpy,
172
+ GDK_WINDOW_XID (gdk_window),
173
+ gdk_x11_get_xatom_by_name_for_display (gdk_drawable_get_display (gdk_window),
174
+ "_NET_WM_ICON_GEOMETRY"),
175
+ XA_CARDINAL, 32, PropModeReplace,
176
+ (guchar *)&data, 4);
179
gtk_window_set_skip_taskbar_hint (window, TRUE);
180
- gtk_window_iconify (window);
181
+ // If the status icon isn't present then the WM will probably choose to
182
+ // iconfy to the taskbar, which doesn't look as good as the taskbar
183
+ // entry has just been removed. Just hide instead.
184
+ if (gtk_status_icon_get_visible (status_icon)) {
185
+ gtk_window_iconify (window);
187
+ gtk_widget_hide (GTK_WIDGET(window));
191
/* Takes care of moving the window to the current workspace. */
193
=== modified file 'po/POTFILES.in'
194
--- po/POTFILES.in 2009-09-18 18:41:05 +0000
195
+++ po/POTFILES.in 2009-09-18 18:41:20 +0000
197
[type: gettext/glade]src/empathy-import-dialog.ui
198
src/empathy-import-widget.c
199
src/empathy-import-mc4-accounts.c
200
+src/empathy-indicator.c
201
+src/empathy-indicator-manager.c
202
src/empathy-main-window.c
203
[type: gettext/glade]src/empathy-main-window.ui
204
src/empathy-new-chatroom-dialog.c
206
=== modified file 'src/Makefile.am'
207
--- src/Makefile.am 2009-09-18 18:41:05 +0000
208
+++ src/Makefile.am 2009-09-18 18:41:20 +0000
212
-DG_LOG_DOMAIN=\"empathy\" \
213
+ -DDESKTOPDIR=\"$(datadir)/applications\" \
215
$(LIBNOTIFY_CFLAGS) \
216
+ $(INDICATE_CFLAGS) \
217
$(LIBCHAMPLAIN_CFLAGS) \
218
$(DISABLE_DEPRECATED) \
221
$(top_builddir)/libempathy/libempathy.la \
222
$(top_builddir)/extensions/libemp-extensions.la \
226
$(LIBCHAMPLAIN_LIBS) \
233
+empathy_handwritten_source += \
234
+ empathy-indicator-manager.c \
235
+ empathy-indicator-manager.h \
236
+ empathy-indicator.c empathy-indicator.h
239
+ empathy-indicator-manager.c \
240
+ empathy-indicator-manager.h \
241
+ empathy-indicator.c empathy-indicator.h
245
empathy_handwritten_source += \
248
=== modified file 'src/empathy-chat-window.c'
249
--- src/empathy-chat-window.c 2009-09-18 18:41:05 +0000
250
+++ src/empathy-chat-window.c 2009-09-18 18:41:20 +0000
252
#include "empathy-about-dialog.h"
253
#include "empathy-misc.h"
255
+#ifdef HAVE_LIBINDICATE
256
+#include "empathy-indicator.h"
257
+#include "empathy-indicator-manager.h"
260
#define DEBUG_FLAG EMPATHY_DEBUG_CHAT
261
#include <libempathy/empathy-debug.h>
266
NotifyNotification *notification;
267
+#ifdef HAVE_LIBINDICATE
268
+ EmpathyIndicatorManager *indicator_manager;
269
+ /* EmpathyChat -> EmpathyIndicator for that chat, if any */
270
+ GHashTable *indicators;
274
GtkUIManager *ui_manager;
276
g_slice_free (NotificationData, cb_data);
279
+#ifdef HAVE_LIBINDICATE
281
+chat_window_indicator_activate_cb (EmpathyIndicator *indicator,
282
+ NotificationData *cb_data)
284
+ empathy_chat_window_present_chat (cb_data->chat);
286
+ empathy_indicator_hide (indicator);
287
+ g_object_unref (cb_data->chat);
288
+ g_slice_free (NotificationData, cb_data);
292
+chat_window_add_indicator (EmpathyChatWindow *window,
293
+ EmpathyMessage *message,
296
+ EmpathyChatWindowPriv *priv = GET_PRIV (window);
297
+ EmpathyContact *sender;
299
+ NotificationData *cb_data;
300
+ gboolean use_libindicate;
301
+ EmpathyIndicator *indicator;
303
+ empathy_conf_get_bool (empathy_conf_get (),
304
+ EMPATHY_PREFS_UI_USE_LIBINDICATE,
307
+ if (!use_libindicate) {
311
+ cb_data = g_slice_new0 (NotificationData);
312
+ cb_data->chat = g_object_ref (chat);
313
+ cb_data->window = window;
315
+ sender = empathy_message_get_sender (message);
316
+ body = empathy_message_get_body (message);
318
+ indicator = g_hash_table_lookup (priv->indicators, chat);
320
+ empathy_indicator_update (indicator, body);
322
+ indicator = empathy_indicator_manager_create_indicator (priv->indicator_manager,
324
+ g_signal_connect (indicator, "activate",
325
+ G_CALLBACK (chat_window_indicator_activate_cb), cb_data);
326
+ g_hash_table_insert (priv->indicators, chat, indicator);
328
+ empathy_indicator_show (indicator);
332
+chat_window_remove_indicator (EmpathyChatWindow *window, EmpathyChat *chat)
334
+ EmpathyIndicator *indicator;
335
+ EmpathyChatWindowPriv *priv = GET_PRIV (window);
337
+ indicator = g_hash_table_lookup (priv->indicators, chat);
343
+ empathy_indicator_hide (indicator);
344
+ g_hash_table_remove (priv->indicators, chat);
345
+ g_object_unref (indicator);
350
chat_window_show_or_update_notification (EmpathyChatWindow *window,
351
EmpathyMessage *message,
352
@@ -1067,6 +1147,9 @@
353
empathy_sound_play (GTK_WIDGET (priv->dialog),
354
EMPATHY_SOUND_MESSAGE_INCOMING);
355
chat_window_show_or_update_notification (window, message, chat);
356
+#ifdef HAVE_LIBINDICATE
357
+ chat_window_add_indicator (window, message, chat);
362
@@ -1126,6 +1209,10 @@
363
priv->chats_new_msg = g_list_remove (priv->chats_new_msg, chat);
365
chat_window_update_chat_tab (chat);
367
+#ifdef HAVE_LIBINDICATE
368
+ chat_window_remove_indicator (window, chat);
373
@@ -1236,6 +1323,11 @@
374
/* Update the title, since we now mark all unread messages as read. */
375
chat_window_update_chat_tab (priv->current_chat);
377
+#ifdef HAVE_LIBINDICATE
378
+ /* Remove the indicator for the active chat */
379
+ chat_window_remove_indicator (window, priv->current_chat);
385
@@ -1452,6 +1544,11 @@
386
g_object_unref (gui);
388
priv->chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL);
389
+#ifdef HAVE_LIBINDICATE
390
+ priv->indicator_manager = empathy_indicator_manager_dup_singleton ();
391
+ priv->indicators = g_hash_table_new_full (g_direct_hash, g_direct_equal,
392
+ NULL, g_object_unref);
395
priv->notebook = gtk_notebook_new ();
396
gtk_notebook_set_group (GTK_NOTEBOOK (priv->notebook), "EmpathyChatWindow");
398
=== added file 'src/empathy-indicator-manager.c'
399
--- src/empathy-indicator-manager.c 1970-01-01 00:00:00 +0000
400
+++ src/empathy-indicator-manager.c 2009-09-18 18:41:43 +0000
402
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
404
+ * Copyright (C) 2009 Canonical Ltd.
406
+ * This program is free software; you can redistribute it and/or
407
+ * modify it under the terms of the GNU General Public License as
408
+ * published by the Free Software Foundation; either version 2 of the
409
+ * License, or (at your option) any later version.
411
+ * This program is distributed in the hope that it will be useful,
412
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
413
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
414
+ * General Public License for more details.
416
+ * You should have received a copy of the GNU General Public
417
+ * License along with this program; if not, write to the
418
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
419
+ * Boston, MA 02110-1301 USA
421
+ * Authors: James Westby <james.westby@ubuntu.com>
427
+#include <gtk/gtk.h>
429
+#include <libempathy/empathy-contact.h>
430
+#include <libempathy/empathy-dispatcher.h>
431
+#include <libempathy/empathy-utils.h>
433
+#include <libempathy-gtk/empathy-conf.h>
434
+#include <libempathy-gtk/empathy-ui-utils.h>
436
+#include <telepathy-glib/util.h>
438
+#include "empathy-event-manager.h"
439
+#include "empathy-indicator.h"
440
+#include "empathy-indicator-manager.h"
441
+#include "empathy-misc.h"
443
+#include <libindicate/server.h>
445
+#define INDICATOR_LOGIN_TIMEOUT 15
446
+#define EMPATHY_DESKTOP_PATH DESKTOPDIR "/empathy.desktop"
448
+#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIndicatorManager)
455
+static guint signals[LAST_SIGNAL];
458
+ EmpathyEventManager *event_manager;
459
+ IndicateServer *indicate_server;
460
+ GSList *indicator_events;
461
+ GHashTable *login_timeouts;
462
+} EmpathyIndicatorManagerPriv;
465
+ EmpathyIndicator *indicator;
466
+ EmpathyEvent *event;
470
+ EmpathyIndicatorManager *manager;
471
+ EmpathyIndicator *indicator;
474
+G_DEFINE_TYPE (EmpathyIndicatorManager, empathy_indicator_manager, G_TYPE_OBJECT);
476
+static EmpathyIndicatorManager *manager_singleton = NULL;
478
+static EmpathyEvent *
479
+event_copy (EmpathyEvent *event)
481
+ EmpathyEvent *ret = g_new0 (EmpathyEvent, 1);
483
+ ret->contact = g_object_ref (event->contact);
484
+ ret->icon_name = g_strdup (event->icon_name);
485
+ ret->header = g_strdup (event->header);
486
+ ret->message = g_strdup (event->message);
487
+ ret->must_ack = event->must_ack;
493
+compare_events (EmpathyEvent *ev1, EmpathyEvent *ev2)
495
+ return ((g_strcmp0 (ev1->icon_name, ev2->icon_name) == 0) &&
496
+ (g_strcmp0 (ev1->header, ev2->header) == 0) &&
497
+ (g_strcmp0 (ev1->message, ev2->message) == 0) &&
498
+ (ev1->must_ack == ev2->must_ack) &&
499
+ (ev1->contact == ev2->contact));
502
+static IndicatorEvent *
503
+indicator_event_new (EmpathyIndicator *indicator,
504
+ EmpathyEvent *event)
506
+ IndicatorEvent *indicator_event;
508
+ indicator_event = g_slice_new0 (IndicatorEvent);
509
+ indicator_event->indicator = g_object_ref (indicator);
510
+ indicator_event->event = event_copy (event);
512
+ return indicator_event;
517
+indicator_event_free (IndicatorEvent *indicator_event)
519
+ g_object_unref (indicator_event->indicator);
520
+ g_free (indicator_event);
525
+indicate_server_activate (IndicateServer *server,
526
+ EmpathyIndicatorManager *manager)
528
+ g_signal_emit (manager, signals[SERVER_ACTIVATE], 0);
533
+indicate_show_cb (EmpathyIndicator *indicator,
534
+ EmpathyEvent *event)
536
+ empathy_event_activate (event);
541
+indicator_manager_event_added_cb (EmpathyEventManager *event_manager,
542
+ EmpathyEvent *event,
543
+ EmpathyIndicatorManager *manager)
545
+ EmpathyIndicator *indicator;
546
+ EmpathyIndicatorManagerPriv *priv;
547
+ IndicatorEvent *indicator_event;
549
+ priv = GET_PRIV (manager);
551
+ if (event->contact == NULL)
553
+ indicator = empathy_indicator_new (event->contact, event->message, "im");
554
+ empathy_indicator_show (indicator);
555
+ g_signal_connect (G_OBJECT(indicator), "activate",
556
+ G_CALLBACK (indicate_show_cb),
558
+ indicator_event = indicator_event_new (indicator, event);
559
+ g_object_unref (indicator);
560
+ priv->indicator_events = g_slist_prepend (priv->indicator_events,
565
+indicator_manager_event_removed_cb (EmpathyEventManager *event_manager,
566
+ EmpathyEvent *event,
567
+ EmpathyIndicatorManager *manager)
569
+ EmpathyIndicatorManagerPriv *priv;
572
+ priv = GET_PRIV (manager);
574
+ for (l = priv->indicator_events; l; l = l->next)
576
+ IndicatorEvent *indicator_event;
577
+ indicator_event = l->data;
579
+ if (compare_events (indicator_event->event, event)) {
580
+ priv->indicator_events = g_slist_remove (priv->indicator_events,
582
+ empathy_indicator_hide (indicator_event->indicator);
590
+indicator_manager_event_updated_cb (EmpathyEventManager *event_manager,
591
+ EmpathyEvent *event,
592
+ EmpathyIndicatorManager *manager)
594
+ EmpathyIndicatorManagerPriv *priv;
597
+ priv = GET_PRIV (manager);
599
+ for (l = priv->indicator_events; l; l = l->next)
601
+ IndicatorEvent *indicator_event;
602
+ indicator_event = l->data;
603
+ if (compare_events (indicator_event->event, event)) {
604
+ empathy_indicator_update (indicator_event->indicator,
612
+/* Remove the login indicator when it times out */
614
+indicate_login_timeout (gpointer data)
616
+ LoginData *login_data;
617
+ EmpathyIndicator *e_indicator;
618
+ EmpathyIndicatorManager *manager;
619
+ EmpathyIndicatorManagerPriv *priv;
621
+ login_data = (LoginData *) data;
622
+ e_indicator = login_data->indicator;
623
+ manager = login_data->manager;
624
+ priv = GET_PRIV (manager);
626
+ empathy_indicator_hide (e_indicator);
627
+ g_hash_table_remove (priv->login_timeouts, e_indicator);
634
+indicate_login_cb (EmpathyIndicator *e_indicator,
635
+ EmpathyIndicatorManager *manager)
637
+ EmpathyIndicatorManagerPriv *priv;
638
+ GSList *events, *l;
639
+ EmpathyContact *contact;
641
+ priv = GET_PRIV (manager);
643
+ empathy_indicator_hide (e_indicator);
644
+ g_hash_table_remove (priv->login_timeouts, e_indicator);
646
+ contact = empathy_indicator_get_contact (e_indicator);
647
+ /* If the contact has an event activate it, otherwise the
648
+ * default handler of row-activated will be called. */
649
+ events = empathy_event_manager_get_events (priv->event_manager);
650
+ for (l = events; l; l = l->next) {
651
+ EmpathyEvent *event;
654
+ if (event->contact == contact) {
655
+ empathy_event_activate (event);
660
+ /* Else start a new conversation */
661
+ empathy_dispatcher_chat_with_contact (contact, NULL, NULL);
665
+EmpathyIndicatorManager *
666
+empathy_indicator_manager_dup_singleton (void)
668
+ return g_object_new (EMPATHY_TYPE_INDICATOR_MANAGER, NULL);
673
+indicator_manager_dispose (GObject *object)
675
+ EmpathyIndicatorManagerPriv *priv;
677
+ priv = GET_PRIV (object);
679
+ if (priv->indicator_events) {
680
+ g_slist_foreach (priv->indicator_events, (GFunc) indicator_event_free,
682
+ g_slist_free (priv->indicator_events);
683
+ priv->indicator_events = NULL;
685
+ if (priv->event_manager) {
686
+ g_object_unref (priv->event_manager);
687
+ priv->event_manager = NULL;
689
+ if (priv->indicate_server) {
690
+ g_object_unref (priv->indicate_server);
691
+ priv->indicate_server = NULL;
693
+ if (priv->login_timeouts) {
694
+ g_hash_table_unref (priv->login_timeouts);
695
+ priv->login_timeouts = NULL;
698
+ G_OBJECT_CLASS (empathy_indicator_manager_parent_class)->dispose (object);
703
+indicator_manager_constructor (GType type,
705
+ GObjectConstructParam *props)
709
+ if (manager_singleton != NULL) {
710
+ retval = g_object_ref (manager_singleton);
712
+ retval = G_OBJECT_CLASS (empathy_indicator_manager_parent_class)->constructor
713
+ (type, n_props, props);
715
+ manager_singleton = EMPATHY_INDICATOR_MANAGER (retval);
716
+ g_object_add_weak_pointer (retval, (gpointer) &manager_singleton);
724
+empathy_indicator_manager_class_init (EmpathyIndicatorManagerClass *klass)
726
+ GObjectClass *object_class;
728
+ object_class = G_OBJECT_CLASS (klass);
729
+ object_class->dispose = indicator_manager_dispose;
730
+ object_class->constructor = indicator_manager_constructor;
732
+ signals[SERVER_ACTIVATE] =
733
+ g_signal_new ("server-activate",
734
+ G_TYPE_FROM_CLASS (klass),
738
+ g_cclosure_marshal_VOID__VOID,
742
+ g_type_class_add_private (object_class, sizeof (EmpathyIndicatorManagerPriv));
747
+empathy_indicator_manager_init (EmpathyIndicatorManager *manager)
749
+ EmpathyIndicatorManagerPriv *priv;
751
+ priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
752
+ EMPATHY_TYPE_INDICATOR_MANAGER, EmpathyIndicatorManagerPriv);
753
+ manager->priv = priv;
755
+ priv->event_manager = empathy_event_manager_dup_singleton ();
756
+ priv->login_timeouts = g_hash_table_new_full (NULL, NULL,
757
+ (GDestroyNotify) g_object_unref, (GDestroyNotify) g_source_unref);
758
+ priv->indicate_server = indicate_server_ref_default ();
759
+ indicate_server_set_type (priv->indicate_server, "message.instant");
760
+ indicate_server_set_desktop_file (priv->indicate_server,
761
+ EMPATHY_DESKTOP_PATH);
763
+ g_signal_connect (priv->indicate_server,
764
+ INDICATE_SERVER_SIGNAL_SERVER_DISPLAY,
765
+ G_CALLBACK (indicate_server_activate),
768
+ g_signal_connect (priv->event_manager, "event-added",
769
+ G_CALLBACK (indicator_manager_event_added_cb),
771
+ g_signal_connect (priv->event_manager, "event-removed",
772
+ G_CALLBACK (indicator_manager_event_removed_cb),
774
+ g_signal_connect (priv->event_manager, "event-updated",
775
+ G_CALLBACK (indicator_manager_event_updated_cb),
781
+empathy_indicator_manager_set_server_visible (EmpathyIndicatorManager *manager,
784
+ EmpathyIndicatorManagerPriv *priv;
786
+ priv = GET_PRIV (manager);
788
+ indicate_server_show (priv->indicate_server);
790
+ /* Causes a crash on next show currently due to object not being
791
+ unregistered from dbus
792
+ indicate_server_hide (priv->indicate_server);
799
+empathy_indicator_manager_create_indicator (EmpathyIndicatorManager *manager,
800
+ EmpathyContact *sender,
803
+ return empathy_indicator_new (sender, body, "im");
808
+login_data_new (EmpathyIndicator *e_indicator,
809
+ EmpathyIndicatorManager *manager)
811
+ LoginData *login_data;
813
+ login_data = g_slice_new0 (LoginData);
814
+ login_data->manager = g_object_ref (manager);
815
+ login_data->indicator = g_object_ref (e_indicator);
822
+indicator_destroy_login_data (gpointer data)
824
+ LoginData *login_data;
826
+ login_data = (LoginData *)data;
828
+ g_object_unref (login_data->manager);
829
+ g_object_unref (login_data->indicator);
830
+ g_slice_free (LoginData, login_data);
834
+/* Add an indicator for someone logging in. This will be displayed for
835
+ * a short period only.
838
+empathy_indicator_manager_add_login_indicator (EmpathyIndicatorManager *manager,
839
+ EmpathyContact *contact)
841
+ EmpathyIndicatorManagerPriv *priv;
843
+ EmpathyIndicator *e_indicator;
844
+ LoginData *login_data;
846
+ priv = GET_PRIV (manager);
847
+ e_indicator = empathy_indicator_new (contact, NULL, "login");
848
+ login_data = login_data_new (e_indicator, manager);
850
+ timeout = g_timeout_source_new_seconds (INDICATOR_LOGIN_TIMEOUT);
851
+ g_source_set_callback (timeout, indicate_login_timeout, login_data,
852
+ indicator_destroy_login_data);
853
+ g_source_attach (timeout, NULL);
855
+ g_hash_table_insert (priv->login_timeouts, e_indicator, timeout);
857
+ g_signal_connect (e_indicator, "activate",
858
+ G_CALLBACK (indicate_login_cb), manager);
859
+ empathy_indicator_show (e_indicator);
862
=== added file 'src/empathy-indicator-manager.h'
863
--- src/empathy-indicator-manager.h 1970-01-01 00:00:00 +0000
864
+++ src/empathy-indicator-manager.h 2009-09-18 18:41:20 +0000
866
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
868
+ * Copyright (C) 2009 Canonical Ltd.
870
+ * This program is free software; you can redistribute it and/or
871
+ * modify it under the terms of the GNU General Public License as
872
+ * published by the Free Software Foundation; either version 2 of the
873
+ * License, or (at your option) any later version.
875
+ * This program is distributed in the hope that it will be useful,
876
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
877
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
878
+ * General Public License for more details.
880
+ * You should have received a copy of the GNU General Public
881
+ * License along with this program; if not, write to the
882
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
883
+ * Boston, MA 02110-1301 USA
885
+ * Authors: James Westby <james.westby@ubuntu.com>
889
+#ifndef __EMPATHY_INDICATOR_MANAGER_H__
890
+#define __EMPATHY_INDICATOR_MANAGER_H__
894
+#include <libempathy/empathy-contact.h>
895
+#include "empathy-indicator.h"
899
+#define EMPATHY_TYPE_INDICATOR_MANAGER \
900
+ (empathy_indicator_manager_get_type ())
901
+#define EMPATHY_INDICATOR_MANAGER(o) \
902
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_INDICATOR_MANAGER, \
903
+ EmpathyIndicatorManager))
904
+#define EMPATHY_INDICATOR_MANAGER_CLASS(k) \
905
+ (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_INDICATOR_MANAGER, \
906
+ EmpathyIndicatorManagerClass))
907
+#define EMPATHY_IS_INDICATOR_MANAGER(o) \
908
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_INDICATOR_MANAGER))
909
+#define EMPATHY_IS_INDICATOR_MANAGER_CLASS(k) \
910
+ (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_INDICATOR_MANAGER))
911
+#define EMPATHY_INDICATOR_MANAGER_GET_CLASS(o) \
912
+ (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_INDICATOR_MANAGER, \
913
+ EmpathyIndicatorManagerClass))
915
+typedef struct _EmpathyIndicatorManager EmpathyIndicatorManager;
916
+typedef struct _EmpathyIndicatorManagerClass EmpathyIndicatorManagerClass;
918
+struct _EmpathyIndicatorManager {
923
+struct _EmpathyIndicatorManagerClass {
924
+ GObjectClass parent_class;
927
+GType empathy_indicator_manager_get_type (void) G_GNUC_CONST;
928
+EmpathyIndicatorManager *empathy_indicator_manager_dup_singleton (void);
929
+void empathy_indicator_manager_set_server_visible (
930
+ EmpathyIndicatorManager *manager,
932
+EmpathyIndicator *empathy_indicator_manager_create_indicator (
933
+ EmpathyIndicatorManager *manager,
934
+ EmpathyContact *sender,
935
+ const gchar *body);
936
+void empathy_indicator_manager_add_login_indicator (
937
+ EmpathyIndicatorManager *manager,
938
+ EmpathyContact *contact);
942
+#endif /* __EMPATHY_INDICATOR_MANAGER_H__ */
944
=== added file 'src/empathy-indicator.c'
945
--- src/empathy-indicator.c 1970-01-01 00:00:00 +0000
946
+++ src/empathy-indicator.c 2009-09-18 18:41:20 +0000
948
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
950
+ * Copyright (C) 2009 Canonical Ltd.
952
+ * This program is free software; you can redistribute it and/or
953
+ * modify it under the terms of the GNU General Public License as
954
+ * published by the Free Software Foundation; either version 2 of the
955
+ * License, or (at your option) any later version.
957
+ * This program is distributed in the hope that it will be useful,
958
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
959
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
960
+ * General Public License for more details.
962
+ * You should have received a copy of the GNU General Public
963
+ * License along with this program; if not, write to the
964
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
965
+ * Boston, MA 02110-1301 USA
967
+ * Authors: James Westby <james.westby@ubuntu.com>
971
+#include <gtk/gtk.h>
973
+#include <libempathy/empathy-contact.h>
974
+#include <libempathy/empathy-utils.h>
976
+#include "empathy-indicator.h"
977
+#include "empathy-misc.h"
979
+#include <libindicate/indicator.h>
981
+#define GET_PRIV(obj) EMPATHY_GET_PRIV ((obj), EmpathyIndicator)
996
+static guint signals[LAST_SIGNAL];
999
+ IndicateIndicator *indicator;
1000
+ EmpathyContact *contact;
1003
+} EmpathyIndicatorPriv;
1005
+G_DEFINE_TYPE (EmpathyIndicator, empathy_indicator, G_TYPE_OBJECT)
1009
+empathy_indicator_dispose (GObject *object)
1011
+ EmpathyIndicatorPriv *priv;
1013
+ priv = GET_PRIV (object);
1015
+ if (priv->indicator) {
1016
+ g_object_unref (priv->indicator);
1017
+ priv->indicator = NULL;
1019
+ if (priv->contact) {
1020
+ g_object_unref (priv->contact);
1021
+ priv->contact = NULL;
1024
+ G_OBJECT_CLASS (empathy_indicator_parent_class)->dispose (object);
1029
+empathy_indicator_finalize (GObject *object)
1031
+ EmpathyIndicatorPriv *priv;
1033
+ priv = GET_PRIV (object);
1035
+ g_free (priv->body);
1036
+ g_free (priv->subtype);
1038
+ G_OBJECT_CLASS (empathy_indicator_parent_class)->finalize (object);
1042
+indicate_show_cb (IndicateIndicator *indicator,
1043
+ EmpathyIndicator *e_indicator)
1045
+ g_signal_emit (e_indicator, signals[ACTIVATE], 0);
1049
+static IndicateIndicator *
1050
+empathy_indicator_get_indicator (EmpathyIndicator *e_indicator)
1052
+ EmpathyIndicatorPriv *priv;
1054
+ priv = GET_PRIV (e_indicator);
1055
+ if (priv->indicator)
1056
+ return priv->indicator;
1058
+ priv->indicator = indicate_indicator_new ();
1059
+ g_assert (priv->indicator);
1060
+ g_signal_connect (G_OBJECT (priv->indicator),
1061
+ INDICATE_INDICATOR_SIGNAL_DISPLAY,
1062
+ G_CALLBACK (indicate_show_cb),
1065
+ return priv->indicator;
1070
+empathy_indicator_set_property (GObject *object,
1072
+ const GValue *value,
1073
+ GParamSpec *pspec)
1075
+ EmpathyIndicator *e_indicator;
1076
+ EmpathyIndicatorPriv *priv;
1077
+ IndicateIndicator *indicator;
1080
+ e_indicator = EMPATHY_INDICATOR (object);
1081
+ priv = GET_PRIV (e_indicator);
1083
+ indicator = empathy_indicator_get_indicator (e_indicator);
1085
+ switch (param_id) {
1086
+ case PROP_CONTACT:
1087
+ priv->contact = g_object_ref (g_value_get_object (value));
1088
+ g_assert (priv->contact);
1089
+ indicate_indicator_set_property (indicator, "sender",
1090
+ empathy_contact_get_name (priv->contact));
1094
+ g_free (priv->body);
1095
+ priv->body = g_strdup (g_value_get_string (value));
1096
+ indicate_indicator_set_property (indicator, "body", priv->body);
1097
+ g_get_current_time (&time);
1098
+ indicate_indicator_set_property_time (indicator, "time", &time);
1100
+ case PROP_SUBTYPE:
1101
+ if (priv->subtype)
1102
+ g_free (priv->subtype);
1103
+ priv->subtype = g_strdup (g_value_get_string (value));
1104
+ indicate_indicator_set_property (indicator, "subtype", priv->subtype);
1106
+ case PROP_VISIBLE:
1107
+ if (g_value_get_boolean (value))
1108
+ indicate_indicator_show (indicator);
1110
+ indicate_indicator_hide (indicator);
1113
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
1120
+empathy_indicator_get_property (GObject *object,
1123
+ GParamSpec *pspec)
1125
+ EmpathyIndicator *e_indicator;
1126
+ EmpathyIndicatorPriv *priv;
1128
+ e_indicator = EMPATHY_INDICATOR (object);
1129
+ priv = GET_PRIV (e_indicator);
1131
+ switch (param_id) {
1132
+ case PROP_CONTACT:
1133
+ g_value_set_object (value, priv->contact);
1136
+ g_value_set_string (value, priv->body);
1138
+ case PROP_SUBTYPE:
1139
+ g_value_set_string (value, priv->subtype);
1141
+ case PROP_VISIBLE:
1142
+ g_value_set_boolean (value, indicate_indicator_is_visible (priv->indicator));
1145
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
1152
+empathy_indicator_class_init (EmpathyIndicatorClass *klass)
1154
+ GObjectClass *object_class;
1156
+ object_class = G_OBJECT_CLASS (klass);
1158
+ object_class->set_property = empathy_indicator_set_property;
1159
+ object_class->get_property = empathy_indicator_get_property;
1160
+ object_class->dispose = empathy_indicator_dispose;
1161
+ object_class->finalize = empathy_indicator_finalize;
1163
+ g_object_class_install_property (object_class, PROP_CONTACT,
1164
+ g_param_spec_object ("contact",
1166
+ "The contact being indicated",
1167
+ EMPATHY_TYPE_CONTACT,
1168
+ (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
1169
+ g_object_class_install_property (object_class, PROP_BODY,
1170
+ g_param_spec_string ("body",
1172
+ "The text for this contact",
1174
+ (G_PARAM_READWRITE | G_PARAM_CONSTRUCT)));
1175
+ g_object_class_install_property (object_class, PROP_SUBTYPE,
1176
+ g_param_spec_string ("subtype",
1178
+ "The type of this indicator",
1180
+ (G_PARAM_READWRITE | G_PARAM_CONSTRUCT)));
1181
+ g_object_class_install_property (object_class, PROP_VISIBLE,
1182
+ g_param_spec_boolean ("visible",
1184
+ "The visibility of this indicator",
1186
+ G_PARAM_READWRITE));
1188
+ signals[ACTIVATE] =
1189
+ g_signal_new ("activate",
1190
+ G_TYPE_FROM_CLASS (klass),
1191
+ G_SIGNAL_RUN_LAST,
1194
+ g_cclosure_marshal_VOID__VOID,
1198
+ g_type_class_add_private (object_class, sizeof (EmpathyIndicatorPriv));
1203
+empathy_indicator_init (EmpathyIndicator *e_indicator)
1205
+ e_indicator->priv = G_TYPE_INSTANCE_GET_PRIVATE (e_indicator,
1206
+ EMPATHY_TYPE_INDICATOR,
1207
+ EmpathyIndicatorPriv);
1212
+empathy_indicator_new (EmpathyContact *sender,
1213
+ const gchar *body,
1214
+ const gchar *subtype)
1216
+ return g_object_new (EMPATHY_TYPE_INDICATOR, "contact", sender, "body", body,
1217
+ "subtype", subtype, NULL);
1222
+empathy_indicator_show (EmpathyIndicator *e_indicator)
1224
+ g_object_set (e_indicator, "visible", TRUE, NULL);
1229
+empathy_indicator_hide (EmpathyIndicator *e_indicator)
1231
+ g_object_set (e_indicator, "visible", FALSE, NULL);
1236
+empathy_indicator_update (EmpathyIndicator *e_indicator,
1237
+ const gchar *body)
1239
+ g_object_set (e_indicator, "body", body, NULL);
1244
+empathy_indicator_get_contact (EmpathyIndicator *e_indicator)
1246
+ EmpathyContact *contact;
1247
+ g_object_get (e_indicator, "contact", &contact, NULL);
1251
=== added file 'src/empathy-indicator.h'
1252
--- src/empathy-indicator.h 1970-01-01 00:00:00 +0000
1253
+++ src/empathy-indicator.h 2009-09-18 18:41:20 +0000
1255
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
1257
+ * Copyright (C) 2009 Canonical Ltd.
1259
+ * This program is free software; you can redistribute it and/or
1260
+ * modify it under the terms of the GNU General Public License as
1261
+ * published by the Free Software Foundation; either version 2 of the
1262
+ * License, or (at your option) any later version.
1264
+ * This program is distributed in the hope that it will be useful,
1265
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1266
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1267
+ * General Public License for more details.
1269
+ * You should have received a copy of the GNU General Public
1270
+ * License along with this program; if not, write to the
1271
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
1272
+ * Boston, MA 02110-1301 USA
1274
+ * Authors: James Westby <james.westby@ubuntu.com>
1278
+#ifndef __EMPATHY_INDICATOR_H__
1279
+#define __EMPATHY_INDICATOR_H__
1283
+#include <libempathy/empathy-contact.h>
1287
+#define EMPATHY_TYPE_INDICATOR (empathy_indicator_get_type ())
1288
+#define EMPATHY_INDICATOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_INDICATOR, EmpathyIndicator))
1289
+#define EMPATHY_INDICATOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_INDICATOR, EmpathyIndicatorClass))
1290
+#define EMPATHY_IS_INDICATOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_INDICATOR))
1291
+#define EMPATHY_IS_INDICATOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_INDICATOR))
1292
+#define EMPATHY_INDICATOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_INDICATOR, EmpathyIndicatorClass))
1294
+typedef struct _EmpathyIndicator EmpathyIndicator;
1295
+typedef struct _EmpathyIndicatorClass EmpathyIndicatorClass;
1297
+struct _EmpathyIndicator {
1302
+struct _EmpathyIndicatorClass {
1303
+ GObjectClass parent_class;
1306
+GType empathy_indicator_get_type (void) G_GNUC_CONST;
1307
+EmpathyIndicator *empathy_indicator_new (EmpathyContact *sender,
1308
+ const gchar *body,
1309
+ const gchar *type);
1310
+void empathy_indicator_show (EmpathyIndicator *e_indicator);
1311
+void empathy_indicator_hide (EmpathyIndicator *e_indicator);
1312
+void empathy_indicator_update (EmpathyIndicator *e_indicator,
1313
+ const gchar *body);
1314
+EmpathyContact *empathy_indicator_get_contact (EmpathyIndicator *e_indicator);
1319
+#endif /* __EMPATHY-INDICATOR_H__ */
1321
=== modified file 'src/empathy-main-window.c'
1322
--- src/empathy-main-window.c 2009-09-18 18:41:05 +0000
1323
+++ src/empathy-main-window.c 2009-09-18 18:41:20 +0000
1325
#include "empathy-event-manager.h"
1326
#include "empathy-ft-manager.h"
1328
+#ifdef HAVE_LIBINDICATE
1329
+#include "empathy-indicator-manager.h"
1332
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
1333
#include <libempathy/empathy-debug.h>
1335
@@ -111,6 +115,10 @@
1337
/* Actions that are enabled when there are connected accounts */
1338
GList *actions_connected;
1339
+#ifdef HAVE_LIBINDICATE
1340
+ EmpathyIndicatorManager *indicator_manager;
1341
+ GHashTable *indicator_timeouts;
1343
} EmpathyMainWindow;
1345
static EmpathyMainWindow *window = NULL;
1346
@@ -600,6 +608,10 @@
1347
/* someone is logging in */
1348
empathy_sound_play (GTK_WIDGET (window->window),
1349
EMPATHY_SOUND_CONTACT_CONNECTED);
1350
+#ifdef HAVE_LIBINDICATE
1351
+ empathy_indicator_manager_add_login_indicator (window->indicator_manager,
1357
@@ -664,6 +676,10 @@
1358
g_object_unref (window->event_manager);
1359
g_object_unref (window->ui_manager);
1361
+#ifdef HAVE_LIBINDICATE
1362
+ g_object_unref (window->indicator_manager);
1368
@@ -1238,6 +1254,10 @@
1369
"help_contents", "activate", main_window_help_contents_cb,
1372
+#ifdef HAVE_LIBINDICATE
1373
+ window->indicator_manager = empathy_indicator_manager_dup_singleton ();
1376
/* Set up connection related widgets. */
1377
main_window_connection_items_setup (window, gui);
1380
=== modified file 'src/empathy-preferences.c'
1381
--- src/empathy-preferences.c 2009-09-18 18:41:05 +0000
1382
+++ src/empathy-preferences.c 2009-09-18 18:41:20 +0000
1385
GtkWidget *checkbutton_show_smileys;
1386
GtkWidget *checkbutton_show_contacts_in_rooms;
1387
+ GtkWidget *checkbutton_use_libindicate;
1388
GtkWidget *combobox_chat_theme;
1389
GtkWidget *checkbutton_separate_chat_windows;
1390
GtkWidget *checkbutton_autoconnect;
1391
@@ -215,6 +216,14 @@
1392
EMPATHY_PREFS_CHAT_SHOW_SMILEYS,
1393
preferences->checkbutton_show_smileys);
1395
+#ifdef HAVE_LIBINDICATE
1396
+ preferences_hookup_toggle_button (preferences,
1397
+ EMPATHY_PREFS_UI_USE_LIBINDICATE,
1398
+ preferences->checkbutton_use_libindicate);
1400
+ gtk_widget_hide (GTK_WIDGET (preferences->checkbutton_use_libindicate));
1403
preferences_hookup_toggle_button (preferences,
1404
EMPATHY_PREFS_CHAT_SHOW_CONTACTS_IN_ROOMS,
1405
preferences->checkbutton_show_contacts_in_rooms);
1406
@@ -1137,6 +1146,7 @@
1407
"notebook", &preferences->notebook,
1408
"checkbutton_show_smileys", &preferences->checkbutton_show_smileys,
1409
"checkbutton_show_contacts_in_rooms", &preferences->checkbutton_show_contacts_in_rooms,
1410
+ "checkbutton_use_libindicate", &preferences->checkbutton_use_libindicate,
1411
"combobox_chat_theme", &preferences->combobox_chat_theme,
1412
"checkbutton_separate_chat_windows", &preferences->checkbutton_separate_chat_windows,
1413
"checkbutton_autoconnect", &preferences->checkbutton_autoconnect,
1415
=== modified file 'src/empathy-preferences.ui'
1416
--- src/empathy-preferences.ui 2009-09-18 18:41:05 +0000
1417
+++ src/empathy-preferences.ui 2009-09-18 18:41:20 +0000
1418
@@ -250,6 +250,20 @@
1419
<property name="position">1</property>
1423
+ <object class="GtkCheckButton" id="checkbutton_use_libindicate">
1424
+ <property name="label" translatable="yes">Use message indicators</property>
1425
+ <property name="visible">True</property>
1426
+ <property name="can_focus">True</property>
1427
+ <property name="receives_default">False</property>
1428
+ <property name="draw_indicator">True</property>
1431
+ <property name="expand">False</property>
1432
+ <property name="fill">False</property>
1433
+ <property name="position">2</property>
1438
<property name="position">1</property>
1440
=== modified file 'src/empathy-status-icon.c'
1441
--- src/empathy-status-icon.c 2009-09-18 18:41:05 +0000
1442
+++ src/empathy-status-icon.c 2009-09-18 18:41:20 +0000
1444
#include <gtk/gtk.h>
1445
#include <gdk/gdkkeysyms.h>
1447
+#include <libnotify/notify.h>
1448
#include <libnotify/notification.h>
1450
#include <libempathy/empathy-utils.h>
1452
#include <libempathy-gtk/empathy-images.h>
1453
#include <libempathy-gtk/empathy-new-message-dialog.h>
1455
+#include <telepathy-glib/util.h>
1457
#include "empathy-accounts-dialog.h"
1458
#include "empathy-status-icon.h"
1459
#include "empathy-preferences.h"
1460
#include "empathy-event-manager.h"
1461
#include "empathy-misc.h"
1463
+#ifdef HAVE_LIBINDICATE
1464
+#include "empathy-indicator-manager.h"
1467
#define DEBUG_FLAG EMPATHY_DEBUG_DISPATCHER
1468
#include <libempathy/empathy-debug.h>
1471
GtkAction *show_window_item;
1472
GtkAction *new_message_item;
1473
GtkAction *status_item;
1474
+#ifdef HAVE_LIBINDICATE
1475
+ EmpathyIndicatorManager *indicator_manager;
1477
} EmpathyStatusIconPriv;
1479
G_DEFINE_TYPE (EmpathyStatusIcon, empathy_status_icon, G_TYPE_OBJECT);
1484
+/* Query whether the notification server supports the "action"
1485
+ * extension to the notifications specification, if it doesn't
1486
+ * the sending actions has undefined results.
1489
+notification_server_supports_actions (void)
1491
+ GList *caps = notify_get_server_caps ();
1493
+ gboolean ret = FALSE;
1495
+ for (l = caps; l; l = l->next) {
1496
+ gchar *cap = (gchar *) l->data;
1500
+ if (!tp_strdiff (cap, "actions")) {
1505
+ g_list_foreach (caps, (GFunc)g_free, NULL);
1506
+ g_list_free (caps);
1512
status_icon_notification_closed_cb (NotifyNotification *notification,
1513
EmpathyStatusIcon *icon)
1514
@@ -110,8 +147,14 @@
1516
g_idle_add ((GSourceFunc) activate_event, priv->event);
1518
- /* inhibit other updates for this event */
1519
- empathy_event_inhibit_updates (priv->event);
1520
+ /* inhibit other updates for this event, but only if
1521
+ * the server supports actions, using that as a proxy
1522
+ * for being click-through, as many notifications aren't
1523
+ * a problem then. Maybe not the right thing to do.
1525
+ if (notification_server_supports_actions ()) {
1526
+ empathy_event_inhibit_updates (priv->event);
1531
@@ -318,6 +361,28 @@
1535
+#ifdef HAVE_LIBINDICATE
1537
+status_icon_set_use_libindicate (EmpathyStatusIcon *icon,
1538
+ gboolean use_libindicate)
1540
+ EmpathyStatusIconPriv *priv = GET_PRIV (icon);
1542
+ if (use_libindicate) {
1543
+ empathy_indicator_manager_set_server_visible (priv->indicator_manager,
1545
+ /* Hide the status icon so there are not two ways to access empathy.
1546
+ * Should use libindicate's "interest" to confirm someone is listening.
1548
+ gtk_status_icon_set_visible (priv->icon, FALSE);
1550
+ empathy_indicator_manager_set_server_visible (priv->indicator_manager,
1552
+ gtk_status_icon_set_visible (priv->icon, TRUE);
1558
status_icon_notify_visibility_cb (EmpathyConf *conf,
1560
@@ -331,16 +396,56 @@
1564
+#ifdef HAVE_LIBINDICATE
1566
+status_icon_notify_libindicate_cb (EmpathyConf *conf,
1568
+ gpointer user_data)
1570
+ EmpathyStatusIcon *icon = user_data;
1571
+ gboolean use_libindicate = FALSE;
1573
+ if (empathy_conf_get_bool (conf, key, &use_libindicate)) {
1574
+ status_icon_set_use_libindicate (icon, use_libindicate);
1580
status_icon_toggle_visibility (EmpathyStatusIcon *icon)
1582
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
1584
+#ifdef HAVE_LIBINDICATE
1585
+ gboolean use_libindicate;
1588
visible = gtk_window_is_active (priv->window);
1589
+#ifdef HAVE_LIBINDICATE
1590
+ empathy_conf_get_bool (empathy_conf_get (),
1591
+ EMPATHY_PREFS_UI_USE_LIBINDICATE,
1592
+ &use_libindicate);
1593
+ if (use_libindicate) {
1594
+ /* If indicators are used then we may very well not be active
1595
+ * when toggled, as they are usually windows themselves. This
1596
+ * makes it damn hard to toggle, so we just look at whether
1599
+ visible = GTK_WIDGET_VISIBLE (priv->window);
1602
status_icon_set_visibility (icon, !visible, TRUE);
1605
+#ifdef HAVE_LIBINDICATE
1607
+indicate_server_activate_cb (EmpathyIndicatorManager *manager,
1608
+ EmpathyStatusIcon *icon)
1610
+ status_icon_toggle_visibility (icon);
1615
status_icon_idle_notify_cb (EmpathyStatusIcon *icon)
1617
@@ -521,6 +626,10 @@
1618
g_object_unref (priv->account_manager);
1619
g_object_unref (priv->event_manager);
1620
g_object_unref (priv->ui_manager);
1622
+#ifdef HAVE_LIBINDICATE
1623
+ g_object_unref (priv->indicator_manager);
1628
@@ -555,6 +664,13 @@
1629
status_icon_notify_visibility_cb,
1632
+#ifdef HAVE_LIBINDICATE
1633
+ empathy_conf_notify_add (empathy_conf_get (),
1634
+ EMPATHY_PREFS_UI_USE_LIBINDICATE,
1635
+ status_icon_notify_libindicate_cb,
1639
status_icon_create_menu (icon);
1640
status_icon_idle_notify_cb (icon);
1643
EmpathyStatusIconPriv *priv;
1644
EmpathyStatusIcon *icon;
1645
gboolean should_hide;
1646
+#ifdef HAVE_LIBINDICATE
1647
+ gboolean use_libindicate;
1650
g_return_val_if_fail (GTK_IS_WINDOW (window), NULL);
1652
@@ -591,6 +710,12 @@
1653
priv = GET_PRIV (icon);
1655
priv->window = g_object_ref (window);
1656
+#ifdef HAVE_LIBINDICATE
1657
+ priv->indicator_manager = empathy_indicator_manager_dup_singleton ();
1658
+ g_signal_connect (priv->indicator_manager, "server-activate",
1659
+ G_CALLBACK (indicate_server_activate_cb),
1663
g_signal_connect_after (priv->window, "key-press-event",
1664
G_CALLBACK (status_icon_key_press_event_cb),
1665
@@ -608,6 +733,13 @@
1669
+#ifdef HAVE_LIBINDICATE
1670
+ empathy_conf_get_bool (empathy_conf_get (),
1671
+ EMPATHY_PREFS_UI_USE_LIBINDICATE,
1672
+ &use_libindicate);
1673
+ status_icon_set_use_libindicate (icon, use_libindicate);
1676
if (gtk_window_is_active (priv->window) == should_hide) {
1677
status_icon_set_visibility (icon, !should_hide, FALSE);