- /* Set up interface */
- filename = empathy_file_lookup ("empathy-main-window.ui", "src");
- gui = empathy_builder_get_file (filename,
- "main_window", &window->window,
- "main_vbox", &window->main_vbox,
- "errors_vbox", &window->errors_vbox,
- "chat_show_offline", &show_offline_widget,
- "room", &window->room,
- "room_sep", &window->room_sep,
- "room_join_favorites", &window->room_join_favorites,
- "edit_context", &window->edit_context,
- "edit_context_separator", &window->edit_context_separator,
- "presence_toolbar", &window->presence_toolbar,
- "roster_scrolledwindow", &sw,
- "chat_history", &window->chat_history_menu_item,
- NULL);
- g_free (filename);
-
- empathy_builder_connect (gui, window,
- "main_window", "destroy", main_window_destroy_cb,
- "main_window", "configure_event", main_window_configure_event_cb,
- "chat_quit", "activate", main_window_chat_quit_cb,
- "chat_new_message", "activate", main_window_chat_new_message_cb,
- "chat_history", "activate", main_window_chat_history_cb,
- "room_join_new", "activate", main_window_room_join_new_cb,
- "room_join_favorites", "activate", main_window_room_join_favorites_cb,
- "room_manage_favorites", "activate", main_window_room_manage_favorites_cb,
- "chat_add_contact", "activate", main_window_chat_add_contact_cb,
- "chat_show_offline", "toggled", main_window_chat_show_offline_cb,
- "edit", "button-press-event", main_window_edit_button_press_event_cb,
- "edit_accounts", "activate", main_window_edit_accounts_cb,
- "edit_personal_information", "activate", main_window_edit_personal_information_cb,
- "edit_preferences", "activate", main_window_edit_preferences_cb,
- "help_about", "activate", main_window_help_about_cb,
- "help_contents", "activate", main_window_help_contents_cb,
- NULL);
-
- /* Set up connection related widgets. */
- main_window_connection_items_setup (window, gui);
- g_object_unref (gui);
-
- window->mc = empathy_mission_control_dup_singleton ();
- window->account_manager = empathy_account_manager_dup_singleton ();
-
- g_signal_connect (window->account_manager,
- "account-connection-changed",
- G_CALLBACK (main_window_connection_changed_cb), window);
-
- window->errors = g_hash_table_new_full (empathy_account_hash,
- empathy_account_equal,
- g_object_unref,
- NULL);
-
- /* Set up menu */
- main_window_favorite_chatroom_menu_setup (window);
-
- gtk_widget_hide (window->edit_context);
- gtk_widget_hide (window->edit_context_separator);
-
- /* Set up presence chooser */
- window->presence_chooser = empathy_presence_chooser_new ();
- gtk_widget_show (window->presence_chooser);
- item = gtk_tool_item_new ();
- gtk_widget_show (GTK_WIDGET (item));
- gtk_container_add (GTK_CONTAINER (item), window->presence_chooser);
- gtk_tool_item_set_is_important (item, TRUE);
- gtk_tool_item_set_expand (item, TRUE);
- gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
-
- /* Set up the throbber */
- ebox = gtk_event_box_new ();
- gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
- gtk_widget_set_tooltip_text (ebox, _("Show and edit accounts"));
- g_signal_connect (ebox,
- "button-press-event",
- G_CALLBACK (main_window_throbber_button_press_event_cb),
- window);
- gtk_widget_show (ebox);
-
- window->throbber = ephy_spinner_new ();
- ephy_spinner_set_size (EPHY_SPINNER (window->throbber), GTK_ICON_SIZE_LARGE_TOOLBAR);
- gtk_container_add (GTK_CONTAINER (ebox), window->throbber);
- gtk_widget_show (window->throbber);
-
- item = gtk_tool_item_new ();
- gtk_container_add (GTK_CONTAINER (item), ebox);
- gtk_toolbar_insert (GTK_TOOLBAR (window->presence_toolbar), item, -1);
- gtk_widget_show (GTK_WIDGET (item));
-
- /* Set up contact list. */
- empathy_status_presets_get_all ();
-
- list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_dup_singleton ());
- monitor = empathy_contact_list_get_monitor (list_iface);
- window->list_store = empathy_contact_list_store_new (list_iface);
- window->list_view = empathy_contact_list_view_new (window->list_store,
- EMPATHY_CONTACT_LIST_FEATURE_ALL,
- EMPATHY_CONTACT_FEATURE_ALL);
- g_signal_connect (monitor, "contact-presence-changed",
- G_CALLBACK (main_window_contact_presence_changed_cb), window);
- g_object_unref (list_iface);
-
- gtk_widget_show (GTK_WIDGET (window->list_view));
- gtk_container_add (GTK_CONTAINER (sw),
- GTK_WIDGET (window->list_view));
- g_signal_connect (window->list_view, "row-activated",
- G_CALLBACK (main_window_row_activated_cb),
- window);
-
- /* Load user-defined accelerators. */
- main_window_accels_load ();
-
- /* Set window size. */
- empathy_geometry_load (GEOMETRY_NAME, &x, &y, &w, &h);
-
- if (w >= 1 && h >= 1) {
- /* Use the defaults from the ui file if we
- * don't have good w, h geometry.
- */
- DEBUG ("Configuring window default size w:%d, h:%d", w, h);
- gtk_window_set_default_size (GTK_WINDOW (window->window), w, h);
- }
-
- if (x >= 0 && y >= 0) {
- /* Let the window manager position it if we
- * don't have good x, y coordinates.
- */
- DEBUG ("Configuring window default position x:%d, y:%d", x, y);
- gtk_window_move (GTK_WINDOW (window->window), x, y);
- }
-
- /* Enable event handling */
- window->event_manager = empathy_event_manager_dup_singleton ();
- g_signal_connect (window->event_manager, "event-added",
- G_CALLBACK (main_window_event_added_cb),
- window);
- g_signal_connect (window->event_manager, "event-removed",
- G_CALLBACK (main_window_event_removed_cb),
- window);
-
- g_signal_connect (window->account_manager, "account-created",
- G_CALLBACK (main_window_account_created_or_deleted_cb),
- window);
- g_signal_connect (window->account_manager, "account-deleted",
- G_CALLBACK (main_window_account_created_or_deleted_cb),
- window);
- main_window_account_created_or_deleted_cb (window->account_manager, NULL, window);
-
- l = empathy_event_manager_get_events (window->event_manager);
- while (l) {
- main_window_event_added_cb (window->event_manager,
- l->data, window);
- l = l->next;
- }
-
- conf = empathy_conf_get ();
-
- /* Show offline ? */
- empathy_conf_get_bool (conf,
- EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE,
- &show_offline);
- empathy_conf_notify_add (conf,
- EMPATHY_PREFS_CONTACTS_SHOW_OFFLINE,
- main_window_notify_show_offline_cb,
- show_offline_widget);
-
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_offline_widget),
- show_offline);
-
- /* Show avatars ? */
- empathy_conf_get_bool (conf,
- EMPATHY_PREFS_UI_SHOW_AVATARS,
- &show_avatars);
- empathy_conf_notify_add (conf,
- EMPATHY_PREFS_UI_SHOW_AVATARS,
- (EmpathyConfNotifyFunc) main_window_notify_show_avatars_cb,
- window);
- empathy_contact_list_store_set_show_avatars (window->list_store, show_avatars);
-
- /* Is compact ? */
- empathy_conf_get_bool (conf,
- EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
- &compact_contact_list);
- empathy_conf_notify_add (conf,
- EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
- (EmpathyConfNotifyFunc) main_window_notify_compact_contact_list_cb,
- window);
- empathy_contact_list_store_set_is_compact (window->list_store, compact_contact_list);
-
- /* Sort criterium */
- empathy_conf_notify_add (conf,
- EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
- (EmpathyConfNotifyFunc) main_window_notify_sort_criterium_cb,
- window);
- main_window_notify_sort_criterium_cb (conf,
- EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
- window);
-
- main_window_update_status (window, window->account_manager);
-
- return window->window;
-}