]> www.fi.muni.cz Git - evince.git/commitdiff
[printing] Embed page setup settings in the print dialog
authorCarlos Garcia Campos <carlosgc@gnome.org>
Mon, 26 Oct 2009 12:17:09 +0000 (13:17 +0100)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Mon, 26 Oct 2009 12:29:02 +0000 (13:29 +0100)
Based on patch by Marek Kašík. Fixes bgo#591551.

shell/ev-print-operation.c
shell/ev-print-operation.h
shell/ev-window.c

index 08c655d4bce6f1100fa9223154c7615723bcc475..8d4df9f81dd41cfeed5fa84a6cd486293c5f1785 100644 (file)
@@ -78,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,
@@ -282,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)
 {
@@ -364,7 +394,8 @@ struct _EvPrintOperationExport {
        gint fd;
        gchar *temp_file;
        gchar *job_name;
-       
+       gboolean embed_page_setup;
+
        guint idle_id;
        
        /* Context */
@@ -1292,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);
@@ -1302,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);
@@ -1333,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)
 {
@@ -1443,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;
@@ -1576,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)
@@ -1761,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;
 }
index 20120d6a11c68f59548272ae540449ca0ebbbfe2..06a2845ff6d72b8d884c93b33214cbe2d6496fc6 100644 (file)
@@ -56,6 +56,9 @@ void              ev_print_operation_run                    (EvPrintOperation *o
 void              ev_print_operation_cancel                 (EvPrintOperation *op);
 void              ev_print_operation_get_error              (EvPrintOperation *op,
                                                             GError          **error);
+void              ev_print_operation_set_embed_page_setup   (EvPrintOperation *op,
+                                                            gboolean          embed);
+gboolean          ev_print_operation_get_embed_page_setup   (EvPrintOperation *op);
 const gchar      *ev_print_operation_get_status             (EvPrintOperation *op);
 gdouble           ev_print_operation_get_progress           (EvPrintOperation *op);
 
index 528226b3ba1325903312e01846626f76d289c85f..6f98711f4a38486fd8f01e60fbb42e5c4b382cdc 100644 (file)
@@ -395,7 +395,9 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
        /* File menu */
        ev_window_set_action_sensitive (ev_window, "FileOpenCopy", has_document);
        ev_window_set_action_sensitive (ev_window, "FileSaveAs", has_document && ok_to_copy);
+#if !GTK_CHECK_VERSION (2, 17, 4)
        ev_window_set_action_sensitive (ev_window, "FilePageSetup", has_pages && ok_to_print);
+#endif
        ev_window_set_action_sensitive (ev_window, "FilePrint", has_pages && ok_to_print);
        ev_window_set_action_sensitive (ev_window, "FileProperties", has_document && has_properties);
 
@@ -2908,6 +2910,13 @@ ev_window_print_operation_done (EvPrintOperation       *op,
 
                print_settings = ev_print_operation_get_print_settings (op);
                ev_window_save_print_settings (ev_window, print_settings);
+
+               if (ev_print_operation_get_embed_page_setup (op)) {
+                       GtkPageSetup *page_setup;
+
+                       page_setup = ev_print_operation_get_default_page_setup (op);
+                       ev_window_save_print_page_setup (ev_window, page_setup);
+               }
        }
 
                break;
@@ -3081,6 +3090,7 @@ ev_window_print_range (EvWindow *ev_window,
        ev_print_operation_set_current_page (op, current_page);
        ev_print_operation_set_print_settings (op, print_settings);
        ev_print_operation_set_default_page_setup (op, print_page_setup);
+       ev_print_operation_set_embed_page_setup (op, TRUE);
 
        g_object_unref (print_settings);
        g_object_unref (print_page_setup);
@@ -6039,7 +6049,17 @@ ev_window_init (EvWindow *ev_window)
                g_error_free (error);
        }
        g_free (ui_path);
-       
+
+#if GTK_CHECK_VERSION (2, 17, 4)
+       {
+               GtkAction *action;
+
+               action = gtk_action_group_get_action (ev_window->priv->action_group,
+                                                     "FilePageSetup");
+               g_object_set (action, "visible", FALSE, "sensitive", FALSE, NULL);
+       }
+#endif
+
        ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
        ev_window->priv->recent_action_group = NULL;
        ev_window->priv->recent_ui_id = 0;