#ifdef WITH_GTK_PRINT
EvJob *print_job;
+ gboolean print_preview;
GtkPrintJob *gtk_print_job;
GtkPrinter *printer;
GtkPrintSettings *print_settings;
ev_window_print_send (EvWindow *window,
const gchar *filename)
{
- GtkPrintJob *job;
GtkPrintSettings *settings;
- GError *error = NULL;
- if (window->priv->gtk_print_job)
- g_object_unref (window->priv->gtk_print_job);
-
/* Some printers take into account some print settings,
* and others don't. However we have exported the document
* to a ps or pdf file according to such print settings. So,
gtk_print_settings_set_scale (settings, 1.0);
gtk_print_settings_set_collate (settings, FALSE);
gtk_print_settings_set_reverse (settings, FALSE);
-
- job = gtk_print_job_new ("evince-print",
- window->priv->printer,
- settings,
- window->priv->print_page_setup);
- g_object_unref (settings);
-
- window->priv->gtk_print_job = job;
+ if (window->priv->print_preview) {
+ gchar *uri;
+ gchar *print_settings_file = NULL;
- if (gtk_print_job_set_source_file (job, filename, &error)) {
- gtk_print_job_send (job,
- (GtkPrintJobCompleteFunc)ev_window_print_finished,
- window, NULL);
+ ev_application_set_print_settings (EV_APP,
+ window->priv->print_settings);
+
+#if GTK_CHECK_VERSION (2, 11, 0)
+ print_settings_file = ev_tmp_filename ("print-settings");
+ gtk_print_settings_to_file (settings, print_settings_file, NULL);
+#endif
+ uri = g_filename_to_uri (filename, NULL, NULL);
+ ev_application_open_uri_at_dest (EV_APP,
+ uri,
+ gtk_window_get_screen (GTK_WINDOW (window)),
+ NULL,
+ EV_WINDOW_MODE_PREVIEW,
+ TRUE,
+ print_settings_file,
+ GDK_CURRENT_TIME);
+ g_free (print_settings_file);
+ g_free (uri);
} else {
- ev_window_clear_print_job (window);
- g_warning (error->message);
- g_error_free (error);
+ GtkPrintJob *job;
+ GError *error = NULL;
+
+ job = gtk_print_job_new ("evince-print",
+ window->priv->printer,
+ settings,
+ window->priv->print_page_setup);
+
+ if (window->priv->gtk_print_job)
+ g_object_unref (window->priv->gtk_print_job);
+ window->priv->gtk_print_job = job;
+
+ if (gtk_print_job_set_source_file (job, filename, &error)) {
+ gtk_print_job_send (job,
+ (GtkPrintJobCompleteFunc)ev_window_print_finished,
+ window, NULL);
+ } else {
+ ev_window_clear_print_job (window);
+ g_warning (error->message);
+ g_error_free (error);
+ }
}
+
+ g_object_unref (settings);
}
static void
GtkPrintPages print_pages;
const gchar *file_format;
- if (response != GTK_RESPONSE_OK) {
+ if (response == GTK_RESPONSE_CANCEL) {
gtk_widget_destroy (GTK_WIDGET (dialog));
window->priv->print_dialog = NULL;
return FALSE;
}
+ window->priv->print_preview = (response == GTK_RESPONSE_APPLY);
+
if (window->priv->printer)
g_object_unref (window->priv->printer);
if (window->priv->print_settings)
GTK_PRINT_CAPABILITY_COLLATE |
GTK_PRINT_CAPABILITY_REVERSE |
GTK_PRINT_CAPABILITY_SCALE |
- GTK_PRINT_CAPABILITY_GENERATE_PS;
+ GTK_PRINT_CAPABILITY_GENERATE_PS |
+ GTK_PRINT_CAPABILITY_PREVIEW;
if (EV_IS_FILE_EXPORTER (ev_window->priv->document) &&
ev_file_exporter_format_supported (EV_FILE_EXPORTER (ev_window->priv->document),