static void
empathy_preferences_init (EmpathyPreferences *preferences)
{
	EmpathyPreferencesPriv    *priv;
	GtkBuilder                *gui;
	gchar                     *filename;
	GtkWidget                 *page;

	priv = preferences->priv = G_TYPE_INSTANCE_GET_PRIVATE (preferences,
			EMPATHY_TYPE_PREFERENCES, EmpathyPreferencesPriv);

	gtk_dialog_add_button (GTK_DIALOG (preferences),
			       GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);

	gtk_container_set_border_width (GTK_CONTAINER (preferences), 5);
	gtk_window_set_title (GTK_WINDOW (preferences), _("Preferences"));
	gtk_window_set_role (GTK_WINDOW (preferences), "preferences");
	gtk_window_set_position (GTK_WINDOW (preferences),
				 GTK_WIN_POS_CENTER_ON_PARENT);
	gtk_window_set_icon_name (GTK_WINDOW (preferences), "gtk-preferences");

	filename = empathy_file_lookup ("empathy-preferences.ui", "src");
	gui = empathy_builder_get_file (filename,
		"notebook", &priv->notebook,
		"checkbutton_show_smileys", &priv->checkbutton_show_smileys,
		"checkbutton_show_contacts_in_rooms", &priv->checkbutton_show_contacts_in_rooms,
		"vbox_chat_theme", &priv->vbox_chat_theme,
		"combobox_chat_theme", &priv->combobox_chat_theme,
		"combobox_chat_theme_variant", &priv->combobox_chat_theme_variant,
		"hbox_chat_theme_variant", &priv->hbox_chat_theme_variant,
		"sw_chat_theme_preview", &priv->sw_chat_theme_preview,
		"radiobutton_chats_new_windows", &priv->radiobutton_chats_new_windows,
		"checkbutton_events_notif_area", &priv->checkbutton_events_notif_area,
		"checkbutton_autoconnect", &priv->checkbutton_autoconnect,
		"checkbutton_logging", &priv->checkbutton_logging,
		"checkbutton_notifications_enabled", &priv->checkbutton_notifications_enabled,
		"checkbutton_notifications_disabled_away", &priv->checkbutton_notifications_disabled_away,
		"checkbutton_notifications_focus", &priv->checkbutton_notifications_focus,
		"checkbutton_notifications_contact_signin", &priv->checkbutton_notifications_contact_signin,
		"checkbutton_notifications_contact_signout", &priv->checkbutton_notifications_contact_signout,
		"checkbutton_sounds_enabled", &priv->checkbutton_sounds_enabled,
		"checkbutton_sounds_disabled_away", &priv->checkbutton_sounds_disabled_away,
		"treeview_sounds", &priv->treeview_sounds,
		"treeview_spell_checker", &priv->treeview_spell_checker,
		"checkbutton_location_publish", &priv->checkbutton_location_publish,
		"checkbutton_location_reduce_accuracy", &priv->checkbutton_location_reduce_accuracy,
		"checkbutton_location_resource_network", &priv->checkbutton_location_resource_network,
		"checkbutton_location_resource_cell", &priv->checkbutton_location_resource_cell,
		"checkbutton_location_resource_gps", &priv->checkbutton_location_resource_gps,
		"call_echo_cancellation", &priv->echo_cancellation,
		NULL);
	g_free (filename);

	gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (preferences))), priv->notebook);
	gtk_widget_show (priv->notebook);

	g_object_unref (gui);

	priv->gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
	priv->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
	priv->gsettings_call = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA);
	priv->gsettings_loc = g_settings_new (EMPATHY_PREFS_LOCATION_SCHEMA);
	priv->gsettings_notify = g_settings_new (EMPATHY_PREFS_NOTIFICATIONS_SCHEMA);
	priv->gsettings_sound = g_settings_new (EMPATHY_PREFS_SOUNDS_SCHEMA);
	priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
	priv->gsettings_logger = g_settings_new (EMPATHY_PREFS_LOGGER_SCHEMA);

	/* Create chat theme preview, and track changes */
	priv->theme_manager = empathy_theme_manager_dup_singleton ();
	tp_g_signal_connect_object (priv->theme_manager, "theme-changed",
			  G_CALLBACK (preferences_preview_theme_changed_cb),
			  preferences, 0);
	preferences_preview_theme_changed_cb (priv->theme_manager, preferences);

	preferences_themes_setup (preferences);

	preferences_setup_widgets (preferences);

	preferences_languages_setup (preferences);
	preferences_languages_add (preferences);
	preferences_languages_load (preferences);

	preferences_sound_setup (preferences);
	preferences_sound_load (preferences);

	if (empathy_spell_supported ()) {
		page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), EMPATHY_PREFERENCES_TAB_SPELL);
		gtk_widget_show (page);
	}

	page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), EMPATHY_PREFERENCES_TAB_LOCATION);
