1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3
* Copyright (C) 2007-2008 Collabora Ltd.
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
* Authors: Xavier Claessens <xclaesse@gmail.com>
29
#include <gdk/gdkkeysyms.h>
30
#include <glib/gi18n.h>
32
#include <libnotify/notify.h>
33
#include <libnotify/notification.h>
34
#include <libnotify/notify.h>
36
#include <telepathy-glib/account-manager.h>
37
#include <telepathy-glib/util.h>
38
#include <telepathy-yell/telepathy-yell.h>
40
#include <libempathy/empathy-gsettings.h>
41
#include <libempathy/empathy-utils.h>
42
#include <libempathy/empathy-tp-streamed-media.h>
44
#include <libempathy-gtk/empathy-presence-chooser.h>
45
#include <libempathy-gtk/empathy-ui-utils.h>
46
#include <libempathy-gtk/empathy-images.h>
47
#include <libempathy-gtk/empathy-new-message-dialog.h>
48
#include <libempathy-gtk/empathy-new-call-dialog.h>
49
#include <libempathy-gtk/empathy-notify-manager.h>
51
#include "empathy-accounts-dialog.h"
52
#include "empathy-status-icon.h"
53
#include "empathy-preferences.h"
54
#include "empathy-event-manager.h"
56
#ifdef HAVE_LIBINDICATE
57
#include "empathy-indicator-manager.h"
58
#include <libindicate/server.h>
59
#include <libindicate/interests.h>
62
#define DEBUG_FLAG EMPATHY_DEBUG_DISPATCHER
63
#include <libempathy/empathy-debug.h>
65
/* Number of ms to wait when blinking */
66
#define BLINK_TIMEOUT 500
68
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyStatusIcon)
71
TpAccountManager *account_manager;
72
EmpathyNotifyManager *notify_mgr;
73
gboolean showing_event_icon;
75
EmpathyEventManager *event_manager;
77
NotifyNotification *notification;
78
GSettings *gsettings_ui;
81
GtkUIManager *ui_manager;
82
GtkWidget *popup_menu;
83
GtkAction *show_window_item;
84
GtkAction *new_message_item;
85
GtkAction *status_item;
86
#ifdef HAVE_LIBINDICATE
87
EmpathyIndicatorManager *indicator_manager;
88
IndicateServer *indicate_server;
90
} EmpathyStatusIconPriv;
92
G_DEFINE_TYPE (EmpathyStatusIcon, empathy_status_icon, G_TYPE_OBJECT);
95
status_icon_notification_closed_cb (NotifyNotification *notification,
96
EmpathyStatusIcon *icon)
98
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
100
g_object_unref (notification);
102
if (priv->notification == notification) {
103
priv->notification = NULL;
110
/* inhibit other updates for this event */
111
empathy_event_inhibit_updates (priv->event);
115
notification_close_helper (EmpathyStatusIconPriv *priv)
117
if (priv->notification != NULL) {
118
notify_notification_close (priv->notification, NULL);
119
priv->notification = NULL;
124
notification_approve_no_video_cb (NotifyNotification *notification,
126
EmpathyStatusIcon *icon)
128
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
131
tpy_call_channel_send_video (
132
TPY_CALL_CHANNEL (priv->event->handler_instance),
134
empathy_event_approve (priv->event);
139
notification_approve_cb (NotifyNotification *notification,
141
EmpathyStatusIcon *icon)
143
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
146
empathy_event_approve (priv->event);
150
notification_decline_cb (NotifyNotification *notification,
152
EmpathyStatusIcon *icon)
154
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
157
empathy_event_decline (priv->event);
161
add_notification_actions (EmpathyStatusIcon *self,
162
NotifyNotification *notification)
164
EmpathyStatusIconPriv *priv = GET_PRIV (self);
167
switch (priv->event->type) {
168
case EMPATHY_EVENT_TYPE_CHAT:
169
notify_notification_add_action (notification,
170
"respond", _("Respond"), (NotifyActionCallback) notification_approve_cb,
174
case EMPATHY_EVENT_TYPE_VOIP:
175
case EMPATHY_EVENT_TYPE_CALL:
176
if (priv->event->type == EMPATHY_EVENT_TYPE_VOIP)
177
video = empathy_tp_streamed_media_has_initial_video (
178
EMPATHY_TP_STREAMED_MEDIA (priv->event->handler_instance));
180
video = tpy_call_channel_has_initial_video (
181
TPY_CALL_CHANNEL (priv->event->handler_instance));
183
notify_notification_add_action (notification,
184
"reject", _("Reject"), (NotifyActionCallback) notification_decline_cb,
188
if (video && priv->event->type == EMPATHY_EVENT_TYPE_CALL)
189
notify_notification_add_action (notification,
190
"answer-no-video", _("Answer"), (NotifyActionCallback)
191
notification_approve_no_video_cb,
194
notify_notification_add_action (notification,
195
"answer", video ? _("Answer with video") : _("Answer"),
196
(NotifyActionCallback) notification_approve_cb,
200
case EMPATHY_EVENT_TYPE_TRANSFER:
201
case EMPATHY_EVENT_TYPE_INVITATION:
202
notify_notification_add_action (notification,
203
"decline", _("Decline"), (NotifyActionCallback) notification_decline_cb,
206
notify_notification_add_action (notification,
207
"accept", _("Accept"), (NotifyActionCallback) notification_approve_cb,
217
status_icon_update_notification (EmpathyStatusIcon *icon)
219
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
220
GdkPixbuf *pixbuf = NULL;
222
if (!empathy_notify_manager_notification_is_enabled (priv->notify_mgr)) {
223
/* always close the notification if this happens */
224
notification_close_helper (priv);
229
if (priv->event->type == EMPATHY_EVENT_TYPE_VOIP
230
|| priv->event->type == EMPATHY_EVENT_TYPE_CALL
231
|| priv->event->type == EMPATHY_EVENT_TYPE_TRANSFER) {
232
empathy_event_activate (priv->event);
235
gchar *message_esc = NULL;
236
gboolean has_x_canonical_append;
237
NotifyNotification *notification = priv->notification;
239
if (priv->event->message != NULL)
240
message_esc = g_markup_escape_text (priv->event->message, -1);
242
has_x_canonical_append =
243
empathy_notify_manager_has_capability (priv->notify_mgr,
244
EMPATHY_NOTIFY_MANAGER_CAP_X_CANONICAL_APPEND);
246
if (notification != NULL && ! has_x_canonical_append) {
247
/* if the notification server supports x-canonical-append, it is
248
better to not use notify_notification_update to avoid
249
overwriting the current notification message */
250
notify_notification_update (notification,
251
priv->event->header, message_esc,
254
/* if the notification server supports x-canonical-append,
255
the hint will be added, so that the message from the
256
just created notification will be automatically appended
257
to an existing notification with the same title.
258
In this way the previous message will not be lost: the new
259
message will appear below it, in the same notification */
260
notification = notify_notification_new
261
(priv->event->header, message_esc, NULL);
263
if (priv->notification == NULL) {
264
priv->notification = notification;
267
notify_notification_set_timeout (notification,
268
NOTIFY_EXPIRES_DEFAULT);
270
if (has_x_canonical_append) {
271
notify_notification_set_hint_string (notification,
272
EMPATHY_NOTIFY_MANAGER_CAP_X_CANONICAL_APPEND, "");
275
if (empathy_notify_manager_has_capability (priv->notify_mgr,
276
EMPATHY_NOTIFY_MANAGER_CAP_ACTIONS))
277
add_notification_actions (icon, notification);
279
g_signal_connect (notification, "closed",
280
G_CALLBACK (status_icon_notification_closed_cb), icon);
283
pixbuf = empathy_notify_manager_get_pixbuf_for_notification (
284
priv->notify_mgr, priv->event->contact,
285
priv->event->icon_name);
287
if (pixbuf != NULL) {
288
notify_notification_set_icon_from_pixbuf (notification, pixbuf);
289
g_object_unref (pixbuf);
292
notify_notification_show (notification, NULL);
294
g_free (message_esc);
296
notification_close_helper (priv);
301
status_icon_update_tooltip (EmpathyStatusIcon *icon)
303
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
306
gchar *tooltip = NULL;
308
if (priv->event->message != NULL)
309
tooltip = g_markup_printf_escaped ("<i>%s</i>\n%s",
311
priv->event->message);
313
tooltip = g_markup_printf_escaped ("<i>%s</i>",
314
priv->event->header);
315
gtk_status_icon_set_tooltip_markup (priv->icon, tooltip);
318
TpConnectionPresenceType type;
321
type = tp_account_manager_get_most_available_presence (
322
priv->account_manager, NULL, &msg);
324
if (!EMP_STR_EMPTY (msg)) {
325
gtk_status_icon_set_tooltip_text (priv->icon, msg);
328
gtk_status_icon_set_tooltip_text (priv->icon,
329
empathy_presence_get_default_message (type));
337
status_icon_update_icon (EmpathyStatusIcon *icon)
339
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
340
const gchar *icon_name;
342
if (priv->event && priv->showing_event_icon) {
343
icon_name = priv->event->icon_name;
345
TpConnectionPresenceType state;
347
state = tp_account_manager_get_most_available_presence (
348
priv->account_manager, NULL, NULL);
350
/* An unset presence type here doesn't make sense. Force it
352
if (state == TP_CONNECTION_PRESENCE_TYPE_UNSET) {
353
state = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
356
icon_name = empathy_icon_name_for_presence (state);
359
if (icon_name != NULL)
360
gtk_status_icon_set_from_icon_name (priv->icon, icon_name);
364
status_icon_blink_timeout_cb (EmpathyStatusIcon *icon)
366
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
368
priv->showing_event_icon = !priv->showing_event_icon;
369
status_icon_update_icon (icon);
374
status_icon_event_added_cb (EmpathyEventManager *manager,
376
EmpathyStatusIcon *icon)
378
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
384
if (event->type == EMPATHY_EVENT_TYPE_AUTH) {
388
DEBUG ("New event %p", event);
391
if (event->must_ack || event->type == EMPATHY_EVENT_TYPE_AUTH) {
392
priv->showing_event_icon = TRUE;
393
status_icon_update_icon (icon);
394
status_icon_update_tooltip (icon);
396
status_icon_update_notification (icon);
398
if (!priv->blink_timeout && priv->showing_event_icon) {
399
priv->blink_timeout = g_timeout_add (BLINK_TIMEOUT,
400
(GSourceFunc) status_icon_blink_timeout_cb,
406
status_icon_event_removed_cb (EmpathyEventManager *manager,
408
EmpathyStatusIcon *icon)
410
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
412
if (event != priv->event) {
416
if (event->type == EMPATHY_EVENT_TYPE_AUTH) {
420
priv->event = empathy_event_manager_get_top_event (priv->event_manager);
422
status_icon_update_tooltip (icon);
423
status_icon_update_icon (icon);
425
/* update notification anyway, as it's safe and we might have been
426
* changed presence in the meanwhile
428
status_icon_update_notification (icon);
430
if (!priv->event && priv->blink_timeout) {
431
g_source_remove (priv->blink_timeout);
432
priv->blink_timeout = 0;
437
status_icon_event_updated_cb (EmpathyEventManager *manager,
439
EmpathyStatusIcon *icon)
441
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
443
if (event != priv->event) {
447
if (event->type == EMPATHY_EVENT_TYPE_AUTH) {
451
if (empathy_notify_manager_notification_is_enabled (priv->notify_mgr)) {
452
status_icon_update_notification (icon);
455
status_icon_update_tooltip (icon);
459
status_icon_set_visibility (EmpathyStatusIcon *icon,
463
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
466
g_settings_set_boolean (priv->gsettings_ui,
467
EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN,
472
empathy_window_iconify (priv->window, priv->icon);
474
empathy_window_present (GTK_WINDOW (priv->window));
477
#ifdef HAVE_LIBINDICATE
479
empathy_status_icon_set_visible (gboolean show_icon, EmpathyStatusIcon *icon)
481
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
482
gtk_status_icon_set_visible (priv->icon, show_icon);
486
empathy_indicator_interest_status_icon (gboolean icon_visibility,
487
EmpathyStatusIcon *icon)
489
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
490
EmpathyIndicatorManager *manager;
491
gboolean use_libindicate;
493
manager = empathy_indicator_manager_dup_singleton();
494
use_libindicate = g_settings_get_boolean (priv->gsettings_ui,
495
EMPATHY_PREFS_UI_USE_LIBINDICATE);
497
if (use_libindicate && !icon_visibility) {
498
empathy_indicator_manager_set_server_visible (manager, TRUE);
499
/* Hide the status icon so there are not two ways to access
502
DEBUG ("Hiding the icon, we are shown in the indicator");
503
empathy_status_icon_set_visible (FALSE, icon);
505
empathy_indicator_manager_set_server_visible (manager,
507
DEBUG ("Show the icon, we are not shown in the indicator");
508
empathy_status_icon_set_visible (TRUE, icon);
513
empathy_indicator_interest_added (IndicateServer * server,
514
IndicateInterests interest, EmpathyStatusIcon *icon)
516
if (interest != INDICATE_INTEREST_SERVER_SIGNAL) {
519
DEBUG ("Indicator received interest-added signal");
520
empathy_indicator_interest_status_icon(FALSE, icon);
524
empathy_indicator_interest_removed (IndicateServer * server,
525
IndicateInterests interest, EmpathyStatusIcon *icon)
527
if (interest != INDICATE_INTEREST_SERVER_SIGNAL) {
531
DEBUG ("Indicator received interest-removed signal");
532
empathy_indicator_interest_status_icon(TRUE, icon);
536
status_icon_set_use_libindicate (EmpathyStatusIcon *icon,
537
gboolean use_libindicate)
539
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
541
if (use_libindicate) {
542
empathy_indicator_manager_set_server_visible (priv->indicator_manager, TRUE);
544
empathy_indicator_manager_set_server_visible (priv->indicator_manager, FALSE);
545
empathy_status_icon_set_visible(TRUE, icon);
550
status_icon_notify_libindicate_cb (GSettings *gsettings,
554
EmpathyStatusIcon *icon = user_data;
555
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
556
gboolean use_libindicate;
558
use_libindicate = g_settings_get_boolean (priv->gsettings_ui,
559
EMPATHY_PREFS_UI_USE_LIBINDICATE);
560
status_icon_set_use_libindicate (icon, use_libindicate);
565
status_icon_notify_visibility_cb (GSettings *gsettings,
569
EmpathyStatusIcon *icon = user_data;
570
gboolean hidden = FALSE;
572
hidden = g_settings_get_boolean (gsettings, key);
573
status_icon_set_visibility (icon, !hidden, FALSE);
577
status_icon_toggle_visibility (EmpathyStatusIcon *icon)
579
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
583
visible = gtk_window_is_active (priv->window);
584
#ifdef HAVE_LIBINDICATE
585
gboolean use_libindicate;
586
use_libindicate = g_settings_get_boolean (priv->gsettings_ui,
587
EMPATHY_PREFS_UI_USE_LIBINDICATE);
588
if (use_libindicate) {
589
/* If indicators are used then we may very well not be active
590
* when toggled, as they are usually windows themselves. This
591
* makes it damn hard to toggle, so we just look at whether
594
visible = GTK_WIDGET_VISIBLE (priv->window);
595
status_icon_set_visibility (icon, TRUE, TRUE);
600
status_icon_set_visibility (icon, !visible, TRUE);
603
#ifdef HAVE_LIBINDICATE
605
indicate_server_activate_cb (EmpathyIndicatorManager *manager,
606
guint timestamp, EmpathyStatusIcon *icon)
608
status_icon_toggle_visibility (icon);
613
status_icon_presence_changed_cb (EmpathyStatusIcon *icon)
615
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
617
status_icon_update_icon (icon);
618
status_icon_update_tooltip (icon);
620
if (!empathy_notify_manager_notification_is_enabled (priv->notify_mgr)) {
621
/* dismiss the outstanding notification if present */
623
if (priv->notification) {
624
notify_notification_close (priv->notification, NULL);
625
priv->notification = NULL;
631
status_icon_delete_event_cb (GtkWidget *widget,
633
EmpathyStatusIcon *icon)
635
status_icon_set_visibility (icon, FALSE, TRUE);
640
status_icon_key_press_event_cb (GtkWidget *window,
642
EmpathyStatusIcon *icon)
644
if (event->keyval == GDK_Escape) {
645
status_icon_set_visibility (icon, FALSE, TRUE);
651
status_icon_activate_cb (GtkStatusIcon *status_icon,
652
EmpathyStatusIcon *icon)
654
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
656
DEBUG ("%s", priv->event ? "event" : "toggle");
659
empathy_event_activate (priv->event);
661
status_icon_toggle_visibility (icon);
666
status_icon_show_hide_window_cb (GtkToggleAction *action,
667
EmpathyStatusIcon *icon)
671
visible = gtk_toggle_action_get_active (action);
672
status_icon_set_visibility (icon, visible, TRUE);
676
status_icon_new_message_cb (GtkAction *action,
677
EmpathyStatusIcon *icon)
679
empathy_new_message_dialog_show (NULL);
683
status_icon_new_call_cb (GtkAction *action,
684
EmpathyStatusIcon *icon)
686
empathy_new_call_dialog_show (NULL);
690
status_icon_quit_cb (GtkAction *action,
691
EmpathyStatusIcon *icon)
697
status_icon_popup_menu_cb (GtkStatusIcon *status_icon,
700
EmpathyStatusIcon *icon)
702
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
703
GtkWidget *menu_item;
707
show = empathy_window_get_is_visible (GTK_WINDOW (priv->window));
709
g_signal_handlers_block_by_func (priv->show_window_item,
710
status_icon_show_hide_window_cb,
712
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (priv->show_window_item),
714
g_signal_handlers_unblock_by_func (priv->show_window_item,
715
status_icon_show_hide_window_cb,
718
menu_item = gtk_ui_manager_get_widget (priv->ui_manager, "/menu/status");
719
submenu = empathy_presence_chooser_create_menu ();
720
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), submenu);
722
gtk_menu_popup (GTK_MENU (priv->popup_menu),
724
gtk_status_icon_position_menu,
731
status_icon_create_menu (EmpathyStatusIcon *icon)
733
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
737
filename = empathy_file_lookup ("empathy-status-icon.ui", "src");
738
gui = empathy_builder_get_file (filename,
739
"ui_manager", &priv->ui_manager,
740
"menu", &priv->popup_menu,
741
"show_list", &priv->show_window_item,
742
"new_message", &priv->new_message_item,
743
"status", &priv->status_item,
747
empathy_builder_connect (gui, icon,
748
"show_list", "toggled", status_icon_show_hide_window_cb,
749
"new_message", "activate", status_icon_new_message_cb,
750
"new_call", "activate", status_icon_new_call_cb,
751
"quit", "activate", status_icon_quit_cb,
754
g_object_ref (priv->ui_manager);
755
g_object_unref (gui);
759
status_icon_status_changed_cb (TpAccount *account,
760
TpConnectionStatus current,
761
TpConnectionStatus previous,
762
TpConnectionStatusReason reason,
763
gchar *dbus_error_name,
765
EmpathyStatusIcon *icon)
767
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
769
gtk_action_set_sensitive (priv->new_message_item,
770
empathy_account_manager_get_accounts_connected (NULL));
774
status_icon_finalize (GObject *object)
776
EmpathyStatusIconPriv *priv = GET_PRIV (object);
778
if (priv->blink_timeout) {
779
g_source_remove (priv->blink_timeout);
782
if (priv->notification) {
783
notify_notification_close (priv->notification, NULL);
784
g_object_unref (priv->notification);
785
priv->notification = NULL;
788
g_object_unref (priv->icon);
789
g_object_unref (priv->account_manager);
790
g_object_unref (priv->event_manager);
791
g_object_unref (priv->ui_manager);
792
g_object_unref (priv->notify_mgr);
793
g_object_unref (priv->gsettings_ui);
794
g_object_unref (priv->window);
795
#ifdef HAVE_LIBINDICATE
796
g_object_unref (priv->indicator_manager);
801
empathy_status_icon_class_init (EmpathyStatusIconClass *klass)
803
GObjectClass *object_class = G_OBJECT_CLASS (klass);
805
object_class->finalize = status_icon_finalize;
807
g_type_class_add_private (object_class, sizeof (EmpathyStatusIconPriv));
811
account_manager_prepared_cb (GObject *source_object,
812
GAsyncResult *result,
816
TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
817
EmpathyStatusIcon *icon = user_data;
818
GError *error = NULL;
820
if (!tp_account_manager_prepare_finish (account_manager, result, &error)) {
821
DEBUG ("Failed to prepare account manager: %s", error->message);
822
g_error_free (error);
826
list = tp_account_manager_get_valid_accounts (account_manager);
827
for (l = list; l != NULL; l = l->next) {
828
tp_g_signal_connect_object (l->data, "status-changed",
829
G_CALLBACK (status_icon_status_changed_cb),
834
status_icon_presence_changed_cb (icon);
838
empathy_status_icon_init (EmpathyStatusIcon *icon)
840
EmpathyStatusIconPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (icon,
841
EMPATHY_TYPE_STATUS_ICON, EmpathyStatusIconPriv);
844
priv->icon = gtk_status_icon_new ();
845
priv->account_manager = tp_account_manager_dup ();
846
priv->event_manager = empathy_event_manager_dup_singleton ();
848
tp_account_manager_prepare_async (priv->account_manager, NULL,
849
account_manager_prepared_cb, icon);
851
/* make icon listen and respond to MAIN_WINDOW_HIDDEN changes */
852
priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
853
g_signal_connect (priv->gsettings_ui,
854
"changed::" EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN,
855
G_CALLBACK (status_icon_notify_visibility_cb),
858
#ifdef HAVE_LIBINDICATE
859
g_signal_connect (priv->gsettings_ui,
860
"changed::" EMPATHY_PREFS_UI_USE_LIBINDICATE,
861
G_CALLBACK (status_icon_notify_libindicate_cb),
865
status_icon_create_menu (icon);
867
g_signal_connect_swapped (priv->account_manager,
868
"most-available-presence-changed",
869
G_CALLBACK (status_icon_presence_changed_cb),
871
g_signal_connect (priv->event_manager, "event-added",
872
G_CALLBACK (status_icon_event_added_cb),
874
g_signal_connect (priv->event_manager, "event-removed",
875
G_CALLBACK (status_icon_event_removed_cb),
877
g_signal_connect (priv->event_manager, "event-updated",
878
G_CALLBACK (status_icon_event_updated_cb),
880
g_signal_connect (priv->icon, "activate",
881
G_CALLBACK (status_icon_activate_cb),
883
g_signal_connect (priv->icon, "popup-menu",
884
G_CALLBACK (status_icon_popup_menu_cb),
887
priv->notification = NULL;
888
priv->notify_mgr = empathy_notify_manager_dup_singleton ();
892
empathy_status_icon_new (GtkWindow *window, gboolean hide_contact_list)
894
EmpathyStatusIconPriv *priv;
895
EmpathyStatusIcon *icon;
896
gboolean should_hide;
897
#ifdef HAVE_LIBINDICATE
898
gboolean use_libindicate;
900
const gchar *desktop_autostart_id;
902
desktop_autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID");
904
g_return_val_if_fail (GTK_IS_WINDOW (window), NULL);
906
icon = g_object_new (EMPATHY_TYPE_STATUS_ICON, NULL);
907
priv = GET_PRIV (icon);
909
priv->window = g_object_ref (window);
910
#ifdef HAVE_LIBINDICATE
911
priv->indicator_manager = empathy_indicator_manager_dup_singleton ();
912
priv->indicate_server = indicate_server_ref_default ();
914
g_signal_connect (priv->indicator_manager, "server-activate",
915
G_CALLBACK (indicate_server_activate_cb),
918
g_signal_connect (priv->indicate_server,
919
INDICATE_SERVER_SIGNAL_INTEREST_ADDED,
920
G_CALLBACK(empathy_indicator_interest_added),
923
g_signal_connect (priv->indicate_server,
924
INDICATE_SERVER_SIGNAL_INTEREST_REMOVED,
925
G_CALLBACK(empathy_indicator_interest_removed),
929
g_signal_connect_after (priv->window, "key-press-event",
930
G_CALLBACK (status_icon_key_press_event_cb),
933
g_signal_connect (priv->window, "delete-event",
934
G_CALLBACK (status_icon_delete_event_cb),
937
if (!hide_contact_list) {
938
/* If not started with the session, we should raise the window.
939
https://bugs.launchpad.net/ubuntu/+source/empathy/+bug/503052 */
940
if (desktop_autostart_id == NULL) {
941
DEBUG ("Not started with session, showing contact list");
944
DEBUG ("Auto-started with session, so honor the previous known state");
945
should_hide = g_settings_get_boolean (priv->gsettings_ui,
946
EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN);
952
#ifdef HAVE_LIBINDICATE
953
use_libindicate = g_settings_get_boolean (priv->gsettings_ui,
954
EMPATHY_PREFS_UI_USE_LIBINDICATE);
955
status_icon_set_use_libindicate (icon, use_libindicate);
958
status_icon_set_visibility (icon, !should_hide, FALSE);