X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-print-operation.c;h=08c655d4bce6f1100fa9223154c7615723bcc475;hb=5f554d8e362a35e05840068e1b3ea935be5d3c47;hp=fe5ef54003743eb60f0e1320f4e573b9db922d8f;hpb=c4b192c34c4758bd078d1a212d69c6ae5084d6c8;p=evince.git diff --git a/shell/ev-print-operation.c b/shell/ev-print-operation.c index fe5ef540..08c655d4 100644 --- a/shell/ev-print-operation.c +++ b/shell/ev-print-operation.c @@ -28,7 +28,6 @@ #include #include -#include "ev-page-cache.h" #include "ev-file-exporter.h" #include "ev-jobs.h" #include "ev-job-scheduler.h" @@ -1253,13 +1252,8 @@ ev_print_operation_export_print_dialog_response_cb (GtkDialog *dial get_first_and_last_page (export, &first_page, &last_page); - if (file_format) { - export->fc.format = g_ascii_strcasecmp (file_format, "pdf") == 0 ? - EV_FILE_FORMAT_PDF : EV_FILE_FORMAT_PS; - } else { - export->fc.format = gtk_printer_accepts_pdf (printer) ? - EV_FILE_FORMAT_PDF : EV_FILE_FORMAT_PS; - } + export->fc.format = file_format && g_ascii_strcasecmp (file_format, "pdf") == 0 ? + EV_FILE_FORMAT_PDF : EV_FILE_FORMAT_PS; export->fc.filename = export->temp_file; export->fc.first_page = MIN (first_page, last_page); export->fc.last_page = MAX (first_page, last_page); @@ -1642,6 +1636,23 @@ print_job_cancelled (EvJobPrint *job, gtk_print_operation_cancel (print->op); } +static void +ev_print_operation_print_request_page_setup (EvPrintOperationPrint *print, + GtkPrintContext *context, + gint page_nr, + GtkPageSetup *setup) +{ + EvPrintOperation *op = EV_PRINT_OPERATION (print); + gdouble width, height; + + ev_document_get_page_size (op->document, page_nr, + &width, &height); + if (width > height) + gtk_page_setup_set_orientation (setup, GTK_PAGE_ORIENTATION_LANDSCAPE); + else + gtk_page_setup_set_orientation (setup, GTK_PAGE_ORIENTATION_PORTRAIT); +} + static void ev_print_operation_print_draw_page (EvPrintOperationPrint *print, GtkPrintContext *context, @@ -1650,7 +1661,7 @@ ev_print_operation_print_draw_page (EvPrintOperationPrint *print, EvPrintOperation *op = EV_PRINT_OPERATION (print); cairo_t *cr; gdouble cr_width, cr_height; - gdouble width, height; + gdouble width, height, scale; gtk_print_operation_set_defer_drawing (print->op); @@ -1671,7 +1682,11 @@ ev_print_operation_print_draw_page (EvPrintOperationPrint *print, cr_height = gtk_print_context_get_height (context); ev_document_get_page_size (op->document, page, &width, &height); - cairo_scale (cr, cr_width / width, cr_height / height); + if (cr_width / width < cr_height / height) + scale = cr_width / width; + else + scale = cr_height / height; + cairo_scale (cr, scale, scale); ev_job_print_set_cairo (EV_JOB_PRINT (print->job_print), cr); ev_job_scheduler_push_job (print->job_print, EV_JOB_PRIORITY_NONE); @@ -1724,6 +1739,9 @@ ev_print_operation_print_init (EvPrintOperationPrint *print) g_signal_connect_swapped (print->op, "status_changed", G_CALLBACK (ev_print_operation_print_status_changed), print); + g_signal_connect_swapped (print->op, "request_page_setup", + G_CALLBACK (ev_print_operation_print_request_page_setup), + print); gtk_print_operation_set_allow_async (print->op, TRUE); }