]> git.sur5r.net Git - glabels/commitdiff
2007-03-28 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Thu, 29 Mar 2007 02:31:25 +0000 (02:31 +0000)
committerJim Evins <evins@snaught.com>
Thu, 29 Mar 2007 02:31:25 +0000 (02:31 +0000)
* src/print-op.c: (gl_print_op_construct),
(gl_print_op_get_settings), (gl_print_op_set_settings),
(gl_print_op_free_settings), (create_custom_widget_cb):
* src/print-op.h:
* src/ui-commands.c: (gl_ui_cmd_file_print):
* src/window.c: (gl_window_init):
* src/window.h:
Save print settings and custom settings between print operations
on the same window.

git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@642 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/ChangeLog
glabels2/src/print-op.c
glabels2/src/print-op.h
glabels2/src/ui-commands.c
glabels2/src/window.c
glabels2/src/window.h

index 629746031bfd5d579124c63555ed13393986399e..a79499c28dd70d19785554160010871e2e8890c3 100644 (file)
@@ -1,3 +1,15 @@
+2007-03-28  Jim Evins  <evins@snaught.com>
+
+       * src/print-op.c: (gl_print_op_construct),
+       (gl_print_op_get_settings), (gl_print_op_set_settings),
+       (gl_print_op_free_settings), (create_custom_widget_cb):
+       * src/print-op.h:
+       * src/ui-commands.c: (gl_ui_cmd_file_print):
+       * src/window.c: (gl_window_init):
+       * src/window.h:
+               Save print settings and custom settings between print operations
+               on the same window.
+
 2007-03-24  Jim Evins  <evins@snaught.com>
 
        * src/object-editor-image-page.c:
index 903d76a7594dcb2d60844fac1c4f53eba55dce98..25de6bcca1e30365a3a65d1efe469755e7407168 100644 (file)
@@ -80,6 +80,23 @@ struct _glPrintOpPrivate {
         glPrintState state;
 };
 
+typedef struct _glPrintOpSettings
+{
+
+        GtkPrintSettings *gtk_settings;
+
+        gboolean          outline_flag;
+        gboolean          reverse_flag;
+        gboolean          crop_marks_flag;
+        gboolean          collate_flag;
+
+        gint              first;
+        gint              last;
+        gint              n_sheets;
+        gint              n_copies;
+        
+};
+
 
 /*===========================================*/
 /* Private globals                           */
