From: Jim Evins Date: Thu, 29 Mar 2007 02:31:25 +0000 (+0000) Subject: 2007-03-28 Jim Evins X-Git-Tag: glabels-2_3_0~354 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=98764f06e25c92bfbd923aaa2b0733ac5a98b888;p=glabels 2007-03-28 Jim Evins * 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 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index 62974603..a79499c2 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,15 @@ +2007-03-28 Jim Evins + + * 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 * src/object-editor-image-page.c: diff --git a/glabels2/src/print-op.c b/glabels2/src/print-op.c index 903d76a7..25de6bcc 100644 --- a/glabels2/src/print-op.c +++ b/glabels2/src/print-op.c @@ -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); } diff --git a/glabels2/src/print-op.h b/glabels2/src/print-op.h index cd82158b..75c893c5 100644 --- a/glabels2/src/print-op.h +++ b/glabels2/src/print-op.h @@ -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 diff --git a/glabels2/src/ui-commands.c b/glabels2/src/ui-commands.c index ae288af6..223d3680 100644 --- a/glabels2/src/ui-commands.c +++ b/glabels2/src/ui-commands.c @@ -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"); } diff --git a/glabels2/src/window.c b/glabels2/src/window.c index 83d90c53..33e3b7e7 100644 --- a/glabels2/src/window.c +++ b/glabels2/src/window.c @@ -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 = diff --git a/glabels2/src/window.h b/glabels2/src/window.h index ff0ded3f..e5a63ab1 100644 --- a/glabels2/src/window.h +++ b/glabels2/src/window.h @@ -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;