]> git.sur5r.net Git - glabels/commitdiff
2009-09-18 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Sat, 19 Sep 2009 02:59:50 +0000 (02:59 +0000)
committerJim Evins <evins@snaught.com>
Sat, 19 Sep 2009 02:59:50 +0000 (02:59 +0000)
* po/POTFILES.in:
Added missing file.
* src/mini-preview.h:
* src/mini-preview.c: (gl_mini_preview_class_init),
(gl_mini_preview_finalize), (gl_mini_preview_set_by_name),
(gl_mini_preview_highlight_range), (gl_mini_preview_set_label),
(gl_mini_preview_set_page), (gl_mini_preview_set_n_sheets),
(gl_mini_preview_set_n_copies), (gl_mini_preview_set_first),
(gl_mini_preview_set_last), (gl_mini_preview_set_collate_flag),
(gl_mini_preview_set_outline_flag),
(gl_mini_preview_set_reverse_flag),
(gl_mini_preview_set_crop_marks_flag), (button_release_event_cb),
(expose_event_cb), (redraw), (draw), (draw_labels),
(draw_rich_preview):
Added rich preview capability to mini preview.
* src/print-op-dialog.c: (create_custom_widget_cb),
(simple_sheets_radio_cb), (simple_first_spin_cb),
(simple_last_spin_cb), (preview_pressed_cb), (preview_released_cb),
(merge_spin_cb), (merge_collate_check_cb), (preview_clicked_cb),
(option_toggled_cb):
Use new rich preview capability of mini preview in print dialog.

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

glabels2/ChangeLog
glabels2/po/POTFILES.in
glabels2/src/mini-preview.c
glabels2/src/mini-preview.h
glabels2/src/print-op-dialog.c

index d5f0f18c7b7a38e53f50ac838d7c4e7787ada8fc..be65a4f7598968b15f977e647e5ec50ec0385896 100644 (file)
@@ -1,3 +1,27 @@
+2009-09-18  Jim Evins  <evins@snaught.com>
+
+       * po/POTFILES.in:
+               Added missing file.
+       * src/mini-preview.h:
+       * src/mini-preview.c: (gl_mini_preview_class_init),
+       (gl_mini_preview_finalize), (gl_mini_preview_set_by_name),
+       (gl_mini_preview_highlight_range), (gl_mini_preview_set_label),
+       (gl_mini_preview_set_page), (gl_mini_preview_set_n_sheets),
+       (gl_mini_preview_set_n_copies), (gl_mini_preview_set_first),
+       (gl_mini_preview_set_last), (gl_mini_preview_set_collate_flag),
+       (gl_mini_preview_set_outline_flag),
+       (gl_mini_preview_set_reverse_flag),
+       (gl_mini_preview_set_crop_marks_flag), (button_release_event_cb),
+       (expose_event_cb), (redraw), (draw), (draw_labels),
+       (draw_rich_preview):
+               Added rich preview capability to mini preview.
+       * src/print-op-dialog.c: (create_custom_widget_cb),
+       (simple_sheets_radio_cb), (simple_first_spin_cb),
+       (simple_last_spin_cb), (preview_pressed_cb), (preview_released_cb),
+       (merge_spin_cb), (merge_collate_check_cb), (preview_clicked_cb),
+       (option_toggled_cb):
+               Use new rich preview capability of mini preview in print dialog.
+
 2009-09-17  Jim Evins  <evins@snaught.com>
 
        * src/stock.c: (add_icons), (add_button_icon):
index f69506ed33a0c1d797774a6a04f020bd70ee6c6a..62af480880f8f948b1a3d8d1328cd4c05eaa301f 100644 (file)
@@ -165,6 +165,7 @@ libglabels/xml-template.h
 [type: gettext/glade]data/builder/prefs-dialog.builder
 [type: gettext/glade]data/builder/property-bar.builder
 [type: gettext/glade]data/builder/template-designer.builder
+[type: gettext/glade]data/builder/print-op-dialog-custom-widget.builder
 
 [type: gettext/xml]data/templates/paper-sizes.xml
 [type: gettext/xml]data/templates/categories.xml
index 8acdf3164a2407035f2cbb71c8efe9638d2f46ad..9bcedbff5671865cb1277eb9b781dd82475b6197 100644 (file)
@@ -28,6 +28,7 @@
 #include "cairo-label-path.h"
 #include "marshal.h"
 #include "color.h"
