static void select_account_once_ready (EmpathyLogWindow *self, TpAccount *account, const gchar *chat_id, gboolean is_chatroom) { EmpathyAccountChooser *account_chooser = EMPATHY_ACCOUNT_CHOOSER (self->account_chooser_chats); tp_clear_object (&self->selected_account); self->selected_account = g_object_ref (account); g_free (self->selected_chat_id); self->selected_chat_id = g_strdup (chat_id); self->selected_is_chatroom = is_chatroom; if (empathy_account_chooser_is_ready (account_chooser)) account_chooser_ready_cb (account_chooser, self); else /* Chat will be selected once the account chooser is ready */ g_signal_connect (account_chooser, "ready", G_CALLBACK (account_chooser_ready_cb), self); }
GtkWidget * empathy_log_window_show (TpAccount *account, const gchar *chat_id, gboolean is_chatroom, GtkWindow *parent) { static EmpathyLogWindow *window = NULL; EmpathyAccountChooser *account_chooser; TpAccountManager *account_manager; GtkBuilder *gui; gchar *filename; if (window) { gtk_window_present (GTK_WINDOW (window->window)); if (account && chat_id) { gtk_notebook_set_current_page (GTK_NOTEBOOK (window->notebook), 1); log_window_chats_set_selected (window, account, chat_id, is_chatroom); } return window->window; } window = g_new0 (EmpathyLogWindow, 1); #ifndef ENABLE_TPL window->log_manager = empathy_log_manager_dup_singleton (); #else window->log_manager = tpl_log_manager_dup_singleton (); #endif /* ENABLE_TPL */ filename = empathy_file_lookup ("empathy-log-window.ui", "libempathy-gtk"); gui = empathy_builder_get_file (filename, "log_window", &window->window, "notebook", &window->notebook, "entry_find", &window->entry_find, "button_find", &window->button_find, "treeview_find", &window->treeview_find, "scrolledwindow_find", &window->scrolledwindow_find, "button_previous", &window->button_previous, "button_next", &window->button_next, "entry_chats", &window->entry_chats, "calendar_chats", &window->calendar_chats, "vbox_chats", &window->vbox_chats, "treeview_chats", &window->treeview_chats, "scrolledwindow_chats", &window->scrolledwindow_chats, NULL); g_free (filename); empathy_builder_connect (gui, window, "log_window", "destroy", log_window_destroy_cb, "entry_find", "changed", log_window_entry_find_changed_cb, "button_previous", "clicked", log_window_button_previous_clicked_cb, "button_next", "clicked", log_window_button_next_clicked_cb, "button_find", "clicked", log_window_button_find_clicked_cb, "entry_chats", "changed", log_window_entry_chats_changed_cb, "entry_chats", "activate", log_window_entry_chats_activate_cb, NULL); g_object_unref (gui); g_object_add_weak_pointer (G_OBJECT (window->window), (gpointer) &window); /* We set this up here so we can block it when needed. */ g_signal_connect (window->calendar_chats, "day-selected", G_CALLBACK (log_window_calendar_chats_day_selected_cb), window); g_signal_connect (window->calendar_chats, "month-changed", G_CALLBACK (log_window_calendar_chats_month_changed_cb), window); /* Configure Search EmpathyChatView */ window->chatview_find = empathy_theme_manager_create_view (empathy_theme_manager_get ()); gtk_container_add (GTK_CONTAINER (window->scrolledwindow_find), GTK_WIDGET (window->chatview_find)); gtk_widget_show (GTK_WIDGET (window->chatview_find)); /* Configure Contacts EmpathyChatView */ window->chatview_chats = empathy_theme_manager_create_view (empathy_theme_manager_get ()); gtk_container_add (GTK_CONTAINER (window->scrolledwindow_chats), GTK_WIDGET (window->chatview_chats)); gtk_widget_show (GTK_WIDGET (window->chatview_chats)); /* Account chooser for chats */ window->account_chooser_chats = empathy_account_chooser_new (); account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser_chats); gtk_box_pack_start (GTK_BOX (window->vbox_chats), window->account_chooser_chats, FALSE, TRUE, 0); g_signal_connect (window->account_chooser_chats, "changed", G_CALLBACK (log_window_chats_accounts_changed_cb), window); /* Populate */ account_manager = tp_account_manager_dup (); tp_account_manager_prepare_async (account_manager, NULL, account_manager_prepared_cb, window); g_object_unref (account_manager); /* Search List */ log_window_find_setup (window); /* Contacts */ log_window_chats_setup (window); log_window_chats_populate (window); if (account && chat_id) { window->selected_account = account; window->selected_chat_id = g_strdup (chat_id); window->selected_is_chatroom = is_chatroom; if (empathy_account_chooser_is_ready (account_chooser)) account_chooser_ready_cb (account_chooser, window); else /* Chat will be selected once the account chooser is ready */ g_signal_connect (account_chooser, "ready", G_CALLBACK (account_chooser_ready_cb), window); } if (parent) { gtk_window_set_transient_for (GTK_WINDOW (window->window), GTK_WINDOW (parent)); } gtk_widget_show (window->window); return window->window; }