]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-print-operation.c
Updated Slovenian translation
[evince.git] / shell / ev-print-operation.c
index fe5ef54003743eb60f0e1320f4e573b9db922d8f..8d4df9f81dd41cfeed5fa84a6cd486293c5f1785 100644 (file)
@@ -28,7 +28,6 @@
 #include <glib/gstdio.h>
 #include <unistd.h>
 
-#include "ev-page-cache.h"
 #include "ev-file-exporter.h"
 #include "ev-jobs.h"
 #include "ev-job-scheduler.h"
@@ -79,6 +78,9 @@ struct _EvPrintOperationClass {
        void              (* cancel)                 (EvPrintOperation       *op);
        void              (* get_error)              (EvPrintOperation       *op,
                                                      GError                **error);
+       void              (* set_embed_page_setup)   (EvPrintOperation       *op,
+                                                     gboolean                embed);
+       gboolean          (* get_embed_page_setup)   (EvPrintOperation       *op);
 
        /* signals */
        void              (* done)                   (EvPrintOperation       *op,
@@ -283,6 +285,33 @@ ev_print_operation_get_error (EvPrintOperation *op,
        class->get_error (op, error);
 }
 
+void
+ev_print_operation_set_embed_page_setup (EvPrintOperation *op,
+                                        gboolean          embed)
+{
+#if GTK_CHECK_VERSION (2, 17, 4)
+       EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
+
+       g_return_if_fail (EV_IS_PRINT_OPERATION (op));
+
+       class->set_embed_page_setup (op, embed);
+#endif
+}
+
+gboolean
+ev_print_operation_get_embed_page_setup (EvPrintOperation *op)
+{
+#if GTK_CHECK_VERSION (2, 17, 4)
+       EvPrintOperationClass *class = EV_PRINT_OPERATION_GET_CLASS (op);
+
+       g_return_val_if_fail (EV_IS_PRINT_OPERATION (op), FALSE);
+
+       return class->get_embed_page_setup (op);
+#else
+       return FALSE;
+#endif
+}
+
 const gchar *
 ev_print_operation_get_status (EvPrintOperation *op)
 {
@@ -365,7 +394,8 @@ struct _EvPrintOperationExport {
        gint fd;
        gchar *temp_file;
        gchar *job_name;
-       
+       gboolean embed_page_setup;
+
        guint idle_id;
        
        /* Context */
@@ -1253,13 +1283,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);
@@ -1298,6 +1323,10 @@ ev_print_operation_export_run (EvPrintOperation *op,
                ev_file_exporter_get_capabilities (EV_FILE_EXPORTER (op->document));
        gtk_print_unix_dialog_set_manual_capabilities (GTK_PRINT_UNIX_DIALOG (dialog),
                                                       capabilities);
+#if GTK_CHECK_VERSION (2, 17, 4)
+       gtk_print_unix_dialog_set_embed_page_setup (GTK_PRINT_UNIX_DIALOG (dialog),
+                                                   export->embed_page_setup);
+#endif
 
        gtk_print_unix_dialog_set_current_page (GTK_PRINT_UNIX_DIALOG (dialog),
                                                export->current_page);
@@ -1308,7 +1337,7 @@ ev_print_operation_export_run (EvPrintOperation *op,
        if (export->page_setup)
                gtk_print_unix_dialog_set_page_setup (GTK_PRINT_UNIX_DIALOG (dialog),
                                                      export->page_setup);
-       
+
        g_signal_connect (dialog, "response",
                          G_CALLBACK (ev_print_operation_export_print_dialog_response_cb),
                          export);
@@ -1339,6 +1368,25 @@ ev_print_operation_export_get_error (EvPrintOperation *op,
        export->error = NULL;
 }
 
+static void
+ev_print_operation_export_set_embed_page_setup (EvPrintOperation *op,
+                                               gboolean          embed)
+{
+#if GTK_CHECK_VERSION (2, 17, 4)
+       EvPrintOperationExport *export = EV_PRINT_OPERATION_EXPORT (op);
+
+       export->embed_page_setup = embed;
+#endif
+}
+
+static gboolean
+ev_print_operation_export_get_embed_page_setup (EvPrintOperation *op)
+{
+       EvPrintOperationExport *export = EV_PRINT_OPERATION_EXPORT (op);
+
+       return export->embed_page_setup;
+}
+
 static void
 ev_print_operation_export_finalize (GObject *object)
 {
@@ -1449,6 +1497,8 @@ ev_print_operation_export_class_init (EvPrintOperationExportClass *klass)
        ev_print_op_class->run = ev_print_operation_export_run;
        ev_print_op_class->cancel = ev_print_operation_export_cancel;
        ev_print_op_class->get_error = ev_print_operation_export_get_error;
+       ev_print_op_class->set_embed_page_setup = ev_print_operation_export_set_embed_page_setup;
+       ev_print_op_class->get_embed_page_setup = ev_print_operation_export_get_embed_page_setup;
 
        g_object_class->constructor = ev_print_operation_export_constructor;
        g_object_class->finalize = ev_print_operation_export_finalize;
@@ -1582,6 +1632,29 @@ ev_print_operation_print_get_error (EvPrintOperation *op,
        gtk_print_operation_get_error (print->op, error);
 }
 
+static void
+ev_print_operation_print_set_embed_page_setup (EvPrintOperation *op,
+                                              gboolean          embed)
+{
+#if GTK_CHECK_VERSION (2, 17, 4)
+       EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (op);
+
+       gtk_print_operation_set_embed_page_setup (print->op, embed);
+#endif
+}
+
+static gboolean
+ev_print_operation_print_get_embed_page_setup (EvPrintOperation *op)
+{
+#if GTK_CHECK_VERSION (2, 17, 4)
+       EvPrintOperationPrint *print = EV_PRINT_OPERATION_PRINT (op);
+
+       return gtk_print_operation_get_embed_page_setup (print->op);
+#else
+       return FALSE;
+#endif
+}
+
 static void
 ev_print_operation_print_begin_print (EvPrintOperationPrint *print,
                                      GtkPrintContext       *context)
@@ -1642,6 +1715,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 +1740,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 +1761,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 +1818,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);
 }
 
@@ -1743,6 +1840,8 @@ ev_print_operation_print_class_init (EvPrintOperationPrintClass *klass)
        ev_print_op_class->run = ev_print_operation_print_run;
        ev_print_op_class->cancel = ev_print_operation_print_cancel;
        ev_print_op_class->get_error = ev_print_operation_print_get_error;
+       ev_print_op_class->set_embed_page_setup = ev_print_operation_print_set_embed_page_setup;
+       ev_print_op_class->get_embed_page_setup = ev_print_operation_print_get_embed_page_setup;
 
        g_object_class->finalize = ev_print_operation_print_finalize;
 }