+#include "print.h"
 
 #include "debug.h"
 
@@ -47,6 +48,7 @@
 enum {
        CLICKED,
        PRESSED,
+       RELEASED,
        LAST_SIGNAL
 };
 
@@ -70,6 +72,19 @@ struct _glMiniPreviewPrivate {
        gint            first_i;
        gint            last_i;
        gint            prev_i;
+
+        gboolean        update_scheduled_flag;
+
+        glLabel        *label;
+        gint            page;
+        gint            n_sheets;
+        gint            n_copies;
+        gint            first;
+        gint            last;
+        gboolean        collate_flag;
+        gboolean        outline_flag;
+        gboolean        reverse_flag;
+        gboolean        crop_marks_flag;
 };
 
 
@@ -124,6 +139,9 @@ static void     draw_labels                    (glMiniPreview          *this,
                                                cairo_t                *cr,
                                                lglTemplate            *template,
                                                gdouble                 line_width);
+static void     draw_rich_preview              (glMiniPreview          *this,
+                                               cairo_t                *cr);
+
 
 static gint     find_closest_label             (glMiniPreview          *this,
                                                gdouble                 x,
@@ -176,6 +194,15 @@ gl_mini_preview_class_init (glMiniPreviewClass *class)
                          gl_marshal_VOID__INT_INT,
                          G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
 
+       mini_preview_signals[RELEASED] =
+           g_signal_new ("released",
+                         G_OBJECT_CLASS_TYPE(object_class),
+                         G_SIGNAL_RUN_LAST,
+                         G_STRUCT_OFFSET (glMiniPreviewClass, released),
+                         NULL, NULL,
+                         gl_marshal_VOID__INT_INT,
+                         G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
+
        gl_debug (DEBUG_MINI_PREVIEW, "END");
 }
 
@@ -222,6 +249,10 @@ gl_mini_preview_finalize (GObject *object)
        g_return_if_fail (object != NULL);
        g_return_if_fail (GL_IS_MINI_PREVIEW (object));
 
+        if (this->priv->label)
+        {
+                g_object_unref (this->priv->label);
+        }
        lgl_template_free (this->priv->template);
        g_free (this->priv->centers);
        g_free (this->priv);
@@ -270,11 +301,11 @@ gl_mini_preview_construct (glMiniPreview *this,
 
 
 /****************************************************************************/
-/* Set label for mini-preview to determine geometry.                        */
+/* Set template for mini-preview to determine geometry.                     */
 /****************************************************************************/
 void
-gl_mini_preview_set_label_by_name (glMiniPreview *this,
-                                   const gchar   *name)
+gl_mini_preview_set_by_name (glMiniPreview *this,
+                             const gchar   *name)
 {
        lglTemplate *template;
 
@@ -292,7 +323,7 @@ gl_mini_preview_set_label_by_name (glMiniPreview *this,
 
 
 /****************************************************************************/
-/* Set label for mini-preview to determine geometry.                        */
+/* Set template for mini-preview to determine geometry.                     */
 /****************************************************************************/
 void
 gl_mini_preview_set_template (glMiniPreview     *this,
@@ -351,15 +382,172 @@ gl_mini_preview_highlight_range (glMiniPreview *this,
 {
        gl_debug (DEBUG_MINI_PREVIEW, "START");
 
-       this->priv->highlight_first = first_label;
-       this->priv->highlight_last =  last_label;
+        if ( (first_label != this->priv->highlight_first) ||
+             (last_label  != this->priv->highlight_last) )
+        {
 
-       redraw (this);
+                this->priv->highlight_first = first_label;
+                this->priv->highlight_last =  last_label;
+
+                redraw (this);
+
+        }
 
        gl_debug (DEBUG_MINI_PREVIEW, "END");
 }
 
 
+/****************************************************************************/
+/* Set label.                                                               */
+/****************************************************************************/
+void
+gl_mini_preview_set_label (glMiniPreview     *this,
+                           glLabel           *label)
+{
+        if ( this->priv->label )
+        {
+                g_object_unref (this->priv->label);
+        }
+        this->priv->label = g_object_ref (label);
+        redraw (this);
+}
+
+
+/****************************************************************************/
+/* Set page number.                                                         */
+/****************************************************************************/
+void
+gl_mini_preview_set_page (glMiniPreview     *this,
+                          gint               page)
+{
+        if ( page != this->priv->page )
+        {
+                this->priv->page = page;
+                redraw (this);
+        }
+}
+
+
+/****************************************************************************/
+/* Set number of sheets.                                                    */
+/****************************************************************************/
+void
+gl_mini_preview_set_n_sheets (glMiniPreview     *this,
+                              gint               n_sheets)
+{
+        if ( n_sheets != this->priv->n_sheets )
+        {
+                this->priv->n_sheets = n_sheets;
+                redraw (this);
+        }
+}
+
+
+/****************************************************************************/
+/* Set number of copies (merge only).                                       */
+/****************************************************************************/
+void
+gl_mini_preview_set_n_copies (glMiniPreview     *this,
+                              gint               n_copies)
+{
+        if ( n_copies != this->priv->n_copies )
+        {
+                this->priv->n_copies = n_copies;
+                redraw (this);
+        }
+}
+
+
+/****************************************************************************/
+/* Set first label number on first sheet.                                   */
+/****************************************************************************/
+void
+gl_mini_preview_set_first (glMiniPreview     *this,
+                           gint               first)
+{
+        if ( first != this->priv->first )
+        {
+                this->priv->first = first;
+                redraw (this);
+        }
+}
+
+
+/****************************************************************************/
+/* Set last label number on first sheet (non-merge only).                   */
+/****************************************************************************/
+void
+gl_mini_preview_set_last (glMiniPreview     *this,
+                          gint               last)
+{
+        if ( last != this->priv->last )
+        {
+                this->priv->last = last;
+                redraw (this);
+        }
+}
+
+
+/****************************************************************************/
+/* Set collate flag (merge only).                                           */
+/****************************************************************************/
+void
+gl_mini_preview_set_collate_flag (glMiniPreview     *this,
+                                  gboolean           collate_flag)
+{
+        if ( collate_flag != this->priv->collate_flag )
+        {
+                this->priv->collate_flag = collate_flag;
+                redraw (this);
+        }
+}
+
+
+/****************************************************************************/
+/* Set outline flag.                                                        */
+/****************************************************************************/
+void
+gl_mini_preview_set_outline_flag (glMiniPreview     *this,
+                                  gboolean           outline_flag)
+{
+        if ( outline_flag != this->priv->outline_flag )
+        {
+                this->priv->outline_flag = outline_flag;
+                redraw (this);
+        }
+}
+
+
+/****************************************************************************/
+/* Set reverse flag.                                                        */
+/****************************************************************************/
+void
+gl_mini_preview_set_reverse_flag (glMiniPreview     *this,
+                                  gboolean           reverse_flag)
+{
+        if ( reverse_flag != this->priv->reverse_flag )
+        {
+                this->priv->reverse_flag = reverse_flag;
+                redraw (this);
+        }
+}
+
+
+/****************************************************************************/
+/* Set crop marks flag.                                                     */
+/****************************************************************************/
+void
+gl_mini_preview_set_crop_marks_flag (glMiniPreview     *this,
+                                     gboolean           crop_marks_flag)
+{
+        if ( crop_marks_flag != this->priv->crop_marks_flag )
+        {
+                this->priv->crop_marks_flag = crop_marks_flag;
+                redraw (this);
+        }
+}
+
+
 /*--------------------------------------------------------------------------*/
 /* Set transformation and return scale.                                     */
 /*--------------------------------------------------------------------------*/
@@ -504,6 +692,10 @@ button_release_event_cb (GtkWidget      *widget,
 
        }
 
+        g_signal_emit (G_OBJECT(this),
+                       mini_preview_signals[RELEASED],
+                       0, this->priv->first_i, this->priv->last_i);
+
        gl_debug (DEBUG_MINI_PREVIEW, "END");
        return FALSE;
 }
@@ -555,6 +747,8 @@ expose_event_cb (GtkWidget       *widget,
 
        gl_debug (DEBUG_MINI_PREVIEW, "START");
 
+        this->priv->update_scheduled_flag = FALSE;
+
        cr = gdk_cairo_create (widget->window);
 
        cairo_rectangle (cr,
@@ -601,12 +795,14 @@ redraw (glMiniPreview      *this)
        if (GTK_WIDGET (this->priv->canvas)->window)
        {
 
-               region = gdk_drawable_get_clip_region (GTK_WIDGET (this->priv->canvas)->window);
-
-               gdk_window_invalidate_region (GTK_WIDGET (this->priv->canvas)->window, region, TRUE);
-               gdk_window_process_updates (GTK_WIDGET (this->priv->canvas)->window, TRUE);
+                if ( !this->priv->update_scheduled_flag )
+                {
+                        this->priv->update_scheduled_flag = TRUE;
 
-               gdk_region_destroy (region);
+                        region = gdk_drawable_get_clip_region (GTK_WIDGET (this->priv->canvas)->window);
+                        gdk_window_invalidate_region (GTK_WIDGET (this->priv->canvas)->window, region, TRUE);
+                        gdk_region_destroy (region);
+                }
        }
 
        gl_debug (DEBUG_MINI_PREVIEW, "END");
@@ -645,6 +841,11 @@ draw (glMiniPreview  *this,
                            1.0/scale);
 
                draw_labels (this, cr, template, 1.0/scale);
+
+                if (this->priv->label)
+                {
+                        draw_rich_preview (this, cr);
+                }
                             
        }
 
@@ -734,7 +935,8 @@ draw_labels (glMiniPreview *this,
         gint                       i, n_labels;
         lglTemplateOrigin         *origins;
        GtkStyle                  *style;
-       guint                      highlight_color, paper_color, outline_color;
+       guint                      base_color;
+        guint                      highlight_color, paper_color, outline_color;
 
         gl_debug (DEBUG_MINI_PREVIEW, "START");
 
@@ -744,9 +946,19 @@ draw_labels (glMiniPreview *this,
         origins  = lgl_template_frame_get_origins (frame);
 
        style = gtk_widget_get_style (GTK_WIDGET(this));
-       highlight_color = gl_color_from_gdk_color (&style->base[GTK_STATE_SELECTED]);
+       base_color      = gl_color_from_gdk_color (&style->base[GTK_STATE_SELECTED]);
+
        paper_color     = gl_color_from_gdk_color (&style->light[GTK_STATE_NORMAL]);
-       outline_color   = gl_color_from_gdk_color (&style->fg[GTK_STATE_NORMAL]);
+        highlight_color = gl_color_set_opacity (base_color, 0.10);
+        if (this->priv->label)
+        {
+                /* Outlines are more subtle when doing a rich preview. */
+                outline_color   = gl_color_set_opacity (base_color, 0.05);
+        }
+        else
+        {
+                outline_color   = gl_color_set_opacity (base_color, 1.00);
+        }
 
         for ( i=0; i < n_labels; i++ ) {
 
@@ -758,17 +970,13 @@ draw_labels (glMiniPreview *this,
                if ( ((i+1) >= this->priv->highlight_first) &&
                     ((i+1) <= this->priv->highlight_last) )
                {
-                       cairo_set_source_rgb (cr, GL_COLOR_RGB_ARGS (highlight_color));
+                       cairo_set_source_rgba (cr, GL_COLOR_RGBA_ARGS (highlight_color));
+                        cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+                        cairo_fill_preserve (cr);
                }
-               else
-               {
-                       cairo_set_source_rgb (cr, GL_COLOR_RGB_ARGS (paper_color));
-               }
-               cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
-               cairo_fill_preserve (cr);
 
                cairo_set_line_width (cr, line_width);
-               cairo_set_source_rgb (cr, GL_COLOR_RGB_ARGS (outline_color));
+               cairo_set_source_rgba (cr, GL_COLOR_RGBA_ARGS (outline_color));
                cairo_stroke (cr);
 
                cairo_restore (cr);
@@ -781,6 +989,68 @@ draw_labels (glMiniPreview *this,
 }
 
 
+/*--------------------------------------------------------------------------*/
+/* Draw rich preview using print renderers.                                 */
+/*--------------------------------------------------------------------------*/
+static void
+draw_rich_preview (glMiniPreview          *this,
+                   cairo_t                *cr)
+{
+        glMerge      *merge;
+        glPrintState  state;
+
+        merge = gl_label_get_merge (this->priv->label);
+
+        if (!merge)
+        {
+                gl_print_simple_sheet (this->priv->label,
+                                       cr,
+                                       this->priv->page,
+                                       this->priv->n_sheets,
+                                       this->priv->first,
+                                       this->priv->last,
+                                       this->priv->outline_flag,
+                                       this->priv->reverse_flag,
+                                       this->priv->crop_marks_flag);
+        }
+        else
+        {
+                /* FIXME: maybe the renderers should be more self contained.
+                 *        This will only work for the first page, since
+                 *        previous pages must be rendered to establish
+                 *        state.
+                 */
+                state.i_copy = 0;
+                state.p_record = (GList *)gl_merge_get_record_list (merge);
+
+                if (this->priv->collate_flag)
+                {
+                        gl_print_collated_merge_sheet (this->priv->label,
+                                                       cr,
+                                                       this->priv->page,
+                                                       this->priv->n_copies,
+                                                       this->priv->first,
+                                                       this->priv->outline_flag,
+                                                       this->priv->reverse_flag,
+                                                       this->priv->crop_marks_flag,
+                                                       &state);
+                }
+                else
+                {
+                        gl_print_uncollated_merge_sheet (this->priv->label,
+                                                         cr,
+                                                         this->priv->page,
+                                                         this->priv->n_copies,
+                                                         this->priv->first,
+                                                         this->priv->outline_flag,
+                                                         this->priv->reverse_flag,
+                                                         this->priv->crop_marks_flag,
+                                                         &state);
+                }
+        }
+}
+
+
 
 /*
  * Local Variables:       -- emacs
index 4eaccd0cbae2826ed5d0cb10e53cfe52a5da7282..caf77ebbbfffb926e820792dbfd6ef89bec66b19 100644 (file)
@@ -51,31 +51,64 @@ struct _glMiniPreview {
 struct _glMiniPreviewClass {
        GtkEventBoxClass      parent_class;
 
-       void (*clicked) (glMiniPreview *this,
-                        gint           index,
-                        gpointer       user_data);
-
-       void (*pressed) (glMiniPreview *this,
-                        gint           index1,
-                        gint           index2,
-                        gpointer       user_data);
+       void (*clicked)  (glMiniPreview *this,
+                          gint           index,
+                          gpointer       user_data);
+
+       void (*pressed)  (glMiniPreview *this,
+                          gint           index1,
+                          gint           index2,
+                          gpointer       user_data);
+
+       void (*released) (glMiniPreview *this,
+                          gint           index1,
+                          gint           index2,
+                          gpointer       user_data);
+
 };
 
 
-GType      gl_mini_preview_get_type          (void) G_GNUC_CONST;
+GType      gl_mini_preview_get_type            (void) G_GNUC_CONST;
+
+GtkWidget *gl_mini_preview_new                 (gint               height,
+                                                gint               width);
 
-GtkWidget *gl_mini_preview_new               (gint               height,
-                                              gint               width);
+void       gl_mini_preview_set_by_name         (glMiniPreview     *this,
+                                                const gchar       *name);
 
-void       gl_mini_preview_set_label_by_name (glMiniPreview     *this,
-                                              const gchar       *name);
+void       gl_mini_preview_set_template        (glMiniPreview     *this,
+                                                const lglTemplate *template);
 
-void       gl_mini_preview_set_template      (glMiniPreview     *this,
-                                              const lglTemplate *template);
+void       gl_mini_preview_highlight_range     (glMiniPreview     *this,
+                                                gint               first_label,
+                                                gint               last_label);
+
+
+/*
+ * If label is set, the preview will be rich.
+ */
+void       gl_mini_preview_set_label           (glMiniPreview     *this,
+                                                glLabel           *label);
+
+void       gl_mini_preview_set_page            (glMiniPreview     *this,
+                                                gint               n_sheets);
+void       gl_mini_preview_set_n_sheets        (glMiniPreview     *this,
+                                                gint               n_sheets);
+void       gl_mini_preview_set_n_copies        (glMiniPreview     *this,
+                                                gint               n_copies);
+void       gl_mini_preview_set_first           (glMiniPreview     *this,
+                                                gint               first);
+void       gl_mini_preview_set_last            (glMiniPreview     *this,
+                                                gint               last);
+void       gl_mini_preview_set_collate_flag    (glMiniPreview     *this,
+                                                gboolean           collate_flag);
+void       gl_mini_preview_set_outline_flag    (glMiniPreview     *this,
+                                                gboolean           outline_flag);
+void       gl_mini_preview_set_reverse_flag    (glMiniPreview     *this,
+                                                gboolean           reverse_flag);
+void       gl_mini_preview_set_crop_marks_flag (glMiniPreview     *this,
+                                                gboolean           crop_marks_flag);
 
-void       gl_mini_preview_highlight_range   (glMiniPreview     *this,
-                                              gint               first_label,
-                                              gint               last_label);
 
 G_END_DECLS
 
index 812682c2face7113a388d930027c0bff7e8c720e..b1889b1c231fdd6ed0754305e42b77b7986b4443 100644 (file)
@@ -113,6 +113,11 @@ static void     preview_pressed_cb            (glMiniPreview     *preview,
                                                gint               last,
                                                glPrintOpDialog   *op);
 
+static void     preview_released_cb           (glMiniPreview     *preview,
+                                               gint               first,
+                                               gint               last,
+                                               glPrintOpDialog   *op);
+
 static void     merge_spin_cb                 (GtkSpinButton     *spinbutton,
                                                glPrintOpDialog   *op);
 
@@ -123,6 +128,9 @@ static void     preview_clicked_cb            (glMiniPreview     *preview,
                                                gint               first,
                                                glPrintOpDialog   *op);
 
+static void     option_toggled_cb             (GtkToggleButton   *togglebutton,
+                                               glPrintOpDialog   *op);
+
 
 /*****************************************************************************/
 /* Boilerplate object stuff.                                                 */
@@ -275,6 +283,7 @@ create_custom_widget_cb (GtkPrintOperation *operation,
         /* ---- Install preview. ---- */
         op->priv->preview = gl_mini_preview_new (MINI_PREVIEW_MIN_HEIGHT, MINI_PREVIEW_MIN_WIDTH);
         gl_mini_preview_set_template (GL_MINI_PREVIEW(op->priv->preview), label->template);
+        gl_mini_preview_set_label (GL_MINI_PREVIEW(op->priv->preview), label);
         gtk_box_pack_start (GTK_BOX(hbox), op->priv->preview, TRUE, TRUE, 0);
         gtk_widget_show_all (op->priv->preview);
 
@@ -303,8 +312,12 @@ create_custom_widget_cb (GtkPrintOperation *operation,
                                            op->priv->labels_per_sheet);
 
                 /* Update preview. */
-                gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview),
-                                                 1, op->priv->labels_per_sheet);
+                gl_mini_preview_set_page     (GL_MINI_PREVIEW (op->priv->preview), 0);
+                gl_mini_preview_set_n_sheets (GL_MINI_PREVIEW (op->priv->preview),
+                                              gl_print_op_get_n_sheets (GL_PRINT_OP(op)));
+                gl_mini_preview_set_first    (GL_MINI_PREVIEW (op->priv->preview), 1);
+                gl_mini_preview_set_last     (GL_MINI_PREVIEW (op->priv->preview),
+                                              op->priv->labels_per_sheet);
 
                gtk_widget_show_all (op->priv->simple_frame);
                gtk_widget_hide_all (op->priv->merge_frame);
@@ -317,6 +330,8 @@ create_custom_widget_cb (GtkPrintOperation *operation,
                                   G_CALLBACK (simple_last_spin_cb), op);
                 g_signal_connect (G_OBJECT (op->priv->preview), "pressed",
                                   G_CALLBACK (preview_pressed_cb), op);
+                g_signal_connect (G_OBJECT (op->priv->preview), "released",
+                                  G_CALLBACK (preview_released_cb), op);
 
        } else {
 
@@ -341,19 +356,24 @@ create_custom_widget_cb (GtkPrintOperation *operation,
 
                 if ( gl_print_op_get_collate_flag (GL_PRINT_OP(op)) )
                 {
-                        pixbuf = gdk_pixbuf_new_from_xpm_data ( (const char **)collate_xpm);
+                        pixbuf = gdk_pixbuf_new_from_xpm_data ( (const char **)nocollate_xpm);
                 }
                 else
                 {
-                        pixbuf = gdk_pixbuf_new_from_xpm_data ( (const char **)nocollate_xpm);
+                        pixbuf = gdk_pixbuf_new_from_xpm_data ( (const char **)collate_xpm);
                 }
 
                 gtk_image_set_from_pixbuf (GTK_IMAGE (op->priv->merge_collate_image), pixbuf);
 
                 /* Update preview. */
-                gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview),
-                                                 gl_print_op_get_first (GL_PRINT_OP(op)),
-                                                 gl_print_op_get_first (GL_PRINT_OP(op)) + op->priv->n_records - 1);
+                gl_mini_preview_set_page     (GL_MINI_PREVIEW (op->priv->preview), 0);
+                gl_mini_preview_set_first    (GL_MINI_PREVIEW (op->priv->preview),
+                                              gl_print_op_get_first (GL_PRINT_OP(op)));
+                gl_mini_preview_set_n_copies (GL_MINI_PREVIEW (op->priv->preview),
+                                              gl_print_op_get_n_copies (GL_PRINT_OP(op)));
+                gl_mini_preview_set_collate_flag (GL_MINI_PREVIEW (op->priv->preview),
+                                                  gl_print_op_get_collate_flag (GL_PRINT_OP(op)));
+
 
                gtk_widget_hide_all (op->priv->simple_frame);
                gtk_widget_show_all (op->priv->merge_frame);
@@ -366,6 +386,10 @@ create_custom_widget_cb (GtkPrintOperation *operation,
                                   G_CALLBACK (merge_collate_check_cb), op);
                 g_signal_connect (G_OBJECT (op->priv->preview), "clicked",
                                   G_CALLBACK (preview_clicked_cb), op);
+                g_signal_connect (G_OBJECT (op->priv->preview), "pressed",
+                                  G_CALLBACK (preview_pressed_cb), op);
+                g_signal_connect (G_OBJECT (op->priv->preview), "released",
+                                  G_CALLBACK (preview_released_cb), op);
 
                g_object_unref (G_OBJECT(merge));
 
@@ -390,6 +414,13 @@ create_custom_widget_cb (GtkPrintOperation *operation,
                 gtk_widget_set_sensitive (op->priv->crop_marks_check, FALSE);
         }
 
+        g_signal_connect (G_OBJECT (op->priv->outline_check), "toggled",
+                          G_CALLBACK (option_toggled_cb), op);
+        g_signal_connect (G_OBJECT (op->priv->reverse_check), "toggled",
+                          G_CALLBACK (option_toggled_cb), op);
+        g_signal_connect (G_OBJECT (op->priv->crop_marks_check), "toggled",
+                          G_CALLBACK (option_toggled_cb), op);
+
        return G_OBJECT (hbox);
 }
 
@@ -483,8 +514,11 @@ simple_sheets_radio_cb (GtkToggleButton   *togglebutton,
                 gtk_spin_button_set_value (GTK_SPIN_BUTTON (op->priv->simple_last_spin),
                                            op->priv->labels_per_sheet);
 
-                gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview),
-                                                 1, op->priv->labels_per_sheet);
+                gl_mini_preview_set_n_sheets (GL_MINI_PREVIEW (op->priv->preview),
+                                              gl_print_op_get_n_sheets (GL_PRINT_OP(op)));
+                gl_mini_preview_set_first    (GL_MINI_PREVIEW (op->priv->preview), 1);
+                gl_mini_preview_set_last     (GL_MINI_PREVIEW (op->priv->preview),
+                                              op->priv->labels_per_sheet);
 
         } else {
 
@@ -497,7 +531,10 @@ simple_sheets_radio_cb (GtkToggleButton   *togglebutton,
                 first = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->simple_first_spin));
                 last  = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->simple_last_spin));
 
-                gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview), first, last);
+                gl_mini_preview_set_n_sheets (GL_MINI_PREVIEW (op->priv->preview), 1);
+                gl_mini_preview_set_first    (GL_MINI_PREVIEW (op->priv->preview), first);
+                gl_mini_preview_set_last     (GL_MINI_PREVIEW (op->priv->preview), last);
+
         }
 }
 
