TotemScrsaver *scr_saver;
gchar *last_chooser_uri;
+
+#ifdef WITH_GTK_PRINT
+ GtkPrintSettings *print_settings;
+#if GTK_CHECK_VERSION (2, 11, 0)
+ gchar *print_settings_file;
+#endif
+#endif
};
struct _EvApplicationClass {
application->recent_model = NULL;
}
#endif
+
+#ifdef WITH_GTK_PRINT
+#if GTK_CHECK_VERSION (2, 11, 0)
+ if (application->print_settings_file) {
+ if (application->print_settings) {
+ GError *error = NULL;
+
+ gtk_print_settings_to_file (application->print_settings,
+ application->print_settings_file,
+ &error);
+ if (error) {
+ g_warning (error->message);
+ g_error_free (error);
+ }
+
+ g_object_unref (application->print_settings);
+ application->print_settings = NULL;
+ }
+
+ g_free (application->print_settings_file);
+ application->print_settings_file = NULL;
+ }
+#else /* ! GTK 2.11.0 */
+ if (application->print_settings) {
+ g_object_unref (application->print_settings);
+ application->print_settings = NULL;
+ }
+#endif /* GTK 2.11.0 */
+#endif /* WITH_GTK_PRINT */
g_free (application->last_chooser_uri);
g_object_unref (application);
}
void
-ev_application_screensaver_enable (EvApplication *application)
+ev_application_screensaver_enable (EvApplication *application)
{
if (application->scr_saver)
totem_scrsaver_enable (application->scr_saver);
if (application->scr_saver)
totem_scrsaver_disable (application->scr_saver);
}
+
+#ifdef WITH_GTK_PRINT
+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);
+}
+#endif /* WITH_GTK_PRINT */
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
+ } else {
+ /* If printed successfully, save print settings */
+ ev_application_set_print_settings (EV_APP,
+ window->priv->print_settings);
}
}
current_page = ev_page_cache_get_current_page (page_cache);
document_last_page = ev_page_cache_get_n_pages (page_cache);
- if (!ev_window->priv->print_settings)
- ev_window->priv->print_settings = gtk_print_settings_new ();
+ if (!ev_window->priv->print_settings) {
+ ev_window->priv->print_settings = g_object_ref (
+ ev_application_get_print_settings (EV_APP));
+ }
if (first_page != 1 || last_page != document_last_page) {
GtkPageRange range;