@@ -200,9 +217,18 @@ static void
 gl_print_op_construct (glPrintOp      *op,
                        glLabel        *label)
 {
+        const glTemplateLabelType *label_type;
+
        op->priv->label              = label;
        op->priv->force_outline_flag = FALSE;
 
+        label_type = gl_template_get_first_label_type (label->template);
+
+        op->priv->n_sheets           = 1;
+        op->priv->first              = 1;
+        op->priv->last               = gl_template_get_n_labels (label_type);
+        op->priv->n_copies           = 1;
+
        gtk_print_operation_set_custom_tab_label ( GTK_PRINT_OPERATION (op),
                                                   _("Labels"));
 
@@ -251,6 +277,79 @@ gl_print_op_new_batch (glLabel       *label,
        return op;
 }
 
+/*****************************************************************************/
+/* Get print operation settings.                                             */
+/*****************************************************************************/
+glPrintOpSettings *
+gl_print_op_get_settings (glPrintOp         *print_op)
+{
+        glPrintOpSettings *settings;
+
+        settings = g_new0 (glPrintOpSettings, 1);
+
+        if ( settings )
+        {
+                settings->gtk_settings =
+                        gtk_print_operation_get_print_settings (GTK_PRINT_OPERATION (print_op));
+
+                settings->outline_flag     = print_op->priv->outline_flag;
+                settings->reverse_flag     = print_op->priv->reverse_flag;
+                settings->crop_marks_flag  = print_op->priv->crop_marks_flag;
+                settings->collate_flag     = print_op->priv->collate_flag;
+
+                settings->first            = print_op->priv->first;
+                settings->last             = print_op->priv->last;
+                settings->n_sheets         = print_op->priv->n_sheets;
+                settings->n_copies         = print_op->priv->n_copies;
+        }
+
+        return settings;
+}
+
+/*****************************************************************************/
+/* Set print operation settings.                                             */
+/*****************************************************************************/
+void
+gl_print_op_set_settings (glPrintOp         *print_op,
+                          glPrintOpSettings *settings)
+{
+
+        if ( settings )
+        {
+                gtk_print_operation_set_print_settings (GTK_PRINT_OPERATION (print_op),
+                                                        settings->gtk_settings);
+
+                print_op->priv->outline_flag     = settings->outline_flag;
+                print_op->priv->reverse_flag     = settings->reverse_flag;
+                print_op->priv->crop_marks_flag  = settings->crop_marks_flag;
+                print_op->priv->collate_flag     = settings->collate_flag;
+
+                print_op->priv->first            = settings->first;
+                print_op->priv->last             = settings->last;
+                print_op->priv->n_sheets         = settings->n_sheets;
+                print_op->priv->n_copies         = settings->n_copies;
+        }
+
+ }
+
+/*****************************************************************************/
+/* Free print operation settings structure.                                  */
+/*****************************************************************************/
+void
+gl_print_op_free_settings(glPrintOpSettings *settings)
+{
+        
+        if ( settings )
+        {
+                if ( settings->gtk_settings )
+                {
+                        g_object_unref (settings->gtk_settings);
+                }
+
+                g_free (settings);
+        }
+}
+
 /*--------------------------------------------------------------------------*/
 /* PRIVATE.  Construct op.                                              */
 /*--------------------------------------------------------------------------*/
@@ -366,14 +465,22 @@ create_custom_widget_cb (GtkPrintOperation *operation,
         merge = gl_label_get_merge (op->priv->label);
        if (merge == NULL) {
 
+                gl_wdgt_print_copies_set_range (GL_WDGT_PRINT_COPIES (op->priv->copies),
+                                                op->priv->n_sheets,
+                                                op->priv->first,
+                                                op->priv->last);
+
                gtk_widget_show_all (op->priv->simple_frame);
                gtk_widget_hide_all (op->priv->merge_frame);
 
        } else {
 
                gint n_records = gl_merge_get_record_count( merge );
-               gl_wdgt_print_merge_set_copies (GL_WDGT_PRINT_MERGE(op->priv->prmerge),
-                                               1, 1, n_records, FALSE);
+                gl_wdgt_print_merge_set_copies (GL_WDGT_PRINT_MERGE (op->priv->prmerge),
+                                                op->priv->n_copies,
+                                                op->priv->first,
+                                                n_records,
+                                                op->priv->collate_flag);
                g_object_unref (G_OBJECT(merge));
 
                gtk_widget_hide_all (op->priv->simple_frame);
@@ -391,6 +498,14 @@ create_custom_widget_cb (GtkPrintOperation *operation,
                 gtk_widget_set_sensitive (op->priv->crop_marks_check, FALSE);
         }
 
+        /* --- Set options --- */
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (op->priv->outline_check),
+                                      op->priv->outline_flag);
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (op->priv->reverse_check),
+                                      op->priv->reverse_flag);
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (op->priv->crop_marks_check),
+                                      op->priv->crop_marks_flag);
+
        return G_OBJECT (vbox);
 }
 
index cd82158b8b93eed4f1e932c43705537c91475980..75c893c5c7fb9d402810ad641c117dfde4b720fa 100644 (file)
@@ -56,23 +56,32 @@ struct  _glPrintOpClass
 };
 
 
-GType          gl_print_op_get_type           (void) G_GNUC_CONST;
+typedef struct _glPrintOpSettings glPrintOpSettings;
 
-glPrintOp     *gl_print_op_new                (glLabel       *label);
 
-void           gl_print_op_force_outline_flag (glPrintOp *print_op);
 