@@ -519,7 +556,8 @@ simple_first_spin_cb (GtkSpinButton     *spinbutton,
                                    first, op->priv->labels_per_sheet);
 
         /* Update preview. */
-        gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview), first, last);
+        gl_mini_preview_set_first    (GL_MINI_PREVIEW (op->priv->preview), first);
+        gl_mini_preview_set_last     (GL_MINI_PREVIEW (op->priv->preview), last);
 
 }
 
@@ -541,7 +579,8 @@ simple_last_spin_cb (GtkSpinButton     *spinbutton,
                                    1, last);
 
         /* Update preview. */
-        gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview), first, last);
+        gl_mini_preview_set_first    (GL_MINI_PREVIEW (op->priv->preview), first);
+        gl_mini_preview_set_last     (GL_MINI_PREVIEW (op->priv->preview), last);
 
 }
 
@@ -582,10 +621,25 @@ preview_pressed_cb (glMiniPreview     *preview,
                         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (op->priv->simple_labels_radio), TRUE);
                 }
 
-                /* Update preview. */
-                gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview), first, last);
-
         }
+
+        gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview), first, last);
+
+}
+
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Preview "pressed" callback                                     */
+/*--------------------------------------------------------------------------*/
+static void
+preview_released_cb (glMiniPreview     *preview,
+                     gint               first,
+                     gint               last,
+                     glPrintOpDialog   *op)
+{
+
+        gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview), 0, 0);
+
 }
 
 
