1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2002-2007 Imendio AB
4 * Copyright (C) 2007-2010 Collabora Ltd.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301 USA
21 * Authors: Xavier Claessens <xclaesse@gmail.com>
22 * Danielle Madeley <danielle.madeley@collabora.co.uk>
29 #include <gdk/gdkkeysyms.h>
30 #include <glib/gi18n.h>
32 #include <telepathy-glib/account-manager.h>
33 #include <telepathy-glib/util.h>
34 #include <folks/folks.h>
36 #include <libempathy/empathy-contact.h>
37 #include <libempathy/empathy-utils.h>
38 #include <libempathy/empathy-request-util.h>
39 #include <libempathy/empathy-chatroom-manager.h>
40 #include <libempathy/empathy-chatroom.h>
41 #include <libempathy/empathy-contact-list.h>
42 #include <libempathy/empathy-contact-manager.h>
43 #include <libempathy/empathy-gsettings.h>
44 #include <libempathy/empathy-individual-manager.h>
45 #include <libempathy/empathy-gsettings.h>
46 #include <libempathy/empathy-status-presets.h>
47 #include <libempathy/empathy-tp-contact-factory.h>
49 #include <libempathy-gtk/empathy-contact-dialogs.h>
50 #include <libempathy-gtk/empathy-contact-list-store.h>
51 #include <libempathy-gtk/empathy-contact-list-view.h>
52 #include <libempathy-gtk/empathy-live-search.h>
53 #include <libempathy-gtk/empathy-contact-blocking-dialog.h>
54 #include <libempathy-gtk/empathy-contact-search-dialog.h>
55 #include <libempathy-gtk/empathy-geometry.h>
56 #include <libempathy-gtk/empathy-gtk-enum-types.h>
57 #include <libempathy-gtk/empathy-individual-dialogs.h>
58 #include <libempathy-gtk/empathy-individual-store.h>
59 #include <libempathy-gtk/empathy-individual-view.h>
60 #include <libempathy-gtk/empathy-new-message-dialog.h>
61 #include <libempathy-gtk/empathy-new-call-dialog.h>
62 #include <libempathy-gtk/empathy-log-window.h>
63 #include <libempathy-gtk/empathy-presence-chooser.h>
64 #include <libempathy-gtk/empathy-sound-manager.h>
65 #include <libempathy-gtk/empathy-ui-utils.h>
67 #include "empathy-accounts-dialog.h"
68 #include "empathy-call-observer.h"
69 #include "empathy-chat-manager.h"
70 #include "empathy-main-window.h"
71 #include "empathy-preferences.h"
72 #include "empathy-about-dialog.h"
73 #include "empathy-debug-window.h"
74 #include "empathy-new-chatroom-dialog.h"
75 #include "empathy-map-view.h"
76 #include "empathy-chatrooms-window.h"
77 #include "empathy-event-manager.h"
78 #include "empathy-ft-manager.h"
79 #include "empathy-migrate-butterfly-logs.h"
81 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
82 #include <libempathy/empathy-debug.h>
84 /* Flashing delay for icons (milliseconds). */
85 #define FLASH_TIMEOUT 500
87 /* Minimum width of roster window if something goes wrong. */
90 /* Accels (menu shortcuts) can be configured and saved */
91 #define ACCELS_FILENAME "accels.txt"
93 /* Name in the geometry file */
94 #define GEOMETRY_NAME "main-window"
97 PAGE_CONTACT_LIST = 0,
101 G_DEFINE_TYPE (EmpathyMainWindow, empathy_main_window, GTK_TYPE_WINDOW);
103 #define GET_PRIV(self) ((EmpathyMainWindowPriv *)((EmpathyMainWindow *) self)->priv)
105 struct _EmpathyMainWindowPriv {
106 EmpathyContactList *contact_manager;
107 EmpathyIndividualStore *individual_store;
108 EmpathyIndividualView *individual_view;
109 TpAccountManager *account_manager;
110 EmpathyChatroomManager *chatroom_manager;
111 EmpathyEventManager *event_manager;
112 EmpathySoundManager *sound_mgr;
113 EmpathyCallObserver *call_observer;
114 guint flash_timeout_id;
118 GSettings *gsettings_ui;
119 GSettings *gsettings_contacts;
121 GtkWidget *preferences;
122 GtkWidget *main_vbox;
124 GtkWidget *throbber_tool_item;
125 GtkWidget *presence_toolbar;
126 GtkWidget *presence_chooser;
127 GtkWidget *errors_vbox;
128 GtkWidget *auth_vbox;
129 GtkWidget *search_bar;
131 GtkWidget *no_entry_label;
133 GtkToggleAction *show_protocols;
134 GtkRadioAction *sort_by_name;
135 GtkRadioAction *sort_by_status;
136 GtkRadioAction *normal_with_avatars;
137 GtkRadioAction *normal_size;
138 GtkRadioAction *compact_size;
140 GtkUIManager *ui_manager;
141 GtkAction *view_history;
142 GtkAction *room_join_favorites;
143 GtkWidget *room_menu;
144 GtkWidget *room_separator;
145 GtkWidget *edit_context;
146 GtkWidget *edit_context_separator;
148 GtkActionGroup *balance_action_group;
149 GtkAction *view_balance_show_in_roster;
150 GtkWidget *balance_vbox;
152 guint size_timeout_id;
154 /* reffed TpAccount* => visible GtkInfoBar* */
157 /* EmpathyEvent* => visible GtkInfoBar* */
160 /* stores a mapping from TpAccount to Handler ID to prevent
161 * to listen more than once to the status-changed signal */
162 GHashTable *status_changed_handlers;
164 /* Actions that are enabled when there are connected accounts */
165 GList *actions_connected;
167 /* The idle event source to migrate butterfly's logs */
168 guint butterfly_log_migration_members_changed_id;
172 main_window_flash_stop (EmpathyMainWindow *window)
174 EmpathyMainWindowPriv *priv = GET_PRIV (window);
176 if (priv->flash_timeout_id == 0) {
180 DEBUG ("Stop flashing");
181 g_source_remove (priv->flash_timeout_id);
182 priv->flash_timeout_id = 0;
183 priv->flash_on = FALSE;
189 EmpathyMainWindow *window;
193 main_window_flash_foreach (GtkTreeModel *model,
198 FlashForeachData *data = (FlashForeachData *) user_data;
199 FolksIndividual *individual;
200 EmpathyContact *contact;
201 const gchar *icon_name;
202 GtkTreePath *parent_path = NULL;
203 GtkTreeIter parent_iter;
204 GdkPixbuf *pixbuf = NULL;
206 gtk_tree_model_get (model, iter,
207 EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL,
211 if (individual == NULL)
214 contact = empathy_contact_dup_from_folks_individual (individual);
215 if (contact != data->event->contact) {
216 tp_clear_object (&contact);
221 icon_name = data->event->icon_name;
222 pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
224 pixbuf = empathy_individual_store_get_individual_status_icon (
225 GET_PRIV (data->window)->individual_store,
228 g_object_ref (pixbuf);
231 gtk_tree_store_set (GTK_TREE_STORE (model), iter,
232 EMPATHY_INDIVIDUAL_STORE_COL_ICON_STATUS, pixbuf,
235 /* To make sure the parent is shown correctly, we emit
236 * the row-changed signal on the parent so it prompts
237 * it to be refreshed by the filter func.
239 if (gtk_tree_model_iter_parent (model, &parent_iter, iter)) {
240 parent_path = gtk_tree_model_get_path (model, &parent_iter);
243 gtk_tree_model_row_changed (model, parent_path, &parent_iter);
244 gtk_tree_path_free (parent_path);
247 g_object_unref (individual);
248 tp_clear_object (&contact);
249 tp_clear_object (&pixbuf);
255 main_window_flash_cb (EmpathyMainWindow *window)
257 EmpathyMainWindowPriv *priv = GET_PRIV (window);
260 gboolean found_event = FALSE;
261 FlashForeachData data;
263 priv->flash_on = !priv->flash_on;
264 data.on = priv->flash_on;
265 model = GTK_TREE_MODEL (priv->individual_store);
267 events = empathy_event_manager_get_events (priv->event_manager);
268 for (l = events; l; l = l->next) {
269 data.event = l->data;
270 data.window = window;
271 if (!data.event->contact || !data.event->must_ack) {
276 gtk_tree_model_foreach (model,
277 main_window_flash_foreach,
282 main_window_flash_stop (window);
289 main_window_flash_start (EmpathyMainWindow *window)
291 EmpathyMainWindowPriv *priv = GET_PRIV (window);
293 if (priv->flash_timeout_id != 0) {
297 DEBUG ("Start flashing");
298 priv->flash_timeout_id = g_timeout_add (FLASH_TIMEOUT,
299 (GSourceFunc) main_window_flash_cb,
301 main_window_flash_cb (window);
305 main_window_remove_auth (EmpathyMainWindow *window,
308 EmpathyMainWindowPriv *priv = GET_PRIV (window);
309 GtkWidget *error_widget;
311 error_widget = g_hash_table_lookup (priv->auths, event);
312 if (error_widget != NULL) {
313 gtk_widget_destroy (error_widget);
314 g_hash_table_remove (priv->auths, event);
319 main_window_auth_add_clicked_cb (GtkButton *button,
320 EmpathyMainWindow *window)
324 event = g_object_get_data (G_OBJECT (button), "event");
326 empathy_event_approve (event);
328 main_window_remove_auth (window, event);
332 main_window_auth_close_clicked_cb (GtkButton *button,
333 EmpathyMainWindow *window)
337 event = g_object_get_data (G_OBJECT (button), "event");
339 empathy_event_decline (event);
340 main_window_remove_auth (window, event);
344 main_window_auth_display (EmpathyMainWindow *window,
347 EmpathyMainWindowPriv *priv = GET_PRIV (window);
348 TpAccount *account = event->account;
350 GtkWidget *content_area;
353 GtkWidget *add_button;
354 GtkWidget *close_button;
355 GtkWidget *action_area;
356 GtkWidget *action_table;
357 const gchar *icon_name;
360 if (g_hash_table_lookup (priv->auths, event) != NULL) {
364 info_bar = gtk_info_bar_new ();
365 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_QUESTION);
367 gtk_widget_set_no_show_all (info_bar, TRUE);
368 gtk_box_pack_start (GTK_BOX (priv->auth_vbox), info_bar, FALSE, TRUE, 0);
369 gtk_widget_show (info_bar);
371 icon_name = tp_account_get_icon_name (account);
372 image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR);
373 gtk_widget_show (image);
375 str = g_markup_printf_escaped ("<b>%s</b>\n%s",
376 tp_account_get_display_name (account),
377 _("Password required"));
379 label = gtk_label_new (str);
380 gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
381 gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
382 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
383 gtk_widget_show (label);
387 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
388 gtk_box_pack_start (GTK_BOX (content_area), image, FALSE, FALSE, 0);
389 gtk_box_pack_start (GTK_BOX (content_area), label, TRUE, TRUE, 0);
391 image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON);
392 add_button = gtk_button_new ();
393 gtk_button_set_image (GTK_BUTTON (add_button), image);
394 gtk_widget_set_tooltip_text (add_button, _("Provide Password"));
395 gtk_widget_show (add_button);
397 image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_BUTTON);
398 close_button = gtk_button_new ();
399 gtk_button_set_image (GTK_BUTTON (close_button), image);
400 gtk_widget_set_tooltip_text (close_button, _("Disconnect"));
401 gtk_widget_show (close_button);
403 action_table = gtk_table_new (1, 2, FALSE);
404 gtk_table_set_col_spacings (GTK_TABLE (action_table), 6);
405 gtk_widget_show (action_table);
407 action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (info_bar));
408 gtk_box_pack_start (GTK_BOX (action_area), action_table, FALSE, FALSE, 0);
410 gtk_table_attach (GTK_TABLE (action_table), add_button, 0, 1, 0, 1,
411 (GtkAttachOptions) (GTK_SHRINK),
412 (GtkAttachOptions) (GTK_SHRINK), 0, 0);
413 gtk_table_attach (GTK_TABLE (action_table), close_button, 1, 2, 0, 1,
414 (GtkAttachOptions) (GTK_SHRINK),
415 (GtkAttachOptions) (GTK_SHRINK), 0, 0);
417 g_object_set_data_full (G_OBJECT (info_bar),
418 "event", event, NULL);
419 g_object_set_data_full (G_OBJECT (add_button),
420 "event", event, NULL);
421 g_object_set_data_full (G_OBJECT (close_button),
422 "event", event, NULL);
424 g_signal_connect (add_button, "clicked",
425 G_CALLBACK (main_window_auth_add_clicked_cb),
427 g_signal_connect (close_button, "clicked",
428 G_CALLBACK (main_window_auth_close_clicked_cb),
431 gtk_widget_show (priv->auth_vbox);
433 g_hash_table_insert (priv->auths, event, info_bar);
437 main_window_event_added_cb (EmpathyEventManager *manager,
439 EmpathyMainWindow *window)
441 if (event->contact) {
442 main_window_flash_start (window);
443 } else if (event->type == EMPATHY_EVENT_TYPE_AUTH) {
444 main_window_auth_display (window, event);
449 main_window_event_removed_cb (EmpathyEventManager *manager,
451 EmpathyMainWindow *window)
453 EmpathyMainWindowPriv *priv = GET_PRIV (window);
454 FlashForeachData data;
456 if (event->type == EMPATHY_EVENT_TYPE_AUTH) {
457 main_window_remove_auth (window, event);
461 if (!event->contact) {
467 data.window = window;
468 gtk_tree_model_foreach (GTK_TREE_MODEL (priv->individual_store),
469 main_window_flash_foreach,
474 main_window_row_activated_cb (EmpathyContactListView *view,
476 GtkTreeViewColumn *col,
477 EmpathyMainWindow *window)
479 EmpathyMainWindowPriv *priv = GET_PRIV (window);
480 EmpathyContact *contact = NULL;
481 FolksIndividual *individual;
486 model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->individual_view));
487 gtk_tree_model_get_iter (model, &iter, path);
489 gtk_tree_model_get (model, &iter,
490 EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL,
494 if (individual != NULL) {
495 contact = empathy_contact_dup_from_folks_individual (individual);
502 /* If the contact has an event activate it, otherwise the
503 * default handler of row-activated will be called. */
504 events = empathy_event_manager_get_events (priv->event_manager);
505 for (l = events; l; l = l->next) {
506 EmpathyEvent *event = l->data;
508 if (event->contact == contact) {
509 DEBUG ("Activate event");
510 empathy_event_activate (event);
512 /* We don't want the default handler of this signal
513 * (e.g. open a chat) */
514 g_signal_stop_emission_by_name (view, "row-activated");
519 g_object_unref (contact);
521 tp_clear_object (&individual);
525 main_window_row_deleted_cb (GtkTreeModel *model,
527 EmpathyMainWindow *window)
529 EmpathyMainWindowPriv *priv = GET_PRIV (window);
530 GtkTreeIter help_iter;
532 if (!gtk_tree_model_get_iter_first (model, &help_iter)) {
535 if (empathy_individual_view_is_searching (
536 priv->individual_view)) {
539 tmp = g_strdup_printf ("<b><span size='xx-large'>%s</span></b>",
540 _("No match found"));
542 gtk_label_set_markup (GTK_LABEL (priv->no_entry_label), tmp);
545 gtk_label_set_line_wrap (GTK_LABEL (priv->no_entry_label),
548 gtk_notebook_set_current_page (
549 GTK_NOTEBOOK (priv->notebook), PAGE_NO_MATCH);
555 main_window_row_inserted_cb (GtkTreeModel *model,
558 EmpathyMainWindow *window)
560 EmpathyMainWindowPriv *priv = GET_PRIV (window);
564 gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
566 gtk_widget_grab_focus (GTK_WIDGET (priv->individual_view));
571 main_window_remove_error (EmpathyMainWindow *window,
574 EmpathyMainWindowPriv *priv = GET_PRIV (window);
575 GtkWidget *error_widget;
577 error_widget = g_hash_table_lookup (priv->errors, account);
578 if (error_widget != NULL) {
579 gtk_widget_destroy (error_widget);
580 g_hash_table_remove (priv->errors, account);
585 main_window_account_disabled_cb (TpAccountManager *manager,
587 EmpathyMainWindow *window)
589 main_window_remove_error (window, account);
593 main_window_error_retry_clicked_cb (GtkButton *button,
594 EmpathyMainWindow *window)
598 account = g_object_get_data (G_OBJECT (button), "account");
599 tp_account_reconnect_async (account, NULL, NULL);
601 main_window_remove_error (window, account);
605 main_window_error_edit_clicked_cb (GtkButton *button,
606 EmpathyMainWindow *window)
610 account = g_object_get_data (G_OBJECT (button), "account");
612 empathy_accounts_dialog_show_application (
613 gtk_widget_get_screen (GTK_WIDGET (button)),
614 account, FALSE, FALSE);
616 main_window_remove_error (window, account);
620 main_window_error_close_clicked_cb (GtkButton *button,
621 EmpathyMainWindow *window)
625 account = g_object_get_data (G_OBJECT (button), "account");
626 main_window_remove_error (window, account);
630 main_window_error_display (EmpathyMainWindow *window,
633 EmpathyMainWindowPriv *priv = GET_PRIV (window);
635 GtkWidget *content_area;
638 GtkWidget *retry_button;
639 GtkWidget *edit_button;
640 GtkWidget *close_button;
641 GtkWidget *action_area;
642 GtkWidget *action_table;
644 const gchar *icon_name;
645 const gchar *error_message;
646 gboolean user_requested;
649 empathy_account_get_error_message (account, &user_requested);
651 if (user_requested) {
655 str = g_markup_printf_escaped ("<b>%s</b>\n%s",
656 tp_account_get_display_name (account),
659 info_bar = g_hash_table_lookup (priv->errors, account);
661 label = g_object_get_data (G_OBJECT (info_bar), "label");
663 /* Just set the latest error and return */
664 gtk_label_set_markup (GTK_LABEL (label), str);
670 info_bar = gtk_info_bar_new ();
671 gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_ERROR);
673 gtk_widget_set_no_show_all (info_bar, TRUE);
674 gtk_box_pack_start (GTK_BOX (priv->errors_vbox), info_bar, FALSE, TRUE, 0);
675 gtk_widget_show (info_bar);
677 icon_name = tp_account_get_icon_name (account);
678 image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR);
679 gtk_widget_show (image);
681 label = gtk_label_new (str);
682 gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
683 gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
684 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
685 gtk_widget_show (label);
688 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
689 gtk_box_pack_start (GTK_BOX (content_area), image, FALSE, FALSE, 0);
690 gtk_box_pack_start (GTK_BOX (content_area), label, TRUE, TRUE, 0);
692 image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON);
693 retry_button = gtk_button_new ();
694 gtk_button_set_image (GTK_BUTTON (retry_button), image);
695 gtk_widget_set_tooltip_text (retry_button, _("Reconnect"));
696 gtk_widget_show (retry_button);
698 image = gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_BUTTON);
699 edit_button = gtk_button_new ();
700 gtk_button_set_image (GTK_BUTTON (edit_button), image);
701 gtk_widget_set_tooltip_text (edit_button, _("Edit Account"));
702 gtk_widget_show (edit_button);
704 image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_BUTTON);
705 close_button = gtk_button_new ();
706 gtk_button_set_image (GTK_BUTTON (close_button), image);
707 gtk_widget_set_tooltip_text (close_button, _("Close"));
708 gtk_widget_show (close_button);
710 action_table = gtk_table_new (1, 3, FALSE);
711 gtk_table_set_col_spacings (GTK_TABLE (action_table), 2);
712 gtk_widget_show (action_table);
714 action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (info_bar));
715 gtk_box_pack_start (GTK_BOX (action_area), action_table, FALSE, FALSE, 0);
717 gtk_table_attach (GTK_TABLE (action_table), retry_button, 0, 1, 0, 1,
718 (GtkAttachOptions) (GTK_SHRINK),
719 (GtkAttachOptions) (GTK_SHRINK), 0, 0);
720 gtk_table_attach (GTK_TABLE (action_table), edit_button, 1, 2, 0, 1,
721 (GtkAttachOptions) (GTK_SHRINK),
722 (GtkAttachOptions) (GTK_SHRINK), 0, 0);
723 gtk_table_attach (GTK_TABLE (action_table), close_button, 2, 3, 0, 1,
724 (GtkAttachOptions) (GTK_SHRINK),
725 (GtkAttachOptions) (GTK_SHRINK), 0, 0);
727 g_object_set_data (G_OBJECT (info_bar), "label", label);
728 g_object_set_data_full (G_OBJECT (info_bar),
729 "account", g_object_ref (account),
731 g_object_set_data_full (G_OBJECT (edit_button),
732 "account", g_object_ref (account),
734 g_object_set_data_full (G_OBJECT (close_button),
735 "account", g_object_ref (account),
737 g_object_set_data_full (G_OBJECT (retry_button),
738 "account", g_object_ref (account),
741 g_signal_connect (edit_button, "clicked",
742 G_CALLBACK (main_window_error_edit_clicked_cb),
744 g_signal_connect (close_button, "clicked",
745 G_CALLBACK (main_window_error_close_clicked_cb),
747 g_signal_connect (retry_button, "clicked",
748 G_CALLBACK (main_window_error_retry_clicked_cb),
751 gtk_widget_set_tooltip_text (priv->errors_vbox, error_message);
752 gtk_widget_show (priv->errors_vbox);
754 g_hash_table_insert (priv->errors, g_object_ref (account), info_bar);
758 main_window_update_status (EmpathyMainWindow *window)
760 EmpathyMainWindowPriv *priv = GET_PRIV (window);
761 gboolean connected, connecting;
764 connected = empathy_account_manager_get_accounts_connected (&connecting);
766 /* Update the spinner state */
768 gtk_spinner_start (GTK_SPINNER (priv->throbber));
769 gtk_widget_show (priv->throbber_tool_item);
771 gtk_spinner_stop (GTK_SPINNER (priv->throbber));
772 gtk_widget_hide (priv->throbber_tool_item);
775 /* Update widgets sensibility */
776 for (l = priv->actions_connected; l; l = l->next) {
777 gtk_action_set_sensitive (l->data, connected);
780 /* Update favourite rooms sensitivity */
781 children = gtk_container_get_children (GTK_CONTAINER (priv->room_menu));
782 for (l = children; l != NULL; l = l->next) {
783 if (g_object_get_data (G_OBJECT (l->data), "is_favorite") != NULL) {
784 gtk_widget_set_sensitive (GTK_WIDGET (l->data), connected);
787 g_list_free (children);
791 main_window_account_to_action_name (TpAccount *account)
795 /* action names can't have '/' in them, replace it with '.' */
796 r = g_strdup (tp_account_get_path_suffix (account));
797 r = g_strdelimit (r, "/", '.');
803 main_window_balance_activate_cb (GtkAction *action,
804 EmpathyMainWindow *window)
808 uri = g_object_get_data (G_OBJECT (action), "manage-credit-uri");
810 if (!tp_str_empty (uri)) {
811 DEBUG ("Top-up credit URI: %s", uri);
812 empathy_url_show (GTK_WIDGET (window), uri);
814 DEBUG ("unknown protocol for top-up");
819 main_window_balance_update_balance (GtkAction *action,
820 GValueArray *balance)
822 TpAccount *account = g_object_get_data (G_OBJECT (action), "account");
825 guint scale = G_MAXINT32;
826 const char *currency = "";
830 tp_value_array_unpack (balance, 3,
836 scale == G_MAXINT32 &&
837 tp_str_empty (currency)) {
838 /* unknown balance */
839 money = g_strdup ("--");
841 char *tmp = empathy_format_currency (amount, scale, currency);
843 money = g_strdup_printf ("%s %s", currency, tmp);
847 /* Translators: this string will be something like:
848 * Top up My Account ($1.23)..." */
849 str = g_strdup_printf (_("Top up %s (%s)..."),
850 tp_account_get_display_name (account),
853 gtk_action_set_label (action, str);
856 /* update the money label in the roster */
857 label = g_object_get_data (G_OBJECT (action), "money-label");
859 gtk_label_set_text (GTK_LABEL (label), money);
864 main_window_setup_balance_got_balance_props (TpProxy *conn,
866 const GError *in_error,
870 GValueArray *balance = NULL;
873 if (in_error != NULL) {
874 DEBUG ("Failed to get account balance properties: %s",
879 balance = tp_asv_get_boxed (props, "AccountBalance",
880 TP_STRUCT_TYPE_CURRENCY_AMOUNT);
881 uri = tp_asv_get_string (props, "ManageCreditURI");
883 g_object_set_data_full (action, "manage-credit-uri",
884 g_strdup (uri), g_free);
885 gtk_action_set_sensitive (GTK_ACTION (action), !tp_str_empty (uri));
888 main_window_balance_update_balance (GTK_ACTION (action), balance);
892 main_window_balance_changed_cb (TpConnection *conn,
893 const GValueArray *balance,
897 main_window_balance_update_balance (GTK_ACTION (action),
898 (GValueArray *) balance);
902 main_window_setup_balance_create_action (EmpathyMainWindow *window,
905 EmpathyMainWindowPriv *priv = GET_PRIV (window);
909 GError *error = NULL;
911 /* create the action group if required */
912 if (priv->balance_action_group == NULL) {
913 priv->balance_action_group =
914 gtk_action_group_new ("balance-action-group");
916 gtk_ui_manager_insert_action_group (priv->ui_manager,
917 priv->balance_action_group, -1);
920 /* create the action */
921 name = main_window_account_to_action_name (account);
922 action = gtk_action_new (name,
923 tp_account_get_display_name (account),
924 _("Top up account credit"),
926 g_object_bind_property (account, "icon-name", action, "icon-name",
927 G_BINDING_SYNC_CREATE);
929 g_object_set_data (G_OBJECT (action), "account", account);
930 g_signal_connect (action, "activate",
931 G_CALLBACK (main_window_balance_activate_cb), window);
933 gtk_action_group_add_action (priv->balance_action_group, action);
934 g_object_unref (action);
936 ui = g_strdup_printf (
938 " <menubar name='menubar'>"
939 " <menu action='view'>"
940 " <placeholder name='view_balance_placeholder'>"
941 " <menuitem action='%s'/>"
948 merge_id = gtk_ui_manager_add_ui_from_string (priv->ui_manager,
951 DEBUG ("Failed to add balance UI for %s: %s",
952 tp_account_get_display_name (account),
954 g_error_free (error);
957 g_object_set_data (G_OBJECT (action),
958 "merge-id", GUINT_TO_POINTER (merge_id));
967 main_window_setup_balance_create_widget (EmpathyMainWindow *window,
970 EmpathyMainWindowPriv *priv = GET_PRIV (window);
972 GtkWidget *hbox, *image, *label, *button;
974 account = g_object_get_data (G_OBJECT (action), "account");
975 g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
977 hbox = gtk_hbox_new (FALSE, 6);
980 image = gtk_image_new ();
981 gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
982 g_object_bind_property (action, "icon-name", image, "icon-name",
983 G_BINDING_SYNC_CREATE);
985 /* account name label */
986 label = gtk_label_new ("");
987 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
988 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
989 g_object_bind_property (account, "display-name", label, "label",
990 G_BINDING_SYNC_CREATE);
993 label = gtk_label_new ("");
994 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
995 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
996 g_object_set_data (G_OBJECT (action), "money-label", label);
999 button = gtk_button_new_with_label (_("Top Up..."));
1000 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
1001 g_signal_connect_swapped (button, "clicked",
1002 G_CALLBACK (gtk_action_activate), action);
1004 gtk_box_pack_start (GTK_BOX (priv->balance_vbox), hbox, FALSE, TRUE, 0);
1005 gtk_widget_show_all (hbox);
1007 /* tie the lifetime of the widget to the lifetime of the action */
1008 g_object_weak_ref (G_OBJECT (action),
1009 (GWeakNotify) gtk_widget_destroy, hbox);
1015 main_window_setup_balance_conn_ready (GObject *conn,
1016 GAsyncResult *result,
1019 EmpathyMainWindow *window = user_data;
1020 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1021 TpAccount *account = g_object_get_data (conn, "account");
1023 GError *error = NULL;
1025 if (!tp_proxy_prepare_finish (conn, result, &error)) {
1026 DEBUG ("Failed to prepare connection: %s", error->message);
1028 g_error_free (error);
1032 if (!tp_proxy_has_interface_by_id (conn,
1033 TP_IFACE_QUARK_CONNECTION_INTERFACE_BALANCE)) {
1037 DEBUG ("Setting up balance for acct: %s",
1038 tp_account_get_display_name (account));
1040 /* create the action */
1041 action = main_window_setup_balance_create_action (window, account);
1046 gtk_action_set_visible (priv->view_balance_show_in_roster, TRUE);
1048 /* create the display widget */
1049 main_window_setup_balance_create_widget (window, action);
1051 /* request the current balance and monitor for any changes */
1052 tp_cli_dbus_properties_call_get_all (conn, -1,
1053 TP_IFACE_CONNECTION_INTERFACE_BALANCE,
1054 main_window_setup_balance_got_balance_props,
1055 window, NULL, G_OBJECT (action));
1057 tp_cli_connection_interface_balance_connect_to_balance_changed (
1058 TP_CONNECTION (conn), main_window_balance_changed_cb,
1059 window, NULL, G_OBJECT (action), NULL);
1063 main_window_setup_balance (EmpathyMainWindow *window,
1066 TpConnection *conn = tp_account_get_connection (account);
1071 /* need to prepare the connection:
1072 * store the account on the connection */
1073 g_object_set_data (G_OBJECT (conn), "account", account);
1074 tp_proxy_prepare_async (conn, NULL,
1075 main_window_setup_balance_conn_ready, window);
1079 main_window_remove_balance_action (EmpathyMainWindow *window,
1082 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1087 if (priv->balance_action_group == NULL)
1090 name = main_window_account_to_action_name (account);
1092 action = gtk_action_group_get_action (
1093 priv->balance_action_group, name);
1095 if (action != NULL) {
1098 DEBUG ("Removing action");
1100 merge_id = GPOINTER_TO_UINT (g_object_get_data (
1104 gtk_ui_manager_remove_ui (priv->ui_manager,
1106 gtk_action_group_remove_action (
1107 priv->balance_action_group, action);
1112 a = gtk_action_group_list_actions (
1113 priv->balance_action_group);
1115 gtk_action_set_visible (
1116 priv->view_balance_show_in_roster,
1117 g_list_length (a) > 0);
1123 main_window_connection_changed_cb (TpAccount *account,
1127 gchar *dbus_error_name,
1128 GHashTable *details,
1129 EmpathyMainWindow *window)
1131 main_window_update_status (window);
1133 if (current == TP_CONNECTION_STATUS_DISCONNECTED &&
1134 reason != TP_CONNECTION_STATUS_REASON_REQUESTED) {
1135 main_window_error_display (window, account);
1138 if (current == TP_CONNECTION_STATUS_DISCONNECTED) {
1139 empathy_sound_manager_play (priv->sound_mgr, GTK_WIDGET (window),
1140 EMPATHY_SOUND_ACCOUNT_DISCONNECTED);
1142 /* remove balance action if required */
1143 main_window_remove_balance_action (window, account);
1146 if (current == TP_CONNECTION_STATUS_CONNECTED) {
1147 empathy_sound_manager_play (priv->sound_mgr, GTK_WIDGET (window),
1148 EMPATHY_SOUND_ACCOUNT_CONNECTED);
1150 /* Account connected without error, remove error message if any */
1151 main_window_remove_error (window, account);
1152 main_window_setup_balance (window, account);
1157 main_window_accels_load (void)
1161 filename = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, ACCELS_FILENAME, NULL);
1162 if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
1163 DEBUG ("Loading from:'%s'", filename);
1164 gtk_accel_map_load (filename);
1171 main_window_accels_save (void)
1174 gchar *file_with_path;
1176 dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL);
1177 g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
1178 file_with_path = g_build_filename (dir, ACCELS_FILENAME, NULL);
1181 DEBUG ("Saving to:'%s'", file_with_path);
1182 gtk_accel_map_save (file_with_path);
1184 g_free (file_with_path);
1188 empathy_main_window_finalize (GObject *window)
1190 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1191 GHashTableIter iter;
1192 gpointer key, value;
1194 /* Save user-defined accelerators. */
1195 main_window_accels_save ();
1197 g_list_free (priv->actions_connected);
1199 g_object_unref (priv->account_manager);
1200 g_object_unref (priv->individual_store);
1201 g_object_unref (priv->contact_manager);
1202 g_object_unref (priv->sound_mgr);
1203 g_hash_table_destroy (priv->errors);
1204 g_hash_table_destroy (priv->auths);
1206 /* disconnect all handlers of status-changed signal */
1207 g_hash_table_iter_init (&iter, priv->status_changed_handlers);
1208 while (g_hash_table_iter_next (&iter, &key, &value))
1209 g_signal_handler_disconnect (TP_ACCOUNT (key),
1210 GPOINTER_TO_UINT (value));
1212 g_hash_table_destroy (priv->status_changed_handlers);
1214 g_signal_handlers_disconnect_by_func (priv->event_manager,
1215 main_window_event_added_cb,
1217 g_signal_handlers_disconnect_by_func (priv->event_manager,
1218 main_window_event_removed_cb,
1220 g_object_unref (priv->call_observer);
1221 g_object_unref (priv->event_manager);
1222 g_object_unref (priv->ui_manager);
1223 g_object_unref (priv->chatroom_manager);
1225 g_object_unref (priv->gsettings_ui);
1226 g_object_unref (priv->gsettings_contacts);
1228 G_OBJECT_CLASS (empathy_main_window_parent_class)->finalize (window);
1232 main_window_key_press_event_cb (GtkWidget *window,
1236 if (event->keyval == GDK_KEY_T
1237 && event->state & GDK_SHIFT_MASK
1238 && event->state & GDK_CONTROL_MASK) {
1239 empathy_chat_manager_call_undo_closed_chat ();
1245 main_window_chat_quit_cb (GtkAction *action,
1246 EmpathyMainWindow *window)
1252 main_window_view_history_cb (GtkAction *action,
1253 EmpathyMainWindow *window)
1255 empathy_log_window_show (NULL, NULL, FALSE, GTK_WINDOW (window));
1259 main_window_chat_new_message_cb (GtkAction *action,
1260 EmpathyMainWindow *window)
1262 empathy_new_message_dialog_show (GTK_WINDOW (window));
1266 main_window_chat_new_call_cb (GtkAction *action,
1267 EmpathyMainWindow *window)
1269 empathy_new_call_dialog_show (GTK_WINDOW (window));
1273 main_window_chat_add_contact_cb (GtkAction *action,
1274 EmpathyMainWindow *window)
1276 empathy_new_individual_dialog_show (GTK_WINDOW (window));
1280 main_window_chat_search_contacts_cb (GtkAction *action,
1281 EmpathyMainWindow *window)
1283 GtkWidget *dialog = empathy_contact_search_dialog_new (
1284 GTK_WINDOW (window));
1285 gtk_widget_show (dialog);
1289 main_window_view_show_ft_manager (GtkAction *action,
1290 EmpathyMainWindow *window)
1292 empathy_ft_manager_show ();
1296 main_window_view_show_offline_cb (GtkToggleAction *action,
1297 EmpathyMainWindow *window)
1299 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1302 current = gtk_toggle_action_get_active (action);
1303 g_settings_set_boolean (priv->gsettings_ui,
1304 EMPATHY_PREFS_UI_SHOW_OFFLINE,
1307 empathy_individual_view_set_show_offline (priv->individual_view,
1312 main_window_notify_sort_contact_cb (GSettings *gsettings,
1314 EmpathyMainWindow *window)
1316 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1319 str = g_settings_get_string (gsettings, key);
1323 GEnumClass *enum_class;
1324 GEnumValue *enum_value;
1326 type = empathy_individual_store_sort_get_type ();
1327 enum_class = G_ENUM_CLASS (g_type_class_peek (type));
1328 enum_value = g_enum_get_value_by_nick (enum_class, str);
1330 /* By changing the value of the GtkRadioAction,
1331 it emits a signal that calls main_window_view_sort_contacts_cb
1332 which updates the contacts list */
1333 gtk_radio_action_set_current_value (priv->sort_by_name,
1336 g_warning ("Wrong value for sort_criterium configuration : %s", str);
1343 main_window_view_sort_contacts_cb (GtkRadioAction *action,
1344 GtkRadioAction *current,
1345 EmpathyMainWindow *window)
1347 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1348 EmpathyContactListStoreSort value;
1351 GEnumClass *enum_class;
1352 GEnumValue *enum_value;
1354 value = gtk_radio_action_get_current_value (action);
1355 group = gtk_radio_action_get_group (action);
1357 /* Get string from index */
1358 type = empathy_individual_store_sort_get_type ();
1359 enum_class = G_ENUM_CLASS (g_type_class_peek (type));
1360 enum_value = g_enum_get_value (enum_class, g_slist_index (group, current));
1363 g_warning ("No GEnumValue for EmpathyContactListSort with GtkRadioAction index:%d",
1364 g_slist_index (group, action));
1366 g_settings_set_string (priv->gsettings_contacts,
1367 EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
1368 enum_value->value_nick);
1370 empathy_individual_store_set_sort_criterium (priv->individual_store,
1375 main_window_view_show_protocols_cb (GtkToggleAction *action,
1376 EmpathyMainWindow *window)
1378 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1381 value = gtk_toggle_action_get_active (action);
1383 g_settings_set_boolean (priv->gsettings_ui,
1384 EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
1386 empathy_individual_store_set_show_protocols (priv->individual_store,
1390 /* Matches GtkRadioAction values set in empathy-main-window.ui */
1391 #define CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS 0
1392 #define CONTACT_LIST_NORMAL_SIZE 1
1393 #define CONTACT_LIST_COMPACT_SIZE 2
1396 main_window_view_contacts_list_size_cb (GtkRadioAction *action,
1397 GtkRadioAction *current,
1398 EmpathyMainWindow *window)
1400 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1401 GSettings *gsettings_ui;
1404 value = gtk_radio_action_get_current_value (action);
1405 /* create a new GSettings, so we can delay the setting until both
1407 gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
1409 DEBUG ("radio button toggled, value = %i", value);
1411 g_settings_delay (gsettings_ui);
1412 g_settings_set_boolean (gsettings_ui,
1413 EMPATHY_PREFS_UI_SHOW_AVATARS,
1414 value == CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS);
1416 g_settings_set_boolean (gsettings_ui,
1417 EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
1418 value == CONTACT_LIST_COMPACT_SIZE);
1419 g_settings_apply (gsettings_ui);
1421 /* FIXME: these enums probably have the wrong namespace */
1422 empathy_individual_store_set_show_avatars (priv->individual_store,
1423 value == CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS);
1424 empathy_individual_store_set_is_compact (priv->individual_store,
1425 value == CONTACT_LIST_COMPACT_SIZE);
1427 g_object_unref (gsettings_ui);
1430 static void main_window_notify_show_protocols_cb (GSettings *gsettings,
1432 EmpathyMainWindow *window)
1434 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1436 gtk_toggle_action_set_active (priv->show_protocols,
1437 g_settings_get_boolean (gsettings,
1438 EMPATHY_PREFS_UI_SHOW_PROTOCOLS));
1443 main_window_notify_contact_list_size_cb (GSettings *gsettings,
1445 EmpathyMainWindow *window)
1447 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1450 if (g_settings_get_boolean (gsettings,
1451 EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST)) {
1452 value = CONTACT_LIST_COMPACT_SIZE;
1453 } else if (g_settings_get_boolean (gsettings,
1454 EMPATHY_PREFS_UI_SHOW_AVATARS)) {
1455 value = CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS;
1457 value = CONTACT_LIST_NORMAL_SIZE;
1460 DEBUG ("setting changed, value = %i", value);
1462 /* By changing the value of the GtkRadioAction,
1463 it emits a signal that calls main_window_view_contacts_list_size_cb
1464 which updates the contacts list */
1465 gtk_radio_action_set_current_value (priv->normal_with_avatars, value);
1469 main_window_edit_search_contacts_cb (GtkCheckMenuItem *item,
1470 EmpathyMainWindow *window)
1472 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1474 empathy_individual_view_start_search (priv->individual_view);
1478 main_window_view_show_map_cb (GtkCheckMenuItem *item,
1479 EmpathyMainWindow *window)
1481 #ifdef HAVE_LIBCHAMPLAIN
1482 empathy_map_view_show ();
1487 join_chatroom (EmpathyChatroom *chatroom,
1493 account = empathy_chatroom_get_account (chatroom);
1494 room = empathy_chatroom_get_room (chatroom);
1496 DEBUG ("Requesting channel for '%s'", room);
1497 empathy_join_muc (account, room, timestamp);
1503 EmpathyChatroom *chatroom;
1507 } join_fav_account_sig_ctx;
1509 static join_fav_account_sig_ctx *
1510 join_fav_account_sig_ctx_new (TpAccount *account,
1511 EmpathyChatroom *chatroom,
1514 join_fav_account_sig_ctx *ctx = g_slice_new0 (
1515 join_fav_account_sig_ctx);
1517 ctx->account = g_object_ref (account);
1518 ctx->chatroom = g_object_ref (chatroom);
1519 ctx->timestamp = timestamp;
1524 join_fav_account_sig_ctx_free (join_fav_account_sig_ctx *ctx)
1526 g_object_unref (ctx->account);
1527 g_object_unref (ctx->chatroom);
1528 g_slice_free (join_fav_account_sig_ctx, ctx);
1532 account_status_changed_cb (TpAccount *account,
1533 TpConnectionStatus old_status,
1534 TpConnectionStatus new_status,
1536 gchar *dbus_error_name,
1537 GHashTable *details,
1540 join_fav_account_sig_ctx *ctx = user_data;
1542 switch (new_status) {
1543 case TP_CONNECTION_STATUS_DISCONNECTED:
1544 /* Don't wait any longer */
1548 case TP_CONNECTION_STATUS_CONNECTING:
1552 case TP_CONNECTION_STATUS_CONNECTED:
1553 /* We can join the room */
1557 g_assert_not_reached ();
1560 join_chatroom (ctx->chatroom, ctx->timestamp);
1563 g_source_remove (ctx->timeout);
1564 g_signal_handler_disconnect (account, ctx->sig_id);
1567 #define JOIN_FAVORITE_TIMEOUT 5
1570 join_favorite_timeout_cb (gpointer data)
1572 join_fav_account_sig_ctx *ctx = data;
1574 /* stop waiting for joining the favorite room */
1575 g_signal_handler_disconnect (ctx->account, ctx->sig_id);
1580 main_window_favorite_chatroom_join (EmpathyChatroom *chatroom)
1584 account = empathy_chatroom_get_account (chatroom);
1585 if (tp_account_get_connection_status (account, NULL) !=
1586 TP_CONNECTION_STATUS_CONNECTED) {
1587 join_fav_account_sig_ctx *ctx;
1589 ctx = join_fav_account_sig_ctx_new (account, chatroom,
1590 empathy_get_current_action_time ());
1592 ctx->sig_id = g_signal_connect_data (account, "status-changed",
1593 G_CALLBACK (account_status_changed_cb), ctx,
1594 (GClosureNotify) join_fav_account_sig_ctx_free, 0);
1596 ctx->timeout = g_timeout_add_seconds (JOIN_FAVORITE_TIMEOUT,
1597 join_favorite_timeout_cb, ctx);
1601 join_chatroom (chatroom, empathy_get_current_action_time ());
1605 main_window_favorite_chatroom_menu_activate_cb (GtkMenuItem *menu_item,
1606 EmpathyChatroom *chatroom)
1608 main_window_favorite_chatroom_join (chatroom);
1612 main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window,
1613 EmpathyChatroom *chatroom)
1615 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1616 GtkWidget *menu_item;
1617 const gchar *name, *account_name;
1621 if (g_object_get_data (G_OBJECT (chatroom), "menu_item")) {
1625 name = empathy_chatroom_get_name (chatroom);
1626 account_name = tp_account_get_display_name (
1627 empathy_chatroom_get_account (chatroom));
1628 label = g_strdup_printf ("%s (%s)", name, account_name);
1629 menu_item = gtk_menu_item_new_with_label (label);
1631 g_object_set_data (G_OBJECT (menu_item), "is_favorite",
1632 GUINT_TO_POINTER (TRUE));
1634 g_object_set_data (G_OBJECT (chatroom), "menu_item", menu_item);
1635 g_signal_connect (menu_item, "activate",
1636 G_CALLBACK (main_window_favorite_chatroom_menu_activate_cb),
1639 gtk_menu_shell_insert (GTK_MENU_SHELL (priv->room_menu),
1642 gtk_widget_show (menu_item);
1646 main_window_favorite_chatroom_menu_added_cb (EmpathyChatroomManager *manager,
1647 EmpathyChatroom *chatroom,
1648 EmpathyMainWindow *window)
1650 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1652 main_window_favorite_chatroom_menu_add (window, chatroom);
1653 gtk_widget_show (priv->room_separator);
1654 gtk_action_set_sensitive (priv->room_join_favorites, TRUE);
1658 main_window_favorite_chatroom_menu_removed_cb (EmpathyChatroomManager *manager,
1659 EmpathyChatroom *chatroom,
1660 EmpathyMainWindow *window)
1662 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1663 GtkWidget *menu_item;
1666 menu_item = g_object_get_data (G_OBJECT (chatroom), "menu_item");
1667 g_object_set_data (G_OBJECT (chatroom), "menu_item", NULL);
1668 gtk_widget_destroy (menu_item);
1670 chatrooms = empathy_chatroom_manager_get_chatrooms (priv->chatroom_manager, NULL);
1672 gtk_widget_show (priv->room_separator);
1674 gtk_widget_hide (priv->room_separator);
1677 gtk_action_set_sensitive (priv->room_join_favorites, chatrooms != NULL);
1678 g_list_free (chatrooms);
1682 main_window_favorite_chatroom_menu_setup (EmpathyMainWindow *window)
1684 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1685 GList *chatrooms, *l;
1688 priv->chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL);
1689 chatrooms = empathy_chatroom_manager_get_chatrooms (
1690 priv->chatroom_manager, NULL);
1691 room = gtk_ui_manager_get_widget (priv->ui_manager,
1693 priv->room_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (room));
1694 priv->room_separator = gtk_ui_manager_get_widget (priv->ui_manager,
1695 "/menubar/room/room_separator");
1697 for (l = chatrooms; l; l = l->next) {
1698 main_window_favorite_chatroom_menu_add (window, l->data);
1702 gtk_widget_hide (priv->room_separator);
1705 gtk_action_set_sensitive (priv->room_join_favorites, chatrooms != NULL);
1707 g_signal_connect (priv->chatroom_manager, "chatroom-added",
1708 G_CALLBACK (main_window_favorite_chatroom_menu_added_cb),
1710 g_signal_connect (priv->chatroom_manager, "chatroom-removed",
1711 G_CALLBACK (main_window_favorite_chatroom_menu_removed_cb),
1714 g_list_free (chatrooms);
1718 main_window_room_join_new_cb (GtkAction *action,
1719 EmpathyMainWindow *window)
1721 empathy_new_chatroom_dialog_show (GTK_WINDOW (window));
1725 main_window_room_join_favorites_cb (GtkAction *action,
1726 EmpathyMainWindow *window)
1728 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1729 GList *chatrooms, *l;
1731 chatrooms = empathy_chatroom_manager_get_chatrooms (priv->chatroom_manager, NULL);
1732 for (l = chatrooms; l; l = l->next) {
1733 main_window_favorite_chatroom_join (l->data);
1735 g_list_free (chatrooms);
1739 main_window_room_manage_favorites_cb (GtkAction *action,
1740 EmpathyMainWindow *window)
1742 empathy_chatrooms_window_show (GTK_WINDOW (window));
1746 main_window_edit_cb (GtkAction *action,
1747 EmpathyMainWindow *window)
1749 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1752 /* FIXME: It should use the UIManager to merge the contact/group submenu */
1753 submenu = empathy_individual_view_get_individual_menu (
1754 priv->individual_view);
1759 item = GTK_MENU_ITEM (priv->edit_context);
1760 label = gtk_bin_get_child (GTK_BIN (item));
1761 gtk_label_set_text (GTK_LABEL (label), _("Contact"));
1763 gtk_widget_show (priv->edit_context);
1764 gtk_widget_show (priv->edit_context_separator);
1766 gtk_menu_item_set_submenu (item, submenu);
1771 submenu = empathy_individual_view_get_group_menu (
1772 priv->individual_view);
1777 item = GTK_MENU_ITEM (priv->edit_context);
1778 label = gtk_bin_get_child (GTK_BIN (item));
1779 gtk_label_set_text (GTK_LABEL (label), _("Group"));
1781 gtk_widget_show (priv->edit_context);
1782 gtk_widget_show (priv->edit_context_separator);
1784 gtk_menu_item_set_submenu (item, submenu);
1789 gtk_widget_hide (priv->edit_context);
1790 gtk_widget_hide (priv->edit_context_separator);
1796 main_window_edit_accounts_cb (GtkAction *action,
1797 EmpathyMainWindow *window)
1799 empathy_accounts_dialog_show_application (gdk_screen_get_default (),
1800 NULL, FALSE, FALSE);
1804 main_window_edit_personal_information_cb (GtkAction *action,
1805 EmpathyMainWindow *window)
1807 empathy_contact_personal_dialog_show (GTK_WINDOW (window));
1811 main_window_edit_blocked_contacts_cb (GtkAction *action,
1812 EmpathyMainWindow *window)
1816 dialog = empathy_contact_blocking_dialog_new (GTK_WINDOW (window));
1817 gtk_widget_show (dialog);
1818 g_signal_connect (dialog, "response",
1819 G_CALLBACK (gtk_widget_destroy), NULL);
1823 main_window_edit_preferences_cb (GtkAction *action,
1824 EmpathyMainWindow *window)
1826 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1828 if (priv->preferences == NULL) {
1829 priv->preferences = empathy_preferences_new (GTK_WINDOW (window));
1830 g_object_add_weak_pointer (G_OBJECT (priv->preferences),
1831 (gpointer) &priv->preferences);
1833 gtk_widget_show (priv->preferences);
1835 gtk_window_present (GTK_WINDOW (priv->preferences));
1840 main_window_help_about_cb (GtkAction *action,
1841 EmpathyMainWindow *window)
1843 empathy_about_dialog_new (GTK_WINDOW (window));
1847 main_window_help_debug_cb (GtkAction *action,
1848 EmpathyMainWindow *window)
1850 GdkDisplay *display;
1851 GError *error = NULL;
1854 GdkAppLaunchContext *context = NULL;
1856 /* Try to run from source directory if possible */
1857 path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "src",
1858 "empathy-debugger", NULL);
1860 if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
1862 path = g_build_filename (BIN_DIR, "empathy-debugger", NULL);
1865 app_info = g_app_info_create_from_commandline (path, NULL, 0, &error);
1866 if (app_info == NULL) {
1867 DEBUG ("Failed to create app info: %s", error->message);
1868 g_error_free (error);
1872 display = gdk_display_get_default ();
1873 context = gdk_display_get_app_launch_context (display);
1875 if (!g_app_info_launch (app_info, NULL, (GAppLaunchContext *) context,
1877 g_warning ("Failed to open debug window: %s", error->message);
1878 g_error_free (error);
1883 tp_clear_object (&app_info);
1884 tp_clear_object (&context);
1889 main_window_help_contents_cb (GtkAction *action,
1890 EmpathyMainWindow *window)
1892 empathy_url_show (GTK_WIDGET (window), "ghelp:empathy");
1896 main_window_throbber_button_press_event_cb (GtkWidget *throbber,
1897 GdkEventButton *event,
1898 EmpathyMainWindow *window)
1900 if (event->type != GDK_BUTTON_PRESS ||
1901 event->button != 1) {
1905 empathy_accounts_dialog_show_application (
1906 gtk_widget_get_screen (GTK_WIDGET (throbber)),
1907 NULL, FALSE, FALSE);
1913 main_window_account_removed_cb (TpAccountManager *manager,
1915 EmpathyMainWindow *window)
1917 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1920 a = tp_account_manager_get_valid_accounts (manager);
1922 gtk_action_set_sensitive (priv->view_history,
1923 g_list_length (a) > 0);
1927 /* remove errors if any */
1928 main_window_remove_error (window, account);
1930 /* remove the balance action if required */
1931 main_window_remove_balance_action (window, account);
1935 main_window_account_validity_changed_cb (TpAccountManager *manager,
1938 EmpathyMainWindow *window)
1940 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1944 handler_id = GPOINTER_TO_UINT (g_hash_table_lookup (
1945 priv->status_changed_handlers, account));
1947 /* connect signal only if it was not connected yet */
1948 if (handler_id == 0) {
1949 handler_id = g_signal_connect (account,
1951 G_CALLBACK (main_window_connection_changed_cb),
1953 g_hash_table_insert (priv->status_changed_handlers,
1954 account, GUINT_TO_POINTER (handler_id));
1958 main_window_account_removed_cb (manager, account, window);
1962 main_window_notify_show_offline_cb (GSettings *gsettings,
1964 gpointer toggle_action)
1966 gtk_toggle_action_set_active (toggle_action,
1967 g_settings_get_boolean (gsettings, key));
1971 main_window_connection_items_setup (EmpathyMainWindow *window,
1974 EmpathyMainWindowPriv *priv = GET_PRIV (window);
1978 const gchar *actions_connected[] = {
1980 "room_join_favorites",
1984 "edit_personal_information",
1985 "edit_blocked_contacts"
1988 for (i = 0, list = NULL; i < G_N_ELEMENTS (actions_connected); i++) {
1989 action = gtk_builder_get_object (gui, actions_connected[i]);
1990 list = g_list_prepend (list, action);
1993 priv->actions_connected = list;
1997 account_manager_prepared_cb (GObject *source_object,
1998 GAsyncResult *result,
2001 GList *accounts, *j;
2002 TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
2003 EmpathyMainWindow *window = user_data;
2004 EmpathyMainWindowPriv *priv = GET_PRIV (window);
2005 GError *error = NULL;
2007 if (!tp_account_manager_prepare_finish (manager, result, &error)) {
2008 DEBUG ("Failed to prepare account manager: %s", error->message);
2009 g_error_free (error);
2013 accounts = tp_account_manager_get_valid_accounts (priv->account_manager);
2014 for (j = accounts; j != NULL; j = j->next) {
2015 TpAccount *account = TP_ACCOUNT (j->data);
2018 handler_id = g_signal_connect (account, "status-changed",
2019 G_CALLBACK (main_window_connection_changed_cb),
2021 g_hash_table_insert (priv->status_changed_handlers,
2022 account, GUINT_TO_POINTER (handler_id));
2024 main_window_setup_balance (window, account);
2027 g_signal_connect (manager, "account-validity-changed",
2028 G_CALLBACK (main_window_account_validity_changed_cb),
2031 main_window_update_status (window);
2033 /* Disable the "Previous Conversations" menu entry if there is no account */
2034 gtk_action_set_sensitive (priv->view_history,
2035 g_list_length (accounts) > 0);
2037 g_list_free (accounts);
2041 main_window_members_changed_cb (EmpathyContactList *list,
2042 EmpathyContact *contact,
2043 EmpathyContact *actor,
2047 EmpathyMainWindow *window)
2049 EmpathyMainWindowPriv *priv = GET_PRIV (window);
2054 if (!empathy_migrate_butterfly_logs (contact)) {
2055 g_signal_handler_disconnect (list,
2056 priv->butterfly_log_migration_members_changed_id);
2057 priv->butterfly_log_migration_members_changed_id = 0;
2062 empathy_main_window_constructor (GType type,
2063 guint n_construct_params,
2064 GObjectConstructParam *construct_params)
2066 static GObject *window = NULL;
2069 return g_object_ref (window);
2071 window = G_OBJECT_CLASS (empathy_main_window_parent_class)->constructor (
2072 type, n_construct_params, construct_params);
2074 g_object_add_weak_pointer (window, (gpointer) &window);
2080 empathy_main_window_class_init (EmpathyMainWindowClass *klass)
2082 GObjectClass *object_class = G_OBJECT_CLASS (klass);
2084 object_class->finalize = empathy_main_window_finalize;
2085 object_class->constructor = empathy_main_window_constructor;
2087 g_type_class_add_private (object_class, sizeof (EmpathyMainWindowPriv));
2091 empathy_main_window_init (EmpathyMainWindow *window)
2093 EmpathyMainWindowPriv *priv;
2094 EmpathyIndividualManager *individual_manager;
2097 GtkToggleAction *show_offline_widget;
2098 GtkAction *show_map_widget;
2100 gboolean show_offline;
2103 GtkTreeModel *model;
2105 priv = window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window,
2106 EMPATHY_TYPE_MAIN_WINDOW, EmpathyMainWindowPriv);
2108 priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
2109 priv->gsettings_contacts = g_settings_new (EMPATHY_PREFS_CONTACTS_SCHEMA);
2111 priv->sound_mgr = empathy_sound_manager_dup_singleton ();
2113 gtk_window_set_title (GTK_WINDOW (window), _("Contact List"));
2114 gtk_window_set_role (GTK_WINDOW (window), "contact_list");
2115 gtk_window_set_default_size (GTK_WINDOW (window), 225, 325);
2117 /* Set up interface */
2118 filename = empathy_file_lookup ("empathy-main-window.ui", "src");
2119 gui = empathy_builder_get_file (filename,
2120 "main_vbox", &priv->main_vbox,
2121 "balance_vbox", &priv->balance_vbox,
2122 "errors_vbox", &priv->errors_vbox,
2123 "auth_vbox", &priv->auth_vbox,
2124 "ui_manager", &priv->ui_manager,
2125 "view_show_offline", &show_offline_widget,
2126 "view_show_protocols", &priv->show_protocols,
2127 "view_sort_by_name", &priv->sort_by_name,
2128 "view_sort_by_status", &priv->sort_by_status,
2129 "view_normal_size_with_avatars", &priv->normal_with_avatars,
2130 "view_normal_size", &priv->normal_size,
2131 "view_compact_size", &priv->compact_size,
2132 "view_history", &priv->view_history,
2133 "view_show_map", &show_map_widget,
2134 "room_join_favorites", &priv->room_join_favorites,
2135 "presence_toolbar", &priv->presence_toolbar,
2136 "notebook", &priv->notebook,
2137 "no_entry_label", &priv->no_entry_label,
2138 "roster_scrolledwindow", &sw,
2139 "view_balance_show_in_roster", &priv->view_balance_show_in_roster,
2143 gtk_container_add (GTK_CONTAINER (window), priv->main_vbox);
2144 gtk_widget_show (priv->main_vbox);
2146 g_signal_connect (window, "key-press-event",
2147 G_CALLBACK (main_window_key_press_event_cb), NULL);
2149 empathy_builder_connect (gui, window,
2150 "chat_quit", "activate", main_window_chat_quit_cb,
2151 "chat_new_message", "activate", main_window_chat_new_message_cb,
2152 "chat_new_call", "activate", main_window_chat_new_call_cb,
2153 "view_history", "activate", main_window_view_history_cb,
2154 "room_join_new", "activate", main_window_room_join_new_cb,
2155 "room_join_favorites", "activate", main_window_room_join_favorites_cb,
2156 "room_manage_favorites", "activate", main_window_room_manage_favorites_cb,
2157 "chat_add_contact", "activate", main_window_chat_add_contact_cb,
2158 "chat_search_contacts", "activate", main_window_chat_search_contacts_cb,
2159 "view_show_ft_manager", "activate", main_window_view_show_ft_manager,
2160 "view_show_offline", "toggled", main_window_view_show_offline_cb,
2161 "view_show_protocols", "toggled", main_window_view_show_protocols_cb,
2162 "view_sort_by_name", "changed", main_window_view_sort_contacts_cb,
2163 "view_normal_size_with_avatars", "changed", main_window_view_contacts_list_size_cb,
2164 "view_show_map", "activate", main_window_view_show_map_cb,
2165 "edit", "activate", main_window_edit_cb,
2166 "edit_accounts", "activate", main_window_edit_accounts_cb,
2167 "edit_personal_information", "activate", main_window_edit_personal_information_cb,
2168 "edit_blocked_contacts", "activate", main_window_edit_blocked_contacts_cb,
2169 "edit_preferences", "activate", main_window_edit_preferences_cb,
2170 "edit_search_contacts", "activate", main_window_edit_search_contacts_cb,
2171 "help_about", "activate", main_window_help_about_cb,
2172 "help_debug", "activate", main_window_help_debug_cb,
2173 "help_contents", "activate", main_window_help_contents_cb,
2176 /* Set up connection related widgets. */
2177 main_window_connection_items_setup (window, gui);
2179 g_object_ref (priv->ui_manager);
2180 g_object_unref (gui);
2182 #ifndef HAVE_LIBCHAMPLAIN
2183 gtk_action_set_visible (show_map_widget, FALSE);
2186 priv->account_manager = tp_account_manager_dup ();
2188 tp_account_manager_prepare_async (priv->account_manager, NULL,
2189 account_manager_prepared_cb, window);
2191 priv->errors = g_hash_table_new_full (g_direct_hash,
2196 priv->auths = g_hash_table_new (NULL, NULL);
2198 priv->status_changed_handlers = g_hash_table_new_full (g_direct_hash,
2204 main_window_favorite_chatroom_menu_setup (window);
2206 priv->edit_context = gtk_ui_manager_get_widget (priv->ui_manager,
2207 "/menubar/edit/edit_context");
2208 priv->edit_context_separator = gtk_ui_manager_get_widget (
2210 "/menubar/edit/edit_context_separator");
2211 gtk_widget_hide (priv->edit_context);
2212 gtk_widget_hide (priv->edit_context_separator);
2214 /* Set up contact list. */
2215 empathy_status_presets_get_all ();
2217 /* Set up presence chooser */
2218 priv->presence_chooser = empathy_presence_chooser_new ();
2219 gtk_widget_show (priv->presence_chooser);
2220 item = gtk_tool_item_new ();
2221 gtk_widget_show (GTK_WIDGET (item));
2222 gtk_widget_set_size_request (priv->presence_chooser, 10, -1);
2223 gtk_container_add (GTK_CONTAINER (item), priv->presence_chooser);
2224 gtk_tool_item_set_is_important (item, TRUE);
2225 gtk_tool_item_set_expand (item, TRUE);
2226 gtk_toolbar_insert (GTK_TOOLBAR (priv->presence_toolbar), item, -1);
2228 /* Set up the throbber */
2229 priv->throbber = gtk_spinner_new ();
2230 gtk_widget_set_size_request (priv->throbber, 16, -1);
2231 gtk_widget_set_tooltip_text (priv->throbber, _("Show and edit accounts"));
2232 gtk_widget_set_events (priv->throbber, GDK_BUTTON_PRESS_MASK);
2233 g_signal_connect (priv->throbber, "button-press-event",
2234 G_CALLBACK (main_window_throbber_button_press_event_cb),
2236 gtk_widget_show (priv->throbber);
2238 item = gtk_tool_item_new ();
2239 gtk_container_set_border_width (GTK_CONTAINER (item), 6);
2240 gtk_toolbar_insert (GTK_TOOLBAR (priv->presence_toolbar), item, -1);
2241 gtk_container_add (GTK_CONTAINER (item), priv->throbber);
2242 priv->throbber_tool_item = GTK_WIDGET (item);
2244 /* XXX: this class is designed to live for the duration of the program,
2245 * so it's got a race condition between its signal handlers and its
2246 * finalization. The class is planned to be removed, so we won't fix
2247 * this before then. */
2248 priv->contact_manager = EMPATHY_CONTACT_LIST (
2249 empathy_contact_manager_dup_singleton ());
2250 individual_manager = empathy_individual_manager_dup_singleton ();
2251 priv->individual_store = empathy_individual_store_new (
2252 individual_manager);
2253 g_object_unref (individual_manager);
2255 /* For the moment, we disallow Persona drops onto the main contact list (e.g. from things such as
2256 * the EmpathyPersonaView in the linking dialogue). No code is hooked up to do anything on a Persona
2257 * drop, so allowing them would achieve nothing except confusion. */
2258 priv->individual_view = empathy_individual_view_new (
2259 priv->individual_store,
2260 EMPATHY_INDIVIDUAL_VIEW_FEATURE_ALL ^ EMPATHY_INDIVIDUAL_VIEW_FEATURE_PERSONA_DROP,
2261 EMPATHY_INDIVIDUAL_FEATURE_ALL);
2263 priv->butterfly_log_migration_members_changed_id = g_signal_connect (
2264 priv->contact_manager, "members-changed",
2265 G_CALLBACK (main_window_members_changed_cb), window);
2267 gtk_widget_show (GTK_WIDGET (priv->individual_view));
2268 gtk_container_add (GTK_CONTAINER (sw),
2269 GTK_WIDGET (priv->individual_view));
2270 g_signal_connect (priv->individual_view, "row-activated",
2271 G_CALLBACK (main_window_row_activated_cb),
2274 /* Set up search bar */
2275 priv->search_bar = empathy_live_search_new (
2276 GTK_WIDGET (priv->individual_view));
2277 empathy_individual_view_set_live_search (priv->individual_view,
2278 EMPATHY_LIVE_SEARCH (priv->search_bar));
2279 gtk_box_pack_start (GTK_BOX (priv->main_vbox), priv->search_bar,
2281 g_signal_connect_swapped (window, "map",
2282 G_CALLBACK (gtk_widget_grab_focus), priv->individual_view);
2284 /* Connect to proper signals to check if contact list is empty or not */
2285 model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->individual_view));
2287 g_signal_connect (model, "row-inserted",
2288 G_CALLBACK (main_window_row_inserted_cb),
2290 g_signal_connect (model, "row-deleted",
2291 G_CALLBACK (main_window_row_deleted_cb),
2294 /* Load user-defined accelerators. */
2295 main_window_accels_load ();
2297 /* Set window size. */
2298 empathy_geometry_bind (GTK_WINDOW (window), GEOMETRY_NAME);
2300 /* bind view_balance_show_in_roster */
2301 g_settings_bind (priv->gsettings_ui, "show-balance-in-roster",
2302 priv->view_balance_show_in_roster, "active",
2303 G_SETTINGS_BIND_DEFAULT);
2304 g_object_bind_property (priv->view_balance_show_in_roster, "active",
2305 priv->balance_vbox, "visible",
2306 G_BINDING_SYNC_CREATE);
2308 /* Enable event handling */
2309 priv->call_observer = empathy_call_observer_dup_singleton ();
2310 priv->event_manager = empathy_event_manager_dup_singleton ();
2312 g_signal_connect (priv->event_manager, "event-added",
2313 G_CALLBACK (main_window_event_added_cb), window);
2314 g_signal_connect (priv->event_manager, "event-removed",
2315 G_CALLBACK (main_window_event_removed_cb), window);
2316 g_signal_connect (priv->account_manager, "account-validity-changed",
2317 G_CALLBACK (main_window_account_validity_changed_cb),
2319 g_signal_connect (priv->account_manager, "account-removed",
2320 G_CALLBACK (main_window_account_removed_cb),
2322 g_signal_connect (priv->account_manager, "account-disabled",
2323 G_CALLBACK (main_window_account_disabled_cb),
2326 l = empathy_event_manager_get_events (priv->event_manager);
2328 main_window_event_added_cb (priv->event_manager, l->data,
2333 /* Show offline ? */
2334 show_offline = g_settings_get_boolean (priv->gsettings_ui,
2335 EMPATHY_PREFS_UI_SHOW_OFFLINE);
2336 g_signal_connect (priv->gsettings_ui,
2337 "changed::" EMPATHY_PREFS_UI_SHOW_OFFLINE,
2338 G_CALLBACK (main_window_notify_show_offline_cb),
2339 show_offline_widget);
2341 gtk_toggle_action_set_active (show_offline_widget, show_offline);
2343 /* Show protocol ? */
2344 g_signal_connect (priv->gsettings_ui,
2345 "changed::" EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
2346 G_CALLBACK (main_window_notify_show_protocols_cb),
2349 main_window_notify_show_protocols_cb (priv->gsettings_ui,
2350 EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
2353 /* Sort by name / by status ? */
2354 g_signal_connect (priv->gsettings_contacts,
2355 "changed::" EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
2356 G_CALLBACK (main_window_notify_sort_contact_cb),
2359 main_window_notify_sort_contact_cb (priv->gsettings_contacts,
2360 EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
2363 /* Contacts list size */
2364 g_signal_connect (priv->gsettings_ui,
2365 "changed::" EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
2366 G_CALLBACK (main_window_notify_contact_list_size_cb),
2368 g_signal_connect (priv->gsettings_ui,
2369 "changed::" EMPATHY_PREFS_UI_SHOW_AVATARS,
2370 G_CALLBACK (main_window_notify_contact_list_size_cb),
2373 main_window_notify_contact_list_size_cb (priv->gsettings_ui,
2374 EMPATHY_PREFS_UI_SHOW_AVATARS,
2379 empathy_main_window_dup (void)
2381 return g_object_new (EMPATHY_TYPE_MAIN_WINDOW, NULL);