GtkWidget * empathy_log_window_show (EmpathyAccount *account, const gchar *chat_id, gboolean is_chatroom, GtkWindow *parent) { static EmpathyLogWindow *window = NULL; EmpathyAccountChooser *account_chooser; EmpathyAccountManager *account_manager; gint account_num; 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); window->log_manager = empathy_log_manager_dup_singleton (); 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 = empathy_account_manager_dup_singleton (); account_num = empathy_account_manager_get_count (account_manager); g_object_unref (account_manager); if (account_num > 1) { gtk_widget_show (window->vbox_chats); gtk_widget_show (window->account_chooser_chats); } else { gtk_widget_hide (window->vbox_chats); gtk_widget_hide (window->account_chooser_chats); } /* Search List */ log_window_find_setup (window); /* Contacts */ log_window_chats_setup (window); log_window_chats_populate (window); /* Select chat */ 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); } if (parent) { gtk_window_set_transient_for (GTK_WINDOW (window->window), GTK_WINDOW (parent)); } gtk_widget_show (window->window); return window->window; }
static void preferences_preview_theme_changed_cb (EmpathyThemeManager *manager, EmpathyPreferences *preferences) { EmpathyPreferencesPriv *priv = GET_PRIV (preferences); TpDBusDaemon *dbus; TpAccount *account; EmpathyContact *juliet; EmpathyContact *romeo; DEBUG ("Theme changed, update preview widget"); if (priv->chat_theme_preview != NULL) { gtk_widget_destroy (GTK_WIDGET (priv->chat_theme_preview)); } priv->chat_theme_preview = empathy_theme_manager_create_view (manager); gtk_container_add (GTK_CONTAINER (priv->sw_chat_theme_preview), GTK_WIDGET (priv->chat_theme_preview)); gtk_widget_show (GTK_WIDGET (priv->chat_theme_preview)); /* FIXME: It is ugly to add a fake conversation like that. * Would be cool if we could request a TplLogManager for a fake * conversation */ dbus = tp_dbus_daemon_dup (NULL); account = tp_account_new (dbus, TP_ACCOUNT_OBJECT_PATH_BASE "cm/jabber/account", NULL); juliet = g_object_new (EMPATHY_TYPE_CONTACT, "account", account, "id", "juliet", /* translators: Contact name for the chat theme preview */ "alias", _("Juliet"), "is-user", FALSE, NULL); romeo = g_object_new (EMPATHY_TYPE_CONTACT, "account", account, "id", "romeo", /* translators: Contact name for the chat theme preview */ "alias", _("Romeo"), "is-user", TRUE, NULL); preferences_preview_theme_append_message (priv->chat_theme_preview, /* translators: Quote from Romeo & Julier, for chat theme preview */ juliet, romeo, _("O Romeo, Romeo, wherefore art thou Romeo?"), TRUE /* this message mentions Romeo */); preferences_preview_theme_append_message (priv->chat_theme_preview, /* translators: Quote from Romeo & Julier, for chat theme preview */ juliet, romeo, _("Deny thy father and refuse thy name;"), FALSE); preferences_preview_theme_append_message (priv->chat_theme_preview, /* translators: Quote from Romeo & Julier, for chat theme preview */ juliet, romeo, _("Or if thou wilt not, be but sworn my love"), FALSE); preferences_preview_theme_append_message (priv->chat_theme_preview, /* translators: Quote from Romeo & Julier, for chat theme preview */ juliet, romeo, _("And I'll no longer be a Capulet."), FALSE); preferences_preview_theme_append_message (priv->chat_theme_preview, /* translators: Quote from Romeo & Julier, for chat theme preview */ romeo, juliet, _("Shall I hear more, or shall I speak at this?"), FALSE); /* translators: Quote from Romeo & Julier, for chat theme preview */ empathy_chat_view_append_event (priv->chat_theme_preview, _("Juliet has disconnected")); g_object_unref (juliet); g_object_unref (romeo); g_object_unref (account); g_object_unref (dbus); }