@@ -594,16 +648,16 @@ preview_pressed_cb (glMiniPreview     *preview,
 /*--------------------------------------------------------------------------*/
 static void
 merge_spin_cb (GtkSpinButton     *spinbutton,
-                     glPrintOpDialog   *op)
+               glPrintOpDialog   *op)
 {
-        gint first, last, n_copies;
+        gint first, n_copies;
 
         first = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->merge_first_spin));
 
         n_copies = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->merge_copies_spin));
-        last = first + (n_copies * op->priv->n_records) - 1;
 
-        gl_mini_preview_highlight_range (GL_MINI_PREVIEW(op->priv->preview), first, last );
+        gl_mini_preview_set_first (GL_MINI_PREVIEW(op->priv->preview), first);
+        gl_mini_preview_set_n_copies (GL_MINI_PREVIEW(op->priv->preview), n_copies);
 
         gtk_widget_set_sensitive (op->priv->merge_collate_check, (n_copies > 1));
         gtk_widget_set_sensitive (op->priv->merge_collate_image, (n_copies > 1));
@@ -621,11 +675,13 @@ merge_collate_check_cb (GtkToggleButton   *togglebutton,
 
         if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (op->priv->merge_collate_check)) )
         {
-                pixbuf = gdk_pixbuf_new_from_xpm_data ( (const char **)collate_xpm);
+                pixbuf = gdk_pixbuf_new_from_xpm_data ( (const char **)nocollate_xpm);
+                gl_mini_preview_set_collate_flag (GL_MINI_PREVIEW (op->priv->preview), TRUE);
         }
         else
         {
-                pixbuf = gdk_pixbuf_new_from_xpm_data ( (const char **)nocollate_xpm);
+                pixbuf = gdk_pixbuf_new_from_xpm_data ( (const char **)collate_xpm);
+                gl_mini_preview_set_collate_flag (GL_MINI_PREVIEW (op->priv->preview), FALSE);
         }
 
         gtk_image_set_from_pixbuf (GTK_IMAGE (op->priv->merge_collate_image), pixbuf);
