- if (application->scr_saver)
- totem_scrsaver_disable (application->scr_saver);
-}
-
-static GKeyFile *
-ev_application_get_print_settings_file (EvApplication *application)
-{
- gchar *filename;
-
- if (application->print_settings_file)
- return application->print_settings_file;
-
- application->print_settings_file = g_key_file_new ();
-
- filename = g_build_filename (ev_application_get_dot_dir (application), EV_PRINT_SETTINGS_FILE, NULL);
- if (g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
- GError *error = NULL;
-
- g_key_file_load_from_file (application->print_settings_file,
- filename,
- G_KEY_FILE_KEEP_COMMENTS |
- G_KEY_FILE_KEEP_TRANSLATIONS,
- &error);
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
- }
- g_free (filename);
-
- return application->print_settings_file;
-}
-
-static void
-ev_application_save_print_settings (EvApplication *application)
-{
- GKeyFile *key_file;
- gchar *filename;
- gchar *data;
- gssize data_length;
- GError *error = NULL;
-
- if (!application->print_settings && !application->page_setup)
- return;
-
- key_file = ev_application_get_print_settings_file (application);
- if (application->print_settings)
- gtk_print_settings_to_key_file (application->print_settings,
- key_file,
- EV_PRINT_SETTINGS_GROUP);
- if (application->page_setup)
- gtk_page_setup_to_key_file (application->page_setup,
- key_file,
- EV_PAGE_SETUP_GROUP);
-
- filename = g_build_filename (ev_application_get_dot_dir (application), EV_PRINT_SETTINGS_FILE, NULL);
- data = g_key_file_to_data (key_file, (gsize *)&data_length, NULL);
- g_file_set_contents (filename, data, data_length, &error);
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
- g_free (data);
- g_free (filename);
-}
-
-GtkPrintSettings *
-ev_application_get_print_settings (EvApplication *application)
-{
- GKeyFile *key_file;
- GtkPrintSettings *print_settings;
-
- if (application->print_settings)
- return application->print_settings;
-
- key_file = ev_application_get_print_settings_file (application);
- print_settings = g_key_file_has_group (key_file, EV_PRINT_SETTINGS_GROUP) ?
- gtk_print_settings_new_from_key_file (key_file, EV_PRINT_SETTINGS_GROUP, NULL) :
- gtk_print_settings_new ();
-
- application->print_settings = print_settings ? print_settings : gtk_print_settings_new ();
-
- return application->print_settings;
-}
-
-void
-ev_application_set_print_settings (EvApplication *application,
- GtkPrintSettings *settings)
-{
- GKeyFile *key_file;
-
- g_return_if_fail (GTK_IS_PRINT_SETTINGS (settings));
-
- if (settings == application->print_settings)
- return;
-
- key_file = ev_application_get_print_settings_file (application);
-
- if (application->print_settings)
- g_object_unref (application->print_settings);
-
- application->print_settings = g_object_ref (settings);
- gtk_print_settings_to_key_file (settings, key_file, EV_PRINT_SETTINGS_GROUP);
-}
-
-GtkPageSetup *
-ev_application_get_page_setup (EvApplication *application)
-{
- GKeyFile *key_file;
- GtkPageSetup *page_setup;
-
- if (application->page_setup)
- return application->page_setup;
-
- key_file = ev_application_get_print_settings_file (application);
- page_setup = g_key_file_has_group (key_file, EV_PAGE_SETUP_GROUP) ?
- gtk_page_setup_new_from_key_file (key_file, EV_PAGE_SETUP_GROUP, NULL) :
- gtk_page_setup_new ();
-
- application->page_setup = page_setup ? page_setup : gtk_page_setup_new ();
-
- return application->page_setup;
-}
-
-void
-ev_application_set_page_setup (EvApplication *application,
- GtkPageSetup *page_setup)
-{
- GKeyFile *key_file;
-
- g_return_if_fail (GTK_IS_PAGE_SETUP (page_setup));
-
- if (page_setup == application->page_setup)
- return;
-
- key_file = ev_application_get_print_settings_file (application);
-
- if (application->page_setup)
- g_object_unref (application->page_setup);
-
- application->page_setup = g_object_ref (page_setup);
- gtk_page_setup_to_key_file (page_setup, key_file, EV_PAGE_SETUP_GROUP);