+2007-12-01 Carlos Garcia Campos <carlosgc@gnome.org>
+
+ * 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 <mclasen@redhat.com>
* backend/tiff/tiff-document.c: (tiff_document_render):
#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,
}
}
+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,
/* If printed successfully, save print settings */
ev_application_set_print_settings (EV_APP,
window->priv->print_settings);
+ ev_window_save_print_settings (window);
}
}
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) {