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 "empathy-contact-dialogs.h"
41 #include "ephy-spinner.h"
42 #include "gossip-contact-list-store.h"
43 #include "gossip-contact-list-view.h"
44 #include "gossip-presence-chooser.h"
45 #include "gossip-ui-utils.h"
46 #include "gossip-status-presets.h"
47 #include "gossip-geometry.h"
48 #include "gossip-preferences.h"
49 #include "gossip-accounts-dialog.h"
50 #include "gossip-about-dialog.h"
51 #include "gossip-new-chatroom-dialog.h"
52 #include "gossip-chatrooms-window.h"
54 #define DEBUG_DOMAIN "MainWindow"
56 /* Minimum width of roster window if something goes wrong. */
59 /* Accels (menu shortcuts) can be configured and saved */
60 #define ACCELS_FILENAME "accels.txt"
62 /* Name in the geometry file */
63 #define GEOMETRY_NAME "main-window"
66 GossipContactListView *list_view;
67 GossipContactListStore *list_store;
69 GossipChatroomManager *chatroom_manager;
75 /* Tooltips for all widgets */
76 GtkTooltips *tooltips;
82 GtkWidget *room_join_favorites;
83 GtkWidget *edit_context;
84 GtkWidget *edit_context_separator;
89 /* Widgets that are enabled when there is... */
90 GList *widgets_connected; /* ... connected accounts */
91 GList *widgets_disconnected; /* ... disconnected accounts */
94 GtkWidget *presence_toolbar;
95 GtkWidget *presence_chooser;
98 guint size_timeout_id;
101 static void main_window_destroy_cb (GtkWidget *widget,
102 EmpathyMainWindow *window);
103 static void main_window_favorite_chatroom_menu_setup (EmpathyMainWindow *window);
104 static void main_window_favorite_chatroom_menu_added_cb (GossipChatroomManager *manager,
105 GossipChatroom *chatroom,
106 EmpathyMainWindow *window);
107 static void main_window_favorite_chatroom_menu_removed_cb (GossipChatroomManager *manager,
108 GossipChatroom *chatroom,
109 EmpathyMainWindow *window);
110 static void main_window_favorite_chatroom_menu_activate_cb (GtkMenuItem *menu_item,
111 GossipChatroom *chatroom);
112 static void main_window_favorite_chatroom_menu_update (EmpathyMainWindow *window);
113 static void main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window,
114 GossipChatroom *chatroom);
115 static void main_window_favorite_chatroom_join (GossipChatroom *chatroom);
116 static void main_window_chat_quit_cb (GtkWidget *widget,
117 EmpathyMainWindow *window);
118 static void main_window_chat_new_message_cb (GtkWidget *widget,
119 EmpathyMainWindow *window);
120 static void main_window_chat_history_cb (GtkWidget *widget,
121 EmpathyMainWindow *window);
122 static void main_window_room_join_new_cb (GtkWidget *widget,
123 EmpathyMainWindow *window);
124 static void main_window_room_join_favorites_cb (GtkWidget *widget,
125 EmpathyMainWindow *window);
126 static void main_window_room_manage_favorites_cb (GtkWidget *widget,
127 EmpathyMainWindow *window);
128 static void main_window_chat_add_contact_cb (GtkWidget *widget,
129 EmpathyMainWindow *window);
130 static void main_window_chat_show_offline_cb (GtkCheckMenuItem *item,
131 EmpathyMainWindow *window);
132 static gboolean main_window_edit_button_press_event_cb (GtkWidget *widget,
133 GdkEventButton *event,
134 EmpathyMainWindow *window);
135 static void main_window_edit_accounts_cb (GtkWidget *widget,
136 EmpathyMainWindow *window);
137 static void main_window_edit_personal_information_cb (GtkWidget *widget,
138 EmpathyMainWindow *window);
139 static void main_window_edit_preferences_cb (GtkWidget *widget,
140 EmpathyMainWindow *window);
141 static void main_window_help_about_cb (GtkWidget *widget,
142 EmpathyMainWindow *window);
143 static void main_window_help_contents_cb (GtkWidget *widget,
144 EmpathyMainWindow *window);
145 static gboolean main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox,
146 GdkEventButton *event,
147 EmpathyMainWindow *window);
148 static void main_window_status_changed_cb (MissionControl *mc,
149 TelepathyConnectionStatus status,
151 TelepathyConnectionStatusReason reason,
152 const gchar *unique_name,
153 EmpathyMainWindow *window);
154 static void main_window_update_status (EmpathyMainWindow *window);
155 static void main_window_accels_load (void);
156 static void main_window_accels_save (void);
157 static void main_window_connection_items_setup (EmpathyMainWindow *window,
159 static gboolean main_window_configure_event_timeout_cb (EmpathyMainWindow *window);
160 static gboolean main_window_configure_event_cb (GtkWidget *widget,
161 GdkEventConfigure *event,
162 EmpathyMainWindow *window);
163 static void main_window_notify_show_offline_cb (GossipConf *conf,
165 gpointer check_menu_item);
166 static void main_window_notify_show_avatars_cb (GossipConf *conf,
168 EmpathyMainWindow *window);
169 static void main_window_notify_compact_contact_list_cb (GossipConf *conf,
171 EmpathyMainWindow *window);
172 static void main_window_notify_sort_criterium_cb (GossipConf *conf,
174 EmpathyMainWindow *window);
177 empathy_main_window_show (void)
179 static EmpathyMainWindow *window = NULL;
180 EmpathyContactList *list_iface;
184 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 = gossip_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 gossip_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->tooltips = g_object_ref_sink (gtk_tooltips_new ());
241 window->mc = gossip_mission_control_new ();
242 dbus_g_proxy_connect_signal (DBUS_G_PROXY (window->mc), "AccountStatusChanged",
243 G_CALLBACK (main_window_status_changed_cb),
247 main_window_favorite_chatroom_menu_setup (window);
249 gtk_widget_hide (window->edit_context);
250 gtk_widget_hide (window->edit_context_separator);
252 /* Set up presence chooser */
253 window->presence_chooser = gossip_presence_chooser_new ();
254 gtk_widget_show (window->presence_chooser);
255 item = gtk_tool_item_new ();
256 gtk_widget_show (GTK_WIDGET (item));
257 gtk_container_add (GTK_CONTAINER (item), window->presence_chooser);
258 gtk_tool_item_set_is_important (item, TRUE);
259 gtk_tool_item_set_expand (item, TRUE);
260 gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
262 /* Set up the throbber */
263 ebox = gtk_event_box_new ();
264 gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
266 window->throbber = ephy_spinner_new ();
267 ephy_spinner_set_size (EPHY_SPINNER (window->throbber), GTK_ICON_SIZE_LARGE_TOOLBAR);
268 gtk_container_add (GTK_CONTAINER (ebox), window->throbber);
270 item = gtk_tool_item_new ();
271 gtk_container_add (GTK_CONTAINER (item), ebox);
272 gtk_widget_show_all (GTK_WIDGET (item));
274 gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
276 str = _("Show and edit accounts");
277 gtk_tooltips_set_tip (GTK_TOOLTIPS (window->tooltips),
280 g_signal_connect (ebox,
281 "button-press-event",
282 G_CALLBACK (main_window_throbber_button_press_event_cb),
285 /* Set up contact list. */
286 gossip_status_presets_get_all ();
288 list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_new ());
289 empathy_contact_list_setup (list_iface);
290 window->list_store = gossip_contact_list_store_new (list_iface);
291 window->list_view = gossip_contact_list_view_new (window->list_store);
292 g_object_unref (list_iface);
294 gtk_widget_show (GTK_WIDGET (window->list_view));
295 gtk_container_add (GTK_CONTAINER (sw),
296 GTK_WIDGET (window->list_view));
298 /* Load user-defined accelerators. */
299 main_window_accels_load ();
301 /* Set window size. */
302 gossip_geometry_load (GEOMETRY_NAME, &x, &y, &w, &h);
304 if (w >= 1 && h >= 1) {
305 /* Use the defaults from the glade file if we
306 * don't have good w, h geometry.
308 gossip_debug (DEBUG_DOMAIN, "Configuring window default size w:%d, h:%d", w, h);
309 gtk_window_set_default_size (GTK_WINDOW (window->window), w, h);
312 if (x >= 0 && y >= 0) {
313 /* Let the window manager position it if we
314 * don't have good x, y coordinates.
316 gossip_debug (DEBUG_DOMAIN, "Configuring window default position x:%d, y:%d", x, y);
317 gtk_window_move (GTK_WINDOW (window->window), x, y);
320 conf = gossip_conf_get ();
323 gossip_conf_get_bool (conf,
324 GOSSIP_PREFS_CONTACTS_SHOW_OFFLINE,
326 gossip_conf_notify_add (conf,
327 GOSSIP_PREFS_CONTACTS_SHOW_OFFLINE,
328 main_window_notify_show_offline_cb,
329 show_offline_widget);
331 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_offline_widget),
335 gossip_conf_get_bool (conf,
336 GOSSIP_PREFS_UI_SHOW_AVATARS,
338 gossip_conf_notify_add (conf,
339 GOSSIP_PREFS_UI_SHOW_AVATARS,
340 (GossipConfNotifyFunc) main_window_notify_show_avatars_cb,
342 gossip_contact_list_store_set_show_avatars (window->list_store, show_avatars);
345 gossip_conf_get_bool (conf,
346 GOSSIP_PREFS_UI_COMPACT_CONTACT_LIST,
347 &compact_contact_list);
348 gossip_conf_notify_add (conf,
349 GOSSIP_PREFS_UI_COMPACT_CONTACT_LIST,
350 (GossipConfNotifyFunc) main_window_notify_compact_contact_list_cb,
352 gossip_contact_list_store_set_is_compact (window->list_store, compact_contact_list);
355 gossip_conf_notify_add (conf,
356 GOSSIP_PREFS_CONTACTS_SORT_CRITERIUM,
357 (GossipConfNotifyFunc) main_window_notify_sort_criterium_cb,
359 main_window_notify_sort_criterium_cb (conf,
360 GOSSIP_PREFS_CONTACTS_SORT_CRITERIUM,
363 main_window_update_status (window);
365 return window->window;
369 main_window_destroy_cb (GtkWidget *widget,
370 EmpathyMainWindow *window)
372 /* Save user-defined accelerators. */
373 main_window_accels_save ();
375 dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (window->mc), "AccountStatusChanged",
376 G_CALLBACK (main_window_status_changed_cb),
379 if (window->size_timeout_id) {
380 g_source_remove (window->size_timeout_id);
383 g_list_free (window->widgets_connected);
384 g_list_free (window->widgets_disconnected);
386 g_object_unref (window->tooltips);
387 g_object_unref (window->mc);
388 g_object_unref (window->list_store);
394 main_window_favorite_chatroom_menu_setup (EmpathyMainWindow *window)
396 GList *chatrooms, *l;
398 window->chatroom_manager = gossip_chatroom_manager_new ();
399 chatrooms = gossip_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
400 window->room_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (window->room));
402 for (l = chatrooms; l; l = l->next) {
403 main_window_favorite_chatroom_menu_add (window, l->data);
407 gtk_widget_hide (window->room_sep);
410 gtk_widget_set_sensitive (window->room_join_favorites, chatrooms != NULL);
412 g_signal_connect (window->chatroom_manager, "chatroom-added",
413 G_CALLBACK (main_window_favorite_chatroom_menu_added_cb),
415 g_signal_connect (window->chatroom_manager, "chatroom-removed",
416 G_CALLBACK (main_window_favorite_chatroom_menu_removed_cb),
419 g_list_free (chatrooms);
423 main_window_favorite_chatroom_menu_added_cb (GossipChatroomManager *manager,
424 GossipChatroom *chatroom,
425 EmpathyMainWindow *window)
427 main_window_favorite_chatroom_menu_add (window, chatroom);
428 gtk_widget_show (window->room_sep);
429 gtk_widget_set_sensitive (window->room_join_favorites, TRUE);
433 main_window_favorite_chatroom_menu_removed_cb (GossipChatroomManager *manager,
434 GossipChatroom *chatroom,
435 EmpathyMainWindow *window)
437 GtkWidget *menu_item;
439 menu_item = g_object_get_data (G_OBJECT (chatroom), "menu_item");
441 g_object_set_data (G_OBJECT (chatroom), "menu_item", NULL);
442 gtk_widget_destroy (menu_item);
444 main_window_favorite_chatroom_menu_update (window);
448 main_window_favorite_chatroom_menu_activate_cb (GtkMenuItem *menu_item,
449 GossipChatroom *chatroom)
451 main_window_favorite_chatroom_join (chatroom);
455 main_window_favorite_chatroom_menu_update (EmpathyMainWindow *window)
459 chatrooms = gossip_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
462 gtk_widget_show (window->room_sep);
464 gtk_widget_hide (window->room_sep);
467 gtk_widget_set_sensitive (window->room_join_favorites, chatrooms != NULL);
468 g_list_free (chatrooms);
472 main_window_favorite_chatroom_menu_add (EmpathyMainWindow *window,
473 GossipChatroom *chatroom)
475 GtkWidget *menu_item;
478 if (g_object_get_data (G_OBJECT (chatroom), "menu_item")) {
482 name = gossip_chatroom_get_name (chatroom);
483 menu_item = gtk_menu_item_new_with_label (name);
485 g_object_set_data (G_OBJECT (chatroom), "menu_item", menu_item);
486 g_signal_connect (menu_item, "activate",
487 G_CALLBACK (main_window_favorite_chatroom_menu_activate_cb),
490 gtk_menu_shell_insert (GTK_MENU_SHELL (window->room_menu),
493 gtk_widget_show (menu_item);
497 main_window_favorite_chatroom_join (GossipChatroom *chatroom)
503 mc = gossip_mission_control_new ();
504 account = gossip_chatroom_get_account (chatroom);
505 room = gossip_chatroom_get_room (chatroom);
507 gossip_debug (DEBUG_DOMAIN, "Requesting channel for '%s'", room);
509 mission_control_request_channel_with_string_handle (mc,
511 TP_IFACE_CHANNEL_TYPE_TEXT,
519 main_window_chat_quit_cb (GtkWidget *widget,
520 EmpathyMainWindow *window)
526 main_window_chat_new_message_cb (GtkWidget *widget,
527 EmpathyMainWindow *window)
529 //gossip_new_message_dialog_show (GTK_WINDOW (window->window));
533 main_window_chat_history_cb (GtkWidget *widget,
534 EmpathyMainWindow *window)
536 //gossip_log_window_show (NULL, NULL);
540 main_window_room_join_new_cb (GtkWidget *widget,
541 EmpathyMainWindow *window)
543 gossip_new_chatroom_dialog_show (GTK_WINDOW (window->window));
547 main_window_room_join_favorites_cb (GtkWidget *widget,
548 EmpathyMainWindow *window)
550 GList *chatrooms, *l;
552 chatrooms = gossip_chatroom_manager_get_chatrooms (window->chatroom_manager, NULL);
553 for (l = chatrooms; l; l = l->next) {
554 main_window_favorite_chatroom_join (l->data);
556 g_list_free (chatrooms);
560 main_window_room_manage_favorites_cb (GtkWidget *widget,
561 EmpathyMainWindow *window)
563 gossip_chatrooms_window_show (GTK_WINDOW (window->window));
567 main_window_chat_add_contact_cb (GtkWidget *widget,
568 EmpathyMainWindow *window)
570 empathy_new_contact_dialog_show (GTK_WINDOW (window->window));
574 main_window_chat_show_offline_cb (GtkCheckMenuItem *item,
575 EmpathyMainWindow *window)
579 current = gtk_check_menu_item_get_active (item);
581 gossip_conf_set_bool (gossip_conf_get (),
582 GOSSIP_PREFS_CONTACTS_SHOW_OFFLINE,
585 /* Turn off sound just while we alter the contact list. */
586 // FIXME: gossip_sound_set_enabled (FALSE);
587 gossip_contact_list_store_set_show_offline (window->list_store, current);
588 //gossip_sound_set_enabled (TRUE);
592 main_window_edit_button_press_event_cb (GtkWidget *widget,
593 GdkEventButton *event,
594 EmpathyMainWindow *window)
596 GossipContact *contact;
599 if (!event->button == 1) {
603 group = gossip_contact_list_view_get_selected_group (window->list_view);
609 item = GTK_MENU_ITEM (window->edit_context);
610 label = gtk_bin_get_child (GTK_BIN (item));
611 gtk_label_set_text (GTK_LABEL (label), _("Group"));
613 gtk_widget_show (window->edit_context);
614 gtk_widget_show (window->edit_context_separator);
616 submenu = gossip_contact_list_view_get_group_menu (window->list_view);
617 gtk_menu_item_set_submenu (item, submenu);
624 contact = gossip_contact_list_view_get_selected (window->list_view);
630 item = GTK_MENU_ITEM (window->edit_context);
631 label = gtk_bin_get_child (GTK_BIN (item));
632 gtk_label_set_text (GTK_LABEL (label), _("Contact"));
634 gtk_widget_show (window->edit_context);
635 gtk_widget_show (window->edit_context_separator);
637 submenu = gossip_contact_list_view_get_contact_menu (window->list_view,
639 gtk_menu_item_set_submenu (item, submenu);
641 g_object_unref (contact);
646 gtk_widget_hide (window->edit_context);
647 gtk_widget_hide (window->edit_context_separator);
653 main_window_edit_accounts_cb (GtkWidget *widget,
654 EmpathyMainWindow *window)
656 gossip_accounts_dialog_show (GTK_WINDOW (window->window));
660 main_window_edit_personal_information_cb (GtkWidget *widget,
661 EmpathyMainWindow *window)
663 //gossip_vcard_dialog_show (GTK_WINDOW (window->window));
667 main_window_edit_preferences_cb (GtkWidget *widget,
668 EmpathyMainWindow *window)
670 gossip_preferences_show (GTK_WINDOW (window->window));
674 main_window_help_about_cb (GtkWidget *widget,
675 EmpathyMainWindow *window)
677 gossip_about_dialog_new (GTK_WINDOW (window->window));
681 main_window_help_contents_cb (GtkWidget *widget,
682 EmpathyMainWindow *window)
684 //gossip_help_show ();
688 main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox,
689 GdkEventButton *event,
690 EmpathyMainWindow *window)
692 if (event->type != GDK_BUTTON_PRESS ||
693 event->button != 1) {
697 gossip_accounts_dialog_show (GTK_WINDOW (window->window));
703 main_window_status_changed_cb (MissionControl *mc,
704 TelepathyConnectionStatus status,
706 TelepathyConnectionStatusReason reason,
707 const gchar *unique_name,
708 EmpathyMainWindow *window)
710 main_window_update_status (window);
714 main_window_update_status (EmpathyMainWindow *window)
718 guint connecting = 0;
719 guint disconnected = 0;
721 /* Count number of connected/connecting/disconnected accounts */
722 accounts = mc_accounts_list ();
723 for (l = accounts; l; l = l->next) {
729 status = mission_control_get_connection_status (window->mc,
735 } else if (status == 1) {
737 } else if (status == 2) {
741 g_object_unref (account);
743 g_list_free (accounts);
745 /* Update the spinner state */
746 if (connecting > 0) {
747 ephy_spinner_start (EPHY_SPINNER (window->throbber));
749 ephy_spinner_stop (EPHY_SPINNER (window->throbber));
752 /* Update widgets sensibility */
753 for (l = window->widgets_connected; l; l = l->next) {
754 gtk_widget_set_sensitive (l->data, (connected > 0));
757 for (l = window->widgets_disconnected; l; l = l->next) {
758 gtk_widget_set_sensitive (l->data, (disconnected > 0));
766 main_window_accels_load (void)
770 filename = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, ACCELS_FILENAME, NULL);
771 if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
772 gossip_debug (DEBUG_DOMAIN, "Loading from:'%s'", filename);
773 gtk_accel_map_load (filename);
780 main_window_accels_save (void)
783 gchar *file_with_path;
785 dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
786 g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
787 file_with_path = g_build_filename (dir, ACCELS_FILENAME, NULL);
790 gossip_debug (DEBUG_DOMAIN, "Saving to:'%s'", file_with_path);
791 gtk_accel_map_save (file_with_path);
793 g_free (file_with_path);
797 main_window_connection_items_setup (EmpathyMainWindow *window,
803 const gchar *widgets_connected[] = {
807 "edit_personal_information"
809 const gchar *widgets_disconnected[] = {
812 for (i = 0, list = NULL; i < G_N_ELEMENTS (widgets_connected); i++) {
813 w = glade_xml_get_widget (glade, widgets_connected[i]);
814 list = g_list_prepend (list, w);
817 window->widgets_connected = list;
819 for (i = 0, list = NULL; i < G_N_ELEMENTS (widgets_disconnected); i++) {
820 w = glade_xml_get_widget (glade, widgets_disconnected[i]);
821 list = g_list_prepend (list, w);
824 window->widgets_disconnected = list;
828 main_window_configure_event_timeout_cb (EmpathyMainWindow *window)
832 gtk_window_get_size (GTK_WINDOW (window->window), &w, &h);
833 gtk_window_get_position (GTK_WINDOW (window->window), &x, &y);
835 gossip_geometry_save (GEOMETRY_NAME, x, y, w, h);
837 window->size_timeout_id = 0;
843 main_window_configure_event_cb (GtkWidget *widget,
844 GdkEventConfigure *event,
845 EmpathyMainWindow *window)
847 if (window->size_timeout_id) {
848 g_source_remove (window->size_timeout_id);
851 window->size_timeout_id = g_timeout_add (500,
852 (GSourceFunc) main_window_configure_event_timeout_cb,
859 main_window_notify_show_offline_cb (GossipConf *conf,
861 gpointer check_menu_item)
863 gboolean show_offline;
865 if (gossip_conf_get_bool (conf, key, &show_offline)) {
866 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (check_menu_item),
872 main_window_notify_show_avatars_cb (GossipConf *conf,
874 EmpathyMainWindow *window)
876 gboolean show_avatars;
878 if (gossip_conf_get_bool (conf, key, &show_avatars)) {
879 gossip_contact_list_store_set_show_avatars (window->list_store,
885 main_window_notify_compact_contact_list_cb (GossipConf *conf,
887 EmpathyMainWindow *window)
889 gboolean compact_contact_list;
891 if (gossip_conf_get_bool (conf, key, &compact_contact_list)) {
892 gossip_contact_list_store_set_is_compact (window->list_store,
893 compact_contact_list);
898 main_window_notify_sort_criterium_cb (GossipConf *conf,
900 EmpathyMainWindow *window)
904 if (gossip_conf_get_string (conf, key, &str)) {
906 GEnumClass *enum_class;
907 GEnumValue *enum_value;
909 type = gossip_contact_list_store_sort_get_type ();
910 enum_class = G_ENUM_CLASS (g_type_class_peek (type));
911 enum_value = g_enum_get_value_by_nick (enum_class, str);
915 gossip_contact_list_store_set_sort_criterium (window->list_store,