From 6cb25ea305880261dca05fe3fbaea7d72119e880 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Sat, 1 Dec 2007 16:04:59 +0000 Subject: [PATCH] Print settings that are specific to the document are now saved per 2007-12-01 Carlos Garcia Campos * shell/ev-window.c: (ev_window_load_print_settings_from_metadata), (ev_window_save_print_settings), (ev_window_print_finished), (ev_window_print_range): Print settings that are specific to the document are now saved per document in the metadata file. Fixes bug #488806. svn path=/trunk/; revision=2754 --- ChangeLog | 10 ++++++++++ shell/ev-window.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5fdb4fe2..a80e3f60 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-12-01 Carlos Garcia Campos + + * shell/ev-window.c: + (ev_window_load_print_settings_from_metadata), + (ev_window_save_print_settings), (ev_window_print_finished), + (ev_window_print_range): + + Print settings that are specific to the document are now saved per + document in the metadata file. Fixes bug #488806. + 2007-11-26 Matthias Clasen * backend/tiff/tiff-document.c: (tiff_document_render): diff --git a/shell/ev-window.c b/shell/ev-window.c index c53b772b..ef9d996d 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -211,6 +211,19 @@ struct _EvWindowPrivate { #define THUMBNAILS_SIDEBAR_ID "thumbnails" #define ATTACHMENTS_SIDEBAR_ID "attachments" +#ifdef WITH_GTK_PRINT +static const gchar *document_print_settings[] = { + GTK_PRINT_SETTINGS_N_COPIES, + GTK_PRINT_SETTINGS_COLLATE, + GTK_PRINT_SETTINGS_REVERSE, + GTK_PRINT_SETTINGS_NUMBER_UP, + GTK_PRINT_SETTINGS_SCALE, + GTK_PRINT_SETTINGS_PRINT_PAGES, + GTK_PRINT_SETTINGS_PAGE_RANGES, + GTK_PRINT_SETTINGS_PAGE_SET +}; +#endif /* WITH_GTK_PRINT */ + static void ev_window_update_actions (EvWindow *ev_window); static void ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar, GParamSpec *pspec, @@ -2117,6 +2130,40 @@ ev_window_clear_print_job (EvWindow *window) } } +static void +ev_window_load_print_settings_from_metadata (EvWindow *window) +{ + gchar *uri = window->priv->uri; + gint i; + + /* Load print setting that are specific to the document */ + for (i = 0; i < G_N_ELEMENTS (document_print_settings); i++) { + GValue value = { 0, }; + gboolean success; + + success = ev_metadata_manager_get (uri, document_print_settings[i], &value, TRUE); + gtk_print_settings_set (window->priv->print_settings, + document_print_settings[i], + success ? g_value_get_string (&value) : NULL); + } +} + +static void +ev_window_save_print_settings (EvWindow *window) +{ + gchar *uri = window->priv->uri; + gint i; + + /* Save print settings that are specific to the document */ + for (i = 0; i < G_N_ELEMENTS (document_print_settings); i++) { + const gchar *value; + + value = gtk_print_settings_get (window->priv->print_settings, + document_print_settings[i]); + ev_metadata_manager_set_string (uri, document_print_settings[i], value); + } +} + static void ev_window_print_finished (GtkPrintJob *print_job, EvWindow *window, @@ -2141,6 +2188,7 @@ ev_window_print_finished (GtkPrintJob *print_job, /* If printed successfully, save print settings */ ev_application_set_print_settings (EV_APP, window->priv->print_settings); + ev_window_save_print_settings (window); } } @@ -2402,8 +2450,9 @@ ev_window_print_range (EvWindow *ev_window, int first_page, int last_page) document_last_page = ev_page_cache_get_n_pages (page_cache); if (!ev_window->priv->print_settings) { - ev_window->priv->print_settings = g_object_ref ( + ev_window->priv->print_settings = gtk_print_settings_copy ( ev_application_get_print_settings (EV_APP)); + ev_window_load_print_settings_from_metadata (ev_window); } if (first_page != 1 || last_page != document_last_page) { -- 2.43.5