@@ -641,7 +697,6 @@ preview_clicked_cb (glMiniPreview     *preview,
                     glPrintOpDialog   *op)
 {
         gint n_copies;
-        gint last;
 
         if ( op->priv->merge_flag )
         {
@@ -653,12 +708,27 @@ preview_clicked_cb (glMiniPreview     *preview,
                 gtk_widget_set_sensitive (op->priv->merge_collate_check, (n_copies > 1));
                 gtk_widget_set_sensitive (op->priv->merge_collate_image, (n_copies > 1));
 
+        }
+}
 
-                /* Update preview. */
-                last = first + (n_copies * op->priv->n_records) - 1;
-                gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview), first, last);
 
-        }
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Option checkbox "toggled" callback                             */
+/*--------------------------------------------------------------------------*/
+static void
+option_toggled_cb (GtkToggleButton   *togglebutton,
+                   glPrintOpDialog   *op)
+{
+        gboolean flag;
+
+        flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (op->priv->outline_check));
+        gl_mini_preview_set_outline_flag (GL_MINI_PREVIEW (op->priv->preview), flag);
+
+        flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (op->priv->reverse_check));
+        gl_mini_preview_set_reverse_flag (GL_MINI_PREVIEW (op->priv->preview), flag);
+
+        flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (op->priv->crop_marks_check));
+        gl_mini_preview_set_crop_marks_flag (GL_MINI_PREVIEW (op->priv->preview), flag);
 }