]> www.fi.muni.cz Git - evince.git/commitdiff
Remember print settings. Fixes bug #349102.
authorCarlos Garcia Campos <carlosgc@gnome.org>
Tue, 8 May 2007 16:40:22 +0000 (16:40 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Tue, 8 May 2007 16:40:22 +0000 (16:40 +0000)
2007-05-08  Carlos Garcia Campos  <carlosgc@gnome.org>
* shell/ev-application.[ch]: (ev_application_shutdown),
(ev_application_get_print_settings),
(ev_application_set_print_settings):
* shell/ev-window.c:
Remember print settings. Fixes bug #349102.

svn path=/trunk/; revision=2442

ChangeLog
shell/ev-application.c
shell/ev-application.h
shell/ev-window.c

index e88543af8180d739661ad42e20659117b3cd9db3..0a6a405000d18f38b96b0b2055c0d032024321ca 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-05-08  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * shell/ev-application.[ch]: (ev_application_shutdown),
+       (ev_application_get_print_settings),
+       (ev_application_set_print_settings):
+       * shell/ev-window.c:
+
+       Remember print settings. Fixes bug #349102. 
+
 2007-05-08  Christian Persch  <chpe@gnome.org>
 
        * configure.ac:
index 75c22470ce8cc486398ee110efa1f33f7940e66d..1d21c2c1dfc6b5d2e4cccb1e2633c8f2f0d43df9 100644 (file)
@@ -59,6 +59,13 @@ struct _EvApplication {
        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 {
@@ -594,6 +601,35 @@ ev_application_shutdown (EvApplication *application)
                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);
@@ -703,7 +739,7 @@ ev_application_get_chooser_uri (EvApplication *application)
 }
 
 void
-ev_application_screensaver_enable  (EvApplication *application)
+ev_application_screensaver_enable (EvApplication *application)
 {
        if (application->scr_saver)
                totem_scrsaver_enable (application->scr_saver); 
@@ -715,3 +751,52 @@ ev_application_screensaver_disable (EvApplication *application)
        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 */
index 7981472115ff1b7badaf2f8ebb5e2c420adc8592..0ba1851bc3bb23cf88d48f218b0f5383273316fb 100644 (file)
 #include <glib/gerror.h>
 #include <glib-object.h>
 
+#ifdef WITH_GTK_PRINT
+#include <gtk/gtkprintsettings.h>
+#endif
+
 #include "ev-window.h"
 
 #include "egg-toolbars-model.h"
@@ -89,6 +93,12 @@ void                   ev_application_set_chooser_uri     (EvApplication   *application,
 const gchar     *ev_application_get_chooser_uri     (EvApplication   *application);
 void             ev_application_screensaver_enable  (EvApplication   *application);
 void             ev_application_screensaver_disable (EvApplication   *application);
+#ifdef WITH_GTK_PRINT
+GtkPrintSettings *ev_application_get_print_settings  (EvApplication   *application);
+void              ev_application_set_print_settings  (EvApplication   *application,
+                                                     GtkPrintSettings *settings);
+#endif
+
 G_END_DECLS
 
 #endif /* !EV_APPLICATION_H */
index b18abe7625ce1af8df1c51166c1f8e5543f6f327..c42864313306db3f2371ee40077a6dde40c352ab 100644 (file)
@@ -2073,6 +2073,10 @@ ev_window_print_finished (GtkPrintJob *print_job,
 
                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);
        }
 }
 
@@ -2280,8 +2284,10 @@ ev_window_print_range (EvWindow *ev_window, int first_page, int last_page)
        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;