#ifdef HAVE_GEOCLUE
	gtk_widget_show (page);
#else
	gtk_widget_hide (page);
#endif
}
Пример #2
0
GtkWidget *
empathy_preferences_show (GtkWindow *parent)
{
	static EmpathyPreferences *preferences;
	GladeXML                 *glade;
	gchar                    *filename;

	if (preferences) {
		gtk_window_present (GTK_WINDOW (preferences->dialog));
		return preferences->dialog;
	}

	preferences = g_new0 (EmpathyPreferences, 1);

	filename = empathy_file_lookup ("empathy-preferences.glade", "src");
	glade = empathy_glade_get_file (filename,
		"preferences_dialog",
		NULL,
		"preferences_dialog", &preferences->dialog,
		"notebook", &preferences->notebook,
		"checkbutton_show_avatars", &preferences->checkbutton_show_avatars,
		"checkbutton_compact_contact_list", &preferences->checkbutton_compact_contact_list,
		"checkbutton_show_smileys", &preferences->checkbutton_show_smileys,
		"combobox_chat_theme", &preferences->combobox_chat_theme,
		"checkbutton_separate_chat_windows", &preferences->checkbutton_separate_chat_windows,
		"checkbutton_autoconnect", &preferences->checkbutton_autoconnect,
		"radiobutton_contact_list_sort_by_name", &preferences->radiobutton_contact_list_sort_by_name,
		"radiobutton_contact_list_sort_by_state", &preferences->radiobutton_contact_list_sort_by_state,
		"checkbutton_sounds_for_messages", &preferences->checkbutton_sounds_for_messages,
		"checkbutton_sounds_when_busy", &preferences->checkbutton_sounds_when_busy,
		"checkbutton_sounds_when_away", &preferences->checkbutton_sounds_when_away,
		"checkbutton_popups_when_available", &preferences->checkbutton_popups_when_available,
		"treeview_spell_checker", &preferences->treeview_spell_checker,
		NULL);
	g_free (filename);

	empathy_glade_connect (glade,
			      preferences,
			      "preferences_dialog", "destroy", preferences_destroy_cb,
			      "preferences_dialog", "response", preferences_response_cb,
			      NULL);

	g_object_unref (glade);

	g_object_add_weak_pointer (G_OBJECT (preferences->dialog), (gpointer) &preferences);

	preferences_themes_setup (preferences);

	preferences_setup_widgets (preferences);

	preferences_languages_setup (preferences);
	preferences_languages_add (preferences);
	preferences_languages_load (preferences);

	if (empathy_spell_supported ()) {
		GtkWidget *page;

		page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (preferences->notebook), 2);
		gtk_widget_show (page);
	}

	if (parent) {
		gtk_window_set_transient_for (GTK_WINDOW (preferences->dialog),
					      GTK_WINDOW (parent));
	}

	gtk_widget_show (preferences->dialog);

	return preferences->dialog;
}