#include "ev-print-operation.h"
+#if GTKUNIXPRINT_ENABLED
#include <gtk/gtkunixprint.h>
+#endif
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include <unistd.h>
return op->progress;
}
+#if GTK_CHECK_VERSION (2, 17, 1) | GTKUNIXPRINT_ENABLED
static void
ev_print_operation_update_status (EvPrintOperation *op,
gint page,
g_signal_emit (op, signals[STATUS_CHANGED], 0);
}
+#endif
+
+#if GTKUNIXPRINT_ENABLED
/* Export interface */
#define EV_TYPE_PRINT_OPERATION_EXPORT (ev_print_operation_export_get_type())
g_object_class->finalize = ev_print_operation_export_finalize;
}
+#endif /* GTKUNIXPRINT_ENABLED */
+
#if GTK_CHECK_VERSION (2, 17, 1)
/* Print to cairo interface */
#define EV_TYPE_PRINT_OPERATION_PRINT (ev_print_operation_print_get_type())
{
EvPrintOperation *op = EV_PRINT_OPERATION (print);
cairo_t *cr;
+ gdouble cr_width, cr_height;
+ gint width, height;
gtk_print_operation_set_defer_drawing (print->op);
ev_job_print_set_page (EV_JOB_PRINT (print->job_print), page);
cr = gtk_print_context_get_cairo_context (context);
- ev_job_print_set_cairo (EV_JOB_PRINT (print->job_print), cr);
+ cr_width = gtk_print_context_get_width (context);
+ cr_height = gtk_print_context_get_height (context);
+ ev_page_cache_get_size (ev_page_cache_get (op->document),
+ page, 0, 1.0,
+ &width, &height);
+ cairo_scale (cr, cr_width / (gdouble)width, cr_height / (gdouble)height);
+ ev_job_print_set_cairo (EV_JOB_PRINT (print->job_print), cr);
ev_job_scheduler_push_job (print->job_print, EV_JOB_PRIORITY_NONE);
}
}
#endif /* GTK_CHECK_VERSION (2, 17, 1) */
+gboolean ev_print_operation_exists_for_document (EvDocument *document)
+{
+#if GTKUNIXPRINT_ENABLED
+#if GTK_CHECK_VERSION (2, 17, 1)
+ return (EV_IS_FILE_EXPORTER(document) || EV_IS_DOCUMENT_PRINT(document));
+#else
+ return EV_IS_FILE_EXPORTER(document);
+#endif
+#else /* ! GTKUNIXPRINT_ENABLED */
+#if GTK_CHECK_VERSION (2, 17, 1)
+ return EV_IS_DOCUMENT_PRINT(document);
+#else
+ return FALSE;
+#endif
+#endif /* GTKUNIXPRINT_ENABLED */
+}
+
/* Factory method */
EvPrintOperation *
ev_print_operation_new (EvDocument *document)
{
- EvPrintOperation *op;
+ EvPrintOperation *op = NULL;
+
+ g_return_val_if_fail (ev_print_operation_exists_for_document (document), NULL);
#if GTK_CHECK_VERSION (2, 17, 1)
if (EV_IS_DOCUMENT_PRINT (document))
"document", document, NULL));
else
#endif
+#if GTKUNIXPRINT_ENABLED
op = EV_PRINT_OPERATION (g_object_new (EV_TYPE_PRINT_OPERATION_EXPORT,
"document", document, NULL));
-
+#endif
return op;
}