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"
54 #include "empathy-gtk-enum-types.h"
56 #define DEBUG_DOMAIN "MainWindow"
58 /* Minimum width of roster window if something goes wrong. */
61 /* Accels (menu shortcuts) can be configured and saved */
62 #define ACCELS_FILENAME "accels.txt"
64 /* Name in the geometry file */
65 #define GEOMETRY_NAME "main-window"
68 EmpathyContactListView *list_view;
69 EmpathyContactListStore *list_store;
71 EmpathyChatroomManager *chatroom_manager;
77 /* Tooltips for all widgets */
78 GtkTooltips *tooltips;
84 GtkWidget *room_join_favorites;
85 GtkWidget *edit_context;
86 GtkWidget *edit_context_separator;
91 /* Widgets that are enabled when there is... */
92 GList *widgets_connected; /* ... connected accounts */
93 GList *widgets_disconnected; /* ... disconnected accounts */
96 GtkWidget *presence_toolbar;
97 GtkWidget *presence_chooser;
100 guint size_timeout_id;
103 static void main_window_destroy_cb (GtkWidget *widget,
104 EmpathyMainWindow *window);
105 static void main_window_favorite_chatroom_menu_setup (EmpathyMainWindow *window);
106 static void main_window_favorite_chatroom_menu_added_cb (EmpathyChatroomManager *manager,
107 EmpathyChatroom *chatroom,
108 EmpathyMainWindow *window);
109 static void main_window_favorite_chatroom_menu_removed_cb (EmpathyChatroomManager *manager,
110 EmpathyChatroom *chatroom,
111 EmpathyMainWindow *window);
112 static void main_window_favorite_chatroom_menu_activate_cb (GtkMenuItem *menu_item,
113 EmpathyChatroom *chatroom);
114 static void main_window_favorite_chatroom_menu_update (EmpathyMainWindow *window);
115 static void main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window,
116 EmpathyChatroom *chatroom);
117 static void main_window_favorite_chatroom_join (EmpathyChatroom *chatroom);
118 static void main_window_chat_quit_cb (GtkWidget *widget,
119 EmpathyMainWindow *window);
120 static void main_window_chat_new_message_cb (GtkWidget *widget,
121 EmpathyMainWindow *window);
122 static void main_window_chat_history_cb (GtkWidget *widget,
123 EmpathyMainWindow *window);
124 static void main_window_room_join_new_cb (GtkWidget *widget,
125 EmpathyMainWindow *window);
126 static void main_window_room_join_favorites_cb (GtkWidget *widget,
127 EmpathyMainWindow *window);
128 static void main_window_room_manage_favorites_cb (GtkWidget *widget,
129 EmpathyMainWindow *window);
130 static void main_window_chat_add_contact_cb (GtkWidget *widget,
131 EmpathyMainWindow *window);
132 static void main_window_chat_show_offline_cb (GtkCheckMenuItem *item,
133 EmpathyMainWindow *window);
134 static gboolean main_window_edit_button_press_event_cb (GtkWidget *widget,
135 GdkEventButton *event,
136 EmpathyMainWindow *window);
137 static void main_window_edit_accounts_cb (GtkWidget *widget,
138 EmpathyMainWindow *window);
139 static void main_window_edit_personal_information_cb (GtkWidget *widget,
140 EmpathyMainWindow *window);
141 static void main_window_edit_preferences_cb (GtkWidget *widget,
142 EmpathyMainWindow *window);
143 static void main_window_help_about_cb (GtkWidget *widget,
144 EmpathyMainWindow *window);
145 static void main_window_help_contents_cb (GtkWidget *widget,
146 EmpathyMainWindow *window);
147 static gboolean main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox,
148 GdkEventButton *event,
149 EmpathyMainWindow *window);
150 static void main_window_status_changed_cb (MissionControl *mc,
151 TelepathyConnectionStatus status,
153 TelepathyConnectionStatusReason reason,
154 const gchar *unique_name,
155 EmpathyMainWindow *window);
156 static void main_window_update_status (EmpathyMainWindow *window);
157 static void main_window_accels_load (void);
158 static void main_window_accels_save (void);
159 static void main_window_connection_items_setup (EmpathyMainWindow *window,
161 static gboolean main_window_configure_event_timeout_cb (EmpathyMainWindow *window);
162 static gboolean main_window_configure_event_cb (GtkWidget *widget,
163 GdkEventConfigure *event,
164 EmpathyMainWindow *window);
165 static void main_window_notify_show_offline_cb (EmpathyConf *conf,
167 gpointer check_menu_item);
168 static void main_window_notify_show_avatars_cb (EmpathyConf *conf,
170 EmpathyMainWindow *window);
171 static void main_window_notify_compact_contact_list_cb (EmpathyConf *conf,
173 EmpathyMainWindow *window);
174 static void main_window_notify_sort_criterium_cb (EmpathyConf *conf,
176 EmpathyMainWindow *window);
179 empathy_main_window_show (void)
181 static EmpathyMainWindow *window = NULL;
182 EmpathyContactList *list_iface;
186 GtkWidget *show_offline_widget;
190 gboolean show_offline;
191 gboolean show_avatars;
192 gboolean compact_contact_list;
196 gtk_window_present (GTK_WINDOW (window->window));
197 return window->window;
200 window = g_new0 (EmpathyMainWindow, 1);
202 /* Set up interface */
203 glade = empathy_glade_get_file ("empathy-main-window.glade",
206 "main_window", &window->window,
207 "main_vbox", &window->main_vbox,
208 "chat_show_offline", &show_offline_widget,
209 "room", &window->room,
210 "room_sep", &window->room_sep,
211 "room_join_favorites", &window->room_join_favorites,
212 "edit_context", &window->edit_context,
213 "edit_context_separator", &window->edit_context_separator,
214 "presence_toolbar", &window->presence_toolbar,
215 "roster_scrolledwindow", &sw,
218 empathy_glade_connect (glade,
220 "main_window", "destroy", main_window_destroy_cb,
221 "main_window", "configure_event", main_window_configure_event_cb,
222 "chat_quit", "activate", main_window_chat_quit_cb,
223 "chat_new_message", "activate", main_window_chat_new_message_cb,
224 "chat_history", "activate", main_window_chat_history_cb,
225 "room_join_new", "activate", main_window_room_join_new_cb,
226 "room_join_favorites", "activate", main_window_room_join_favorites_cb,
227 "room_manage_favorites", "activate", main_window_room_manage_favorites_cb,
228 "chat_add_contact", "activate", main_window_chat_add_contact_cb,
229 "chat_show_offline", "toggled", main_window_chat_show_offline_cb,
230 "edit", "button-press-event", main_window_edit_button_press_event_cb,
231 "edit_accounts", "activate", main_window_edit_accounts_cb,
232 "edit_personal_information", "activate", main_window_edit_personal_information_cb,
233 "edit_preferences", "activate", main_window_edit_preferences_cb,
234 "help_about", "activate", main_window_help_about_cb,
235 "help_contents", "activate", main_window_help_contents_cb,
238 /* Set up connection related widgets. */
239 main_window_connection_items_setup (window, glade);
240 g_object_unref (glade);
242 window->tooltips = g_object_ref_sink (gtk_tooltips_new ());
243 window->mc = empathy_mission_control_new ();
244 dbus_g_proxy_connect_signal (DBUS_G_PROXY (window->mc), "AccountStatusChanged",
245 G_CALLBACK (main_window_status_changed_cb),
249 main_window_favorite_chatroom_menu_setup (window);
251 gtk_widget_hide (window->edit_context);
252 gtk_widget_hide (window->edit_context_separator);
254 /* Set up presence chooser */
255 window->presence_chooser = empathy_presence_chooser_new ();
256 gtk_widget_show (window->presence_chooser);
257 item = gtk_tool_item_new ();
258 gtk_widget_show (GTK_WIDGET (item));
259 gtk_container_add (GTK_CONTAINER (item), window->presence_chooser);
260 gtk_tool_item_set_is_important (item, TRUE);
261 gtk_tool_item_set_expand (item, TRUE);
262 gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
264 /* Set up the throbber */
265 ebox = gtk_event_box_new ();
266 gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
268 window->throbber = ephy_spinner_new ();
269 ephy_spinner_set_size (EPHY_SPINNER (window->throbber), GTK_ICON_SIZE_LARGE_TOOLBAR);
270 gtk_container_add (GTK_CONTAINER (ebox), window->throbber);
272 item = gtk_tool_item_new ();
273 gtk_container_add (GTK_CONTAINER (item), ebox);
274 gtk_widget_show_all (GTK_WIDGET (item));
276 gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
278 str = _("Show and edit accounts");
279 gtk_tooltips_set_tip (GTK_TOOLTIPS (window->tooltips),
282 g_signal_connect (ebox,
283 "button-press-event",
284 G_CALLBACK (main_window_throbber_button_press_event_cb),
287 /* Set up contact list. */
288 empathy_status_presets_get_all ();
290 list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_new ());
291 empathy_contact_list_setup (list_iface);
292 window->list_store = empathy_contact_list_store_new (list_iface);
293 window->list_view = empathy_contact_list_view_new (window->list_store);
294 g_object_unref (list_iface);
296 gtk_widget_show (GTK_WIDGET (window->list_view));
297 gtk_container_add (GTK_CONTAINER (sw),
298 GTK_WIDGET (window->list_view));
300 /* Load user-defined accelerators. */
301 main_window_accels_load ();
303 /* Set window size. */
304 empathy_geometry_load (GEOMETRY_NAME, &x, &y, &w, &h);
306 if (w >= 1 && h >= 1) {
307 /* Use the defaults from the glade file if we
308 * don't have good w, h geometry.
310 empathy_debug (DEBUG_DOMAIN, "Configuring window default size w:%d, h:%d", w, h);
311 gtk_window_set_default_size (GTK_WINDOW (window->window), w, h);
314 if (x >= 0 && y >= 0) {
315 /* Let the window manager position it if we
316 * don't have good x, y coordinates.
318 empathy_debug (DEBUG_DOMAIN, "Configuring window default position x:%d, y:%d", x, y);
319 gtk_window_move (GTK_WINDOW (window->window), x, y);
322 conf = empathy_conf_get ();
325 empathy_conf_get_bool (conf,
326 EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE,
328 empathy_conf_notify_add (conf,
329 EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE,
330 main_window_notify_show_offline_cb,
331 show_offline_widget);
333 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_offline_widget),
337 empathy_conf_get_bool (conf,
338 EMPATHY_PREFS_UI_SHOW_AVATARS,
340 empathy_conf_notify_add (conf,
341 EMPATHY_PREFS_UI_SHOW_AVATARS,
342 (EmpathyConfNotifyFunc) main_window_notify_show_avatars_cb,
344 empathy_contact_list_store_set_show_avatars (window->list_store, show_avatars);
347 empathy_conf_get_bool (conf,
348 EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
349 &compact_contact_list);
350 empathy_conf_notify_add (conf,
351 EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
352 (EmpathyConfNotifyFunc) main_window_notify_compact_contact_list_cb,
354 empathy_contact_list_store_set_is_compact (window->list_store, compact_contact_list);
357 empathy_conf_notify_add (conf,
358 EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
359 (EmpathyConfNotifyFunc) main_window_notify_sort_criterium_cb,
361 main_window_notify_sort_criterium_cb (conf,
362 EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
365 main_window_update_status (window);
367 return window->window;
371 main_window_destroy_cb (GtkWidget *widget,
372 EmpathyMainWindow *window)
374 /* Save user-defined accelerators. */
375 main_window_accels_save ();
377 dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (window->mc), "AccountStatusChanged",
378 G_CALLBACK (main_window_status_changed_cb),
381 if (window->size_timeout_id) {
382 g_source_remove (window->size_timeout_id);
385 g_list_free (window->widgets_connected);
386 g_list_free (window->widgets_disconnected);
388 g_object_unref (window->tooltips);
389 g_object_unref (window->mc);
390 g_object_unref (window->list_store);
396 main_window_favorite_chatroom_menu_setup (EmpathyMainWindow *window)
398 GList *chatrooms, *l;
400 window->chatroom_manager = empathy_chatroom_manager_new ();
401 chatrooms = empathy_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
402 window->room_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (window->room));
404 for (l = chatrooms; l; l = l->next) {
405 main_window_favorite_chatroom_menu_add (window, l->data);
409 gtk_widget_hide (window->room_sep);
412 gtk_widget_set_sensitive (window->room_join_favorites, chatrooms != NULL);
414 g_signal_connect (window->chatroom_manager, "chatroom-added",
415 G_CALLBACK (main_window_favorite_chatroom_menu_added_cb),
417 g_signal_connect (window->chatroom_manager, "chatroom-removed",
418 G_CALLBACK (main_window_favorite_chatroom_menu_removed_cb),
421 g_list_free (chatrooms);
425 main_window_favorite_chatroom_menu_added_cb (EmpathyChatroomManager *manager,
426 EmpathyChatroom *chatroom,
427 EmpathyMainWindow *window)
429 main_window_favorite_chatroom_menu_add (window, chatroom);
430 gtk_widget_show (window->room_sep);
431 gtk_widget_set_sensitive (window->room_join_favorites, TRUE);
435 main_window_favorite_chatroom_menu_removed_cb (EmpathyChatroomManager *manager,
436 EmpathyChatroom *chatroom,
437 EmpathyMainWindow *window)
439 GtkWidget *menu_item;
441 menu_item = g_object_get_data (G_OBJECT (chatroom), "menu_item");
443 g_object_set_data (G_OBJECT (chatroom), "menu_item", NULL);
444 gtk_widget_destroy (menu_item);
446 main_window_favorite_chatroom_menu_update (window);
450 main_window_favorite_chatroom_menu_activate_cb (GtkMenuItem *menu_item,
451 EmpathyChatroom *chatroom)
453 main_window_favorite_chatroom_join (chatroom);
457 main_window_favorite_chatroom_menu_update (EmpathyMainWindow *window)
461 chatrooms = empathy_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
464 gtk_widget_show (window->room_sep);
466 gtk_widget_hide (window->room_sep);
469 gtk_widget_set_sensitive (window->room_join_favorites, chatrooms != NULL);
470 g_list_free (chatrooms);
474 main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window,
475 EmpathyChatroom *chatroom)
477 GtkWidget *menu_item;
480 if (g_object_get_data (G_OBJECT (chatroom), "menu_item")) {
484 name = empathy_chatroom_get_name (chatroom);
485 menu_item = gtk_menu_item_new_with_label (name);
487 g_object_set_data (G_OBJECT (chatroom), "menu_item", menu_item);
488 g_signal_connect (menu_item, "activate",
489 G_CALLBACK (main_window_favorite_chatroom_menu_activate_cb),
492 gtk_menu_shell_insert (GTK_MENU_SHELL (window->room_menu),
495 gtk_widget_show (menu_item);
499 main_window_favorite_chatroom_join (EmpathyChatroom *chatroom)
505 mc = empathy_mission_control_new ();
506 account = empathy_chatroom_get_account (chatroom);
507 room = empathy_chatroom_get_room (chatroom);
509 empathy_debug (DEBUG_DOMAIN, "Requesting channel for '%s'", room);
511 mission_control_request_channel_with_string_handle (mc,
513 TP_IFACE_CHANNEL_TYPE_TEXT,
521 main_window_chat_quit_cb (GtkWidget *widget,
522 EmpathyMainWindow *window)
528 main_window_chat_new_message_cb (GtkWidget *widget,
529 EmpathyMainWindow *window)
531 //empathy_new_message_dialog_show (GTK_WINDOW (window->window));
535 main_window_chat_history_cb (GtkWidget *widget,
536 EmpathyMainWindow *window)
538 empathy_log_window_show (NULL, NULL, FALSE, GTK_WINDOW (window->window));
542 main_window_room_join_new_cb (GtkWidget *widget,
543 EmpathyMainWindow *window)
545 empathy_new_chatroom_dialog_show (GTK_WINDOW (window->window));
549 main_window_room_join_favorites_cb (GtkWidget *widget,
550 EmpathyMainWindow *window)
552 GList *chatrooms, *l;
554 chatrooms = empathy_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
555 for (l = chatrooms; l; l = l->next) {
556 main_window_favorite_chatroom_join (l->data);
558 g_list_free (chatrooms);
562 main_window_room_manage_favorites_cb (GtkWidget *widget,
563 EmpathyMainWindow *window)
565 empathy_chatrooms_window_show (GTK_WINDOW (window->window));
569 main_window_chat_add_contact_cb (GtkWidget *widget,
570 EmpathyMainWindow *window)
572 empathy_new_contact_dialog_show (GTK_WINDOW (window->window));
576 main_window_chat_show_offline_cb (GtkCheckMenuItem *item,
577 EmpathyMainWindow *window)
581 current = gtk_check_menu_item_get_active (item);
583 empathy_conf_set_bool (empathy_conf_get (),
584 EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE,
587 /* Turn off sound just while we alter the contact list. */
588 // FIXME: empathy_sound_set_enabled (FALSE);
589 empathy_contact_list_store_set_show_offline (window->list_store, current);
590 //empathy_sound_set_enabled (TRUE);
594 main_window_edit_button_press_event_cb (GtkWidget *widget,
595 GdkEventButton *event,
596 EmpathyMainWindow *window)
598 EmpathyContact *contact;
601 if (!event->button == 1) {
605 group = empathy_contact_list_view_get_selected_group (window->list_view);
611 item = GTK_MENU_ITEM (window->edit_context);
612 label = gtk_bin_get_child (GTK_BIN (item));
613 gtk_label_set_text (GTK_LABEL (label), _("Group"));
615 gtk_widget_show (window->edit_context);
616 gtk_widget_show (window->edit_context_separator);
618 submenu = empathy_contact_list_view_get_group_menu (window->list_view);
619 gtk_menu_item_set_submenu (item, submenu);
626 contact = empathy_contact_list_view_get_selected (window->list_view);
632 item = GTK_MENU_ITEM (window->edit_context);
633 label = gtk_bin_get_child (GTK_BIN (item));
634 gtk_label_set_text (GTK_LABEL (label), _("Contact"));
636 gtk_widget_show (window->edit_context);
637 gtk_widget_show (window->edit_context_separator);
639 submenu = empathy_contact_list_view_get_contact_menu (window->list_view,
641 gtk_menu_item_set_submenu (item, submenu);
643 g_object_unref (contact);
648 gtk_widget_hide (window->edit_context);
649 gtk_widget_hide (window->edit_context_separator);
655 main_window_edit_accounts_cb (GtkWidget *widget,
656 EmpathyMainWindow *window)
658 empathy_accounts_dialog_show (GTK_WINDOW (window->window));
662 main_window_edit_personal_information_cb (GtkWidget *widget,
663 EmpathyMainWindow *window)
665 //empathy_vcard_dialog_show (GTK_WINDOW (window->window));
669 main_window_edit_preferences_cb (GtkWidget *widget,
670 EmpathyMainWindow *window)
672 empathy_preferences_show (GTK_WINDOW (window->window));
676 main_window_help_about_cb (GtkWidget *widget,
677 EmpathyMainWindow *window)
679 empathy_about_dialog_new (GTK_WINDOW (window->window));
683 main_window_help_contents_cb (GtkWidget *widget,
684 EmpathyMainWindow *window)
686 //empathy_help_show ();
690 main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox,
691 GdkEventButton *event,
692 EmpathyMainWindow *window)
694 if (event->type != GDK_BUTTON_PRESS ||
695 event->button != 1) {
699 empathy_accounts_dialog_show (GTK_WINDOW (window->window));
705 main_window_status_changed_cb (MissionControl *mc,
706 TelepathyConnectionStatus status,
708 TelepathyConnectionStatusReason reason,
709 const gchar *unique_name,
710 EmpathyMainWindow *window)
712 main_window_update_status (window);
716 main_window_update_status (EmpathyMainWindow *window)
720 guint connecting = 0;
721 guint disconnected = 0;
723 /* Count number of connected/connecting/disconnected accounts */
724 accounts = mc_accounts_list ();
725 for (l = accounts; l; l = l->next) {
731 status = mission_control_get_connection_status (window->mc,
737 } else if (status == 1) {
739 } else if (status == 2) {
743 g_object_unref (account);
745 g_list_free (accounts);
747 /* Update the spinner state */
748 if (connecting > 0) {
749 ephy_spinner_start (EPHY_SPINNER (window->throbber));
751 ephy_spinner_stop (EPHY_SPINNER (window->throbber));
754 /* Update widgets sensibility */
755 for (l = window->widgets_connected; l; l = l->next) {
756 gtk_widget_set_sensitive (l->data, (connected > 0));
759 for (l = window->widgets_disconnected; l; l = l->next) {
760 gtk_widget_set_sensitive (l->data, (disconnected > 0));
768 main_window_accels_load (void)
772 filename = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, ACCELS_FILENAME, NULL);
773 if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
774 empathy_debug (DEBUG_DOMAIN, "Loading from:'%s'", filename);
775 gtk_accel_map_load (filename);
782 main_window_accels_save (void)
785 gchar *file_with_path;
787 dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
788 g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
789 file_with_path = g_build_filename (dir, ACCELS_FILENAME, NULL);
792 empathy_debug (DEBUG_DOMAIN, "Saving to:'%s'", file_with_path);
793 gtk_accel_map_save (file_with_path);
795 g_free (file_with_path);
799 main_window_connection_items_setup (EmpathyMainWindow *window,
805 const gchar *widgets_connected[] = {
809 "edit_personal_information"
811 const gchar *widgets_disconnected[] = {
814 for (i = 0, list = NULL; i < G_N_ELEMENTS (widgets_connected); i++) {
815 w = glade_xml_get_widget (glade, widgets_connected[i]);
816 list = g_list_prepend (list, w);
819 window->widgets_connected = list;
821 for (i = 0, list = NULL; i < G_N_ELEMENTS (widgets_disconnected); i++) {
822 w = glade_xml_get_widget (glade, widgets_disconnected[i]);
823 list = g_list_prepend (list, w);
826 window->widgets_disconnected = list;
830 main_window_configure_event_timeout_cb (EmpathyMainWindow *window)
834 gtk_window_get_size (GTK_WINDOW (window->window), &w, &h);
835 gtk_window_get_position (GTK_WINDOW (window->window), &x, &y);
837 empathy_geometry_save (GEOMETRY_NAME, x, y, w, h);
839 window->size_timeout_id = 0;
845 main_window_configure_event_cb (GtkWidget *widget,
846 GdkEventConfigure *event,
847 EmpathyMainWindow *window)
849 if (window->size_timeout_id) {
850 g_source_remove (window->size_timeout_id);
853 window->size_timeout_id = g_timeout_add (500,
854 (GSourceFunc) main_window_configure_event_timeout_cb,
861 main_window_notify_show_offline_cb (EmpathyConf *conf,
863 gpointer check_menu_item)
865 gboolean show_offline;
867 if (empathy_conf_get_bool (conf, key, &show_offline)) {
868 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (check_menu_item),
874 main_window_notify_show_avatars_cb (EmpathyConf *conf,
876 EmpathyMainWindow *window)
878 gboolean show_avatars;
880 if (empathy_conf_get_bool (conf, key, &show_avatars)) {
881 empathy_contact_list_store_set_show_avatars (window->list_store,
887 main_window_notify_compact_contact_list_cb (EmpathyConf *conf,
889 EmpathyMainWindow *window)
891 gboolean compact_contact_list;
893 if (empathy_conf_get_bool (conf, key, &compact_contact_list)) {
894 empathy_contact_list_store_set_is_compact (window->list_store,
895 compact_contact_list);
900 main_window_notify_sort_criterium_cb (EmpathyConf *conf,
902 EmpathyMainWindow *window)
906 if (empathy_conf_get_string (conf, key, &str)) {
908 GEnumClass *enum_class;
909 GEnumValue *enum_value;
911 type = empathy_contact_list_store_sort_get_type ();
912 enum_class = G_ENUM_CLASS (g_type_class_peek (type));
913 enum_value = g_enum_get_value_by_nick (enum_class, str);
917 empathy_contact_list_store_set_sort_criterium (window->list_store,