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_chat_quit_cb (GtkWidget *widget,
115 EmpathyMainWindow *window);
116 static void main_window_chat_new_message_cb (GtkWidget *widget,
117 EmpathyMainWindow *window);
118 static void main_window_chat_history_cb (GtkWidget *widget,
119 EmpathyMainWindow *window);
120 static void main_window_room_join_new_cb (GtkWidget *widget,
121 EmpathyMainWindow *window);
122 static void main_window_room_join_favorites_cb (GtkWidget *widget,
123 EmpathyMainWindow *window);
124 static void main_window_room_manage_favorites_cb (GtkWidget *widget,
125 EmpathyMainWindow *window);
126 static void main_window_chat_add_contact_cb (GtkWidget *widget,
127 EmpathyMainWindow *window);
128 static void main_window_chat_show_offline_cb (GtkCheckMenuItem *item,
129 EmpathyMainWindow *window);
130 static gboolean main_window_edit_button_press_event_cb (GtkWidget *widget,
131 GdkEventButton *event,
132 EmpathyMainWindow *window);
133 static void main_window_edit_accounts_cb (GtkWidget *widget,
134 EmpathyMainWindow *window);
135 static void main_window_edit_personal_information_cb (GtkWidget *widget,
136 EmpathyMainWindow *window);
137 static void main_window_edit_preferences_cb (GtkWidget *widget,
138 EmpathyMainWindow *window);
139 static void main_window_help_about_cb (GtkWidget *widget,
140 EmpathyMainWindow *window);
141 static void main_window_help_contents_cb (GtkWidget *widget,
142 EmpathyMainWindow *window);
143 static gboolean main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox,
144 GdkEventButton *event,
145 EmpathyMainWindow *window);
146 static void main_window_status_changed_cb (MissionControl *mc,
147 TelepathyConnectionStatus status,
149 TelepathyConnectionStatusReason reason,
150 const gchar *unique_name,
151 EmpathyMainWindow *window);
152 static void main_window_update_status (EmpathyMainWindow *window);
153 static void main_window_accels_load (void);
154 static void main_window_accels_save (void);
155 static void main_window_connection_items_setup (EmpathyMainWindow *window,
157 static gboolean main_window_configure_event_timeout_cb (EmpathyMainWindow *window);
158 static gboolean main_window_configure_event_cb (GtkWidget *widget,
159 GdkEventConfigure *event,
160 EmpathyMainWindow *window);
161 static void main_window_notify_show_offline_cb (GossipConf *conf,
163 gpointer check_menu_item);
164 static void main_window_notify_show_avatars_cb (GossipConf *conf,
166 EmpathyMainWindow *window);
167 static void main_window_notify_compact_contact_list_cb (GossipConf *conf,
169 EmpathyMainWindow *window);
170 static void main_window_notify_sort_criterium_cb (GossipConf *conf,
172 EmpathyMainWindow *window);
175 empathy_main_window_show (void)
177 static EmpathyMainWindow *window = NULL;
178 EmpathyContactList *list_iface;
182 GtkWidget *show_offline_widget;
186 gboolean show_offline;
187 gboolean show_avatars;
188 gboolean compact_contact_list;
192 gtk_window_present (GTK_WINDOW (window->window));
193 return window->window;
196 window = g_new0 (EmpathyMainWindow, 1);
198 /* Set up interface */
199 glade = gossip_glade_get_file ("empathy-main-window.glade",
202 "main_window", &window->window,
203 "main_vbox", &window->main_vbox,
204 "chat_show_offline", &show_offline_widget,
205 "room", &window->room,
206 "room_sep", &window->room_sep,
207 "room_join_favorites", &window->room_join_favorites,
208 "edit_context", &window->edit_context,
209 "edit_context_separator", &window->edit_context_separator,
210 "presence_toolbar", &window->presence_toolbar,
211 "roster_scrolledwindow", &sw,
214 gossip_glade_connect (glade,
216 "main_window", "destroy", main_window_destroy_cb,
217 "main_window", "configure_event", main_window_configure_event_cb,
218 "chat_quit", "activate", main_window_chat_quit_cb,
219 "chat_new_message", "activate", main_window_chat_new_message_cb,
220 "chat_history", "activate", main_window_chat_history_cb,
221 "room_join_new", "activate", main_window_room_join_new_cb,
222 "room_join_favorites", "activate", main_window_room_join_favorites_cb,
223 "room_manage_favorites", "activate", main_window_room_manage_favorites_cb,
224 "chat_add_contact", "activate", main_window_chat_add_contact_cb,
225 "chat_show_offline", "toggled", main_window_chat_show_offline_cb,
226 "edit", "button-press-event", main_window_edit_button_press_event_cb,
227 "edit_accounts", "activate", main_window_edit_accounts_cb,
228 "edit_personal_information", "activate", main_window_edit_personal_information_cb,
229 "edit_preferences", "activate", main_window_edit_preferences_cb,
230 "help_about", "activate", main_window_help_about_cb,
231 "help_contents", "activate", main_window_help_contents_cb,
234 /* Set up connection related widgets. */
235 main_window_connection_items_setup (window, glade);
236 g_object_unref (glade);
238 window->tooltips = g_object_ref_sink (gtk_tooltips_new ());
239 window->mc = gossip_mission_control_new ();
240 dbus_g_proxy_connect_signal (DBUS_G_PROXY (window->mc), "AccountStatusChanged",
241 G_CALLBACK (main_window_status_changed_cb),
245 main_window_favorite_chatroom_menu_setup (window);
247 gtk_widget_hide (window->edit_context);
248 gtk_widget_hide (window->edit_context_separator);
250 /* Set up presence chooser */
251 window->presence_chooser = gossip_presence_chooser_new ();
252 gtk_widget_show (window->presence_chooser);
253 item = gtk_tool_item_new ();
254 gtk_widget_show (GTK_WIDGET (item));
255 gtk_container_add (GTK_CONTAINER (item), window->presence_chooser);
256 gtk_tool_item_set_is_important (item, TRUE);
257 gtk_tool_item_set_expand (item, TRUE);
258 gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
260 /* Set up the throbber */
261 ebox = gtk_event_box_new ();
262 gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
264 window->throbber = ephy_spinner_new ();
265 ephy_spinner_set_size (EPHY_SPINNER (window->throbber), GTK_ICON_SIZE_LARGE_TOOLBAR);
266 gtk_container_add (GTK_CONTAINER (ebox), window->throbber);
268 item = gtk_tool_item_new ();
269 gtk_container_add (GTK_CONTAINER (item), ebox);
270 gtk_widget_show_all (GTK_WIDGET (item));
272 gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
274 str = _("Show and edit accounts");
275 gtk_tooltips_set_tip (GTK_TOOLTIPS (window->tooltips),
278 g_signal_connect (ebox,
279 "button-press-event",
280 G_CALLBACK (main_window_throbber_button_press_event_cb),
283 /* Set up contact list. */
284 gossip_status_presets_get_all ();
286 list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_new ());
287 empathy_contact_list_setup (list_iface);
288 window->list_store = gossip_contact_list_store_new (list_iface);
289 window->list_view = gossip_contact_list_view_new (window->list_store);
290 g_object_unref (list_iface);
292 gtk_widget_show (GTK_WIDGET (window->list_view));
293 gtk_container_add (GTK_CONTAINER (sw),
294 GTK_WIDGET (window->list_view));
296 /* Load user-defined accelerators. */
297 main_window_accels_load ();
299 /* Set window size. */
300 gossip_geometry_load (GEOMETRY_NAME, &x, &y, &w, &h);
302 if (w >= 1 && h >= 1) {
303 /* Use the defaults from the glade file if we
304 * don't have good w, h geometry.
306 gossip_debug (DEBUG_DOMAIN, "Configuring window default size w:%d, h:%d", w, h);
307 gtk_window_set_default_size (GTK_WINDOW (window->window), w, h);
310 if (x >= 0 && y >= 0) {
311 /* Let the window manager position it if we
312 * don't have good x, y coordinates.
314 gossip_debug (DEBUG_DOMAIN, "Configuring window default position x:%d, y:%d", x, y);
315 gtk_window_move (GTK_WINDOW (window->window), x, y);
318 conf = gossip_conf_get ();
321 gossip_conf_get_bool (conf,
322 GOSSIP_PREFS_CONTACTS_SHOW_OFFLINE,
324 gossip_conf_notify_add (conf,
325 GOSSIP_PREFS_CONTACTS_SHOW_OFFLINE,
326 main_window_notify_show_offline_cb,
327 show_offline_widget);
329 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_offline_widget),
333 gossip_conf_get_bool (conf,
334 GOSSIP_PREFS_UI_SHOW_AVATARS,
336 gossip_conf_notify_add (conf,
337 GOSSIP_PREFS_UI_SHOW_AVATARS,
338 (GossipConfNotifyFunc) main_window_notify_show_avatars_cb,
340 gossip_contact_list_store_set_show_avatars (window->list_store, show_avatars);
343 gossip_conf_get_bool (conf,
344 GOSSIP_PREFS_UI_COMPACT_CONTACT_LIST,
345 &compact_contact_list);
346 gossip_conf_notify_add (conf,
347 GOSSIP_PREFS_UI_COMPACT_CONTACT_LIST,
348 (GossipConfNotifyFunc) main_window_notify_compact_contact_list_cb,
350 gossip_contact_list_store_set_is_compact (window->list_store, compact_contact_list);
353 gossip_conf_notify_add (conf,
354 GOSSIP_PREFS_CONTACTS_SORT_CRITERIUM,
355 (GossipConfNotifyFunc) main_window_notify_sort_criterium_cb,
357 main_window_notify_sort_criterium_cb (conf,
358 GOSSIP_PREFS_CONTACTS_SORT_CRITERIUM,
361 main_window_update_status (window);
363 return window->window;
367 main_window_destroy_cb (GtkWidget *widget,
368 EmpathyMainWindow *window)
370 /* Save user-defined accelerators. */
371 main_window_accels_save ();
373 dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (window->mc), "AccountStatusChanged",
374 G_CALLBACK (main_window_status_changed_cb),
377 if (window->size_timeout_id) {
378 g_source_remove (window->size_timeout_id);
381 g_list_free (window->widgets_connected);
382 g_list_free (window->widgets_disconnected);
384 g_object_unref (window->tooltips);
385 g_object_unref (window->mc);
386 g_object_unref (window->list_store);
392 main_window_favorite_chatroom_menu_setup (EmpathyMainWindow *window)
394 GList *chatrooms, *l;
396 window->chatroom_manager = gossip_chatroom_manager_new ();
397 chatrooms = gossip_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
398 window->room_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (window->room));
400 for (l = chatrooms; l; l = l->next) {
401 main_window_favorite_chatroom_menu_add (window, l->data);
405 gtk_widget_hide (window->room_sep);
408 gtk_widget_set_sensitive (window->room_join_favorites, chatrooms != NULL);
410 g_signal_connect (window->chatroom_manager, "chatroom-added",
411 G_CALLBACK (main_window_favorite_chatroom_menu_added_cb),
413 g_signal_connect (window->chatroom_manager, "chatroom-removed",
414 G_CALLBACK (main_window_favorite_chatroom_menu_removed_cb),
417 g_list_free (chatrooms);
421 main_window_favorite_chatroom_menu_added_cb (GossipChatroomManager *manager,
422 GossipChatroom *chatroom,
423 EmpathyMainWindow *window)
425 main_window_favorite_chatroom_menu_add (window, chatroom);
426 gtk_widget_show (window->room_sep);
427 gtk_widget_set_sensitive (window->room_join_favorites, TRUE);
431 main_window_favorite_chatroom_menu_removed_cb (GossipChatroomManager *manager,
432 GossipChatroom *chatroom,
433 EmpathyMainWindow *window)
435 GtkWidget *menu_item;
437 menu_item = g_object_get_data (G_OBJECT (chatroom), "menu_item");
439 g_object_set_data (G_OBJECT (chatroom), "menu_item", NULL);
440 gtk_widget_destroy (menu_item);
442 main_window_favorite_chatroom_menu_update (window);
446 main_window_favorite_chatroom_menu_activate_cb (GtkMenuItem *menu_item,
447 GossipChatroom *chatroom)
450 GossipSession *session;
451 GossipAccount *account;
452 GossipChatroomProvider *provider;
454 session = gossip_app_get_session ();
455 account = gossip_chatroom_get_account (chatroom);
456 provider = gossip_session_get_chatroom_provider (session, account);
458 gossip_group_chat_new (provider, chatroom);
463 main_window_favorite_chatroom_menu_update (EmpathyMainWindow *window)
467 chatrooms = gossip_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
470 gtk_widget_show (window->room_sep);
472 gtk_widget_hide (window->room_sep);
475 gtk_widget_set_sensitive (window->room_join_favorites, chatrooms != NULL);
476 g_list_free (chatrooms);
480 main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window,
481 GossipChatroom *chatroom)
483 GtkWidget *menu_item;
486 if (g_object_get_data (G_OBJECT (chatroom), "menu_item")) {
490 name = gossip_chatroom_get_name (chatroom);
491 menu_item = gtk_menu_item_new_with_label (name);
493 g_object_set_data (G_OBJECT (chatroom), "menu_item", menu_item);
494 g_signal_connect (menu_item, "activate",
495 G_CALLBACK (main_window_favorite_chatroom_menu_activate_cb),
498 gtk_menu_shell_insert (GTK_MENU_SHELL (window->room_menu),
501 gtk_widget_show (menu_item);
505 main_window_chat_quit_cb (GtkWidget *widget,
506 EmpathyMainWindow *window)
512 main_window_chat_new_message_cb (GtkWidget *widget,
513 EmpathyMainWindow *window)
515 //gossip_new_message_dialog_show (GTK_WINDOW (window->window));
519 main_window_chat_history_cb (GtkWidget *widget,
520 EmpathyMainWindow *window)
522 //gossip_log_window_show (NULL, NULL);
526 main_window_room_join_new_cb (GtkWidget *widget,
527 EmpathyMainWindow *window)
529 gossip_new_chatroom_dialog_show (GTK_WINDOW (window->window));
533 main_window_room_join_favorites_cb (GtkWidget *widget,
534 EmpathyMainWindow *window)
536 //gossip_session_chatroom_join_favorites (window->session);
540 main_window_room_manage_favorites_cb (GtkWidget *widget,
541 EmpathyMainWindow *window)
543 gossip_chatrooms_window_show (GTK_WINDOW (window->window));
547 main_window_chat_add_contact_cb (GtkWidget *widget,
548 EmpathyMainWindow *window)
550 //gossip_add_contact_dialog_show (GTK_WINDOW (window->window), NULL);
554 main_window_chat_show_offline_cb (GtkCheckMenuItem *item,
555 EmpathyMainWindow *window)
559 current = gtk_check_menu_item_get_active (item);
561 gossip_conf_set_bool (gossip_conf_get (),
562 GOSSIP_PREFS_CONTACTS_SHOW_OFFLINE,
565 /* Turn off sound just while we alter the contact list. */
566 // FIXME: gossip_sound_set_enabled (FALSE);
567 gossip_contact_list_store_set_show_offline (window->list_store, current);
568 //gossip_sound_set_enabled (TRUE);
572 main_window_edit_button_press_event_cb (GtkWidget *widget,
573 GdkEventButton *event,
574 EmpathyMainWindow *window)
576 GossipContact *contact;
579 if (!event->button == 1) {
583 group = gossip_contact_list_view_get_selected_group (window->list_view);
589 item = GTK_MENU_ITEM (window->edit_context);
590 label = gtk_bin_get_child (GTK_BIN (item));
591 gtk_label_set_text (GTK_LABEL (label), _("Group"));
593 gtk_widget_show (window->edit_context);
594 gtk_widget_show (window->edit_context_separator);
596 submenu = gossip_contact_list_view_get_group_menu (window->list_view);
597 gtk_menu_item_set_submenu (item, submenu);
604 contact = gossip_contact_list_view_get_selected (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), _("Contact"));
614 gtk_widget_show (window->edit_context);
615 gtk_widget_show (window->edit_context_separator);
617 submenu = gossip_contact_list_view_get_contact_menu (window->list_view,
619 gtk_menu_item_set_submenu (item, submenu);
621 g_object_unref (contact);
626 gtk_widget_hide (window->edit_context);
627 gtk_widget_hide (window->edit_context_separator);
633 main_window_edit_accounts_cb (GtkWidget *widget,
634 EmpathyMainWindow *window)
636 gossip_accounts_dialog_show (GTK_WINDOW (window->window));
640 main_window_edit_personal_information_cb (GtkWidget *widget,
641 EmpathyMainWindow *window)
643 //gossip_vcard_dialog_show (GTK_WINDOW (window->window));
647 main_window_edit_preferences_cb (GtkWidget *widget,
648 EmpathyMainWindow *window)
650 gossip_preferences_show (GTK_WINDOW (window->window));
654 main_window_help_about_cb (GtkWidget *widget,
655 EmpathyMainWindow *window)
657 gossip_about_dialog_new (GTK_WINDOW (window->window));
661 main_window_help_contents_cb (GtkWidget *widget,
662 EmpathyMainWindow *window)
664 //gossip_help_show ();
668 main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox,
669 GdkEventButton *event,
670 EmpathyMainWindow *window)
672 if (event->type != GDK_BUTTON_PRESS ||
673 event->button != 1) {
677 gossip_accounts_dialog_show (GTK_WINDOW (window->window));
683 main_window_status_changed_cb (MissionControl *mc,
684 TelepathyConnectionStatus status,
686 TelepathyConnectionStatusReason reason,
687 const gchar *unique_name,
688 EmpathyMainWindow *window)
690 main_window_update_status (window);
694 main_window_update_status (EmpathyMainWindow *window)
698 guint connecting = 0;
699 guint disconnected = 0;
701 /* Count number of connected/connecting/disconnected accounts */
702 accounts = mc_accounts_list ();
703 for (l = accounts; l; l = l->next) {
709 status = mission_control_get_connection_status (window->mc,
715 } else if (status == 1) {
717 } else if (status == 2) {
721 g_object_unref (account);
723 g_list_free (accounts);
725 /* Update the spinner state */
726 if (connecting > 0) {
727 ephy_spinner_start (EPHY_SPINNER (window->throbber));
729 ephy_spinner_stop (EPHY_SPINNER (window->throbber));
732 /* Update widgets sensibility */
733 for (l = window->widgets_connected; l; l = l->next) {
734 gtk_widget_set_sensitive (l->data, (connected > 0));
737 for (l = window->widgets_disconnected; l; l = l->next) {
738 gtk_widget_set_sensitive (l->data, (disconnected > 0));
746 main_window_accels_load (void)
750 filename = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, ACCELS_FILENAME, NULL);
751 if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
752 gossip_debug (DEBUG_DOMAIN, "Loading from:'%s'", filename);
753 gtk_accel_map_load (filename);
760 main_window_accels_save (void)
763 gchar *file_with_path;
765 dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
766 g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
767 file_with_path = g_build_filename (dir, ACCELS_FILENAME, NULL);
770 gossip_debug (DEBUG_DOMAIN, "Saving to:'%s'", file_with_path);
771 gtk_accel_map_save (file_with_path);
773 g_free (file_with_path);
777 main_window_connection_items_setup (EmpathyMainWindow *window,
783 const gchar *widgets_connected[] = {
787 "edit_personal_information"
789 const gchar *widgets_disconnected[] = {
792 for (i = 0, list = NULL; i < G_N_ELEMENTS (widgets_connected); i++) {
793 w = glade_xml_get_widget (glade, widgets_connected[i]);
794 list = g_list_prepend (list, w);
797 window->widgets_connected = list;
799 for (i = 0, list = NULL; i < G_N_ELEMENTS (widgets_disconnected); i++) {
800 w = glade_xml_get_widget (glade, widgets_disconnected[i]);
801 list = g_list_prepend (list, w);
804 window->widgets_disconnected = list;
808 main_window_configure_event_timeout_cb (EmpathyMainWindow *window)
812 gtk_window_get_size (GTK_WINDOW (window->window), &w, &h);
813 gtk_window_get_position (GTK_WINDOW (window->window), &x, &y);
815 gossip_geometry_save (GEOMETRY_NAME, x, y, w, h);
817 window->size_timeout_id = 0;
823 main_window_configure_event_cb (GtkWidget *widget,
824 GdkEventConfigure *event,
825 EmpathyMainWindow *window)
827 if (window->size_timeout_id) {
828 g_source_remove (window->size_timeout_id);
831 window->size_timeout_id = g_timeout_add (500,
832 (GSourceFunc) main_window_configure_event_timeout_cb,
839 main_window_notify_show_offline_cb (GossipConf *conf,
841 gpointer check_menu_item)
843 gboolean show_offline;
845 if (gossip_conf_get_bool (conf, key, &show_offline)) {
846 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (check_menu_item),
852 main_window_notify_show_avatars_cb (GossipConf *conf,
854 EmpathyMainWindow *window)
856 gboolean show_avatars;
858 if (gossip_conf_get_bool (conf, key, &show_avatars)) {
859 gossip_contact_list_store_set_show_avatars (window->list_store,
865 main_window_notify_compact_contact_list_cb (GossipConf *conf,
867 EmpathyMainWindow *window)
869 gboolean compact_contact_list;
871 if (gossip_conf_get_bool (conf, key, &compact_contact_list)) {
872 gossip_contact_list_store_set_is_compact (window->list_store,
873 compact_contact_list);
878 main_window_notify_sort_criterium_cb (GossipConf *conf,
880 EmpathyMainWindow *window)
884 if (gossip_conf_get_string (conf, key, &str)) {
886 GEnumClass *enum_class;
887 GEnumValue *enum_value;
889 type = gossip_contact_list_store_sort_get_type ();
890 enum_class = G_ENUM_CLASS (g_type_class_peek (type));
891 enum_value = g_enum_get_value_by_nick (enum_class, str);
895 gossip_contact_list_store_set_sort_criterium (window->list_store,