static void megaphone_applet_show_preferences (MegaphoneApplet *applet) { GtkWidget *dialog; GtkWidget *scroll; EmpathyContactListView *contact_list; EmpathyContactListStore *contact_store; EmpathyContactManager *contact_manager; dialog = gtk_dialog_new_with_buttons (_("Select contact..."), NULL, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); /* Show all contacts, even offline and sort alphabetically */ contact_manager = empathy_contact_manager_dup_singleton (); contact_store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (contact_manager)); g_object_set (contact_store, "is-compact", TRUE, "show-avatars", TRUE, "show-offline", TRUE, "sort-criterium", EMPATHY_CONTACT_LIST_STORE_SORT_NAME, NULL); contact_list = empathy_contact_list_view_new (contact_store, EMPATHY_CONTACT_LIST_FEATURE_NONE, EMPATHY_CONTACT_FEATURE_NONE); g_object_unref (contact_manager); g_object_unref (contact_store); gtk_widget_show (GTK_WIDGET (contact_list)); gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 500); scroll = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET (contact_list)); gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), scroll); gtk_widget_show (scroll); g_object_set_data (G_OBJECT (dialog), "contact-list", contact_list); g_signal_connect (dialog, "response", G_CALLBACK (megaphone_applet_preferences_response_cb), applet); gtk_widget_show (dialog); }
GtkWidget * empathy_main_window_show (void) { EmpathyMainWindow *window; EmpathyContactList *list_iface; EmpathyContactMonitor *monitor; GtkBuilder *gui; EmpathyConf *conf; GtkWidget *sw; GtkToggleAction *show_offline_widget; GtkWidget *ebox; GtkAction *show_map_widget; GtkToolItem *item; gboolean show_offline; gchar *filename; GSList *l; if (main_window) { empathy_window_present (GTK_WINDOW (main_window->window)); return main_window->window; } main_window = g_new0 (EmpathyMainWindow, 1); window = main_window; /* 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, "ui_manager", &window->ui_manager, "view_show_offline", &show_offline_widget, "view_show_protocols", &window->show_protocols, "view_sort_by_name", &window->sort_by_name, "view_sort_by_status", &window->sort_by_status, "view_normal_size_with_avatars", &window->normal_with_avatars, "view_normal_size", &window->normal_size, "view_compact_size", &window->compact_size, "view_history", &window->view_history, "view_show_map", &show_map_widget, "room_join_favorites", &window->room_join_favorites, "presence_toolbar", &window->presence_toolbar, "roster_scrolledwindow", &sw, NULL); g_free (filename); empathy_builder_connect (gui, window, "main_window", "destroy", main_window_destroy_cb, "main_window", "key-press-event", main_window_key_press_event_cb, "chat_quit", "activate", main_window_chat_quit_cb, "chat_new_message", "activate", main_window_chat_new_message_cb, "chat_new_call", "activate", main_window_chat_new_call_cb, "view_history", "activate", main_window_view_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, "view_show_ft_manager", "activate", main_window_view_show_ft_manager, "view_show_offline", "toggled", main_window_view_show_offline_cb, "view_show_protocols", "toggled", main_window_view_show_protocols_cb, "view_sort_by_name", "changed", main_window_view_sort_contacts_cb, "view_normal_size_with_avatars", "changed", main_window_view_contacts_list_size_cb, "view_show_map", "activate", main_window_view_show_map_cb, "edit", "activate", main_window_edit_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_debug", "activate", main_window_help_debug_cb, "help_contents", "activate", main_window_help_contents_cb, NULL); /* Set up connection related widgets. */ main_window_connection_items_setup (window, gui); g_object_ref (window->ui_manager); g_object_unref (gui); #if !HAVE_LIBCHAMPLAIN gtk_action_set_visible (show_map_widget, FALSE); #endif window->account_manager = tp_account_manager_dup (); tp_account_manager_prepare_async (window->account_manager, NULL, account_manager_prepared_cb, window); window->errors = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL); window->status_changed_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL); /* Set up menu */ main_window_favorite_chatroom_menu_setup (window); window->edit_context = gtk_ui_manager_get_widget (window->ui_manager, "/menubar/edit/edit_context"); window->edit_context_separator = gtk_ui_manager_get_widget (window->ui_manager, "/menubar/edit/edit_context_separator"); gtk_widget_hide (window->edit_context); gtk_widget_hide (window->edit_context_separator); /* Set up contact list. */ empathy_status_presets_get_all (); /* 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)); 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); window->butterfly_log_migration_contact_added_id = g_signal_connect (monitor, "contact-added", G_CALLBACK (main_window_contact_added_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_bind (GTK_WINDOW (window->window), GEOMETRY_NAME); /* 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-validity-changed", G_CALLBACK (main_window_account_validity_changed_cb), window); g_signal_connect (window->account_manager, "account-removed", G_CALLBACK (main_window_account_removed_cb), window); g_signal_connect (window->account_manager, "account-disabled", G_CALLBACK (main_window_account_disabled_cb), 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_toggle_action_set_active (show_offline_widget, show_offline); /* Show protocol ? */ empathy_conf_notify_add (conf, EMPATHY_PREFS_UI_SHOW_PROTOCOLS, (EmpathyConfNotifyFunc) main_window_notify_show_protocols_cb, window); main_window_notify_show_protocols_cb (conf, EMPATHY_PREFS_UI_SHOW_PROTOCOLS, window); /* Sort by name / by status ? */ empathy_conf_notify_add (conf, EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, (EmpathyConfNotifyFunc) main_window_notify_sort_contact_cb, window); main_window_notify_sort_contact_cb (conf, EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, window); /* Contacts list size */ empathy_conf_notify_add (conf, EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, (EmpathyConfNotifyFunc) main_window_notify_contact_list_size_cb, window); empathy_conf_notify_add (conf, EMPATHY_PREFS_UI_SHOW_AVATARS, (EmpathyConfNotifyFunc) main_window_notify_contact_list_size_cb, window); main_window_notify_contact_list_size_cb (conf, EMPATHY_PREFS_UI_SHOW_AVATARS, window); return window->window; }