+GType              gl_print_op_get_type           (void) G_GNUC_CONST;
+
+glPrintOp         *gl_print_op_new                (glLabel           *label);
+
+void               gl_print_op_force_outline_flag (glPrintOp         *print_op);
+
+glPrintOpSettings *gl_print_op_get_settings          (glPrintOp         *print_op);
+void               gl_print_op_set_settings          (glPrintOp         *print_op,
+                                                      glPrintOpSettings *settings);
+void               gl_print_op_free_settings         (glPrintOpSettings *settings);
+                                          
 /*
  * Batch print operation
  */
-glPrintOp     *gl_print_op_new_batch          (glLabel       *label,
-                                               gchar         *filename,
-                                               gint           n_sheets,
-                                               gint           n_copies,
-                                               gint           first,
-                                               gboolean       outline_flag,
-                                               gboolean       reverse_flag,
-                                               gboolean       crop_marks_flag);
+glPrintOp         *gl_print_op_new_batch          (glLabel           *label,
+                                                   gchar             *filename,
+                                                   gint               n_sheets,
+                                                   gint               n_copies,
+                                                   gint               first,
+                                                   gboolean           outline_flag,
+                                                   gboolean           reverse_flag,
+                                                   gboolean           crop_marks_flag);
 
 G_END_DECLS
 
index ae288af6131dcf56bcd52936eedfe8cfa1f7b062..223d36800c83068b904b7dc21b579d2551e472d2 100644 (file)
@@ -184,7 +184,8 @@ void
 gl_ui_cmd_file_print (GtkAction *action,
                       glWindow  *window)
 {
-        glPrintOp *op;
+        glPrintOp               *op;
+        GtkPrintOperationResult  result;
 
         gl_debug (DEBUG_COMMANDS, "START");
 
@@ -193,10 +194,23 @@ gl_ui_cmd_file_print (GtkAction *action,
 
         op = gl_print_op_new (GL_VIEW(window->view)->label);
 
-        gtk_print_operation_run (GTK_PRINT_OPERATION (op),
-                                 GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
-                                 GTK_WINDOW (window),
-                                 NULL);
+        if (window->print_settings)
+        {
+                gl_print_op_set_settings (op, window->print_settings);
+        }
+
+        result = gtk_print_operation_run (GTK_PRINT_OPERATION (op),
+                                          GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
+                                          GTK_WINDOW (window),
+                                          NULL);
+
+        if ( result == GTK_PRINT_OPERATION_RESULT_APPLY )
+        {
+                gl_print_op_free_settings (window->print_settings);
+                window->print_settings = gl_print_op_get_settings (op);
+
+                g_object_unref (op);
+        }
 
         gl_debug (DEBUG_COMMANDS, "END");
 }
index 83d90c53f3cb5388b2a883a176c4a012ab593a81..33e3b7e71c6ea20fb04684375ef0e81f32c335b4 100644 (file)
@@ -193,6 +193,7 @@ gl_window_init (glWindow *window)
        window->menu_tips_context_id =
                gtk_statusbar_get_context_id (GTK_STATUSBAR (window->status_bar), "menu_tips");
 
+       window->print_settings = NULL;
        window->merge_dialog = NULL;
        window->context_menu = GTK_MENU (gtk_ui_manager_get_widget (ui, "/ContextMenu"));
        window->empty_selection_context_menu =
index ff0ded3f7e0947cd82619323b85fcc9f1523b088..e5a63ab1e368dc926021b32028ec2f676f408d3e 100644 (file)
@@ -33,6 +33,7 @@
 #include "label.h"
 #include "ui-property-bar.h"
 #include "ui-sidebar.h"
+#include "print-op.h"
 #include "merge-properties-dialog.h"
 
 G_BEGIN_DECLS
@@ -70,6 +71,7 @@ struct _glWindow {
 
        guint                    menu_tips_context_id;
 
+        glPrintOpSettings       *print_settings;
        glMergePropertiesDialog *merge_dialog;
        GtkMenu                 *context_menu;
        GtkMenu                 *empty_selection_context_menu;