1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007 Collabora Ltd.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program 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 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Authors: Xavier Claessens <xclaesse@gmail.com>
27 #include <glade/glade.h>
28 #include <glib/gi18n.h>
30 #include <libempathy/empathy-conf.h>
31 #include <libempathy/empathy-contact.h>
32 #include <libempathy/empathy-debug.h>
33 #include <libempathy/empathy-utils.h>
34 #include <libempathy/empathy-chatroom-manager.h>
35 #include <libempathy/empathy-chatroom.h>
36 #include <libempathy/empathy-contact-list.h>
37 #include <libempathy/empathy-contact-manager.h>
39 #include "empathy-main-window.h"
40 #include "empathy-contact-dialogs.h"
41 #include "ephy-spinner.h"
42 #include "empathy-contact-list-store.h"
43 #include "empathy-contact-list-view.h"
44 #include "empathy-presence-chooser.h"
45 #include "empathy-ui-utils.h"
46 #include "empathy-status-presets.h"
47 #include "empathy-geometry.h"
48 #include "empathy-preferences.h"
49 #include "empathy-accounts-dialog.h"
50 #include "empathy-about-dialog.h"
51 #include "empathy-new-chatroom-dialog.h"
52 #include "empathy-chatrooms-window.h"
53 #include "empathy-log-window.h"
55 #define DEBUG_DOMAIN "MainWindow"
57 /* Minimum width of roster window if something goes wrong. */
60 /* Accels (menu shortcuts) can be configured and saved */
61 #define ACCELS_FILENAME "accels.txt"
63 /* Name in the geometry file */
64 #define GEOMETRY_NAME "main-window"
67 EmpathyContactListView *list_view;
68 EmpathyContactListStore *list_store;
70 EmpathyChatroomManager *chatroom_manager;
76 /* Tooltips for all widgets */
77 GtkTooltips *tooltips;
83 GtkWidget *room_join_favorites;
84 GtkWidget *edit_context;
85 GtkWidget *edit_context_separator;
90 /* Widgets that are enabled when there is... */
91 GList *widgets_connected; /* ... connected accounts */
92 GList *widgets_disconnected; /* ... disconnected accounts */
95 GtkWidget *presence_toolbar;
96 GtkWidget *presence_chooser;
99 guint size_timeout_id;
102 static void main_window_destroy_cb (GtkWidget *widget,
103 EmpathyMainWindow *window);
104 static void main_window_favorite_chatroom_menu_setup (EmpathyMainWindow *window);
105 static void main_window_favorite_chatroom_menu_added_cb (EmpathyChatroomManager *manager,
106 EmpathyChatroom *chatroom,
107 EmpathyMainWindow *window);
108 static void main_window_favorite_chatroom_menu_removed_cb (EmpathyChatroomManager *manager,
109 EmpathyChatroom *chatroom,
110 EmpathyMainWindow *window);
111 static void main_window_favorite_chatroom_menu_activate_cb (GtkMenuItem *menu_item,
112 EmpathyChatroom *chatroom);
113 static void main_window_favorite_chatroom_menu_update (EmpathyMainWindow *window);
114 static void main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window,
115 EmpathyChatroom *chatroom);
116 static void main_window_favorite_chatroom_join (EmpathyChatroom *chatroom);
117 static void main_window_chat_quit_cb (GtkWidget *widget,
118 EmpathyMainWindow *window);
119 static void main_window_chat_new_message_cb (GtkWidget *widget,
120 EmpathyMainWindow *window);
121 static void main_window_chat_history_cb (GtkWidget *widget,
122 EmpathyMainWindow *window);
123 static void main_window_room_join_new_cb (GtkWidget *widget,
124 EmpathyMainWindow *window);
125 static void main_window_room_join_favorites_cb (GtkWidget *widget,
126 EmpathyMainWindow *window);
127 static void main_window_room_manage_favorites_cb (GtkWidget *widget,
128 EmpathyMainWindow *window);
129 static void main_window_chat_add_contact_cb (GtkWidget *widget,
130 EmpathyMainWindow *window);
131 static void main_window_chat_show_offline_cb (GtkCheckMenuItem *item,
132 EmpathyMainWindow *window);
133 static gboolean main_window_edit_button_press_event_cb (GtkWidget *widget,
134 GdkEventButton *event,
135 EmpathyMainWindow *window);
136 static void main_window_edit_accounts_cb (GtkWidget *widget,
137 EmpathyMainWindow *window);
138 static void main_window_edit_personal_information_cb (GtkWidget *widget,
139 EmpathyMainWindow *window);
140 static void main_window_edit_preferences_cb (GtkWidget *widget,
141 EmpathyMainWindow *window);
142 static void main_window_help_about_cb (GtkWidget *widget,
143 EmpathyMainWindow *window);
144 static void main_window_help_contents_cb (GtkWidget *widget,
145 EmpathyMainWindow *window);
146 static gboolean main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox,
147 GdkEventButton *event,
148 EmpathyMainWindow *window);
149 static void main_window_status_changed_cb (MissionControl *mc,
150 TelepathyConnectionStatus status,
152 TelepathyConnectionStatusReason reason,
153 const gchar *unique_name,
154 EmpathyMainWindow *window);
155 static void main_window_update_status (EmpathyMainWindow *window);
156 static void main_window_accels_load (void);
157 static void main_window_accels_save (void);
158 static void main_window_connection_items_setup (EmpathyMainWindow *window,
160 static gboolean main_window_configure_event_timeout_cb (EmpathyMainWindow *window);
161 static gboolean main_window_configure_event_cb (GtkWidget *widget,
162 GdkEventConfigure *event,
163 EmpathyMainWindow *window);
164 static void main_window_notify_show_offline_cb (EmpathyConf *conf,
166 gpointer check_menu_item);
167 static void main_window_notify_show_avatars_cb (EmpathyConf *conf,
169 EmpathyMainWindow *window);
170 static void main_window_notify_compact_contact_list_cb (EmpathyConf *conf,
172 EmpathyMainWindow *window);
173 static void main_window_notify_sort_criterium_cb (EmpathyConf *conf,
175 EmpathyMainWindow *window);
178 empathy_main_window_show (void)
180 static EmpathyMainWindow *window = NULL;
181 EmpathyContactList *list_iface;
185 GtkWidget *show_offline_widget;
189 gboolean show_offline;
190 gboolean show_avatars;
191 gboolean compact_contact_list;
195 gtk_window_present (GTK_WINDOW (window->window));
196 return window->window;
199 window = g_new0 (EmpathyMainWindow, 1);
201 /* Set up interface */
202 glade = empathy_glade_get_file ("empathy-main-window.glade",
205 "main_window", &window->window,
206 "main_vbox", &window->main_vbox,
207 "chat_show_offline", &show_offline_widget,
208 "room", &window->room,
209 "room_sep", &window->room_sep,
210 "room_join_favorites", &window->room_join_favorites,
211 "edit_context", &window->edit_context,
212 "edit_context_separator", &window->edit_context_separator,
213 "presence_toolbar", &window->presence_toolbar,
214 "roster_scrolledwindow", &sw,
217 empathy_glade_connect (glade,
219 "main_window", "destroy", main_window_destroy_cb,
220 "main_window", "configure_event", main_window_configure_event_cb,
221 "chat_quit", "activate", main_window_chat_quit_cb,
222 "chat_new_message", "activate", main_window_chat_new_message_cb,
223 "chat_history", "activate", main_window_chat_history_cb,
224 "room_join_new", "activate", main_window_room_join_new_cb,
225 "room_join_favorites", "activate", main_window_room_join_favorites_cb,
226 "room_manage_favorites", "activate", main_window_room_manage_favorites_cb,
227 "chat_add_contact", "activate", main_window_chat_add_contact_cb,
228 "chat_show_offline", "toggled", main_window_chat_show_offline_cb,
229 "edit", "button-press-event", main_window_edit_button_press_event_cb,
230 "edit_accounts", "activate", main_window_edit_accounts_cb,
231 "edit_personal_information", "activate", main_window_edit_personal_information_cb,
232 "edit_preferences", "activate", main_window_edit_preferences_cb,
233 "help_about", "activate", main_window_help_about_cb,
234 "help_contents", "activate", main_window_help_contents_cb,
237 /* Set up connection related widgets. */
238 main_window_connection_items_setup (window, glade);
239 g_object_unref (glade);
241 window->tooltips = g_object_ref_sink (gtk_tooltips_new ());
242 window->mc = empathy_mission_control_new ();
243 dbus_g_proxy_connect_signal (DBUS_G_PROXY (window->mc), "AccountStatusChanged",
244 G_CALLBACK (main_window_status_changed_cb),
248 main_window_favorite_chatroom_menu_setup (window);
250 gtk_widget_hide (window->edit_context);
251 gtk_widget_hide (window->edit_context_separator);
253 /* Set up presence chooser */
254 window->presence_chooser = empathy_presence_chooser_new ();
255 gtk_widget_show (window->presence_chooser);
256 item = gtk_tool_item_new ();
257 gtk_widget_show (GTK_WIDGET (item));
258 gtk_container_add (GTK_CONTAINER (item), window->presence_chooser);
259 gtk_tool_item_set_is_important (item, TRUE);
260 gtk_tool_item_set_expand (item, TRUE);
261 gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
263 /* Set up the throbber */
264 ebox = gtk_event_box_new ();
265 gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
267 window->throbber = ephy_spinner_new ();
268 ephy_spinner_set_size (EPHY_SPINNER (window->throbber), GTK_ICON_SIZE_LARGE_TOOLBAR);
269 gtk_container_add (GTK_CONTAINER (ebox), window->throbber);
271 item = gtk_tool_item_new ();
272 gtk_container_add (GTK_CONTAINER (item), ebox);
273 gtk_widget_show_all (GTK_WIDGET (item));
275 gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
277 str = _("Show and edit accounts");
278 gtk_tooltips_set_tip (GTK_TOOLTIPS (window->tooltips),
281 g_signal_connect (ebox,
282 "button-press-event",
283 G_CALLBACK (main_window_throbber_button_press_event_cb),
286 /* Set up contact list. */
287 empathy_status_presets_get_all ();
289 list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_new ());
290 empathy_contact_list_setup (list_iface);
291 window->list_store = empathy_contact_list_store_new (list_iface);
292 window->list_view = empathy_contact_list_view_new (window->list_store);
293 g_object_unref (list_iface);
295 gtk_widget_show (GTK_WIDGET (window->list_view));
296 gtk_container_add (GTK_CONTAINER (sw),
297 GTK_WIDGET (window->list_view));
299 /* Load user-defined accelerators. */
300 main_window_accels_load ();
302 /* Set window size. */
303 empathy_geometry_load (GEOMETRY_NAME, &x, &y, &w, &h);
305 if (w >= 1 && h >= 1) {
306 /* Use the defaults from the glade file if we
307 * don't have good w, h geometry.
309 empathy_debug (DEBUG_DOMAIN, "Configuring window default size w:%d, h:%d", w, h);
310 gtk_window_set_default_size (GTK_WINDOW (window->window), w, h);
313 if (x >= 0 && y >= 0) {
314 /* Let the window manager position it if we
315 * don't have good x, y coordinates.
317 empathy_debug (DEBUG_DOMAIN, "Configuring window default position x:%d, y:%d", x, y);
318 gtk_window_move (GTK_WINDOW (window->window), x, y);
321 conf = empathy_conf_get ();
324 empathy_conf_get_bool (conf,
325 EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE,
327 empathy_conf_notify_add (conf,
328 EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE,
329 main_window_notify_show_offline_cb,
330 show_offline_widget);
332 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_offline_widget),
336 empathy_conf_get_bool (conf,
337 EMPATHY_PREFS_UI_SHOW_AVATARS,
339 empathy_conf_notify_add (conf,
340 EMPATHY_PREFS_UI_SHOW_AVATARS,
341 (EmpathyConfNotifyFunc) main_window_notify_show_avatars_cb,
343 empathy_contact_list_store_set_show_avatars (window->list_store, show_avatars);
346 empathy_conf_get_bool (conf,
347 EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
348 &compact_contact_list);
349 empathy_conf_notify_add (conf,
350 EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
351 (EmpathyConfNotifyFunc) main_window_notify_compact_contact_list_cb,
353 empathy_contact_list_store_set_is_compact (window->list_store, compact_contact_list);
356 empathy_conf_notify_add (conf,
357 EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
358 (EmpathyConfNotifyFunc) main_window_notify_sort_criterium_cb,
360 main_window_notify_sort_criterium_cb (conf,
361 EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
364 main_window_update_status (window);
366 return window->window;
370 main_window_destroy_cb (GtkWidget *widget,
371 EmpathyMainWindow *window)
373 /* Save user-defined accelerators. */
374 main_window_accels_save ();
376 dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (window->mc), "AccountStatusChanged",
377 G_CALLBACK (main_window_status_changed_cb),
380 if (window->size_timeout_id) {
381 g_source_remove (window->size_timeout_id);
384 g_list_free (window->widgets_connected);
385 g_list_free (window->widgets_disconnected);
387 g_object_unref (window->tooltips);
388 g_object_unref (window->mc);
389 g_object_unref (window->list_store);
395 main_window_favorite_chatroom_menu_setup (EmpathyMainWindow *window)
397 GList *chatrooms, *l;
399 window->chatroom_manager = empathy_chatroom_manager_new ();
400 chatrooms = empathy_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
401 window->room_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (window->room));
403 for (l = chatrooms; l; l = l->next) {
404 main_window_favorite_chatroom_menu_add (window, l->data);
408 gtk_widget_hide (window->room_sep);
411 gtk_widget_set_sensitive (window->room_join_favorites, chatrooms != NULL);
413 g_signal_connect (window->chatroom_manager, "chatroom-added",
414 G_CALLBACK (main_window_favorite_chatroom_menu_added_cb),
416 g_signal_connect (window->chatroom_manager, "chatroom-removed",
417 G_CALLBACK (main_window_favorite_chatroom_menu_removed_cb),
420 g_list_free (chatrooms);
424 main_window_favorite_chatroom_menu_added_cb (EmpathyChatroomManager *manager,
425 EmpathyChatroom *chatroom,
426 EmpathyMainWindow *window)
428 main_window_favorite_chatroom_menu_add (window, chatroom);
429 gtk_widget_show (window->room_sep);
430 gtk_widget_set_sensitive (window->room_join_favorites, TRUE);
434 main_window_favorite_chatroom_menu_removed_cb (EmpathyChatroomManager *manager,
435 EmpathyChatroom *chatroom,
436 EmpathyMainWindow *window)
438 GtkWidget *menu_item;
440 menu_item = g_object_get_data (G_OBJECT (chatroom), "menu_item");
442 g_object_set_data (G_OBJECT (chatroom), "menu_item", NULL);
443 gtk_widget_destroy (menu_item);
445 main_window_favorite_chatroom_menu_update (window);
449 main_window_favorite_chatroom_menu_activate_cb (GtkMenuItem *menu_item,
450 EmpathyChatroom *chatroom)
452 main_window_favorite_chatroom_join (chatroom);
456 main_window_favorite_chatroom_menu_update (EmpathyMainWindow *window)
460 chatrooms = empathy_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
463 gtk_widget_show (window->room_sep);
465 gtk_widget_hide (window->room_sep);
468 gtk_widget_set_sensitive (window->room_join_favorites, chatrooms != NULL);
469 g_list_free (chatrooms);
473 main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window,
474 EmpathyChatroom *chatroom)
476 GtkWidget *menu_item;
479 if (g_object_get_data (G_OBJECT (chatroom), "menu_item")) {
483 name = empathy_chatroom_get_name (chatroom);
484 menu_item = gtk_menu_item_new_with_label (name);
486 g_object_set_data (G_OBJECT (chatroom), "menu_item", menu_item);
487 g_signal_connect (menu_item, "activate",
488 G_CALLBACK (main_window_favorite_chatroom_menu_activate_cb),
491 gtk_menu_shell_insert (GTK_MENU_SHELL (window->room_menu),
494 gtk_widget_show (menu_item);
498 main_window_favorite_chatroom_join (EmpathyChatroom *chatroom)
504 mc = empathy_mission_control_new ();
505 account = empathy_chatroom_get_account (chatroom);
506 room = empathy_chatroom_get_room (chatroom);
508 empathy_debug (DEBUG_DOMAIN, "Requesting channel for '%s'", room);
510 mission_control_request_channel_with_string_handle (mc,
512 TP_IFACE_CHANNEL_TYPE_TEXT,
520 main_window_chat_quit_cb (GtkWidget *widget,
521 EmpathyMainWindow *window)
527 main_window_chat_new_message_cb (GtkWidget *widget,
528 EmpathyMainWindow *window)
530 //empathy_new_message_dialog_show (GTK_WINDOW (window->window));
534 main_window_chat_history_cb (GtkWidget *widget,
535 EmpathyMainWindow *window)
537 empathy_log_window_show (NULL, NULL, FALSE, GTK_WINDOW (window->window));
541 main_window_room_join_new_cb (GtkWidget *widget,
542 EmpathyMainWindow *window)
544 empathy_new_chatroom_dialog_show (GTK_WINDOW (window->window));
548 main_window_room_join_favorites_cb (GtkWidget *widget,
549 EmpathyMainWindow *window)
551 GList *chatrooms, *l;
553 chatrooms = empathy_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
554 for (l = chatrooms; l; l = l->next) {
555 main_window_favorite_chatroom_join (l->data);
557 g_list_free (chatrooms);
561 main_window_room_manage_favorites_cb (GtkWidget *widget,
562 EmpathyMainWindow *window)
564 empathy_chatrooms_window_show (GTK_WINDOW (window->window));
568 main_window_chat_add_contact_cb (GtkWidget *widget,
569 EmpathyMainWindow *window)
571 empathy_new_contact_dialog_show (GTK_WINDOW (window->window));
575 main_window_chat_show_offline_cb (GtkCheckMenuItem *item,
576 EmpathyMainWindow *window)
580 current = gtk_check_menu_item_get_active (item);
582 empathy_conf_set_bool (empathy_conf_get (),
583 EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE,
586 /* Turn off sound just while we alter the contact list. */
587 // FIXME: empathy_sound_set_enabled (FALSE);
588 empathy_contact_list_store_set_show_offline (window->list_store, current);
589 //empathy_sound_set_enabled (TRUE);
593 main_window_edit_button_press_event_cb (GtkWidget *widget,
594 GdkEventButton *event,
595 EmpathyMainWindow *window)
597 EmpathyContact *contact;
600 if (!event->button == 1) {
604 group = empathy_contact_list_view_get_selected_group (window->list_view);
610 item = GTK_MENU_ITEM (window->edit_context);
611 label = gtk_bin_get_child (GTK_BIN (item));
612 gtk_label_set_text (GTK_LABEL (label), _("Group"));
614 gtk_widget_show (window->edit_context);
615 gtk_widget_show (window->edit_context_separator);
617 submenu = empathy_contact_list_view_get_group_menu (window->list_view);
618 gtk_menu_item_set_submenu (item, submenu);
625 contact = empathy_contact_list_view_get_selected (window->list_view);
631 item = GTK_MENU_ITEM (window->edit_context);
632 label = gtk_bin_get_child (GTK_BIN (item));
633 gtk_label_set_text (GTK_LABEL (label), _("Contact"));
635 gtk_widget_show (window->edit_context);
636 gtk_widget_show (window->edit_context_separator);
638 submenu = empathy_contact_list_view_get_contact_menu (window->list_view,
640 gtk_menu_item_set_submenu (item, submenu);
642 g_object_unref (contact);
647 gtk_widget_hide (window->edit_context);
648 gtk_widget_hide (window->edit_context_separator);
654 main_window_edit_accounts_cb (GtkWidget *widget,
655 EmpathyMainWindow *window)
657 empathy_accounts_dialog_show (GTK_WINDOW (window->window));
661 main_window_edit_personal_information_cb (GtkWidget *widget,
662 EmpathyMainWindow *window)
664 //empathy_vcard_dialog_show (GTK_WINDOW (window->window));
668 main_window_edit_preferences_cb (GtkWidget *widget,
669 EmpathyMainWindow *window)
671 empathy_preferences_show (GTK_WINDOW (window->window));
675 main_window_help_about_cb (GtkWidget *widget,
676 EmpathyMainWindow *window)
678 empathy_about_dialog_new (GTK_WINDOW (window->window));
682 main_window_help_contents_cb (GtkWidget *widget,
683 EmpathyMainWindow *window)
685 //empathy_help_show ();
689 main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox,
690 GdkEventButton *event,
691 EmpathyMainWindow *window)
693 if (event->type != GDK_BUTTON_PRESS ||
694 event->button != 1) {
698 empathy_accounts_dialog_show (GTK_WINDOW (window->window));
704 main_window_status_changed_cb (MissionControl *mc,
705 TelepathyConnectionStatus status,
707 TelepathyConnectionStatusReason reason,
708 const gchar *unique_name,
709 EmpathyMainWindow *window)
711 main_window_update_status (window);
715 main_window_update_status (EmpathyMainWindow *window)
719 guint connecting = 0;
720 guint disconnected = 0;
722 /* Count number of connected/connecting/disconnected accounts */
723 accounts = mc_accounts_list ();
724 for (l = accounts; l; l = l->next) {
730 status = mission_control_get_connection_status (window->mc,
736 } else if (status == 1) {
738 } else if (status == 2) {
742 g_object_unref (account);
744 g_list_free (accounts);
746 /* Update the spinner state */
747 if (connecting > 0) {
748 ephy_spinner_start (EPHY_SPINNER (window->throbber));
750 ephy_spinner_stop (EPHY_SPINNER (window->throbber));
753 /* Update widgets sensibility */
754 for (l = window->widgets_connected; l; l = l->next) {
755 gtk_widget_set_sensitive (l->data, (connected > 0));
758 for (l = window->widgets_disconnected; l; l = l->next) {
759 gtk_widget_set_sensitive (l->data, (disconnected > 0));
767 main_window_accels_load (void)
771 filename = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, ACCELS_FILENAME, NULL);
772 if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
773 empathy_debug (DEBUG_DOMAIN, "Loading from:'%s'", filename);
774 gtk_accel_map_load (filename);
781 main_window_accels_save (void)
784 gchar *file_with_path;
786 dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
787 g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
788 file_with_path = g_build_filename (dir, ACCELS_FILENAME, NULL);
791 empathy_debug (DEBUG_DOMAIN, "Saving to:'%s'", file_with_path);
792 gtk_accel_map_save (file_with_path);
794 g_free (file_with_path);
798 main_window_connection_items_setup (EmpathyMainWindow *window,
804 const gchar *widgets_connected[] = {
808 "edit_personal_information"
810 const gchar *widgets_disconnected[] = {
813 for (i = 0, list = NULL; i < G_N_ELEMENTS (widgets_connected); i++) {
814 w = glade_xml_get_widget (glade, widgets_connected[i]);
815 list = g_list_prepend (list, w);
818 window->widgets_connected = list;
820 for (i = 0, list = NULL; i < G_N_ELEMENTS (widgets_disconnected); i++) {
821 w = glade_xml_get_widget (glade, widgets_disconnected[i]);
822 list = g_list_prepend (list, w);
825 window->widgets_disconnected = list;
829 main_window_configure_event_timeout_cb (EmpathyMainWindow *window)
833 gtk_window_get_size (GTK_WINDOW (window->window), &w, &h);
834 gtk_window_get_position (GTK_WINDOW (window->window), &x, &y);
836 empathy_geometry_save (GEOMETRY_NAME, x, y, w, h);
838 window->size_timeout_id = 0;
844 main_window_configure_event_cb (GtkWidget *widget,
845 GdkEventConfigure *event,
846 EmpathyMainWindow *window)
848 if (window->size_timeout_id) {
849 g_source_remove (window->size_timeout_id);
852 window->size_timeout_id = g_timeout_add (500,
853 (GSourceFunc) main_window_configure_event_timeout_cb,
860 main_window_notify_show_offline_cb (EmpathyConf *conf,
862 gpointer check_menu_item)
864 gboolean show_offline;
866 if (empathy_conf_get_bool (conf, key, &show_offline)) {
867 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (check_menu_item),
873 main_window_notify_show_avatars_cb (EmpathyConf *conf,
875 EmpathyMainWindow *window)
877 gboolean show_avatars;
879 if (empathy_conf_get_bool (conf, key, &show_avatars)) {
880 empathy_contact_list_store_set_show_avatars (window->list_store,
886 main_window_notify_compact_contact_list_cb (EmpathyConf *conf,
888 EmpathyMainWindow *window)
890 gboolean compact_contact_list;
892 if (empathy_conf_get_bool (conf, key, &compact_contact_list)) {
893 empathy_contact_list_store_set_is_compact (window->list_store,
894 compact_contact_list);
899 main_window_notify_sort_criterium_cb (EmpathyConf *conf,
901 EmpathyMainWindow *window)
905 if (empathy_conf_get_string (conf, key, &str)) {
907 GEnumClass *enum_class;
908 GEnumValue *enum_value;
910 type = empathy_contact_list_store_sort_get_type ();
911 enum_class = G_ENUM_CLASS (g_type_class_peek (type));
912 enum_value = g_enum_get_value_by_nick (enum_class, str);
916 empathy_contact_list_store_set_sort_criterium (window->list_store,