+ gint i;
+
+#if WITH_GNOME
+ init_session (ev_application);
+#endif
+
+ ev_application->toolbars_model = egg_toolbars_model_new ();
+
+ ev_application->toolbars_file = g_build_filename
+ (ev_dot_dir (), "evince_toolbar.xml", NULL);
+
+ egg_toolbars_model_load_names (ev_application->toolbars_model,
+ DATADIR "/evince-toolbar.xml");
+
+ if (!egg_toolbars_model_load_toolbars (ev_application->toolbars_model,
+ ev_application->toolbars_file)) {
+ egg_toolbars_model_load_toolbars (ev_application->toolbars_model,
+ DATADIR"/evince-toolbar.xml");
+ }
+
+ /* Open item doesn't exist anymore,
+ * convert it to OpenRecent for compatibility
+ */
+ for (i = 0; i < egg_toolbars_model_n_items (ev_application->toolbars_model, 0); i++) {
+ const gchar *item;
+
+ item = egg_toolbars_model_item_nth (ev_application->toolbars_model, 0, i);
+ if (g_ascii_strcasecmp (item, "FileOpen") == 0) {
+ egg_toolbars_model_remove_item (ev_application->toolbars_model, 0, i);
+ egg_toolbars_model_add_item (ev_application->toolbars_model, 0, i,
+ "FileOpenRecent");
+ ev_application_save_toolbars_model (ev_application);
+ break;
+ }
+ }
+
+ egg_toolbars_model_set_flags (ev_application->toolbars_model, 0,
+ EGG_TB_MODEL_NOT_REMOVABLE);
+}
+
+/**
+ * ev_application_get_windows:
+ * @application: The instance of the application.
+ *
+ * It creates a list of the top level windows.
+ *
+ * Returns: A #GList of the top level windows.
+ */
+GList *
+ev_application_get_windows (EvApplication *application)
+{
+ GList *l, *toplevels;
+ GList *windows = NULL;
+
+ toplevels = gtk_window_list_toplevels ();
+
+ for (l = toplevels; l != NULL; l = l->next) {
+ if (EV_IS_WINDOW (l->data)) {
+ windows = g_list_append (windows, l->data);
+ }
+ }
+
+ g_list_free (toplevels);
+
+ return windows;
+}
+
+EggToolbarsModel *
+ev_application_get_toolbars_model (EvApplication *application)
+{
+ return application->toolbars_model;
+}
+
+void
+ev_application_save_toolbars_model (EvApplication *application)
+{
+ egg_toolbars_model_save_toolbars (application->toolbars_model,
+ application->toolbars_file, "1.0");
+}
+
+void
+ev_application_set_chooser_uri (EvApplication *application, const gchar *uri)
+{
+ g_free (application->last_chooser_uri);
+ application->last_chooser_uri = g_strdup (uri);
+}
+
+const gchar *
+ev_application_get_chooser_uri (EvApplication *application)
+{
+ return application->last_chooser_uri;
+}
+
+void
+ev_application_screensaver_enable (EvApplication *application)
+{
+ if (application->scr_saver)
+ totem_scrsaver_enable (application->scr_saver);
+}
+
+void
+ev_application_screensaver_disable (EvApplication *application)
+{
+ if (application->scr_saver)
+ totem_scrsaver_disable (application->scr_saver);
+}
+
+GtkPrintSettings *
+ev_application_get_print_settings (EvApplication *application)
+{
+ if (application->print_settings)
+ return application->print_settings;
+
+#if GTK_CHECK_VERSION (2, 11, 0)
+ if (!application->print_settings_file) {
+ application->print_settings_file =
+ g_build_filename (ev_dot_dir (), "print-settings", NULL);
+ }
+
+ if (g_file_test (application->print_settings_file, G_FILE_TEST_IS_REGULAR)) {
+ GError *error = NULL;
+
+ application->print_settings =
+ gtk_print_settings_new_from_file (application->print_settings_file, &error);
+
+ if (error) {
+ g_warning (error->message);
+ g_error_free (error);
+ } else {
+ return application->print_settings;
+ }
+ }
+#endif /* GTK 2.11.0 */
+
+ application->print_settings = gtk_print_settings_new ();
+
+ return application->print_settings;
+}
+
+void
+ev_application_set_print_settings (EvApplication *application,
+ GtkPrintSettings *settings)
+{
+ g_return_if_fail (GTK_IS_PRINT_SETTINGS (settings));
+
+ if (settings == application->print_settings)
+ return;
+
+ if (application->print_settings)
+ g_object_unref (application->print_settings);
+
+ application->print_settings = g_object_ref (settings);