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 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., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
21 * Authors: Xavier Claessens <xclaesse@gmail.com>
28 #include <glade/glade.h>
29 #include <glib/gi18n.h>
31 #include <libempathy/empathy-conf.h>
32 #include <libempathy/empathy-contact.h>
33 #include <libempathy/empathy-debug.h>
34 #include <libempathy/empathy-utils.h>
35 #include <libempathy/empathy-chatroom-manager.h>
36 #include <libempathy/empathy-chatroom.h>
37 #include <libempathy/empathy-contact-list.h>
38 #include <libempathy/empathy-contact-manager.h>
39 #include <libempathy/empathy-contact-factory.h>
41 #include "empathy-main-window.h"
42 #include "empathy-contact-dialogs.h"
43 #include "ephy-spinner.h"
44 #include "empathy-contact-list-store.h"
45 #include "empathy-contact-list-view.h"
46 #include "empathy-presence-chooser.h"
47 #include "empathy-ui-utils.h"
48 #include "empathy-status-presets.h"
49 #include "empathy-geometry.h"
50 #include "empathy-preferences.h"
51 #include "empathy-accounts-dialog.h"
52 #include "empathy-about-dialog.h"
53 #include "empathy-new-chatroom-dialog.h"
54 #include "empathy-chatrooms-window.h"
55 #include "empathy-log-window.h"
56 #include "empathy-gtk-enum-types.h"
58 #define DEBUG_DOMAIN "MainWindow"
60 /* Minimum width of roster window if something goes wrong. */
63 /* Accels (menu shortcuts) can be configured and saved */
64 #define ACCELS_FILENAME "accels.txt"
66 /* Name in the geometry file */
67 #define GEOMETRY_NAME "main-window"
70 EmpathyContactListView *list_view;
71 EmpathyContactListStore *list_store;
73 EmpathyChatroomManager *chatroom_manager;
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;
188 gboolean show_offline;
189 gboolean show_avatars;
190 gboolean compact_contact_list;
194 gtk_window_present (GTK_WINDOW (window->window));
195 return window->window;
198 window = g_new0 (EmpathyMainWindow, 1);
200 /* Set up interface */
201 glade = empathy_glade_get_file ("empathy-main-window.glade",
204 "main_window", &window->window,
205 "main_vbox", &window->main_vbox,
206 "chat_show_offline", &show_offline_widget,
207 "room", &window->room,
208 "room_sep", &window->room_sep,
209 "room_join_favorites", &window->room_join_favorites,
210 "edit_context", &window->edit_context,
211 "edit_context_separator", &window->edit_context_separator,
212 "presence_toolbar", &window->presence_toolbar,
213 "roster_scrolledwindow", &sw,
216 empathy_glade_connect (glade,
218 "main_window", "destroy", main_window_destroy_cb,
219 "main_window", "configure_event", main_window_configure_event_cb,
220 "chat_quit", "activate", main_window_chat_quit_cb,
221 "chat_new_message", "activate", main_window_chat_new_message_cb,
222 "chat_history", "activate", main_window_chat_history_cb,
223 "room_join_new", "activate", main_window_room_join_new_cb,
224 "room_join_favorites", "activate", main_window_room_join_favorites_cb,
225 "room_manage_favorites", "activate", main_window_room_manage_favorites_cb,
226 "chat_add_contact", "activate", main_window_chat_add_contact_cb,
227 "chat_show_offline", "toggled", main_window_chat_show_offline_cb,
228 "edit", "button-press-event", main_window_edit_button_press_event_cb,
229 "edit_accounts", "activate", main_window_edit_accounts_cb,
230 "edit_personal_information", "activate", main_window_edit_personal_information_cb,
231 "edit_preferences", "activate", main_window_edit_preferences_cb,
232 "help_about", "activate", main_window_help_about_cb,
233 "help_contents", "activate", main_window_help_contents_cb,
236 /* Set up connection related widgets. */
237 main_window_connection_items_setup (window, glade);
238 g_object_unref (glade);
240 window->mc = empathy_mission_control_new ();
241 dbus_g_proxy_connect_signal (DBUS_G_PROXY (window->mc), "AccountStatusChanged",
242 G_CALLBACK (main_window_status_changed_cb),
246 main_window_favorite_chatroom_menu_setup (window);
248 gtk_widget_hide (window->edit_context);
249 gtk_widget_hide (window->edit_context_separator);
251 /* Set up presence chooser */
252 window->presence_chooser = empathy_presence_chooser_new ();
253 gtk_widget_show (window->presence_chooser);
254 item = gtk_tool_item_new ();
255 gtk_widget_show (GTK_WIDGET (item));
256 gtk_container_add (GTK_CONTAINER (item), window->presence_chooser);
257 gtk_tool_item_set_is_important (item, TRUE);
258 gtk_tool_item_set_expand (item, TRUE);
259 gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
261 /* Set up the throbber */
262 ebox = gtk_event_box_new ();
263 gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
265 window->throbber = ephy_spinner_new ();
266 ephy_spinner_set_size (EPHY_SPINNER (window->throbber), GTK_ICON_SIZE_LARGE_TOOLBAR);
267 gtk_container_add (GTK_CONTAINER (ebox), window->throbber);
269 item = gtk_tool_item_new ();
270 gtk_container_add (GTK_CONTAINER (item), ebox);
271 gtk_widget_show_all (GTK_WIDGET (item));
273 gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
275 gtk_widget_set_tooltip_text (ebox, _("Show and edit accounts"));
277 g_signal_connect (ebox,
278 "button-press-event",
279 G_CALLBACK (main_window_throbber_button_press_event_cb),
282 /* Set up contact list. */
283 empathy_status_presets_get_all ();
285 list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_new ());
286 window->list_store = empathy_contact_list_store_new (list_iface);
287 window->list_view = empathy_contact_list_view_new (window->list_store);
288 empathy_contact_list_view_set_interactive (window->list_view, TRUE);
289 g_object_unref (list_iface);
291 gtk_widget_show (GTK_WIDGET (window->list_view));
292 gtk_container_add (GTK_CONTAINER (sw),
293 GTK_WIDGET (window->list_view));
295 /* Load user-defined accelerators. */
296 main_window_accels_load ();
298 /* Set window size. */
299 empathy_geometry_load (GEOMETRY_NAME, &x, &y, &w, &h);
301 if (w >= 1 && h >= 1) {
302 /* Use the defaults from the glade file if we
303 * don't have good w, h geometry.
305 empathy_debug (DEBUG_DOMAIN, "Configuring window default size w:%d, h:%d", w, h);
306 gtk_window_set_default_size (GTK_WINDOW (window->window), w, h);
309 if (x >= 0 && y >= 0) {
310 /* Let the window manager position it if we
311 * don't have good x, y coordinates.
313 empathy_debug (DEBUG_DOMAIN, "Configuring window default position x:%d, y:%d", x, y);
314 gtk_window_move (GTK_WINDOW (window->window), x, y);
317 conf = empathy_conf_get ();
320 empathy_conf_get_bool (conf,
321 EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE,
323 empathy_conf_notify_add (conf,
324 EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE,
325 main_window_notify_show_offline_cb,
326 show_offline_widget);
328 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_offline_widget),
332 empathy_conf_get_bool (conf,
333 EMPATHY_PREFS_UI_SHOW_AVATARS,
335 empathy_conf_notify_add (conf,
336 EMPATHY_PREFS_UI_SHOW_AVATARS,
337 (EmpathyConfNotifyFunc) main_window_notify_show_avatars_cb,
339 empathy_contact_list_store_set_show_avatars (window->list_store, show_avatars);
342 empathy_conf_get_bool (conf,
343 EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
344 &compact_contact_list);
345 empathy_conf_notify_add (conf,
346 EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
347 (EmpathyConfNotifyFunc) main_window_notify_compact_contact_list_cb,
349 empathy_contact_list_store_set_is_compact (window->list_store, compact_contact_list);
352 empathy_conf_notify_add (conf,
353 EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
354 (EmpathyConfNotifyFunc) main_window_notify_sort_criterium_cb,
356 main_window_notify_sort_criterium_cb (conf,
357 EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
360 main_window_update_status (window);
362 return window->window;
366 main_window_destroy_cb (GtkWidget *widget,
367 EmpathyMainWindow *window)
369 /* Save user-defined accelerators. */
370 main_window_accels_save ();
372 dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (window->mc), "AccountStatusChanged",
373 G_CALLBACK (main_window_status_changed_cb),
376 if (window->size_timeout_id) {
377 g_source_remove (window->size_timeout_id);
380 g_list_free (window->widgets_connected);
381 g_list_free (window->widgets_disconnected);
383 g_object_unref (window->mc);
384 g_object_unref (window->list_store);
390 main_window_favorite_chatroom_menu_setup (EmpathyMainWindow *window)
392 GList *chatrooms, *l;
394 window->chatroom_manager = empathy_chatroom_manager_new ();
395 chatrooms = empathy_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
396 window->room_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (window->room));
398 for (l = chatrooms; l; l = l->next) {
399 main_window_favorite_chatroom_menu_add (window, l->data);
403 gtk_widget_hide (window->room_sep);
406 gtk_widget_set_sensitive (window->room_join_favorites, chatrooms != NULL);
408 g_signal_connect (window->chatroom_manager, "chatroom-added",
409 G_CALLBACK (main_window_favorite_chatroom_menu_added_cb),
411 g_signal_connect (window->chatroom_manager, "chatroom-removed",
412 G_CALLBACK (main_window_favorite_chatroom_menu_removed_cb),
415 g_list_free (chatrooms);
419 main_window_favorite_chatroom_menu_added_cb (EmpathyChatroomManager *manager,
420 EmpathyChatroom *chatroom,
421 EmpathyMainWindow *window)
423 main_window_favorite_chatroom_menu_add (window, chatroom);
424 gtk_widget_show (window->room_sep);
425 gtk_widget_set_sensitive (window->room_join_favorites, TRUE);
429 main_window_favorite_chatroom_menu_removed_cb (EmpathyChatroomManager *manager,
430 EmpathyChatroom *chatroom,
431 EmpathyMainWindow *window)
433 GtkWidget *menu_item;
435 menu_item = g_object_get_data (G_OBJECT (chatroom), "menu_item");
437 g_object_set_data (G_OBJECT (chatroom), "menu_item", NULL);
438 gtk_widget_destroy (menu_item);
440 main_window_favorite_chatroom_menu_update (window);
444 main_window_favorite_chatroom_menu_activate_cb (GtkMenuItem *menu_item,
445 EmpathyChatroom *chatroom)
447 main_window_favorite_chatroom_join (chatroom);
451 main_window_favorite_chatroom_menu_update (EmpathyMainWindow *window)
455 chatrooms = empathy_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
458 gtk_widget_show (window->room_sep);
460 gtk_widget_hide (window->room_sep);
463 gtk_widget_set_sensitive (window->room_join_favorites, chatrooms != NULL);
464 g_list_free (chatrooms);
468 main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window,
469 EmpathyChatroom *chatroom)
471 GtkWidget *menu_item;
474 if (g_object_get_data (G_OBJECT (chatroom), "menu_item")) {
478 name = empathy_chatroom_get_name (chatroom);
479 menu_item = gtk_menu_item_new_with_label (name);
481 g_object_set_data (G_OBJECT (chatroom), "menu_item", menu_item);
482 g_signal_connect (menu_item, "activate",
483 G_CALLBACK (main_window_favorite_chatroom_menu_activate_cb),
486 gtk_menu_shell_insert (GTK_MENU_SHELL (window->room_menu),
489 gtk_widget_show (menu_item);
493 main_window_favorite_chatroom_join (EmpathyChatroom *chatroom)
499 mc = empathy_mission_control_new ();
500 account = empathy_chatroom_get_account (chatroom);
501 room = empathy_chatroom_get_room (chatroom);
503 empathy_debug (DEBUG_DOMAIN, "Requesting channel for '%s'", room);
505 mission_control_request_channel_with_string_handle (mc,
507 TP_IFACE_CHANNEL_TYPE_TEXT,
515 main_window_chat_quit_cb (GtkWidget *widget,
516 EmpathyMainWindow *window)
522 main_window_chat_new_message_cb (GtkWidget *widget,
523 EmpathyMainWindow *window)
525 //empathy_new_message_dialog_show (GTK_WINDOW (window->window));
529 main_window_chat_history_cb (GtkWidget *widget,
530 EmpathyMainWindow *window)
532 empathy_log_window_show (NULL, NULL, FALSE, GTK_WINDOW (window->window));
536 main_window_room_join_new_cb (GtkWidget *widget,
537 EmpathyMainWindow *window)
539 empathy_new_chatroom_dialog_show (GTK_WINDOW (window->window));
543 main_window_room_join_favorites_cb (GtkWidget *widget,
544 EmpathyMainWindow *window)
546 GList *chatrooms, *l;
548 chatrooms = empathy_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
549 for (l = chatrooms; l; l = l->next) {
550 main_window_favorite_chatroom_join (l->data);
552 g_list_free (chatrooms);
556 main_window_room_manage_favorites_cb (GtkWidget *widget,
557 EmpathyMainWindow *window)
559 empathy_chatrooms_window_show (GTK_WINDOW (window->window));
563 main_window_chat_add_contact_cb (GtkWidget *widget,
564 EmpathyMainWindow *window)
566 empathy_new_contact_dialog_show (GTK_WINDOW (window->window));
570 main_window_chat_show_offline_cb (GtkCheckMenuItem *item,
571 EmpathyMainWindow *window)
575 current = gtk_check_menu_item_get_active (item);
577 empathy_conf_set_bool (empathy_conf_get (),
578 EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE,
581 /* Turn off sound just while we alter the contact list. */
582 // FIXME: empathy_sound_set_enabled (FALSE);
583 empathy_contact_list_store_set_show_offline (window->list_store, current);
584 //empathy_sound_set_enabled (TRUE);
588 main_window_edit_button_press_event_cb (GtkWidget *widget,
589 GdkEventButton *event,
590 EmpathyMainWindow *window)
592 EmpathyContact *contact;
595 if (!event->button == 1) {
599 group = empathy_contact_list_view_get_selected_group (window->list_view);
605 item = GTK_MENU_ITEM (window->edit_context);
606 label = gtk_bin_get_child (GTK_BIN (item));
607 gtk_label_set_text (GTK_LABEL (label), _("Group"));
609 gtk_widget_show (window->edit_context);
610 gtk_widget_show (window->edit_context_separator);
612 submenu = empathy_contact_list_view_get_group_menu (window->list_view);
613 gtk_menu_item_set_submenu (item, submenu);
620 contact = empathy_contact_list_view_get_selected (window->list_view);
626 item = GTK_MENU_ITEM (window->edit_context);
627 label = gtk_bin_get_child (GTK_BIN (item));
628 gtk_label_set_text (GTK_LABEL (label), _("Contact"));
630 gtk_widget_show (window->edit_context);
631 gtk_widget_show (window->edit_context_separator);
633 submenu = empathy_contact_list_view_get_contact_menu (window->list_view,
635 gtk_menu_item_set_submenu (item, submenu);
637 g_object_unref (contact);
642 gtk_widget_hide (window->edit_context);
643 gtk_widget_hide (window->edit_context_separator);
649 main_window_edit_accounts_cb (GtkWidget *widget,
650 EmpathyMainWindow *window)
652 empathy_accounts_dialog_show (GTK_WINDOW (window->window));
656 main_window_edit_personal_information_cb (GtkWidget *widget,
657 EmpathyMainWindow *window)
661 accounts = mission_control_get_online_connections (window->mc, NULL);
663 EmpathyContactFactory *factory;
664 EmpathyContact *contact;
667 account = accounts->data;
668 factory = empathy_contact_factory_new ();
669 contact = empathy_contact_factory_get_user (factory, account);
670 empathy_contact_information_dialog_show (contact,
671 GTK_WINDOW (window->window),
673 g_slist_foreach (accounts, (GFunc) g_object_unref, NULL);
674 g_slist_free (accounts);
675 g_object_unref (factory);
680 main_window_edit_preferences_cb (GtkWidget *widget,
681 EmpathyMainWindow *window)
683 empathy_preferences_show (GTK_WINDOW (window->window));
687 main_window_help_about_cb (GtkWidget *widget,
688 EmpathyMainWindow *window)
690 empathy_about_dialog_new (GTK_WINDOW (window->window));
694 main_window_help_contents_cb (GtkWidget *widget,
695 EmpathyMainWindow *window)
697 //empathy_help_show ();
701 main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox,
702 GdkEventButton *event,
703 EmpathyMainWindow *window)
705 if (event->type != GDK_BUTTON_PRESS ||
706 event->button != 1) {
710 empathy_accounts_dialog_show (GTK_WINDOW (window->window));
716 main_window_status_changed_cb (MissionControl *mc,
717 TelepathyConnectionStatus status,
719 TelepathyConnectionStatusReason reason,
720 const gchar *unique_name,
721 EmpathyMainWindow *window)
723 main_window_update_status (window);
727 main_window_update_status (EmpathyMainWindow *window)
731 guint connecting = 0;
732 guint disconnected = 0;
734 /* Count number of connected/connecting/disconnected accounts */
735 accounts = mc_accounts_list ();
736 for (l = accounts; l; l = l->next) {
742 status = mission_control_get_connection_status (window->mc,
748 } else if (status == 1) {
750 } else if (status == 2) {
754 g_object_unref (account);
756 g_list_free (accounts);
758 /* Update the spinner state */
759 if (connecting > 0) {
760 ephy_spinner_start (EPHY_SPINNER (window->throbber));
762 ephy_spinner_stop (EPHY_SPINNER (window->throbber));
765 /* Update widgets sensibility */
766 for (l = window->widgets_connected; l; l = l->next) {
767 gtk_widget_set_sensitive (l->data, (connected > 0));
770 for (l = window->widgets_disconnected; l; l = l->next) {
771 gtk_widget_set_sensitive (l->data, (disconnected > 0));
779 main_window_accels_load (void)
783 filename = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, ACCELS_FILENAME, NULL);
784 if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
785 empathy_debug (DEBUG_DOMAIN, "Loading from:'%s'", filename);
786 gtk_accel_map_load (filename);
793 main_window_accels_save (void)
796 gchar *file_with_path;
798 dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
799 g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
800 file_with_path = g_build_filename (dir, ACCELS_FILENAME, NULL);
803 empathy_debug (DEBUG_DOMAIN, "Saving to:'%s'", file_with_path);
804 gtk_accel_map_save (file_with_path);
806 g_free (file_with_path);
810 main_window_connection_items_setup (EmpathyMainWindow *window,
816 const gchar *widgets_connected[] = {
820 "edit_personal_information"
822 const gchar *widgets_disconnected[] = {
825 for (i = 0, list = NULL; i < G_N_ELEMENTS (widgets_connected); i++) {
826 w = glade_xml_get_widget (glade, widgets_connected[i]);
827 list = g_list_prepend (list, w);
830 window->widgets_connected = list;
832 for (i = 0, list = NULL; i < G_N_ELEMENTS (widgets_disconnected); i++) {
833 w = glade_xml_get_widget (glade, widgets_disconnected[i]);
834 list = g_list_prepend (list, w);
837 window->widgets_disconnected = list;
841 main_window_configure_event_timeout_cb (EmpathyMainWindow *window)
845 gtk_window_get_size (GTK_WINDOW (window->window), &w, &h);
846 gtk_window_get_position (GTK_WINDOW (window->window), &x, &y);
848 empathy_geometry_save (GEOMETRY_NAME, x, y, w, h);
850 window->size_timeout_id = 0;
856 main_window_configure_event_cb (GtkWidget *widget,
857 GdkEventConfigure *event,
858 EmpathyMainWindow *window)
860 if (window->size_timeout_id) {
861 g_source_remove (window->size_timeout_id);
864 window->size_timeout_id = g_timeout_add_seconds (1,
865 (GSourceFunc) main_window_configure_event_timeout_cb,
872 main_window_notify_show_offline_cb (EmpathyConf *conf,
874 gpointer check_menu_item)
876 gboolean show_offline;
878 if (empathy_conf_get_bool (conf, key, &show_offline)) {
879 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (check_menu_item),
885 main_window_notify_show_avatars_cb (EmpathyConf *conf,
887 EmpathyMainWindow *window)
889 gboolean show_avatars;
891 if (empathy_conf_get_bool (conf, key, &show_avatars)) {
892 empathy_contact_list_store_set_show_avatars (window->list_store,
898 main_window_notify_compact_contact_list_cb (EmpathyConf *conf,
900 EmpathyMainWindow *window)
902 gboolean compact_contact_list;
904 if (empathy_conf_get_bool (conf, key, &compact_contact_list)) {
905 empathy_contact_list_store_set_is_compact (window->list_store,
906 compact_contact_list);
911 main_window_notify_sort_criterium_cb (EmpathyConf *conf,
913 EmpathyMainWindow *window)
917 if (empathy_conf_get_string (conf, key, &str) && str) {
919 GEnumClass *enum_class;
920 GEnumValue *enum_value;
922 type = empathy_contact_list_store_sort_get_type ();
923 enum_class = G_ENUM_CLASS (g_type_class_peek (type));
924 enum_value = g_enum_get_value_by_nick (enum_class, str);
928 empathy_contact_list_store_set_sort_criterium (window->list_store,