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/gossip-conf.h>
31 #include <libempathy/gossip-contact.h>
32 #include <libempathy/gossip-debug.h>
33 #include <libempathy/gossip-utils.h>
34 #include <libempathy/gossip-chatroom-manager.h>
35 #include <libempathy/gossip-chatroom.h>
36 #include <libempathy/empathy-contact-list.h>
37 #include <libempathy/empathy-contact-manager.h>
39 #include "empathy-main-window.h"
40 #include "ephy-spinner.h"
41 #include "gossip-contact-list-store.h"
42 #include "gossip-contact-list-view.h"
43 #include "gossip-presence-chooser.h"
44 #include "gossip-ui-utils.h"
45 #include "gossip-status-presets.h"
46 #include "gossip-geometry.h"
47 #include "gossip-preferences.h"
48 #include "gossip-accounts-dialog.h"
49 #include "gossip-about-dialog.h"
50 #include "gossip-new-chatroom-dialog.h"
51 #include "gossip-chatrooms-window.h"
53 #define DEBUG_DOMAIN "MainWindow"
55 /* Minimum width of roster window if something goes wrong. */
58 /* Accels (menu shortcuts) can be configured and saved */
59 #define ACCELS_FILENAME "accels.txt"
61 /* Name in the geometry file */
62 #define GEOMETRY_NAME "main-window"
65 GossipContactListView *list_view;
66 GossipContactListStore *list_store;
68 GossipChatroomManager *chatroom_manager;
74 /* Tooltips for all widgets */
75 GtkTooltips *tooltips;
81 GtkWidget *room_join_favorites;
82 GtkWidget *edit_context;
83 GtkWidget *edit_context_separator;
88 /* Widgets that are enabled when there is... */
89 GList *widgets_connected; /* ... connected accounts */
90 GList *widgets_disconnected; /* ... disconnected accounts */
93 GtkWidget *presence_toolbar;
94 GtkWidget *presence_chooser;
97 guint size_timeout_id;
100 static void main_window_destroy_cb (GtkWidget *widget,
101 EmpathyMainWindow *window);
102 static void main_window_favorite_chatroom_menu_setup (EmpathyMainWindow *window);
103 static void main_window_favorite_chatroom_menu_added_cb (GossipChatroomManager *manager,
104 GossipChatroom *chatroom,
105 EmpathyMainWindow *window);
106 static void main_window_favorite_chatroom_menu_removed_cb (GossipChatroomManager *manager,
107 GossipChatroom *chatroom,
108 EmpathyMainWindow *window);
109 static void main_window_favorite_chatroom_menu_activate_cb (GtkMenuItem *menu_item,
110 GossipChatroom *chatroom);
111 static void main_window_favorite_chatroom_menu_update (EmpathyMainWindow *window);
112 static void main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window,
113 GossipChatroom *chatroom);
114 static void main_window_favorite_chatroom_join (GossipChatroom *chatroom);
115 static void main_window_chat_quit_cb (GtkWidget *widget,
116 EmpathyMainWindow *window);
117 static void main_window_chat_new_message_cb (GtkWidget *widget,
118 EmpathyMainWindow *window);
119 static void main_window_chat_history_cb (GtkWidget *widget,
120 EmpathyMainWindow *window);
121 static void main_window_room_join_new_cb (GtkWidget *widget,
122 EmpathyMainWindow *window);
123 static void main_window_room_join_favorites_cb (GtkWidget *widget,
124 EmpathyMainWindow *window);
125 static void main_window_room_manage_favorites_cb (GtkWidget *widget,
126 EmpathyMainWindow *window);
127 static void main_window_chat_add_contact_cb (GtkWidget *widget,
128 EmpathyMainWindow *window);
129 static void main_window_chat_show_offline_cb (GtkCheckMenuItem *item,
130 EmpathyMainWindow *window);
131 static gboolean main_window_edit_button_press_event_cb (GtkWidget *widget,
132 GdkEventButton *event,
133 EmpathyMainWindow *window);
134 static void main_window_edit_accounts_cb (GtkWidget *widget,
135 EmpathyMainWindow *window);
136 static void main_window_edit_personal_information_cb (GtkWidget *widget,
137 EmpathyMainWindow *window);
138 static void main_window_edit_preferences_cb (GtkWidget *widget,
139 EmpathyMainWindow *window);
140 static void main_window_help_about_cb (GtkWidget *widget,
141 EmpathyMainWindow *window);
142 static void main_window_help_contents_cb (GtkWidget *widget,
143 EmpathyMainWindow *window);
144 static gboolean main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox,
145 GdkEventButton *event,
146 EmpathyMainWindow *window);
147 static void main_window_status_changed_cb (MissionControl *mc,
148 TelepathyConnectionStatus status,
150 TelepathyConnectionStatusReason reason,
151 const gchar *unique_name,
152 EmpathyMainWindow *window);
153 static void main_window_update_status (EmpathyMainWindow *window);
154 static void main_window_accels_load (void);
155 static void main_window_accels_save (void);
156 static void main_window_connection_items_setup (EmpathyMainWindow *window,
158 static gboolean main_window_configure_event_timeout_cb (EmpathyMainWindow *window);
159 static gboolean main_window_configure_event_cb (GtkWidget *widget,
160 GdkEventConfigure *event,
161 EmpathyMainWindow *window);
162 static void main_window_notify_show_offline_cb (GossipConf *conf,
164 gpointer check_menu_item);
165 static void main_window_notify_show_avatars_cb (GossipConf *conf,
167 EmpathyMainWindow *window);
168 static void main_window_notify_compact_contact_list_cb (GossipConf *conf,
170 EmpathyMainWindow *window);
171 static void main_window_notify_sort_criterium_cb (GossipConf *conf,
173 EmpathyMainWindow *window);
176 empathy_main_window_show (void)
178 static EmpathyMainWindow *window = NULL;
179 EmpathyContactList *list_iface;
183 GtkWidget *show_offline_widget;
187 gboolean show_offline;
188 gboolean show_avatars;
189 gboolean compact_contact_list;
193 gtk_window_present (GTK_WINDOW (window->window));
194 return window->window;
197 window = g_new0 (EmpathyMainWindow, 1);
199 /* Set up interface */
200 glade = gossip_glade_get_file ("empathy-main-window.glade",
203 "main_window", &window->window,
204 "main_vbox", &window->main_vbox,
205 "chat_show_offline", &show_offline_widget,
206 "room", &window->room,
207 "room_sep", &window->room_sep,
208 "room_join_favorites", &window->room_join_favorites,
209 "edit_context", &window->edit_context,
210 "edit_context_separator", &window->edit_context_separator,
211 "presence_toolbar", &window->presence_toolbar,
212 "roster_scrolledwindow", &sw,
215 gossip_glade_connect (glade,
217 "main_window", "destroy", main_window_destroy_cb,
218 "main_window", "configure_event", main_window_configure_event_cb,
219 "chat_quit", "activate", main_window_chat_quit_cb,
220 "chat_new_message", "activate", main_window_chat_new_message_cb,
221 "chat_history", "activate", main_window_chat_history_cb,
222 "room_join_new", "activate", main_window_room_join_new_cb,
223 "room_join_favorites", "activate", main_window_room_join_favorites_cb,
224 "room_manage_favorites", "activate", main_window_room_manage_favorites_cb,
225 "chat_add_contact", "activate", main_window_chat_add_contact_cb,
226 "chat_show_offline", "toggled", main_window_chat_show_offline_cb,
227 "edit", "button-press-event", main_window_edit_button_press_event_cb,
228 "edit_accounts", "activate", main_window_edit_accounts_cb,
229 "edit_personal_information", "activate", main_window_edit_personal_information_cb,
230 "edit_preferences", "activate", main_window_edit_preferences_cb,
231 "help_about", "activate", main_window_help_about_cb,
232 "help_contents", "activate", main_window_help_contents_cb,
235 /* Set up connection related widgets. */
236 main_window_connection_items_setup (window, glade);
237 g_object_unref (glade);
239 window->tooltips = g_object_ref_sink (gtk_tooltips_new ());
240 window->mc = gossip_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 = gossip_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 str = _("Show and edit accounts");
276 gtk_tooltips_set_tip (GTK_TOOLTIPS (window->tooltips),
279 g_signal_connect (ebox,
280 "button-press-event",
281 G_CALLBACK (main_window_throbber_button_press_event_cb),
284 /* Set up contact list. */
285 gossip_status_presets_get_all ();
287 list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_new ());
288 empathy_contact_list_setup (list_iface);
289 window->list_store = gossip_contact_list_store_new (list_iface);
290 window->list_view = gossip_contact_list_view_new (window->list_store);
291 g_object_unref (list_iface);
293 gtk_widget_show (GTK_WIDGET (window->list_view));
294 gtk_container_add (GTK_CONTAINER (sw),
295 GTK_WIDGET (window->list_view));
297 /* Load user-defined accelerators. */
298 main_window_accels_load ();
300 /* Set window size. */
301 gossip_geometry_load (GEOMETRY_NAME, &x, &y, &w, &h);
303 if (w >= 1 && h >= 1) {
304 /* Use the defaults from the glade file if we
305 * don't have good w, h geometry.
307 gossip_debug (DEBUG_DOMAIN, "Configuring window default size w:%d, h:%d", w, h);
308 gtk_window_set_default_size (GTK_WINDOW (window->window), w, h);
311 if (x >= 0 && y >= 0) {
312 /* Let the window manager position it if we
313 * don't have good x, y coordinates.
315 gossip_debug (DEBUG_DOMAIN, "Configuring window default position x:%d, y:%d", x, y);
316 gtk_window_move (GTK_WINDOW (window->window), x, y);
319 conf = gossip_conf_get ();
322 gossip_conf_get_bool (conf,
323 GOSSIP_PREFS_CONTACTS_SHOW_OFFLINE,
325 gossip_conf_notify_add (conf,
326 GOSSIP_PREFS_CONTACTS_SHOW_OFFLINE,
327 main_window_notify_show_offline_cb,
328 show_offline_widget);
330 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_offline_widget),
334 gossip_conf_get_bool (conf,
335 GOSSIP_PREFS_UI_SHOW_AVATARS,
337 gossip_conf_notify_add (conf,
338 GOSSIP_PREFS_UI_SHOW_AVATARS,
339 (GossipConfNotifyFunc) main_window_notify_show_avatars_cb,
341 gossip_contact_list_store_set_show_avatars (window->list_store, show_avatars);
344 gossip_conf_get_bool (conf,
345 GOSSIP_PREFS_UI_COMPACT_CONTACT_LIST,
346 &compact_contact_list);
347 gossip_conf_notify_add (conf,
348 GOSSIP_PREFS_UI_COMPACT_CONTACT_LIST,
349 (GossipConfNotifyFunc) main_window_notify_compact_contact_list_cb,
351 gossip_contact_list_store_set_is_compact (window->list_store, compact_contact_list);
354 gossip_conf_notify_add (conf,
355 GOSSIP_PREFS_CONTACTS_SORT_CRITERIUM,
356 (GossipConfNotifyFunc) main_window_notify_sort_criterium_cb,
358 main_window_notify_sort_criterium_cb (conf,
359 GOSSIP_PREFS_CONTACTS_SORT_CRITERIUM,
362 main_window_update_status (window);
364 return window->window;
368 main_window_destroy_cb (GtkWidget *widget,
369 EmpathyMainWindow *window)
371 /* Save user-defined accelerators. */
372 main_window_accels_save ();
374 dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (window->mc), "AccountStatusChanged",
375 G_CALLBACK (main_window_status_changed_cb),
378 if (window->size_timeout_id) {
379 g_source_remove (window->size_timeout_id);
382 g_list_free (window->widgets_connected);
383 g_list_free (window->widgets_disconnected);
385 g_object_unref (window->tooltips);
386 g_object_unref (window->mc);
387 g_object_unref (window->list_store);
393 main_window_favorite_chatroom_menu_setup (EmpathyMainWindow *window)
395 GList *chatrooms, *l;
397 window->chatroom_manager = gossip_chatroom_manager_new ();
398 chatrooms = gossip_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
399 window->room_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (window->room));
401 for (l = chatrooms; l; l = l->next) {
402 main_window_favorite_chatroom_menu_add (window, l->data);
406 gtk_widget_hide (window->room_sep);
409 gtk_widget_set_sensitive (window->room_join_favorites, chatrooms != NULL);
411 g_signal_connect (window->chatroom_manager, "chatroom-added",
412 G_CALLBACK (main_window_favorite_chatroom_menu_added_cb),
414 g_signal_connect (window->chatroom_manager, "chatroom-removed",
415 G_CALLBACK (main_window_favorite_chatroom_menu_removed_cb),
418 g_list_free (chatrooms);
422 main_window_favorite_chatroom_menu_added_cb (GossipChatroomManager *manager,
423 GossipChatroom *chatroom,
424 EmpathyMainWindow *window)
426 main_window_favorite_chatroom_menu_add (window, chatroom);
427 gtk_widget_show (window->room_sep);
428 gtk_widget_set_sensitive (window->room_join_favorites, TRUE);
432 main_window_favorite_chatroom_menu_removed_cb (GossipChatroomManager *manager,
433 GossipChatroom *chatroom,
434 EmpathyMainWindow *window)
436 GtkWidget *menu_item;
438 menu_item = g_object_get_data (G_OBJECT (chatroom), "menu_item");
440 g_object_set_data (G_OBJECT (chatroom), "menu_item", NULL);
441 gtk_widget_destroy (menu_item);
443 main_window_favorite_chatroom_menu_update (window);
447 main_window_favorite_chatroom_menu_activate_cb (GtkMenuItem *menu_item,
448 GossipChatroom *chatroom)
450 main_window_favorite_chatroom_join (chatroom);
454 main_window_favorite_chatroom_menu_update (EmpathyMainWindow *window)
458 chatrooms = gossip_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
461 gtk_widget_show (window->room_sep);
463 gtk_widget_hide (window->room_sep);
466 gtk_widget_set_sensitive (window->room_join_favorites, chatrooms != NULL);
467 g_list_free (chatrooms);
471 main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window,
472 GossipChatroom *chatroom)
474 GtkWidget *menu_item;
477 if (g_object_get_data (G_OBJECT (chatroom), "menu_item")) {
481 name = gossip_chatroom_get_name (chatroom);
482 menu_item = gtk_menu_item_new_with_label (name);
484 g_object_set_data (G_OBJECT (chatroom), "menu_item", menu_item);
485 g_signal_connect (menu_item, "activate",
486 G_CALLBACK (main_window_favorite_chatroom_menu_activate_cb),
489 gtk_menu_shell_insert (GTK_MENU_SHELL (window->room_menu),
492 gtk_widget_show (menu_item);
496 main_window_favorite_chatroom_join (GossipChatroom *chatroom)
502 mc = gossip_mission_control_new ();
503 account = gossip_chatroom_get_account (chatroom);
504 room = gossip_chatroom_get_room (chatroom);
506 gossip_debug (DEBUG_DOMAIN, "Requesting channel for '%s'", room);
508 mission_control_request_channel_with_string_handle (mc,
510 TP_IFACE_CHANNEL_TYPE_TEXT,
518 main_window_chat_quit_cb (GtkWidget *widget,
519 EmpathyMainWindow *window)
525 main_window_chat_new_message_cb (GtkWidget *widget,
526 EmpathyMainWindow *window)
528 //gossip_new_message_dialog_show (GTK_WINDOW (window->window));
532 main_window_chat_history_cb (GtkWidget *widget,
533 EmpathyMainWindow *window)
535 //gossip_log_window_show (NULL, NULL);
539 main_window_room_join_new_cb (GtkWidget *widget,
540 EmpathyMainWindow *window)
542 gossip_new_chatroom_dialog_show (GTK_WINDOW (window->window));
546 main_window_room_join_favorites_cb (GtkWidget *widget,
547 EmpathyMainWindow *window)
549 GList *chatrooms, *l;
551 chatrooms = gossip_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
552 for (l = chatrooms; l; l = l->next) {
553 main_window_favorite_chatroom_join (l->data);
555 g_list_free (chatrooms);
559 main_window_room_manage_favorites_cb (GtkWidget *widget,
560 EmpathyMainWindow *window)
562 gossip_chatrooms_window_show (GTK_WINDOW (window->window));
566 main_window_chat_add_contact_cb (GtkWidget *widget,
567 EmpathyMainWindow *window)
569 //gossip_add_contact_dialog_show (GTK_WINDOW (window->window), NULL);
573 main_window_chat_show_offline_cb (GtkCheckMenuItem *item,
574 EmpathyMainWindow *window)
578 current = gtk_check_menu_item_get_active (item);
580 gossip_conf_set_bool (gossip_conf_get (),
581 GOSSIP_PREFS_CONTACTS_SHOW_OFFLINE,
584 /* Turn off sound just while we alter the contact list. */
585 // FIXME: gossip_sound_set_enabled (FALSE);
586 gossip_contact_list_store_set_show_offline (window->list_store, current);
587 //gossip_sound_set_enabled (TRUE);
591 main_window_edit_button_press_event_cb (GtkWidget *widget,
592 GdkEventButton *event,
593 EmpathyMainWindow *window)
595 GossipContact *contact;
598 if (!event->button == 1) {
602 group = gossip_contact_list_view_get_selected_group (window->list_view);
608 item = GTK_MENU_ITEM (window->edit_context);
609 label = gtk_bin_get_child (GTK_BIN (item));
610 gtk_label_set_text (GTK_LABEL (label), _("Group"));
612 gtk_widget_show (window->edit_context);
613 gtk_widget_show (window->edit_context_separator);
615 submenu = gossip_contact_list_view_get_group_menu (window->list_view);
616 gtk_menu_item_set_submenu (item, submenu);
623 contact = gossip_contact_list_view_get_selected (window->list_view);
629 item = GTK_MENU_ITEM (window->edit_context);
630 label = gtk_bin_get_child (GTK_BIN (item));
631 gtk_label_set_text (GTK_LABEL (label), _("Contact"));
633 gtk_widget_show (window->edit_context);
634 gtk_widget_show (window->edit_context_separator);
636 submenu = gossip_contact_list_view_get_contact_menu (window->list_view,
638 gtk_menu_item_set_submenu (item, submenu);
640 g_object_unref (contact);
645 gtk_widget_hide (window->edit_context);
646 gtk_widget_hide (window->edit_context_separator);
652 main_window_edit_accounts_cb (GtkWidget *widget,
653 EmpathyMainWindow *window)
655 gossip_accounts_dialog_show (GTK_WINDOW (window->window));
659 main_window_edit_personal_information_cb (GtkWidget *widget,
660 EmpathyMainWindow *window)
662 //gossip_vcard_dialog_show (GTK_WINDOW (window->window));
666 main_window_edit_preferences_cb (GtkWidget *widget,
667 EmpathyMainWindow *window)
669 gossip_preferences_show (GTK_WINDOW (window->window));
673 main_window_help_about_cb (GtkWidget *widget,
674 EmpathyMainWindow *window)
676 gossip_about_dialog_new (GTK_WINDOW (window->window));
680 main_window_help_contents_cb (GtkWidget *widget,
681 EmpathyMainWindow *window)
683 //gossip_help_show ();
687 main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox,
688 GdkEventButton *event,
689 EmpathyMainWindow *window)
691 if (event->type != GDK_BUTTON_PRESS ||
692 event->button != 1) {
696 gossip_accounts_dialog_show (GTK_WINDOW (window->window));
702 main_window_status_changed_cb (MissionControl *mc,
703 TelepathyConnectionStatus status,
705 TelepathyConnectionStatusReason reason,
706 const gchar *unique_name,
707 EmpathyMainWindow *window)
709 main_window_update_status (window);
713 main_window_update_status (EmpathyMainWindow *window)
717 guint connecting = 0;
718 guint disconnected = 0;
720 /* Count number of connected/connecting/disconnected accounts */
721 accounts = mc_accounts_list ();
722 for (l = accounts; l; l = l->next) {
728 status = mission_control_get_connection_status (window->mc,
734 } else if (status == 1) {
736 } else if (status == 2) {
740 g_object_unref (account);
742 g_list_free (accounts);
744 /* Update the spinner state */
745 if (connecting > 0) {
746 ephy_spinner_start (EPHY_SPINNER (window->throbber));
748 ephy_spinner_stop (EPHY_SPINNER (window->throbber));
751 /* Update widgets sensibility */
752 for (l = window->widgets_connected; l; l = l->next) {
753 gtk_widget_set_sensitive (l->data, (connected > 0));
756 for (l = window->widgets_disconnected; l; l = l->next) {
757 gtk_widget_set_sensitive (l->data, (disconnected > 0));
765 main_window_accels_load (void)
769 filename = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, ACCELS_FILENAME, NULL);
770 if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
771 gossip_debug (DEBUG_DOMAIN, "Loading from:'%s'", filename);
772 gtk_accel_map_load (filename);
779 main_window_accels_save (void)
782 gchar *file_with_path;
784 dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
785 g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
786 file_with_path = g_build_filename (dir, ACCELS_FILENAME, NULL);
789 gossip_debug (DEBUG_DOMAIN, "Saving to:'%s'", file_with_path);
790 gtk_accel_map_save (file_with_path);
792 g_free (file_with_path);
796 main_window_connection_items_setup (EmpathyMainWindow *window,
802 const gchar *widgets_connected[] = {
806 "edit_personal_information"
808 const gchar *widgets_disconnected[] = {
811 for (i = 0, list = NULL; i < G_N_ELEMENTS (widgets_connected); i++) {
812 w = glade_xml_get_widget (glade, widgets_connected[i]);
813 list = g_list_prepend (list, w);
816 window->widgets_connected = list;
818 for (i = 0, list = NULL; i < G_N_ELEMENTS (widgets_disconnected); i++) {
819 w = glade_xml_get_widget (glade, widgets_disconnected[i]);
820 list = g_list_prepend (list, w);
823 window->widgets_disconnected = list;
827 main_window_configure_event_timeout_cb (EmpathyMainWindow *window)
831 gtk_window_get_size (GTK_WINDOW (window->window), &w, &h);
832 gtk_window_get_position (GTK_WINDOW (window->window), &x, &y);
834 gossip_geometry_save (GEOMETRY_NAME, x, y, w, h);
836 window->size_timeout_id = 0;
842 main_window_configure_event_cb (GtkWidget *widget,
843 GdkEventConfigure *event,
844 EmpathyMainWindow *window)
846 if (window->size_timeout_id) {
847 g_source_remove (window->size_timeout_id);
850 window->size_timeout_id = g_timeout_add (500,
851 (GSourceFunc) main_window_configure_event_timeout_cb,
858 main_window_notify_show_offline_cb (GossipConf *conf,
860 gpointer check_menu_item)
862 gboolean show_offline;
864 if (gossip_conf_get_bool (conf, key, &show_offline)) {
865 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (check_menu_item),
871 main_window_notify_show_avatars_cb (GossipConf *conf,
873 EmpathyMainWindow *window)
875 gboolean show_avatars;
877 if (gossip_conf_get_bool (conf, key, &show_avatars)) {
878 gossip_contact_list_store_set_show_avatars (window->list_store,
884 main_window_notify_compact_contact_list_cb (GossipConf *conf,
886 EmpathyMainWindow *window)
888 gboolean compact_contact_list;
890 if (gossip_conf_get_bool (conf, key, &compact_contact_list)) {
891 gossip_contact_list_store_set_is_compact (window->list_store,
892 compact_contact_list);
897 main_window_notify_sort_criterium_cb (GossipConf *conf,
899 EmpathyMainWindow *window)
903 if (gossip_conf_get_string (conf, key, &str)) {
905 GEnumClass *enum_class;
906 GEnumValue *enum_value;
908 type = gossip_contact_list_store_sort_get_type ();
909 enum_class = G_ENUM_CLASS (g_type_class_peek (type));
910 enum_value = g_enum_get_value_by_nick (enum_class, str);
914 gossip_contact_list_store_set_sort_criterium (window->list_store,