Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/ev-application.c
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2007-05-08 16:40:22 (GMT)
committer Carlos Garcia Campos <carlosgc@src.gnome.org>2007-05-08 16:40:22 (GMT)
commita6368109ee6bbc2fa76ddc4ee50acf02ea755693 (patch)
treed6c99334f5274d834bd73b84568c32a2f5a3f519 /shell/ev-application.c
parent2b2137037940edb324ae915a3b59f727e374700f (diff)
Remember print settings. Fixes bug #349102.
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
Diffstat (limited to 'shell/ev-application.c')
-rw-r--r--shell/ev-application.c87
1 files changed, 86 insertions, 1 deletions
diff --git a/shell/ev-application.c b/shell/ev-application.c
index 75c2247..1d21c2c 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -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 */