]> git.sur5r.net Git - glabels/commitdiff
2007-01-15 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Tue, 16 Jan 2007 03:12:29 +0000 (03:12 +0000)
committerJim Evins <evins@snaught.com>
Tue, 16 Jan 2007 03:12:29 +0000 (03:12 +0000)
* data/glade/Makefile.am:
* data/glade/print-custom-widget.glade:
* src/print-dialog.c:
* src/print-dialog.h:
* src/print.c:
* src/print.h:
* src/template-designer.c: (print_test_cb):
* src/ui-commands.c: (gl_ui_cmd_file_print):
* src/wdgt-print-merge.c: (gl_wdgt_print_merge_get_copies):
* src/wdgt-print-merge.h:
* src/window.c: (gl_window_init):
* src/window.h:
Initial conversion to GtkPrintOperation.
Still to do:
 - Remove font and other libgnomeprint[ui] from elsewhere
 - Add batch initialization of print operation

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

13 files changed:
glabels2/ChangeLog
glabels2/data/glade/Makefile.am
glabels2/data/glade/print-custom-widget.glade [new file with mode: 0644]
glabels2/src/print-dialog.c
glabels2/src/print-dialog.h
glabels2/src/print.c
glabels2/src/print.h
glabels2/src/template-designer.c
glabels2/src/ui-commands.c
glabels2/src/wdgt-print-merge.c
glabels2/src/wdgt-print-merge.h
glabels2/src/window.c
glabels2/src/window.h

index ea1c2215cf47eadc2b38ed82443d06ae484d797f..eba7352995606376dd73bee9f9bb645da2075042 100644 (file)
@@ -1,3 +1,22 @@
+2007-01-15  Jim Evins  <evins@snaught.com>
+
+       * data/glade/Makefile.am:
+       * data/glade/print-custom-widget.glade:
+       * src/print-dialog.c:
+       * src/print-dialog.h:
+       * src/print.c:
+       * src/print.h:
+       * src/template-designer.c: (print_test_cb):
+       * src/ui-commands.c: (gl_ui_cmd_file_print):
+       * src/wdgt-print-merge.c: (gl_wdgt_print_merge_get_copies):
+       * src/wdgt-print-merge.h:
+       * src/window.c: (gl_window_init):
+       * src/window.h:
+               Initial conversion to GtkPrintOperation.
+               Still to do:
+                - Remove font and other libgnomeprint[ui] from elsewhere
+                - Add batch initialization of print operation
+
 2007-01-08  Jim Evins  <evins@snaught.com>
        * configure.in:
                Updated dependencies.  Set version to 2.1.pre4cvs.
index 0e81e6b506575bdea09ef8ee37f84828002d2500..4747c88fb5602d7dc83ac52b2e1e9a991ca11685 100644 (file)
@@ -8,6 +8,7 @@ glade_DATA = \
        template-designer.glade         \
        merge-properties-dialog.glade   \
        property-bar.glade              \
+       print-custom-widget.glade       \
        wdgt-media-select.glade         \
        wdgt-rotate-label.glade         \
        new-label-dialog.glade
diff --git a/glabels2/data/glade/print-custom-widget.glade b/glabels2/data/glade/print-custom-widget.glade
new file mode 100644 (file)
index 0000000..f5063ab
--- /dev/null
@@ -0,0 +1,287 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+
+<widget class="GtkWindow" id="window1">
+  <property name="visible">True</property>
+  <property name="title" translatable="yes">window1</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="focus_on_map">True</property>
+  <property name="urgency_hint">False</property>
+
+  <child>
+    <widget class="GtkVBox" id="print_custom_widget_vbox">
+      <property name="border_width">12</property>
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">12</property>
+
+      <child>
+       <widget class="GtkVBox" id="vbox3">
+         <property name="visible">True</property>
+         <property name="homogeneous">False</property>
+         <property name="spacing">0</property>
+
+         <child>
+           <widget class="GtkFrame" id="simple_frame">
+             <property name="visible">True</property>
+             <property name="label_xalign">0</property>
+             <property name="label_yalign">0.5</property>
+             <property name="shadow_type">GTK_SHADOW_NONE</property>
+
+             <child>
+               <widget class="GtkAlignment" id="alignment1">
+                 <property name="visible">True</property>
+                 <property name="xalign">0.5</property>
+                 <property name="yalign">0.5</property>
+                 <property name="xscale">1</property>
+                 <property name="yscale">1</property>
+                 <property name="top_padding">0</property>
+                 <property name="bottom_padding">0</property>
+                 <property name="left_padding">12</property>
+                 <property name="right_padding">0</property>
+
+                 <child>
+                   <widget class="GtkVBox" id="copies_vbox">
+                     <property name="visible">True</property>
+                     <property name="homogeneous">False</property>
+                     <property name="spacing">0</property>
+
+                     <child>
+                       <placeholder/>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+
+             <child>
+               <widget class="GtkLabel" id="label2">
+                 <property name="visible">True</property>
+                 <property name="label" translatable="yes">&lt;b&gt;Print control (Simple)&lt;/b&gt;</property>
+                 <property name="use_underline">False</property>
+                 <property name="use_markup">True</property>
+                 <property name="justify">GTK_JUSTIFY_LEFT</property>
+                 <property name="wrap">False</property>
+                 <property name="selectable">False</property>
+                 <property name="xalign">0.5</property>
+                 <property name="yalign">0.5</property>
+                 <property name="xpad">0</property>
+                 <property name="ypad">0</property>
+                 <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+                 <property name="width_chars">-1</property>
+                 <property name="single_line_mode">False</property>
+                 <property name="angle">0</property>
+               </widget>
+               <packing>
+                 <property name="type">label_item</property>
+               </packing>
+             </child>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">True</property>
+             <property name="fill">True</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkFrame" id="merge_frame">
+             <property name="visible">True</property>
+             <property name="label_xalign">0</property>
+             <property name="label_yalign">0.5</property>
+             <property name="shadow_type">GTK_SHADOW_NONE</property>
+
+             <child>
+               <widget class="GtkAlignment" id="alignment2">
+                 <property name="visible">True</property>
+                 <property name="xalign">0.5</property>
+                 <property name="yalign">0.5</property>
+                 <property name="xscale">1</property>
+                 <property name="yscale">1</property>
+                 <property name="top_padding">0</property>
+                 <property name="bottom_padding">0</property>
+                 <property name="left_padding">12</property>
+                 <property name="right_padding">0</property>
+
+                 <child>
+                   <widget class="GtkVBox" id="prmerge_vbox">
+                     <property name="visible">True</property>
+                     <property name="homogeneous">False</property>
+                     <property name="spacing">0</property>
+
+                     <child>
+                       <placeholder/>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+
+             <child>
+               <widget class="GtkLabel" id="label3">
+                 <property name="visible">True</property>
+                 <property name="label" translatable="yes">&lt;b&gt;Print control (Merge)&lt;/b&gt;</property>
+                 <property name="use_underline">False</property>
+                 <property name="use_markup">True</property>
+                 <property name="justify">GTK_JUSTIFY_LEFT</property>
+                 <property name="wrap">False</property>
+                 <property name="selectable">False</property>
+                 <property name="xalign">0.5</property>
+                 <property name="yalign">0.5</property>
+                 <property name="xpad">0</property>
+                 <property name="ypad">0</property>
+                 <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+                 <property name="width_chars">-1</property>
+                 <property name="single_line_mode">False</property>
+                 <property name="angle">0</property>
+               </widget>
+               <packing>
+                 <property name="type">label_item</property>
+               </packing>
+             </child>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">True</property>
+             <property name="fill">True</property>
+           </packing>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">False</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkFrame" id="frame3">
+         <property name="visible">True</property>
+         <property name="label_xalign">0</property>
+         <property name="label_yalign">0.5</property>
+         <property name="shadow_type">GTK_SHADOW_NONE</property>
+
+         <child>
+           <widget class="GtkAlignment" id="alignment3">
+             <property name="visible">True</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.5</property>
+             <property name="xscale">1</property>
+             <property name="yscale">1</property>
+             <property name="top_padding">0</property>
+             <property name="bottom_padding">0</property>
+             <property name="left_padding">12</property>
+             <property name="right_padding">0</property>
+
+             <child>
+               <widget class="GtkVBox" id="vbox2">
+                 <property name="visible">True</property>
+                 <property name="homogeneous">False</property>
+                 <property name="spacing">0</property>
+
+                 <child>
+                   <widget class="GtkCheckButton" id="outline_check">
+                     <property name="visible">True</property>
+                     <property name="can_focus">True</property>
+                     <property name="label" translatable="yes">print outlines (to test printer alignment)</property>
+                     <property name="use_underline">True</property>
+                     <property name="relief">GTK_RELIEF_NORMAL</property>
+                     <property name="focus_on_click">True</property>
+                     <property name="active">False</property>
+                     <property name="inconsistent">False</property>
+                     <property name="draw_indicator">True</property>
+                   </widget>
+                   <packing>
+                     <property name="padding">0</property>
+                     <property name="expand">False</property>
+                     <property name="fill">False</property>
+                   </packing>
+                 </child>
+
+                 <child>
+                   <widget class="GtkCheckButton" id="reverse_check">
+                     <property name="visible">True</property>
+                     <property name="can_focus">True</property>
+                     <property name="label" translatable="yes">print in reverse (i.e. a mirror image)</property>
+                     <property name="use_underline">True</property>
+                     <property name="relief">GTK_RELIEF_NORMAL</property>
+                     <property name="focus_on_click">True</property>
+                     <property name="active">False</property>
+                     <property name="inconsistent">False</property>
+                     <property name="draw_indicator">True</property>
+                   </widget>
+                   <packing>
+                     <property name="padding">0</property>
+                     <property name="expand">False</property>
+                     <property name="fill">False</property>
+                   </packing>
+                 </child>
+
+                 <child>
+                   <widget class="GtkCheckButton" id="crop_marks_check">
+                     <property name="visible">True</property>
+                     <property name="can_focus">True</property>
+                     <property name="label" translatable="yes">print crop marks</property>
+                     <property name="use_underline">True</property>
+                     <property name="relief">GTK_RELIEF_NORMAL</property>
+                     <property name="focus_on_click">True</property>
+                     <property name="active">False</property>
+                     <property name="inconsistent">False</property>
+                     <property name="draw_indicator">True</property>
+                   </widget>
+                   <packing>
+                     <property name="padding">0</property>
+                     <property name="expand">False</property>
+                     <property name="fill">False</property>
+                   </packing>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkLabel" id="label4">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">&lt;b&gt;Options&lt;/b&gt;</property>
+             <property name="use_underline">False</property>
+             <property name="use_markup">True</property>
+             <property name="justify">GTK_JUSTIFY_LEFT</property>
+             <property name="wrap">False</property>
+             <property name="selectable">False</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.5</property>
+             <property name="xpad">0</property>
+             <property name="ypad">0</property>
+             <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+             <property name="width_chars">-1</property>
+             <property name="single_line_mode">False</property>
+             <property name="angle">0</property>
+           </widget>
+           <packing>
+             <property name="type">label_item</property>
+           </packing>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">True</property>
+         <property name="fill">True</property>
+       </packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
+</glade-interface>
index 1b574c1e4ecc3d7387e0e5f406e9887f484f80bd..5051da21c308132d8d69228c1be974105124bd86 100644 (file)
@@ -1,11 +1,11 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
 
 /*
  *  (GLABELS) Label and Business Card Creation program for GNOME
  *
  *  print-dialog.c:  Print dialog module
  *
- *  Copyright (C) 2001-2003  Jim Evins <evins@snaught.com>.
+ *  Copyright (C) 2001-2007  Jim Evins <evins@snaught.com>.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #include "print-dialog.h"
 
 #include <glib/gi18n.h>
+#include <glade/glade-xml.h>
 #include <math.h>
 #include <time.h>
 #include <ctype.h>
-#include <gtk/gtkdialog.h>
-#include <gtk/gtknotebook.h>
-#include <libgnomeprintui/gnome-print-dialog.h>
-#include <libgnomeprint/gnome-print-job.h>
-#include <libgnomeprintui/gnome-print-job-preview.h>
+#include <gtk/gtktogglebutton.h>
 
 #include "print.h"
 #include "label.h"
 
 #include "debug.h"
 
-/***************************************************************************/
-/* FIXME: GnomePrinterSelector is not public in libgnomeprintui-2.2.       */
-/*                                                                         */
-/* I know that I'm asking for trouble, but here are standin prototypes:    */
-GtkWidget          *gnome_printer_selector_new (GnomePrintConfig *config);
-GnomePrintConfig   *gnome_printer_selector_get_config (GtkWidget *psel);
-#define GNOME_PRINTER_SELECTOR(x) (x)
-/***************************************************************************/
-
 /*===========================================*/
 /* Private data types                        */
 /*===========================================*/
@@ -60,17 +48,34 @@ struct _glPrintDialogPrivate {
 
        glLabel   *label;
 
+       GladeXML  *gui;
+
        GtkWidget *simple_frame;
+       GtkWidget *copies_vbox;
        GtkWidget *copies;
 
        GtkWidget *merge_frame;
+       GtkWidget *prmerge_vbox;
        GtkWidget *prmerge;
 
        GtkWidget *outline_check;
        GtkWidget *reverse_check;
        GtkWidget *crop_marks_check;
 
-       GtkWidget *printer_select;
+        gboolean   force_outline_flag;
+
+       gboolean   outline_flag;
+        gboolean   reverse_flag;
+        gboolean   crop_marks_flag;
+        gboolean   merge_flag;
+        gboolean   collate_flag;
+
+       gint       first;
+        gint       last;
+        gint       n_sheets;
+        gint       n_copies;
+
+        glPrintState state;
 };
 
 
@@ -78,58 +83,35 @@ struct _glPrintDialogPrivate {
 /* Private globals                           */
 /*===========================================*/
 
-static GtkDialogClass* parent_class = NULL;
+static GtkPrintOperationClass* parent_class = NULL;
 
 /*===========================================*/
 /* Local function prototypes                 */
 /*===========================================*/
 
-static void       gl_print_dialog_class_init      (glPrintDialogClass *klass);
-static void       gl_print_dialog_init            (glPrintDialog      *dlg);
-static void       gl_print_dialog_finalize        (GObject            *object);
+static void     gl_print_dialog_class_init    (glPrintDialogClass *klass);
+static void     gl_print_dialog_init          (glPrintDialog      *dialog);
+static void     gl_print_dialog_finalize      (GObject            *object);
 
-static void       gl_print_dialog_construct       (glPrintDialog      *dialog,
-                                                  glLabel            *label,
-                                                  GtkWindow          *win);
+static void     gl_print_dialog_construct     (glPrintDialog      *dialog,
+                                               glLabel            *label);
 
-static GtkWidget *job_page_new                    (glPrintDialog      *dialog,
-                                                  glLabel            *label);
 
-static GtkWidget *printer_page_new                (glPrintDialog      *dialog,
-                                                  glLabel            *label);
+static GObject *create_custom_widget_cb       (GtkPrintOperation *operation,
+                                               gpointer           user_data);
 
-static void       merge_changed_cb                (glLabel            *label,
-                                                  glPrintDialog      *dialog);
+static void     custom_widget_apply_cb        (GtkPrintOperation *operation,
+                                               GtkWidget         *widget,
+                                               gpointer           user_data);
 
-static void       size_changed_cb                 (glLabel            *label,
-                                                  glPrintDialog      *dialog);
+static void     begin_print_cb                (GtkPrintOperation *operation,
+                                               GtkPrintContext   *context,
+                                               gpointer           user_data);
 
-static void       delete_event_cb                 (glPrintDialog      *dialog,
-                                                  gpointer            user_data);
-
-static void       print_response_cb               (glPrintDialog      *dialog,
-                                                  gint                response,
-                                                  glLabel            *label);
-
-static void       print_sheets                    (GnomePrintConfig   *config,
-                                                  glLabel            *label,
-                                                  gboolean            preview_flag,
-                                                  gint                n_sheets,
-                                                  gint                first,
-                                                  gint                last,
-                                                  gboolean            outline_flag,
-                                                  gboolean            reverse_flag,
-                                                  gboolean            crop_marks_flag);
-
-static void      print_sheets_merge               (GnomePrintConfig   *config,
-                                                  glLabel            *label,
-                                                  gboolean            preview_flag,
-                                                  gint                n_copies,
-                                                  gint                first,
-                                                  gboolean            collate_flag,
-                                                  gboolean            outline_flag,
-                                                  gboolean            reverse_flag,
-                                                  gboolean            crop_marks_flag);
+static void     draw_page_cb                  (GtkPrintOperation *operation,
+                                               GtkPrintContext   *context,
+                                               int                page_nr,
+                                               gpointer           user_data);
 
 
 
@@ -158,7 +140,7 @@ gl_print_dialog_get_type (void)
                        NULL
                };
 
-               type = g_type_register_static (GTK_TYPE_DIALOG,
+               type = g_type_register_static (GTK_TYPE_PRINT_OPERATION,
                                               "glPrintDialog", &info, 0);
        }
 
@@ -169,12 +151,13 @@ static void
 gl_print_dialog_class_init (glPrintDialogClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       GtkPrintOperationClass *print_class = GTK_PRINT_OPERATION_CLASS (klass);
 
        gl_debug (DEBUG_PRINT, "");
        
        parent_class = g_type_class_peek_parent (klass);
 
-       object_class->finalize = gl_print_dialog_finalize;      
+       object_class->finalize = gl_print_dialog_finalize;
 }
 
 static void
@@ -184,31 +167,14 @@ gl_print_dialog_init (glPrintDialog *dialog)
 
        gl_debug (DEBUG_PRINT, "");
 
+       gtk_print_operation_set_use_full_page (GTK_PRINT_OPERATION (dialog),
+                                              TRUE);
+
+        gtk_print_operation_set_unit (GTK_PRINT_OPERATION (dialog),
+                                      GTK_UNIT_POINTS);
+
        dialog->priv = g_new0 (glPrintDialogPrivate, 1);
 
-       gtk_container_set_border_width (GTK_CONTAINER(dialog), GL_HIG_PAD2);
-
-       gtk_dialog_set_has_separator (GTK_DIALOG(dialog), FALSE);
-       gtk_dialog_add_buttons (GTK_DIALOG(dialog),
-                               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                               GTK_STOCK_PRINT,  GNOME_PRINT_DIALOG_RESPONSE_PRINT,
-                               NULL);
-
-       pp_button =
-               gtk_dialog_add_button (GTK_DIALOG (dialog),
-                                      GTK_STOCK_PRINT_PREVIEW, GNOME_PRINT_DIALOG_RESPONSE_PREVIEW);
-       gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (dialog)->action_area), 
-                                           pp_button, TRUE);
-       gtk_dialog_set_default_response (GTK_DIALOG (dialog),
-                                        GNOME_PRINT_DIALOG_RESPONSE_PRINT);
-
-        gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
-
-       g_signal_connect (G_OBJECT(dialog),
-                         "delete_event",
-                         G_CALLBACK (delete_event_cb),
-                         NULL);
-                                                                                
 }
 
 static void 
@@ -236,19 +202,18 @@ gl_print_dialog_finalize (GObject *object)
 }
 
 /*****************************************************************************/
-/* NEW object properties dialog.                                              */
+/* NEW print dialog.                                                         */
 /*****************************************************************************/
-GtkWidget *
-gl_print_dialog_new (glLabel      *label,
-                    GtkWindow    *win)
+glPrintDialog *
+gl_print_dialog_new (glLabel      *label)
 {
-       GtkWidget *dialog;
+       glPrintDialog *dialog;
 
        gl_debug (DEBUG_PRINT, "");
 
-       dialog = GTK_WIDGET (g_object_new (GL_TYPE_PRINT_DIALOG, NULL));
+       dialog = GL_PRINT_DIALOG (g_object_new (GL_TYPE_PRINT_DIALOG, NULL));
 
-       gl_print_dialog_construct (GL_PRINT_DIALOG(dialog), label, win);
+       gl_print_dialog_construct (GL_PRINT_DIALOG(dialog), label);
 
        return dialog;
 }
@@ -258,152 +223,80 @@ gl_print_dialog_new (glLabel      *label,
 /*--------------------------------------------------------------------------*/
 static void
 gl_print_dialog_construct (glPrintDialog      *dialog,
-                          glLabel            *label,
-                          GtkWindow          *win)
+                          glLabel            *label)
 {
-       GtkWidget *notebook, *page;
-       gchar     *name, *title;
-
-       gl_debug (DEBUG_PRINT, "START");
-
-       g_return_if_fail (label && GL_IS_LABEL(label));
-
-       dialog->priv->label = GL_LABEL(g_object_ref (G_OBJECT(label)));
-
-       name = gl_label_get_short_name (label);
-       title = g_strdup_printf ("%s \"%s\"", _("Print"), name);
-       g_free (name);
-
-       gtk_window_set_title (GTK_WINDOW(dialog), title);
-       if (win) {
-               gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(win));
-               gtk_window_set_destroy_with_parent (GTK_WINDOW(dialog), TRUE);
-       }
-
-       notebook = gtk_notebook_new ();
-       gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, FALSE, FALSE, 0);
-
-       /* ----- Create Job notebook page ----- */
-       page = job_page_new (dialog, label);
-       gtk_notebook_append_page (GTK_NOTEBOOK(notebook), page,
-                                 gtk_label_new_with_mnemonic (_("_Job")));
+       dialog->priv->label              = label;
+       dialog->priv->force_outline_flag = FALSE;
 
-       /* ----- Create Printer notebook page ----- */
-       page = printer_page_new (dialog, label);
-       gtk_notebook_append_page (GTK_NOTEBOOK(notebook), page,
-                                 gtk_label_new_with_mnemonic (_("P_rinter")));
+       gtk_print_operation_set_custom_tab_label ( GTK_PRINT_OPERATION (dialog),
+                                                  _("Labels"));
 
-       g_signal_connect (G_OBJECT(dialog), "response",
-                         G_CALLBACK (print_response_cb), label);
+       g_signal_connect (G_OBJECT (dialog), "create-custom-widget",
+                         G_CALLBACK (create_custom_widget_cb), label);
 
-       gtk_widget_show_all (GTK_WIDGET (dialog));
+       g_signal_connect (G_OBJECT (dialog), "custom-widget-apply",
+                         G_CALLBACK (custom_widget_apply_cb), label);
 
-       merge_changed_cb (GL_LABEL(label), dialog);
+       g_signal_connect (G_OBJECT (dialog), "begin-print",
+                         G_CALLBACK (begin_print_cb), label);
 
-       g_free (title);
-
-
-       gl_debug (DEBUG_PRINT, "END");
+       g_signal_connect (G_OBJECT (dialog), "draw-page",
+                         G_CALLBACK (draw_page_cb), label);
 }
 
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  Create "Job" page.                                              */
-/*---------------------------------------------------------------------------*/
-static GtkWidget *
-job_page_new (glPrintDialog *dialog,
-             glLabel       *label)
-{
-       GtkWidget *vbox;
-       GtkWidget *wframe;
-
-       vbox = gl_hig_vbox_new (GL_HIG_VBOX_OUTER);
-
-       /* ----------- Add simple-copies widget ------------ */
-       dialog->priv->simple_frame = gl_hig_category_new (_("Copies"));
-       gl_hig_vbox_add_widget (GL_HIG_VBOX(vbox), dialog->priv->simple_frame);
-
-       dialog->priv->copies = gl_wdgt_print_copies_new (label);
-       gl_hig_category_add_widget (GL_HIG_CATEGORY(dialog->priv->simple_frame),
-                                   dialog->priv->copies);
-
-       /* ------- Add merge control widget ------------ */
-       dialog->priv->merge_frame = gl_hig_category_new (_("Document merge control"));
-       gl_hig_vbox_add_widget (GL_HIG_VBOX(vbox), dialog->priv->merge_frame);
-
-       dialog->priv->prmerge = gl_wdgt_print_merge_new (label);
-       gl_hig_category_add_widget (GL_HIG_CATEGORY(dialog->priv->merge_frame),
-                                   dialog->priv->prmerge);
-
-       /* ----------- Add custom print options area ------------ */
-       wframe = gl_hig_category_new (_("Options"));
-       gl_hig_vbox_add_widget (GL_HIG_VBOX(vbox), wframe);
-
-       /* add Outline check button */
-       dialog->priv->outline_check =
-           gtk_check_button_new_with_label (
-                   _("print outlines (to test printer alignment)"));
-       gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), dialog->priv->outline_check);
-       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->outline_check),
-                                     FALSE);
-
-       /* add Reverse check button */
-       dialog->priv->reverse_check =
-           gtk_check_button_new_with_label (
-                   _("print in reverse (i.e. a mirror image)"));
-       gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), dialog->priv->reverse_check);
-       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->reverse_check),
-                                     FALSE);
-
-       /* add Crop marks check button */
-       dialog->priv->crop_marks_check =
-           gtk_check_button_new_with_label (_("print crop marks"));
-       gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), dialog->priv->crop_marks_check);
-       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->crop_marks_check),
-                                     FALSE);
-
-       g_signal_connect (G_OBJECT(label), "merge_changed",
-                         G_CALLBACK (merge_changed_cb), dialog);
-
-       g_signal_connect (G_OBJECT(label), "size_changed",
-                         G_CALLBACK (size_changed_cb), dialog);
-
-       return vbox;
-}
-
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  Create "Printer" page.                                          */
-/*---------------------------------------------------------------------------*/
-static GtkWidget *
-printer_page_new (glPrintDialog *dialog,
-                 glLabel       *label)
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  "Create custom widget" callback                                */
+/*--------------------------------------------------------------------------*/
+static GObject *
+create_custom_widget_cb (GtkPrintOperation *operation,
+                        gpointer           user_data)
 {
-       GtkWidget *vbox;
-       GtkWidget *printer_select;
+       glPrintDialog *dialog = GL_PRINT_DIALOG (operation);
+       glLabel       *label  = GL_LABEL (user_data);
 
-       vbox = gl_hig_vbox_new (GL_HIG_VBOX_OUTER);
+       GtkWidget     *vbox;
 
-       /* FIXME: GnomePrinterSelector is not public in libgnomeprintui-2.2 */
-       dialog->priv->printer_select =
-               gnome_printer_selector_new (gnome_print_config_default ());
-       gtk_widget_show (dialog->priv->printer_select);
-       gtk_box_pack_start (GTK_BOX(vbox), dialog->priv->printer_select, TRUE, TRUE, 0);
+        glMerge       *merge = NULL;
 
-       return vbox;
-}
+       dialog->priv->gui = glade_xml_new (GLABELS_GLADE_DIR "print-custom-widget.glade",
+                                          "print_custom_widget_vbox",
+                                          NULL);
 
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  "merge_changed" callback.                                      */
-/*--------------------------------------------------------------------------*/
-static void
-merge_changed_cb (glLabel            *label,
-                 glPrintDialog      *dialog)
-{
-       glMerge   *merge;
-       gint       n_records;
+       if (!dialog->priv->gui) {
+               g_warning ("Could not open print-dialog.glade, reinstall glabels!");
+               return;
+       }
 
-       gl_debug (DEBUG_PRINT, "START");
+       vbox = glade_xml_get_widget (dialog->priv->gui, "print_custom_widget_vbox");
 
-       merge = gl_label_get_merge (label);
+       /* ----- Simple print control ----- */
+       dialog->priv->simple_frame = glade_xml_get_widget (dialog->priv->gui,
+                                                          "simple_frame");
+       dialog->priv->copies_vbox  = glade_xml_get_widget (dialog->priv->gui,
+                                                          "copies_vbox");
+       dialog->priv->copies = gl_wdgt_print_copies_new (label);
+       gtk_box_pack_start (GTK_BOX(dialog->priv->copies_vbox),
+                           dialog->priv->copies, FALSE, FALSE, 0);
+
+       /* ----- Merge print control ----- */
+       dialog->priv->merge_frame  = glade_xml_get_widget (dialog->priv->gui,
+                                                          "merge_frame");
+       dialog->priv->prmerge_vbox = glade_xml_get_widget (dialog->priv->gui,
+                                                          "prmerge_vbox");
+       dialog->priv->prmerge = gl_wdgt_print_merge_new (label);
+       gtk_box_pack_start (GTK_BOX(dialog->priv->prmerge_vbox),
+                           dialog->priv->prmerge, FALSE, FALSE, 0);
+
+       /* ----- Options ----------------- */
+       dialog->priv->outline_check    = glade_xml_get_widget (dialog->priv->gui,
+                                                              "outline_check");
+       dialog->priv->reverse_check    = glade_xml_get_widget (dialog->priv->gui,
+                                                              "reverse_check");
+       dialog->priv->crop_marks_check = glade_xml_get_widget (dialog->priv->gui,
+                                                              "crop_marks_check");
+
+        /* ---- Activate either simple or merge print control widgets. ---- */
+        merge = gl_label_get_merge (dialog->priv->label);
        if (merge == NULL) {
 
                gtk_widget_show_all (dialog->priv->simple_frame);
@@ -411,7 +304,7 @@ merge_changed_cb (glLabel            *label,
 
        } else {
 
-               n_records = gl_merge_get_record_count( merge );
+               gint n_records = gl_merge_get_record_count( merge );
                gl_wdgt_print_merge_set_copies (GL_WDGT_PRINT_MERGE(dialog->priv->prmerge),
                                                1, 1, n_records, FALSE);
                g_object_unref (G_OBJECT(merge));
@@ -420,191 +313,136 @@ merge_changed_cb (glLabel            *label,
                gtk_widget_show_all (dialog->priv->merge_frame);
        }
 
-       gl_debug (DEBUG_PRINT, "END");
-}
+        /* --- Do we need to force the outline flag --- */
+        if (dialog->priv->force_outline_flag)
+        {
+                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(dialog->priv->outline_check),
+                                              TRUE);
 
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  "size_changed" (template changed) callback.                    */
-/*--------------------------------------------------------------------------*/
-static void
-size_changed_cb (glLabel            *label,
-                glPrintDialog      *dialog)
-{
-       gl_debug (DEBUG_PRINT, "START");
-
-       /* Remove and unref original widgets. */
-       gtk_container_remove (GTK_CONTAINER(GL_HIG_CATEGORY(dialog->priv->simple_frame)->vbox),
-                             dialog->priv->copies);
-       gtk_container_remove (GTK_CONTAINER(GL_HIG_CATEGORY(dialog->priv->merge_frame)->vbox),
-                             dialog->priv->prmerge);
-
-       /* Create new widgets based on updated label and install */
-       dialog->priv->copies = gl_wdgt_print_copies_new (label);
-       gl_hig_category_add_widget (GL_HIG_CATEGORY(dialog->priv->simple_frame),
-                                   dialog->priv->copies);
-       dialog->priv->prmerge = gl_wdgt_print_merge_new (label);
-       gl_hig_category_add_widget (GL_HIG_CATEGORY(dialog->priv->merge_frame),
-                                   dialog->priv->prmerge);
-
-       /* Update these widgets. */
-       merge_changed_cb (label, dialog);
+                gtk_widget_set_sensitive (dialog->priv->outline_check, FALSE);
+                gtk_widget_set_sensitive (dialog->priv->reverse_check, FALSE);
+                gtk_widget_set_sensitive (dialog->priv->crop_marks_check, FALSE);
+        }
 
-       gl_debug (DEBUG_PRINT, "END");
+       return G_OBJECT (vbox);
 }
 
 /*--------------------------------------------------------------------------*/
-/* PRIVATE.  delete event callback.                                         */
+/* PRIVATE.  "Custom widget apply" callback                                 */
 /*--------------------------------------------------------------------------*/
 static void
-delete_event_cb (glPrintDialog *dialog,
-                 gpointer       user_data)
+custom_widget_apply_cb (GtkPrintOperation *operation,
+                        GtkWidget         *widget,
+                        gpointer           user_data)
 {
-       gl_debug (DEBUG_PRINT, "START");
+        glPrintDialog *dialog = GL_PRINT_DIALOG (operation);
+        glMerge       *merge = NULL;
+
+
+        dialog->priv->outline_flag =
+                gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+                                              (dialog->priv->outline_check));
+        dialog->priv->reverse_flag =
+                gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+                                              (dialog->priv->reverse_check));
+        dialog->priv->crop_marks_flag =
+                gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
+                                              (dialog->priv->crop_marks_check));
+
+        merge = gl_label_get_merge (dialog->priv->label);
+
+        if (merge == NULL)
+        {
+
+                dialog->priv->merge_flag = FALSE;
+                gl_wdgt_print_copies_get_range (GL_WDGT_PRINT_COPIES (dialog->priv->copies),
+                                                &dialog->priv->n_sheets,
+                                                &dialog->priv->first,
+                                                &dialog->priv->last);
+        }
+        else
+        {
+
+                dialog->priv->merge_flag = TRUE;
+                gl_wdgt_print_merge_get_copies (GL_WDGT_PRINT_MERGE (dialog->priv->prmerge),
+                                                &dialog->priv->n_copies,
+                                                &dialog->priv->first,
+                                                &dialog->priv->collate_flag,
+                                                &dialog->priv->n_sheets);
+                g_object_unref (G_OBJECT(merge));
+        }
 
-       gtk_widget_hide (GTK_WIDGET(dialog));
-
-       gl_debug (DEBUG_PRINT, "END");
 }
 
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  Print "response" callback.                                      */
-/*---------------------------------------------------------------------------*/
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  "Begin print" callback                                         */
+/*--------------------------------------------------------------------------*/
 static void
-print_response_cb (glPrintDialog *dialog,
-                  gint           response,
-                  glLabel       *label)
+begin_print_cb (GtkPrintOperation *operation,
+               GtkPrintContext   *context,
+               gpointer           user_data)
 {
-       GnomePrintConfig *config;
-       glMerge          *merge;
-       gboolean          outline_flag, reverse_flag, crop_marks_flag, collate_flag;
-       gint              first, last, n_sheets, n_copies;
-
-       switch (response) {
-
-       case GNOME_PRINT_DIALOG_RESPONSE_PRINT:
-       case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW:
-
-               /* FIXME: GnomePrinterSelector is not public in libgnomeprintui-2.2. */
-               config = gnome_printer_selector_get_config (GNOME_PRINTER_SELECTOR(dialog->priv->printer_select));
-
-               outline_flag =
-                       gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
-                                                     (dialog->priv->outline_check));
-               reverse_flag =
-                       gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
-                                                     (dialog->priv->reverse_check));
-               crop_marks_flag =
-                       gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
-                                                     (dialog->priv->crop_marks_check));
-
-               merge = gl_label_get_merge (label);
-
-               if (merge == NULL) {
-
-                       gl_wdgt_print_copies_get_range (GL_WDGT_PRINT_COPIES (dialog->priv->copies),
-                                                       &n_sheets, &first, &last);
-                       print_sheets (config, label,
-                                     (response == GNOME_PRINT_DIALOG_RESPONSE_PREVIEW),
-                                     n_sheets, first, last,
-                                     outline_flag, reverse_flag, crop_marks_flag);
-
-               } else {
-
-                       gl_wdgt_print_merge_get_copies (GL_WDGT_PRINT_MERGE (dialog->priv->prmerge),
-                                                       &n_copies, &first,
-                                                       &collate_flag);
-                       print_sheets_merge (config, label,
-                                           (response == GNOME_PRINT_DIALOG_RESPONSE_PREVIEW),
-                                           n_copies, first,
-                                           collate_flag,
-                                           outline_flag,
-                                           reverse_flag,
-                                           crop_marks_flag);
-                       g_object_unref (G_OBJECT(merge));
-               }
-               break;
-
-       default:
-               break;
+        glPrintDialog *dialog = GL_PRINT_DIALOG (operation);
 
-       }
+        gtk_print_operation_set_n_pages (operation, dialog->priv->n_sheets);
 
-       gtk_widget_hide (GTK_WIDGET(dialog));
 }
 
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  print the sheets                                                */
-/*---------------------------------------------------------------------------*/
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  "Draw page" callback.                                          */
+/*--------------------------------------------------------------------------*/
 static void
-print_sheets (GnomePrintConfig *config,
-             glLabel          *label,
-             gboolean          preview_flag,
-             gint              n_sheets,
-             gint              first,
-             gint              last,
-             gboolean          outline_flag,
-             gboolean          reverse_flag,
-             gboolean          crop_marks_flag)
+draw_page_cb (GtkPrintOperation *operation,
+             GtkPrintContext   *context,
+             int                page_nr,
+             gpointer           user_data)
 {
-       GnomePrintJob *job;
-       glPrintFlags   flags;
-
-       job = gnome_print_job_new (config);
-       flags.outline = outline_flag;
-       flags.reverse = reverse_flag;
-       flags.crop_marks = crop_marks_flag;
-       gl_print_simple (job, label, n_sheets, first, last, &flags);
-       gnome_print_job_close (job);
-
-       if (preview_flag) {
-               GtkWidget *preview_widget =
-                   gnome_print_job_preview_new (job, (guchar *)_("Print preview"));
-               gtk_widget_show (GTK_WIDGET (preview_widget));
-       } else {
-               gnome_print_job_print (job);
-       }
-
-       g_object_unref (G_OBJECT (job));
+        glPrintDialog *dialog = GL_PRINT_DIALOG (operation);
+        cairo_t       *cr;
+
+        cr = gtk_print_context_get_cairo_context (context);
+
+        if (!dialog->priv->merge_flag)
+        {
+                gl_print_simple_sheet (dialog->priv->label,
+                                       cr,
+                                       page_nr,
+                                       dialog->priv->n_sheets,
+                                       dialog->priv->first,
+                                       dialog->priv->last,
+                                       dialog->priv->outline_flag,
+                                       dialog->priv->reverse_flag,
+                                       dialog->priv->crop_marks_flag);
+        }
+        else
+        {
+                if (dialog->priv->collate_flag)
+                {
+                        gl_print_collated_merge_sheet (dialog->priv->label,
+                                                       cr,
+                                                       page_nr,
+                                                       dialog->priv->n_copies,
+                                                       dialog->priv->first,
+                                                       dialog->priv->outline_flag,
+                                                       dialog->priv->reverse_flag,
+                                                       dialog->priv->crop_marks_flag,
+                                                       &dialog->priv->state);
+                }
+                else
+                {
+                        gl_print_uncollated_merge_sheet (dialog->priv->label,
+                                                         cr,
+                                                         page_nr,
+                                                         dialog->priv->n_copies,
+                                                         dialog->priv->first,
+                                                         dialog->priv->outline_flag,
+                                                         dialog->priv->reverse_flag,
+                                                         dialog->priv->crop_marks_flag,
+                                                         &dialog->priv->state);
+                }
+        }
 }
 
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  print the sheets with merge data                                */
-/*---------------------------------------------------------------------------*/
-static void
-print_sheets_merge (GnomePrintConfig *config,
-                   glLabel          *label,
-                   gboolean          preview_flag,
-                   gint              n_copies,
-                   gint              first,
-                   gboolean          collate_flag,
-                   gboolean          outline_flag,
-                   gboolean          reverse_flag,
-                   gboolean          crop_marks_flag)
-{
-       GnomePrintJob *job;
-       glPrintFlags   flags;
-
-       job = gnome_print_job_new (config);
-       flags.outline = outline_flag;
-       flags.reverse = reverse_flag;
-       flags.crop_marks = crop_marks_flag;
-       if ( collate_flag ) {
-               gl_print_merge_collated (job, label, n_copies, first, &flags);
-       } else {
-               gl_print_merge_uncollated (job, label, n_copies, first, &flags);
-       }
-       gnome_print_job_close (job);
-
-       if (preview_flag) {
-               GtkWidget *preview_widget =
-                   gnome_print_job_preview_new (job, (guchar *)_("Print preview"));
-               gtk_widget_show (GTK_WIDGET (preview_widget));
-       } else {
-               gnome_print_job_print (job);
-       }
-
-       g_object_unref (G_OBJECT (job));
-}
 
 /*****************************************************************************/
 /* Set outline flag/checkbox.                                                */
@@ -612,12 +450,7 @@ print_sheets_merge (GnomePrintConfig *config,
 void
 gl_print_dialog_force_outline_flag (glPrintDialog *dialog)
 {
-       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(dialog->priv->outline_check),
-                                     TRUE);
-
-       gtk_widget_set_sensitive (dialog->priv->outline_check, FALSE);
-       gtk_widget_set_sensitive (dialog->priv->reverse_check, FALSE);
-       gtk_widget_set_sensitive (dialog->priv->crop_marks_check, FALSE);
+        dialog->priv->force_outline_flag = TRUE;
 }
 
 
index b084197dfb75c2ca51507ebff7a0295224b38c54..d41bc4523ba00b964876c24d53daef6c44c4fbc0 100644 (file)
@@ -1,11 +1,11 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
 
 /*
  *  (GLABELS) Label and Business Card Creation program for GNOME
  *
  *  print-dialog.h:  Print dialog module header file
  *
- *  Copyright (C) 2001-2003  Jim Evins <evins@snaught.com>.
+ *  Copyright (C) 2001-2007  Jim Evins <evins@snaught.com>.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -24,9 +24,8 @@
 #ifndef __PRINT_DIALOG_H__
 #define __PRINT_DIALOG_H__
 
-#include <gtk/gtkwindow.h>
-#include <gtk/gtkdialog.h>
-#include "view.h"
+#include <gtk/gtkprintoperation.h>
+#include "label.h"
 
 G_BEGIN_DECLS
 
@@ -45,24 +44,23 @@ typedef struct _glPrintDialogPrivate  glPrintDialogPrivate;
 
 struct _glPrintDialog
 {
-       GtkDialog             parent_instance;
+        GtkPrintOperation     parent_instance;
 
-       glPrintDialogPrivate *priv;
+        glPrintDialogPrivate *priv;
 
 };
 
 struct  _glPrintDialogClass
 {
-       GtkDialogClass        parent_class;
+        GtkPrintOperationClass        parent_class;
 };
 
 
-GType      gl_print_dialog_get_type            (void) G_GNUC_CONST;
+GType          gl_print_dialog_get_type            (void) G_GNUC_CONST;
 
-GtkWidget *gl_print_dialog_new                 (glLabel       *label,
-                                               GtkWindow     *win);
+glPrintDialog *gl_print_dialog_new                 (glLabel       *label);
 
-void       gl_print_dialog_force_outline_flag  (glPrintDialog *dialog);
+void           gl_print_dialog_force_outline_flag  (glPrintDialog *dialog);
 
 G_END_DECLS
 
index 5856a025eacbb0c243febf0fcdf12e179c73fb6c..29dbb6428010ef186ac3eba8dbf0cbfa8152ba27 100644 (file)
@@ -5,7 +5,7 @@
  *
  *  print.c:  Print module
  *
- *  Copyright (C) 2001-2006  Jim Evins <evins@snaught.com>.
+ *  Copyright (C) 2001-2007  Jim Evins <evins@snaught.com>.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -45,8 +45,8 @@
 #include "debug.h"
 
 #define ARC_FINE   2  /* Resolution in degrees of large arcs */
-#define ARC_COURSE 5  /* Resolution in degrees of small arcs */
 
+#define FONT_SCALE (72.0/96.0)
 #define TICK_OFFSET  2.25
 #define TICK_LENGTH 18.0
 
 /*=========================================================================*/
 
 typedef struct _PrintInfo {
-       /* gnome print context */
-       GnomePrintContext *pc;
-
-       /* gnome print configuration */
-       GnomePrintConfig *config;
+        cairo_t    *cr;
 
        /* gLabels Template */
        glTemplate *template;
-       gboolean label_rotate_flag;
+       gboolean    label_rotate_flag;
 
        /* page size */
        gdouble page_width;
        gdouble page_height;
 
-       /* page counter */
-       gint sheet;
 } PrintInfo;
 
 
 /*=========================================================================*/
 /* Private function prototypes.                                            */
 /*=========================================================================*/
-static PrintInfo *print_info_new              (GnomePrintJob    *job,
+static PrintInfo *print_info_new              (cairo_t          *cr,
                                               glLabel          *label);
 
 static void       print_info_free             (PrintInfo       **pi);
 
-
-static void       print_page_begin            (PrintInfo        *pi);
-
-static void       print_page_end              (PrintInfo        *pi);
-
 static void       print_crop_marks            (PrintInfo        *pi);
 
 static void       print_label                 (PrintInfo        *pi,
@@ -142,77 +131,65 @@ static void       clip_punchouts              (PrintInfo        *pi,
                                               glLabel          *label);
 
 
-static void       create_rectangle_path         (GnomePrintContext *pc,
+static void       create_rounded_rectangle_path (cairo_t           *cr,
                                                 gdouble            x0,
                                                 gdouble            y0,
                                                 gdouble            w,
-                                                gdouble            h);
+                                                gdouble            h,
+                                                gdouble            r);
 
-static void       create_ellipse_path           (GnomePrintContext *pc,
+static void       create_ellipse_path           (cairo_t           *cr,
                                                 gdouble            x0,
                                                 gdouble            y0,
                                                 gdouble            rx,
                                                 gdouble            ry);
 
-static void       create_rounded_rectangle_path (GnomePrintContext *pc,
+static void       create_cd_path                (cairo_t           *cr,
                                                 gdouble            x0,
                                                 gdouble            y0,
                                                 gdouble            w,
                                                 gdouble            h,
-                                                gdouble            r);
-
-static void       create_clipped_circle_path    (GnomePrintContext *pc,
-                                                gdouble            x0,
-                                                gdouble            y0,
-                                                gdouble            w,
-                                                gdouble            h,
-                                                gdouble            r);
-
-#ifndef NO_ALPHA_HACK
-static guchar *   get_pixels_as_rgb             (const GdkPixbuf   *pixbuf);
-#endif
+                                                gdouble            r1,
+                                                 gdouble            r2);
 
 \f
 /*****************************************************************************/
-/* Simple (no merge data) print command.                                     */
+/* Print simple sheet (no merge data) command.                               */
 /*****************************************************************************/
 void
-gl_print_simple (GnomePrintJob    *job,
-                glLabel          *label,
-                gint              n_sheets,
-                gint              first,
-                gint              last,
-                glPrintFlags     *flags)
+gl_print_simple_sheet (glLabel          *label,
+                       cairo_t          *cr,
+                       gint              page,
+                       gint              n_sheets,
+                       gint              first,
+                       gint              last,
+                       gboolean          outline_flag,
+                       gboolean          reverse_flag,
+                       gboolean          crop_marks_flag)
 {
        PrintInfo                 *pi;
        const glTemplateLabelType *label_type;
-       gint                       i_sheet, i_label;
+       gint                       i_label;
        glTemplateOrigin          *origins;
 
        gl_debug (DEBUG_PRINT, "START");
 
-       pi         = print_info_new (job, label);
-       label_type = gl_template_get_first_label_type (pi->template);
+       pi         = print_info_new (cr, label);
 
+       label_type = gl_template_get_first_label_type (pi->template);
        origins = gl_template_get_origins (label_type);
 
-       for (i_sheet = 0; i_sheet < n_sheets; i_sheet++) {
-
-               print_page_begin (pi);
-               if (flags->crop_marks) {
-                       print_crop_marks (pi);
-               }
-
-               for (i_label = first - 1; i_label < last; i_label++) {
+        if (crop_marks_flag) {
+                print_crop_marks (pi);
+        }
 
-                       print_label (pi, label,
-                                    origins[i_label].x, origins[i_label].y,
-                                    NULL, flags->outline, flags->reverse);
+        for (i_label = first - 1; i_label < last; i_label++) {
 
-               }
+                print_label (pi, label,
+                             origins[i_label].x, origins[i_label].y,
+                             NULL, outline_flag, reverse_flag);
 
-               print_page_end (pi);
-       }
+        }
 
        g_free (origins);
 
@@ -222,20 +199,24 @@ gl_print_simple (GnomePrintJob    *job,
 }
 
 /*****************************************************************************/
-/* Merge print command (collated copies)                                     */
+/* Print collated merge sheet command                                        */
 /*****************************************************************************/
 void
-gl_print_merge_collated (GnomePrintJob    *job,
-                        glLabel          *label,
-                        gint              n_copies,
-                        gint              first,
-                        glPrintFlags     *flags)
+gl_print_collated_merge_sheet   (glLabel          *label,
+                                 cairo_t          *cr,
+                                 gint              page,
+                                 gint              n_copies,
+                                 gint              first,
+                                 gboolean          outline_flag,
+                                 gboolean          reverse_flag,
+                                 gboolean          crop_marks_flag,
+                                 glPrintState     *state)
 {
        glMerge                   *merge;
        const GList               *record_list;
        PrintInfo                 *pi;
        const glTemplateLabelType *label_type;
-       gint                       i_sheet, i_label, n_labels_per_page, i_copy;
+       gint                       i_label, n_labels_per_page, i_copy;
        glMergeRecord             *record;
        GList                     *p;
        glTemplateOrigin          *origins;
@@ -245,69 +226,88 @@ gl_print_merge_collated (GnomePrintJob    *job,
        merge = gl_label_get_merge (label);
        record_list = gl_merge_get_record_list (merge);
 
-       pi = print_info_new (job, label);
+       pi = print_info_new (cr, label);
        label_type = gl_template_get_first_label_type (pi->template);
 
        n_labels_per_page = gl_template_get_n_labels (label_type);
        origins = gl_template_get_origins (label_type);
 
-       i_sheet = 0;
-       i_label = first - 1;
+        if (crop_marks_flag) {
+                print_crop_marks (pi);
+        }
 
-       for ( p=(GList *)record_list; p!=NULL; p=p->next ) {
+        if (page == 0)
+        {
+                state->i_copy  = 0;
+                state->p_record = (GList *)record_list;
+
+                i_label = first - 1;
+        }
+        else
+        {
+                i_label = 0;
+        }
+
+
+       for ( p=(GList *)state->p_record; p!=NULL; p=p->next ) {
                record = (glMergeRecord *)p->data;
                        
                if ( record->select_flag ) {
-                       for (i_copy = 0; i_copy < n_copies; i_copy++) {
-
-                               if ((i_label == 0) || (i_sheet == 0)) {
-                                       i_sheet++;
-                                       print_page_begin (pi);
-                                       if (flags->crop_marks) {
-                                               print_crop_marks (pi);
-                                       }
-                               }
+                       for (i_copy = state->i_copy; i_copy < n_copies; i_copy++) {
 
                                print_label (pi, label,
                                             origins[i_label].x,
                                             origins[i_label].y,
                                             record,
-                                            flags->outline, flags->reverse);
-
-                               i_label = (i_label + 1) % n_labels_per_page;
-                               if (i_label == 0) {
-                                       print_page_end (pi);
-                               }
+                                            outline_flag, reverse_flag);
+
+                               i_label++;
+                                if (i_label == n_labels_per_page)
+                                {
+                                        g_free (origins);
+                                        print_info_free (&pi);
+
+                                        state->i_copy = (i_copy+1) % n_copies;
+                                        if (state->i_copy == 0)
+                                        {
+                                                state->p_record = p->next;
+                                        }
+                                        else
+                                        {
+                                                state->p_record = p;
+                                        }
+                                        return;
+                                }
                        }
+                        state->i_copy = 0;
                }
        }
 
-       if (i_label != 0) {
-               print_page_end (pi);
-       }
-
-       g_free (origins);
-
-       print_info_free (&pi);
+        g_free (origins);
+        print_info_free (&pi);
 
        gl_debug (DEBUG_PRINT, "END");
 }
 
 /*****************************************************************************/
-/* Merge print command (uncollated copies)                                   */
+/* Print uncollated merge sheet command                                      */
 /*****************************************************************************/
 void
-gl_print_merge_uncollated (GnomePrintJob    *job,
-                          glLabel          *label,
-                          gint              n_copies,
-                          gint              first,
-                          glPrintFlags     *flags)
+gl_print_uncollated_merge_sheet (glLabel          *label,
+                                 cairo_t          *cr,
+                                 gint              page,
+                                 gint              n_copies,
+                                 gint              first,
+                                 gboolean          outline_flag,
+                                 gboolean          reverse_flag,
+                                 gboolean          crop_marks_flag,
+                                 glPrintState     *state)
 {
        glMerge                   *merge;
        const GList               *record_list;
        PrintInfo                 *pi;
        const glTemplateLabelType *label_type;
-       gint                       i_sheet, i_label, n_labels_per_page, i_copy;
+       gint                       i_label, n_labels_per_page, i_copy;
        glMergeRecord             *record;
        GList                     *p;
        glTemplateOrigin          *origins;
@@ -317,56 +317,72 @@ gl_print_merge_uncollated (GnomePrintJob    *job,
        merge = gl_label_get_merge (label);
        record_list = gl_merge_get_record_list (merge);
 
-       pi = print_info_new (job, label);
+       pi = print_info_new (cr, label);
        label_type = gl_template_get_first_label_type (pi->template);
 
        n_labels_per_page = gl_template_get_n_labels (label_type);
        origins = gl_template_get_origins (label_type);
 
-       i_sheet = 0;
-       i_label = first - 1;
+        if (crop_marks_flag) {
+                print_crop_marks (pi);
+        }
+
+        if (page == 0)
+        {
+                state->i_copy  = 0;
+                state->p_record = (GList *)record_list;
+
+                i_label = first - 1;
+        }
+        else
+        {
+                i_label = 0;
+        }
 
-       for (i_copy = 0; i_copy < n_copies; i_copy++) {
+       for (i_copy = state->i_copy; i_copy < n_copies; i_copy++) {
 
-               for ( p=(GList *)record_list; p!=NULL; p=p->next ) {
+               for ( p=state->p_record; p!=NULL; p=p->next ) {
                        record = (glMergeRecord *)p->data;
                        
                        if ( record->select_flag ) {
 
-
-                               if ((i_label == 0) || (i_sheet == 0)) {
-                                       i_sheet++;
-                                       print_page_begin (pi);
-                                       if (flags->crop_marks) {
-                                               print_crop_marks (pi);
-                                       }
-                               }
-
-                               print_label (pi, label,
+                                print_label (pi, label,
                                             origins[i_label].x,
                                             origins[i_label].y,
                                             record,
-                                            flags->outline, flags->reverse);
-
-                               i_label = (i_label + 1) % n_labels_per_page;
-                               if (i_label == 0) {
-                                       print_page_end (pi);
-                               }
+                                            outline_flag, reverse_flag);
+
+                               i_label++;
+                                if (i_label == n_labels_per_page)
+                                {
+                                        g_free (origins);
+                                        print_info_free (&pi);
+
+                                        state->p_record = p->next;
+                                        if (state->p_record == NULL)
+                                        {
+                                                state->p_record = (GList *)record_list;
+                                                state->i_copy = i_copy + 1;
+                                        }
+                                        else
+                                        {
+                                                state->i_copy = i_copy;
+                                        }
+                                        return;
+                                }
                        }
                }
+                state->p_record = (GList *)record_list;
 
        }
-       if (i_label != 0) {
-               print_page_end (pi);
-       }
 
        g_free (origins);
-
        print_info_free (&pi);
 
        gl_debug (DEBUG_PRINT, "END");
 }
 
+#ifdef TODO
 /*****************************************************************************/
 /* Batch print.  Call appropriate function above.                            */
 /*****************************************************************************/
@@ -400,12 +416,13 @@ gl_print_batch (GnomePrintJob    *job,
 
        gl_debug (DEBUG_PRINT, "END");
 }
+#endif
 
 /*---------------------------------------------------------------------------*/
 /* PRIVATE.  new print info structure                                        */
 /*---------------------------------------------------------------------------*/
 static PrintInfo *
-print_info_new (GnomePrintJob    *job,
+print_info_new (cairo_t          *cr,
                glLabel          *label)
 {
        PrintInfo            *pi = g_new0 (PrintInfo, 1);
@@ -413,7 +430,6 @@ print_info_new (GnomePrintJob    *job,
 
        gl_debug (DEBUG_PRINT, "START");
 
-       g_return_val_if_fail (job && GNOME_IS_PRINT_JOB (job), NULL);
        g_return_val_if_fail (label && GL_IS_LABEL (label), NULL);
 
        template = gl_label_get_template (label);
@@ -423,29 +439,17 @@ print_info_new (GnomePrintJob    *job,
        g_return_val_if_fail (template->page_width > 0, NULL);
        g_return_val_if_fail (template->page_height > 0, NULL);
 
-       pi->pc = gnome_print_job_get_context (job);
-       pi->config = gnome_print_job_get_config (job);
+       pi->cr = cr;
 
        gl_debug (DEBUG_PRINT,
                  "setting page size = \"%s\"", template->page_size);
 
-       gnome_print_config_set_length (pi->config,
-                                      (guchar *)GNOME_PRINT_KEY_PAPER_WIDTH,
-                                      template->page_width,
-                                      GNOME_PRINT_PS_UNIT);
-       gnome_print_config_set_length (pi->config,
-                                      (guchar *)GNOME_PRINT_KEY_PAPER_HEIGHT,
-                                      template->page_height,
-                                      GNOME_PRINT_PS_UNIT);
-
        pi->page_width  = template->page_width;
        pi->page_height = template->page_height;
 
        pi->template = template;
        pi->label_rotate_flag = gl_label_get_rotate_flag (label);
 
-       pi->sheet = 0;
-
        gl_debug (DEBUG_PRINT, "END");
 
        return pi;
@@ -462,50 +466,12 @@ print_info_free (PrintInfo **pi)
        gl_template_free ((*pi)->template);
        (*pi)->template = NULL;
 
-       gnome_print_context_close ((*pi)->pc);
-
        g_free (*pi);
        *pi = NULL;
 
        gl_debug (DEBUG_PRINT, "END");
 }
 
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  Begin a new page.                                               */
-/*---------------------------------------------------------------------------*/
-static void
-print_page_begin (PrintInfo *pi)
-{
-       gchar *str;
-
-       gl_debug (DEBUG_PRINT, "START");
-
-       pi->sheet++;
-
-       str = g_strdup_printf ("sheet%02d", pi->sheet);
-       gnome_print_beginpage (pi->pc, (guchar *)str);
-       g_free (str);
-
-       /* Translate and scale, so that our origin is at the upper left. */
-       gnome_print_translate (pi->pc, 0.0, pi->page_height);
-       gnome_print_scale (pi->pc, 1.0, -1.0);
-
-       gl_debug (DEBUG_PRINT, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  End a page.                                                     */
-/*---------------------------------------------------------------------------*/
-static void
-print_page_end (PrintInfo *pi)
-{
-       gl_debug (DEBUG_PRINT, "START");
-
-       gnome_print_showpage (pi->pc);
-
-       gl_debug (DEBUG_PRINT, "END");
-}
-
 /*---------------------------------------------------------------------------*/
 /* PRIVATE.  Print crop tick marks.                                          */
 /*---------------------------------------------------------------------------*/
@@ -529,9 +495,10 @@ print_crop_marks (PrintInfo *pi)
        page_w = pi->page_width;
        page_h = pi->page_height;
 
-       gnome_print_setrgbcolor (pi->pc, 0.0, 0.0, 0.0);
-       gnome_print_setopacity (pi->pc, 1.0);
-       gnome_print_setlinewidth (pi->pc, 0.25);
+        cairo_save (pi->cr);
+
+        cairo_set_source_rgba (pi->cr, 0.0, 0.0, 0.0, 1.0);
+       cairo_set_line_width  (pi->cr, 0.25);
 
        for (p=label_type->layouts; p != NULL; p=p->next) {
 
@@ -559,21 +526,21 @@ print_crop_marks (PrintInfo *pi)
                        y3 = MIN((ymax + TICK_OFFSET), page_h);
                        y4 = MIN((y3 + TICK_LENGTH), page_h);
 
-                       gnome_print_moveto (pi->pc, x1, y1);
-                       gnome_print_lineto (pi->pc, x1, y2);
-                       gnome_print_stroke (pi->pc);
+                       cairo_move_to (pi->cr, x1, y1);
+                       cairo_line_to (pi->cr, x1, y2);
+                       cairo_stroke  (pi->cr);
 
-                       gnome_print_moveto (pi->pc, x2, y1);
-                       gnome_print_lineto (pi->pc, x2, y2);
-                       gnome_print_stroke (pi->pc);
+                       cairo_move_to (pi->cr, x2, y1);
+                       cairo_line_to (pi->cr, x2, y2);
+                       cairo_stroke  (pi->cr);
 
-                       gnome_print_moveto (pi->pc, x1, y3);
-                       gnome_print_lineto (pi->pc, x1, y4);
-                       gnome_print_stroke (pi->pc);
+                       cairo_move_to (pi->cr, x1, y3);
+                       cairo_line_to (pi->cr, x1, y4);
+                       cairo_stroke  (pi->cr);
 
-                       gnome_print_moveto (pi->pc, x2, y3);
-                       gnome_print_lineto (pi->pc, x2, y4);
-                       gnome_print_stroke (pi->pc);
+                       cairo_move_to (pi->cr, x2, y3);
+                       cairo_line_to (pi->cr, x2, y4);
+                       cairo_stroke  (pi->cr);
 
                }
 
@@ -588,26 +555,28 @@ print_crop_marks (PrintInfo *pi)
                        x3 = MIN((xmax + TICK_OFFSET), page_w);
                        x4 = MIN((x3 + TICK_LENGTH), page_w);
 
-                       gnome_print_moveto (pi->pc, x1, y1);
-                       gnome_print_lineto (pi->pc, x2, y1);
-                       gnome_print_stroke (pi->pc);
+                       cairo_move_to (pi->cr, x1, y1);
+                       cairo_line_to (pi->cr, x2, y1);
+                       cairo_stroke  (pi->cr);
 
-                       gnome_print_moveto (pi->pc, x1, y2);
-                       gnome_print_lineto (pi->pc, x2, y2);
-                       gnome_print_stroke (pi->pc);
+                       cairo_move_to (pi->cr, x1, y2);
+                       cairo_line_to (pi->cr, x2, y2);
+                       cairo_stroke  (pi->cr);
 
-                       gnome_print_moveto (pi->pc, x3, y1);
-                       gnome_print_lineto (pi->pc, x4, y1);
-                       gnome_print_stroke (pi->pc);
+                       cairo_move_to (pi->cr, x3, y1);
+                       cairo_line_to (pi->cr, x4, y1);
+                       cairo_stroke  (pi->cr);
 
-                       gnome_print_moveto (pi->pc, x3, y2);
-                       gnome_print_lineto (pi->pc, x4, y2);
-                       gnome_print_stroke (pi->pc);
+                       cairo_move_to (pi->cr, x3, y2);
+                       cairo_line_to (pi->cr, x4, y2);
+                       cairo_stroke  (pi->cr);
 
                }
 
        }
 
+        cairo_restore (pi->cr);
+
        gl_debug (DEBUG_PRINT, "END");
 }
 
@@ -632,19 +601,19 @@ print_label (PrintInfo     *pi,
 
        gl_label_get_size (label, &width, &height);
 
-       gnome_print_gsave (pi->pc);
+       cairo_save (pi->cr);
 
        /* Transform coordinate system to be relative to upper corner */
        /* of the current label */
-       gnome_print_translate (pi->pc, x, y);
+       cairo_translate (pi->cr, x, y);
        if (gl_label_get_rotate_flag (label)) {
                gl_debug (DEBUG_PRINT, "Rotate flag set");
-               gnome_print_rotate (pi->pc, -90.0);
-               gnome_print_translate (pi->pc, -width, 0.0);
+               cairo_rotate (pi->cr, -M_PI/2.0);
+               cairo_translate (pi->cr, -width, 0.0);
        }
        if ( reverse_flag ) {
-               gnome_print_translate (pi->pc, width, 0.0);
-               gnome_print_scale (pi->pc, -1.0, 1.0);
+               cairo_translate (pi->cr, width, 0.0);
+               cairo_scale (pi->cr, -1.0, 1.0);
        }
 
        clip_to_outline (pi, label);
@@ -652,9 +621,8 @@ print_label (PrintInfo     *pi,
        if (outline_flag) {
                draw_outline (pi, label);
        }
-       clip_punchouts (pi, label);
 
-       gnome_print_grestore (pi->pc);
+       cairo_restore (pi->cr);
 
        gl_debug (DEBUG_PRINT, "END");
 }
@@ -690,17 +658,20 @@ draw_object (PrintInfo     *pi,
             glMergeRecord *record)
 {
        gdouble x0, y0;
-       gdouble affine[6];
+       gdouble a[6];
+        cairo_matrix_t matrix;
 
        gl_debug (DEBUG_PRINT, "START");
 
        gl_label_object_get_position (object, &x0, &y0);
-       gl_label_object_get_affine (object, affine);
+       gl_label_object_get_affine (object, a);
+        cairo_matrix_init (&matrix, a[0], a[1], a[2], a[3], a[4], a[5]);
+
+       cairo_save (pi->cr);
 
-       gnome_print_gsave (pi->pc);
+       cairo_translate (pi->cr, x0, y0);
+       cairo_transform (pi->cr, &matrix);
 
-       gnome_print_translate (pi->pc, x0, y0);
-       gnome_print_concat (pi->pc, affine);
 
        if (GL_IS_LABEL_TEXT(object)) {
                draw_text_object (pi, GL_LABEL_TEXT(object), record);
@@ -716,7 +687,7 @@ draw_object (PrintInfo     *pi,
                draw_barcode_object (pi, GL_LABEL_BARCODE(object), record);
        }
 
-       gnome_print_grestore (pi->pc);
+       cairo_restore (pi->cr);
 
        gl_debug (DEBUG_PRINT, "END");
 }
@@ -729,8 +700,6 @@ draw_text_object (PrintInfo     *pi,
                  glLabelText   *object,
                  glMergeRecord *record)
 {
-       GnomeFont       *font;
-       gchar          **line;
        gint             i;
        gdouble          x_offset, y_offset, w, object_w, object_h;
        gchar           *text;
@@ -743,7 +712,6 @@ draw_text_object (PrintInfo     *pi,
        glColorNode     *color_node;
        GtkJustification just;
        gboolean         auto_shrink;
-       GnomeGlyphList  *glyphlist;
        ArtDRect         bbox;
        gdouble          affine[6];
        gdouble          text_line_spacing;
@@ -752,6 +720,10 @@ draw_text_object (PrintInfo     *pi,
        glColorNode     *shadow_color_node;
        gdouble          shadow_opacity;
        guint            shadow_color;
+        PangoAlignment   alignment;
+        PangoStyle       style;
+        PangoLayout     *layout;
+        PangoFontDescription *desc;
 
 
        gl_debug (DEBUG_PRINT, "START");
@@ -784,163 +756,99 @@ draw_text_object (PrintInfo     *pi,
        gl_color_node_free (&shadow_color_node);
 
        text = gl_text_node_lines_expand (lines, record);
-       line = g_strsplit (text, "\n", -1);
-       g_free (text);
 
-       art_affine_identity (affine);
+        switch (just) {
+        case GTK_JUSTIFY_LEFT:
+                alignment = PANGO_ALIGN_LEFT;
+                break;
+        case GTK_JUSTIFY_CENTER:
+                alignment = PANGO_ALIGN_CENTER;
+                break;
+        case GTK_JUSTIFY_RIGHT:
+                alignment = PANGO_ALIGN_RIGHT;
+                break;
+        default:
+                alignment = PANGO_ALIGN_LEFT;
+                break; /* shouldn't happen */
+        }
+
+        style = font_italic_flag ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL;
+
 
        if (record && auto_shrink) {
-               /* auto shrink text size to keep within text box limits. */
-               for (i = 0; line[i] != NULL; i++) {
-
-                       font = gnome_font_find_closest_from_weight_slant (
-                               (guchar *)font_family,
-                               font_weight,
-                               font_italic_flag,
-                               font_size);
-                       glyphlist = gnome_glyphlist_from_text_dumb (
-                               font,
-                               color,
-                               0.0, 0.0,
-                               (guchar *)line[i]);
-                       gnome_glyphlist_bbox (glyphlist, affine, 0, &bbox);
-                       w = bbox.x1;
-                       gnome_glyphlist_unref (glyphlist);
-
-                       /* If width is too large, iteratively shrink font_size until this
-                          line fits the width, or until the font size is ridiculously
-                          small. */
-                       while ( (w > object_w) && (font_size >= 1.0) ) {
-
-                               font_size -= 0.5;
-
-                               font = gnome_font_find_closest_from_weight_slant (
-                                       (guchar *)font_family,
-                                       font_weight,
-                                       font_italic_flag,
-                                       font_size);
-                               glyphlist = gnome_glyphlist_from_text_dumb (
-                                       font,
-                                       color,
-                                       0.0, 0.0,
-                                       (guchar *)line[i]);
-                               gnome_glyphlist_bbox (glyphlist, affine, 0, &bbox);
-                               w = bbox.x1;
-                               gnome_glyphlist_unref (glyphlist);
-                       }
-               }
 
-       }
+               /* auto shrink text size to keep within text box limits. */
 
-       font = gnome_font_find_closest_from_weight_slant (
-                                       (guchar *)font_family,
-                                      font_weight,
-                                      font_italic_flag,
-                                      font_size);
-       gnome_print_setfont (pi->pc, font);
+                layout = pango_cairo_create_layout (pi->cr);
 
-        if (shadow_state)
-        {
-                gnome_print_setrgbcolor (pi->pc,
-                                         GL_COLOR_F_RED (shadow_color),
-                                         GL_COLOR_F_GREEN (shadow_color),
-                                         GL_COLOR_F_BLUE (shadow_color));
-                gnome_print_setopacity (pi->pc, GL_COLOR_F_ALPHA (shadow_color));
-
-                for (i = 0; line[i] != NULL; i++) {
-
-                        glyphlist = gnome_glyphlist_from_text_dumb (font, color,
-                                                                    0.0, 0.0,
-                                                                    (guchar *)line[i]);
-
-                        gnome_glyphlist_bbox (glyphlist, affine, 0, &bbox);
-                        w = bbox.x1;
-                        gnome_glyphlist_unref (glyphlist);
-
-                        switch (just) {
-                        case GTK_JUSTIFY_LEFT:
-                                x_offset = GL_LABEL_TEXT_MARGIN;
-                                break;
-                        case GTK_JUSTIFY_CENTER:
-                                x_offset = (object_w - GL_LABEL_TEXT_MARGIN - w) / 2.0;
-                                break;
-                        case GTK_JUSTIFY_RIGHT:
-                                x_offset = object_w - GL_LABEL_TEXT_MARGIN - w;
-                                break;
-                        default:
-                                x_offset = 0.0;
-                                break; /* shouldn't happen */
-                        }
-                        x_offset += shadow_x;
+                desc = pango_font_description_new ();
+                pango_font_description_set_family (desc, font_family);
+                pango_font_description_set_weight (desc, font_weight);
+                pango_font_description_set_style  (desc, style);
+                pango_font_description_set_size   (desc, font_size * PANGO_SCALE * FONT_SCALE);
+                pango_layout_set_font_description (layout, desc);
+                pango_font_description_free       (desc);
 
-                        /* Work out the y position to the BOTTOM of the first line */
-                        y_offset = GL_LABEL_TEXT_MARGIN +
-                                + gnome_font_get_descender (font)
-                                + (i + 1) * font_size * text_line_spacing
-                                + shadow_y;
+                pango_layout_set_text (layout, text, -1);
+                w = pango_layout_get_width (layout) / PANGO_SCALE;
 
-                        /* Remove any text line spacing from the first row. */
-                        y_offset -= font_size * (text_line_spacing - 1);
+                g_object_unref (layout);
 
+                if ( w > object_w )
+                {
+                        /* Scale down. */
+                        font_size *= (object_w-2*GL_LABEL_TEXT_MARGIN)/w;
 
-                        gnome_print_moveto (pi->pc, x_offset, y_offset);
+                        /* Round down to nearest 1/2 point */
+                        font_size = (int)(font_size*2.0) / 2.0;
 
-                        gnome_print_gsave (pi->pc);
-                        gnome_print_scale (pi->pc, 1.0, -1.0);
-                        gnome_print_show (pi->pc, (guchar *)line[i]);
-                        gnome_print_grestore (pi->pc);
+                        /* don't get ridiculously small. */
+                        if (font_size < 1.0)
+                        {
+                                font_size = 1.0;
+                        }
                 }
         }
 
-       gnome_print_setrgbcolor (pi->pc,
-                                GL_COLOR_F_RED (color),
-                                GL_COLOR_F_GREEN (color),
-                                GL_COLOR_F_BLUE (color));
-       gnome_print_setopacity (pi->pc, GL_COLOR_F_ALPHA (color));
-
-       for (i = 0; line[i] != NULL; i++) {
-
-               glyphlist = gnome_glyphlist_from_text_dumb (font, color,
-                                                           0.0, 0.0,
-                                                           (guchar *)line[i]);
-
-               gnome_glyphlist_bbox (glyphlist, affine, 0, &bbox);
-               w = bbox.x1;
-               gnome_glyphlist_unref (glyphlist);
-
-               switch (just) {
-               case GTK_JUSTIFY_LEFT:
-                       x_offset = GL_LABEL_TEXT_MARGIN;
-                       break;
-               case GTK_JUSTIFY_CENTER:
-                       x_offset = (object_w - GL_LABEL_TEXT_MARGIN - w) / 2.0;
-                       break;
-               case GTK_JUSTIFY_RIGHT:
-                       x_offset = object_w - GL_LABEL_TEXT_MARGIN - w;
-                       break;
-               default:
-                       x_offset = 0.0;
-                       break;  /* shouldn't happen */
-               }
 
-               /* Work out the y position to the BOTTOM of the first line */
-               y_offset = GL_LABEL_TEXT_MARGIN +
-                          + gnome_font_get_descender (font)
-                          + (i + 1) * font_size * text_line_spacing;
+        layout = pango_cairo_create_layout (pi->cr);
 
-               /* Remove any text line spacing from the first row. */
-               y_offset -= font_size * (text_line_spacing - 1);
+        desc = pango_font_description_new ();
+        pango_font_description_set_family (desc, font_family);
+        pango_font_description_set_weight (desc, font_weight);
+        pango_font_description_set_style  (desc, style);
+        pango_font_description_set_size   (desc, font_size * PANGO_SCALE * FONT_SCALE);
+        pango_layout_set_font_description (layout, desc);
+        pango_font_description_free       (desc);
+
+        pango_layout_set_text (layout, text, -1);
+        pango_layout_set_spacing (layout, font_size * (text_line_spacing-1) * PANGO_SCALE);
+        pango_layout_set_width (layout, object_w * PANGO_SCALE);
+        pango_layout_set_alignment (layout, alignment);
+
+        if (shadow_state)
+        {
+                cairo_set_source_rgba (pi->cr,
+                                       GL_COLOR_F_RED (shadow_color),
+                                       GL_COLOR_F_GREEN (shadow_color),
+                                       GL_COLOR_F_BLUE (shadow_color),
+                                       GL_COLOR_F_ALPHA (shadow_color));
+
+                cairo_move_to (pi->cr, shadow_x + GL_LABEL_TEXT_MARGIN, shadow_y);
+                pango_cairo_show_layout (pi->cr, layout);
+        }
 
+        cairo_set_source_rgba (pi->cr,
+                               GL_COLOR_F_RED (color),
+                               GL_COLOR_F_GREEN (color),
+                               GL_COLOR_F_BLUE (color),
+                               GL_COLOR_F_ALPHA (color));
 
-               gnome_print_moveto (pi->pc, x_offset, y_offset);
+        cairo_move_to (pi->cr, GL_LABEL_TEXT_MARGIN, 0);
+        pango_cairo_show_layout (pi->cr, layout);
 
-               gnome_print_gsave (pi->pc);
-               gnome_print_scale (pi->pc, 1.0, -1.0);
-               gnome_print_show (pi->pc, (guchar *)line[i]);
-               gnome_print_grestore (pi->pc);
-       }
+        g_object_unref (layout);
 
-       g_strfreev (line);
 
        gl_text_node_lines_free (&lines);
        g_free (font_family);
@@ -996,43 +904,42 @@ draw_box_object (PrintInfo  *pi,
        if (shadow_state)
        {
                /* Draw fill shadow */
-               create_rectangle_path (pi->pc, shadow_x, shadow_y, w, h);
-               gnome_print_setrgbcolor (pi->pc,
-                                        GL_COLOR_F_RED (shadow_fill_color),
-                                        GL_COLOR_F_GREEN (shadow_fill_color),
-                                        GL_COLOR_F_BLUE (shadow_fill_color));
-               gnome_print_setopacity (pi->pc, GL_COLOR_F_ALPHA (shadow_fill_color));
-               gnome_print_fill (pi->pc);
+               cairo_rectangle (pi->cr, shadow_x, shadow_y, w, h);
+
+               cairo_set_source_rgba (pi->cr,
+                                       GL_COLOR_F_RED (shadow_fill_color),
+                                       GL_COLOR_F_GREEN (shadow_fill_color),
+                                       GL_COLOR_F_BLUE (shadow_fill_color),
+                                       GL_COLOR_F_ALPHA (shadow_fill_color));
+               cairo_fill_preserve (pi->cr);
 
                /* Draw outline shadow */
-               create_rectangle_path (pi->pc, shadow_x, shadow_y, w, h);
-               gnome_print_setrgbcolor (pi->pc,
-                                        GL_COLOR_F_RED (shadow_line_color),
-                                        GL_COLOR_F_GREEN (shadow_line_color),
-                                        GL_COLOR_F_BLUE (shadow_line_color));
-               gnome_print_setopacity (pi->pc, GL_COLOR_F_ALPHA (shadow_line_color));
-               gnome_print_setlinewidth (pi->pc, line_width);
-               gnome_print_stroke (pi->pc);
+               cairo_set_source_rgba (pi->cr,
+                                       GL_COLOR_F_RED (shadow_line_color),
+                                       GL_COLOR_F_GREEN (shadow_line_color),
+                                       GL_COLOR_F_BLUE (shadow_line_color),
+                                       GL_COLOR_F_ALPHA (shadow_line_color));
+               cairo_set_line_width (pi->cr, line_width);
+               cairo_stroke (pi->cr);
        }
 
        /* Paint fill color */
-       create_rectangle_path (pi->pc, 0.0, 0.0, w, h);
-       gnome_print_setrgbcolor (pi->pc,
-                                GL_COLOR_F_RED (fill_color),
-                                GL_COLOR_F_GREEN (fill_color),
-                                GL_COLOR_F_BLUE (fill_color));
-       gnome_print_setopacity (pi->pc, GL_COLOR_F_ALPHA (fill_color));
-       gnome_print_fill (pi->pc);
+       cairo_rectangle (pi->cr, 0.0, 0.0, w, h);
+        cairo_set_source_rgba (pi->cr,
+                               GL_COLOR_F_RED (fill_color),
+                               GL_COLOR_F_GREEN (fill_color),
+                               GL_COLOR_F_BLUE (fill_color),
+                               GL_COLOR_F_ALPHA (fill_color));
+       cairo_fill_preserve (pi->cr);
 
        /* Draw outline */
-       create_rectangle_path (pi->pc, 0.0, 0.0, w, h);
-       gnome_print_setrgbcolor (pi->pc,
-                                GL_COLOR_F_RED (line_color),
-                                GL_COLOR_F_GREEN (line_color),
-                                GL_COLOR_F_BLUE (line_color));
-       gnome_print_setopacity (pi->pc, GL_COLOR_F_ALPHA (line_color));
-       gnome_print_setlinewidth (pi->pc, line_width);
-       gnome_print_stroke (pi->pc);
+        cairo_set_source_rgba (pi->cr,
+                               GL_COLOR_F_RED (line_color),
+                               GL_COLOR_F_GREEN (line_color),
+                               GL_COLOR_F_BLUE (line_color),
+                               GL_COLOR_F_ALPHA (line_color));
+        cairo_set_line_width (pi->cr, line_width);
+        cairo_stroke (pi->cr);
 
        gl_debug (DEBUG_PRINT, "END");
 }
@@ -1077,26 +984,26 @@ draw_line_object (PrintInfo   *pi,
 
        if (shadow_state)
        {
-               gnome_print_moveto (pi->pc, shadow_x, shadow_y);
-               gnome_print_lineto (pi->pc, shadow_x + w, shadow_y + h);
-               gnome_print_setrgbcolor (pi->pc,
-                                        GL_COLOR_F_RED (shadow_line_color),
-                                        GL_COLOR_F_GREEN (shadow_line_color),
-                                        GL_COLOR_F_BLUE (shadow_line_color));
-               gnome_print_setopacity (pi->pc, GL_COLOR_F_ALPHA (shadow_line_color));
-               gnome_print_setlinewidth (pi->pc, line_width);
-               gnome_print_stroke (pi->pc);
+               cairo_move_to (pi->cr, shadow_x, shadow_y);
+               cairo_line_to (pi->cr, shadow_x + w, shadow_y + h);
+               cairo_set_source_rgba (pi->cr,
+                                       GL_COLOR_F_RED (shadow_line_color),
+                                       GL_COLOR_F_GREEN (shadow_line_color),
+                                       GL_COLOR_F_BLUE (shadow_line_color),
+                                       GL_COLOR_F_ALPHA (shadow_line_color));
+               cairo_set_line_width (pi->cr, line_width);
+               cairo_stroke (pi->cr);
        }
 
-       gnome_print_moveto (pi->pc, 0.0, 0.0);
-       gnome_print_lineto (pi->pc, w, h);
-       gnome_print_setrgbcolor (pi->pc,
-                                GL_COLOR_F_RED (line_color),
-                                GL_COLOR_F_GREEN (line_color),
-                                GL_COLOR_F_BLUE (line_color));
-       gnome_print_setopacity (pi->pc, GL_COLOR_F_ALPHA (line_color));
-       gnome_print_setlinewidth (pi->pc, line_width);
-       gnome_print_stroke (pi->pc);
+       cairo_move_to (pi->cr, 0.0, 0.0);
+       cairo_line_to (pi->cr, w, h);
+       cairo_set_source_rgba (pi->cr,
+                               GL_COLOR_F_RED (line_color),
+                               GL_COLOR_F_GREEN (line_color),
+                               GL_COLOR_F_BLUE (line_color),
+                               GL_COLOR_F_ALPHA (line_color));
+       cairo_set_line_width (pi->cr, line_width);
+       cairo_stroke (pi->cr);
 
        gl_debug (DEBUG_PRINT, "END");
 }
@@ -1154,43 +1061,41 @@ draw_ellipse_object (PrintInfo      *pi,
        if (shadow_state)
        {
                /* Draw fill shadow */
-               create_ellipse_path (pi->pc, x0+shadow_x, y0+shadow_y, rx, ry);
-               gnome_print_setrgbcolor (pi->pc,
-                                        GL_COLOR_F_RED (shadow_fill_color),
-                                        GL_COLOR_F_GREEN (shadow_fill_color),
-                                        GL_COLOR_F_BLUE (shadow_fill_color));
-               gnome_print_setopacity (pi->pc, GL_COLOR_F_ALPHA (shadow_fill_color));
-               gnome_print_fill (pi->pc);
+               create_ellipse_path (pi->cr, x0+shadow_x, y0+shadow_y, rx, ry);
+               cairo_set_source_rgba (pi->cr,
+                                       GL_COLOR_F_RED (shadow_fill_color),
+                                       GL_COLOR_F_GREEN (shadow_fill_color),
+                                       GL_COLOR_F_BLUE (shadow_fill_color),
+                                       GL_COLOR_F_ALPHA (shadow_fill_color));
+               cairo_fill_preserve (pi->cr);
 
                /* Draw outline shadow */
-               create_ellipse_path (pi->pc, x0+shadow_x, y0+shadow_y, rx, ry);
-               gnome_print_setrgbcolor (pi->pc,
-                                        GL_COLOR_F_RED (shadow_line_color),
-                                        GL_COLOR_F_GREEN (shadow_line_color),
-                                        GL_COLOR_F_BLUE (shadow_line_color));
-               gnome_print_setopacity (pi->pc, GL_COLOR_F_ALPHA (shadow_line_color));
-               gnome_print_setlinewidth (pi->pc, line_width);
-               gnome_print_stroke (pi->pc);
+               cairo_set_source_rgba (pi->cr,
+                                       GL_COLOR_F_RED (shadow_line_color),
+                                       GL_COLOR_F_GREEN (shadow_line_color),
+                                       GL_COLOR_F_BLUE (shadow_line_color),
+                                       GL_COLOR_F_ALPHA (shadow_line_color));
+               cairo_set_line_width (pi->cr, line_width);
+               cairo_stroke (pi->cr);
        }
 
        /* Paint fill color */
-       create_ellipse_path (pi->pc, x0, y0, rx, ry);
-       gnome_print_setrgbcolor (pi->pc,
-                                GL_COLOR_F_RED (fill_color),
-                                GL_COLOR_F_GREEN (fill_color),
-                                GL_COLOR_F_BLUE (fill_color));
-       gnome_print_setopacity (pi->pc, GL_COLOR_F_ALPHA (fill_color));
-       gnome_print_fill (pi->pc);
+       create_ellipse_path (pi->cr, x0, y0, rx, ry);
+       cairo_set_source_rgba (pi->cr,
+                               GL_COLOR_F_RED (fill_color),
+                               GL_COLOR_F_GREEN (fill_color),
+                               GL_COLOR_F_BLUE (fill_color),
+                               GL_COLOR_F_ALPHA (fill_color));
+       cairo_fill_preserve (pi->cr);
 
        /* Draw outline */
-       create_ellipse_path (pi->pc, x0, y0, rx, ry);
-       gnome_print_setrgbcolor (pi->pc,
-                                GL_COLOR_F_RED (line_color),
-                                GL_COLOR_F_GREEN (line_color),
-                                GL_COLOR_F_BLUE (line_color));
-       gnome_print_setopacity (pi->pc, GL_COLOR_F_ALPHA (line_color));
-       gnome_print_setlinewidth (pi->pc, line_width);
-       gnome_print_stroke (pi->pc);
+       cairo_set_source_rgba (pi->cr,
+                               GL_COLOR_F_RED (line_color),
+                               GL_COLOR_F_GREEN (line_color),
+                               GL_COLOR_F_BLUE (line_color),
+                               GL_COLOR_F_ALPHA (line_color));
+       cairo_set_line_width (pi->cr, line_width);
+       cairo_stroke (pi->cr);
 
        gl_debug (DEBUG_PRINT, "END");
 }
@@ -1205,48 +1110,30 @@ draw_image_object (PrintInfo     *pi,
 {
        gdouble w, h;
        const GdkPixbuf *pixbuf;
-       guchar *image_data;
-       gint image_w, image_h, image_stride;
-       gboolean image_alpha_flag;
-       gint ret;
+       gint image_w, image_h;
 
        gl_debug (DEBUG_PRINT, "START");
 
        gl_label_object_get_size     (GL_LABEL_OBJECT(object), &w, &h);
 
        pixbuf = gl_label_image_get_pixbuf (object, record);
-       image_data = gdk_pixbuf_get_pixels (pixbuf);
        image_w = gdk_pixbuf_get_width (pixbuf);
        image_h = gdk_pixbuf_get_height (pixbuf);
-       image_stride = gdk_pixbuf_get_rowstride(pixbuf);
-       image_alpha_flag = gdk_pixbuf_get_has_alpha(pixbuf);
-
-       gnome_print_gsave (pi->pc);
-       gnome_print_translate (pi->pc, 0.0, h);
-       gnome_print_scale (pi->pc, w, -h);
-       if (image_alpha_flag) {
-#ifndef NO_ALPHA_HACK
-               guchar *image_data2;
-
-               image_data2 = get_pixels_as_rgb (pixbuf);
-               ret = gnome_print_rgbimage (pi->pc, image_data2,
-                                           image_w, image_h, image_stride);
-               g_free (image_data2);
-#else
-               ret = gnome_print_rgbaimage (pi->pc, image_data,
-                                           image_w, image_h, image_stride);
-#endif
-       } else {
-               ret = gnome_print_rgbimage (pi->pc, image_data,
-                                           image_w, image_h, image_stride);
-       }
-       gnome_print_grestore (pi->pc);
+
+       cairo_save (pi->cr);
+        cairo_rectangle (pi->cr, 0.0, 0.0, w, h);
+        cairo_clip (pi->cr);
+       cairo_scale (pi->cr, w/image_w, h/image_h);
+        gdk_cairo_set_source_pixbuf (pi->cr, (GdkPixbuf *)pixbuf, 0, 0);
+        cairo_paint (pi->cr);
+
+       cairo_restore (pi->cr);
 
        gl_debug (DEBUG_PRINT, "END");
 }
 
 /*---------------------------------------------------------------------------*/
-/* PRIVATE.  Draw box object.                                                */
+/* PRIVATE.  Draw barcode object.                                            */
 /*---------------------------------------------------------------------------*/
 static void
 draw_barcode_object (PrintInfo      *pi,
@@ -1258,7 +1145,8 @@ draw_barcode_object (PrintInfo      *pi,
        glBarcodeChar      *bchar;
        GList              *li;
        gdouble             y_offset;
-       GnomeFont          *font;
+        PangoLayout        *layout;
+        PangoFontDescription *desc;
        gchar              *text, *cstring;
        glTextNode         *text_node;
        gchar              *id;
@@ -1297,74 +1185,61 @@ draw_barcode_object (PrintInfo      *pi,
        gl_text_node_free (&text_node);
        g_free (id);
 
+        cairo_set_source_rgba (pi->cr,
+                               GL_COLOR_F_RED (color),
+                               GL_COLOR_F_GREEN (color),
+                               GL_COLOR_F_BLUE (color),
+                               GL_COLOR_F_ALPHA (color));
+
        if (gbc == NULL) {
 
-               font = gnome_font_find_closest_from_weight_slant (
-                       (guchar *)GL_BARCODE_FONT_FAMILY,
-                       GL_BARCODE_FONT_WEIGHT,
-                       FALSE, 12.0);
-               gnome_print_setfont (pi->pc, font);
+                layout = pango_cairo_create_layout (pi->cr);
 
-               gnome_print_setrgbcolor (pi->pc,
-                                        GL_COLOR_F_RED (color),
-                                        GL_COLOR_F_GREEN (color),
-                                        GL_COLOR_F_BLUE (color));
-               gnome_print_setopacity (pi->pc,
-                                       GL_COLOR_F_ALPHA (color));
+                desc = pango_font_description_new ();
+                pango_font_description_set_family (desc, GL_BARCODE_FONT_FAMILY);
+                pango_font_description_set_size   (desc, 12 * PANGO_SCALE * FONT_SCALE);
+                pango_layout_set_font_description (layout, desc);
+                pango_font_description_free       (desc);
 
-               y_offset = 12.0 - fabs (gnome_font_get_descender (font));
-               gnome_print_moveto (pi->pc, 0.0, y_offset);
+                pango_layout_set_text (layout, _("Invalid barcode data"), -1);
 
-               gnome_print_gsave (pi->pc);
-               gnome_print_scale (pi->pc, 1.0, -1.0);
-               gnome_print_show (pi->pc, (guchar *)_("Invalid barcode data"));
-               gnome_print_grestore (pi->pc);
+                pango_cairo_show_layout (pi->cr, layout);
+
+                g_object_unref (layout);
 
        } else {
 
                for (li = gbc->lines; li != NULL; li = li->next) {
                        line = (glBarcodeLine *) li->data;
 
-                       gnome_print_moveto (pi->pc, line->x, line->y);
-                       gnome_print_lineto (pi->pc, line->x, line->y + line->length);
-                       gnome_print_setrgbcolor (pi->pc,
-                                                GL_COLOR_F_RED (color),
-                                                GL_COLOR_F_GREEN (color),
-                                                GL_COLOR_F_BLUE (color));
-                       gnome_print_setopacity (pi->pc,
-                                               GL_COLOR_F_ALPHA (color));
-                       gnome_print_setlinewidth (pi->pc, line->width);
-                       gnome_print_stroke (pi->pc);
+                       cairo_move_to (pi->cr, line->x, line->y);
+                       cairo_line_to (pi->cr, line->x, line->y + line->length);
+                       cairo_set_line_width (pi->cr, line->width);
+                       cairo_stroke (pi->cr);
                }
 
                for (li = gbc->chars; li != NULL; li = li->next) {
                        bchar = (glBarcodeChar *) li->data;
 
-                       font = gnome_font_find_closest_from_weight_slant (
-                               (guchar *)GL_BARCODE_FONT_FAMILY,
-                               GL_BARCODE_FONT_WEIGHT,
-                               FALSE, bchar->fsize);
-                       gnome_print_setfont (pi->pc, font);
-
-                       gnome_print_setrgbcolor (pi->pc,
-                                                GL_COLOR_F_RED (color),
-                                                GL_COLOR_F_GREEN (color),
-                                                GL_COLOR_F_BLUE (color));
-                       gnome_print_setopacity (pi->pc,
-                                               GL_COLOR_F_ALPHA (color));
-
-                       y_offset =
-                           bchar->fsize - fabs (gnome_font_get_descender (font));
+                        layout = pango_cairo_create_layout (pi->cr);
 
-                       gnome_print_moveto (pi->pc, bchar->x, bchar->y+y_offset);
+                        desc = pango_font_description_new ();
+                        pango_font_description_set_family (desc, GL_BARCODE_FONT_FAMILY);
+                        pango_font_description_set_size   (desc, bchar->fsize * PANGO_SCALE * FONT_SCALE);
+                        pango_layout_set_font_description (layout, desc);
+                        pango_font_description_free       (desc);
 
                        cstring = g_strdup_printf ("%c", bchar->c);
-                       gnome_print_gsave (pi->pc);
-                       gnome_print_scale (pi->pc, 1.0, -1.0);
-                       gnome_print_show (pi->pc, (guchar *)cstring);
-                       gnome_print_grestore (pi->pc);
+                        pango_layout_set_text (layout, cstring, -1);
                        g_free (cstring);
 
+                        y_offset = 0.2 * bchar->fsize;
+
+                       cairo_move_to (pi->cr, bchar->x, bchar->y-y_offset);
+                        pango_cairo_show_layout (pi->cr, layout);
+
+                        g_object_unref (layout);
+
                }
 
                gl_barcode_free (&gbc);
@@ -1389,9 +1264,10 @@ draw_outline (PrintInfo *pi,
 
        label_type = gl_template_get_first_label_type (pi->template);
 
-       gnome_print_setrgbcolor (pi->pc, 0.0, 0.0, 0.0);
-       gnome_print_setopacity (pi->pc, 1.0);
-       gnome_print_setlinewidth (pi->pc, 0.25);
+        cairo_save (pi->cr);
+
+       cairo_set_source_rgba (pi->cr, 0.0, 0.0, 0.0, 1.0);
+       cairo_set_line_width  (pi->cr, 0.25);
 
        switch (label_type->shape) {
 
@@ -1400,40 +1276,35 @@ draw_outline (PrintInfo *pi,
                r = label_type->size.rect.r;
                if (r == 0.0) {
                        /* simple rectangle */
-                       create_rectangle_path (pi->pc, 0.0, 0.0, w, h);
+                       cairo_rectangle (pi->cr, 0.0, 0.0, w, h);
                } else {
                        /* rectangle with rounded corners */
-                       create_rounded_rectangle_path (pi->pc, 0.0, 0.0,
+                       create_rounded_rectangle_path (pi->cr, 0.0, 0.0,
                                                       w, h, r);
                }
-               gnome_print_stroke (pi->pc);
+               cairo_stroke (pi->cr);
                break;
 
        case GL_TEMPLATE_SHAPE_ROUND:
                /* Round style */
                r1 = label_type->size.round.r;
-               create_ellipse_path (pi->pc, r1, r1, r1, r1);
-               gnome_print_stroke (pi->pc);
+               create_ellipse_path (pi->cr, r1, r1, r1, r1);
+               cairo_stroke (pi->cr);
                break;
 
        case GL_TEMPLATE_SHAPE_CD:
+                r1 = label_type->size.cd.r1;
+                r2 = label_type->size.cd.r2;
                if ((label_type->size.cd.h == 0) && (label_type->size.cd.w == 0)) {
                        /* CD style, round label w/ concentric round hole */
-                       r1 = label_type->size.cd.r1;
-                       r2 = label_type->size.cd.r2;
-                       create_ellipse_path (pi->pc, r1, r1, r1, r1);
-                       gnome_print_stroke (pi->pc);
-                       create_ellipse_path (pi->pc, r1, r1, r2, r2);
-                       gnome_print_stroke (pi->pc);
+                        create_cd_path (pi->cr, r1, r1, 2*r1, 2*r1, r1, r2);
+
+                       cairo_stroke (pi->cr);
                } else {
                        /* Business Card CD style, clipped round label w/ hole */
                        gl_label_get_size (label, &w, &h);
-                       r1 = label_type->size.cd.r1;
-                       r2 = label_type->size.cd.r2;
-                       create_clipped_circle_path (pi->pc, w/2, h/2, w, h, r1);
-                       gnome_print_stroke (pi->pc);
-                       create_ellipse_path (pi->pc, w/2, h/2, r2, r2);
-                       gnome_print_stroke (pi->pc);
+                       create_cd_path (pi->cr, w/2, h/2, w, h, r1, r2);
+                       cairo_stroke (pi->cr);
                }
                break;
 
@@ -1442,6 +1313,8 @@ draw_outline (PrintInfo *pi,
                break;
        }
 
+        cairo_restore (pi->cr);
+
        gl_debug (DEBUG_PRINT, "END");
 }
 
@@ -1454,7 +1327,7 @@ clip_to_outline (PrintInfo *pi,
 {
        const glTemplateLabelType *label_type;
        gdouble                    w, h, r;
-       gdouble                    r1;
+       gdouble                    r1, r2;
        gdouble                    waste, x_waste, y_waste;
 
        gl_debug (DEBUG_PRINT, "START");
@@ -1470,41 +1343,47 @@ clip_to_outline (PrintInfo *pi,
                y_waste = label_type->size.rect.y_waste;
                if (r == 0.0) {
                        /* simple rectangle */
-                       create_rectangle_path (pi->pc,
-                                              -x_waste, -y_waste,
-                                              w+2*x_waste, h+2*y_waste);
+                       cairo_rectangle (pi->cr,
+                                         -x_waste, -y_waste,
+                                         w+2*x_waste, h+2*y_waste);
                } else {
                        /* rectangle with rounded corners */
-                       create_rounded_rectangle_path (pi->pc,
+                       create_rounded_rectangle_path (pi->cr,
                                                       -x_waste, -y_waste,
                                                       w+2*x_waste, h+2*y_waste, r);
                }
-               gnome_print_clip (pi->pc);
+               cairo_clip (pi->cr);
                break;
 
        case GL_TEMPLATE_SHAPE_ROUND:
                r1 = label_type->size.round.r;
                waste = label_type->size.round.waste;
-               create_ellipse_path (pi->pc, r1, r1, r1+waste, r1+waste);
-               gnome_print_clip (pi->pc);
+               create_ellipse_path (pi->cr, r1, r1, r1+waste, r1+waste);
+               cairo_clip (pi->cr);
                break;
 
        case GL_TEMPLATE_SHAPE_CD:
                waste = label_type->size.cd.waste;
+                r1    = label_type->size.cd.r1;
+                r2    = label_type->size.cd.r2;
                if ((label_type->size.cd.h == 0) && (label_type->size.cd.w == 0)) {
                        /* CD style, round label w/ concentric round hole */
-                       r1 = label_type->size.cd.r1;
-                       create_ellipse_path (pi->pc, r1, r1, r1+waste, r1+waste);
+                        create_cd_path (pi->cr,
+                                        r1, r1,
+                                        2*(r1+waste), 2*(r1+waste),
+                                        r1+waste,
+                                        r2-waste);
                } else {
                        /* Business Card CD style, clipped round label w/ hole */
                        gl_label_get_size (label, &w, &h);
-                       r1 = label_type->size.cd.r1;
-                       create_clipped_circle_path (pi->pc,
-                                                   w/2, h/2,
-                                                   w+2*waste, h+2*waste,
-                                                   r1+waste);
+                       create_cd_path (pi->cr,
+                                        w/2, h/2,
+                                        w+2*waste, h+2*waste,
+                                        r1+waste,
+                                        r2-waste);
                }
-               gnome_print_clip (pi->pc);
+               cairo_set_fill_rule (pi->cr, CAIRO_FILL_RULE_EVEN_ODD);
+               cairo_clip (pi->cr);
                break;
 
        default:
@@ -1516,73 +1395,34 @@ clip_to_outline (PrintInfo *pi,
 }
 
 /*---------------------------------------------------------------------------*/
-/* PRIVATE.  Clip punchouts.  (Save some ink by not printing in CD holes)    */
-/*                                                                           */
-/* Ideally this would be done in clip_to_outline, but I am not sure how to   */
-/* invert the region for gnome_print_clip, so instead, I will just draw      */
-/* a white circle on top of everything else.                                 */
+/* PRIVATE.  Path creation utilities.                                        */
 /*---------------------------------------------------------------------------*/
 static void
-clip_punchouts (PrintInfo *pi,
-               glLabel   *label)
+create_rounded_rectangle_path (cairo_t           *cr,
+                              gdouble            x0,
+                              gdouble            y0,
+                              gdouble            w,
+                              gdouble            h,
+                              gdouble            r)
 {
-       const glTemplateLabelType *label_type;
-       gdouble                    w, h, r2;
-       gdouble                    waste;
+       gdouble x, y;
+       gint i_theta;
 
        gl_debug (DEBUG_PRINT, "START");
 
-       label_type = gl_template_get_first_label_type (pi->template);
-
-       switch (label_type->shape) {
-
-       case GL_TEMPLATE_SHAPE_RECT:
-       case GL_TEMPLATE_SHAPE_ROUND:
-               break;
-
-       case GL_TEMPLATE_SHAPE_CD:
-               gl_label_get_size (label, &w, &h);
-               waste = label_type->size.cd.waste;
-               r2    = label_type->size.cd.r2;
-               create_ellipse_path (pi->pc, w/2, h/2, r2-waste, r2-waste);
-               gnome_print_setrgbcolor (pi->pc, 1.0, 1.0, 1.0);
-               gnome_print_setopacity (pi->pc, 1.0);
-               gnome_print_fill (pi->pc);
-               break;
-
-       default:
-               g_message ("Unknown template label style");
-               break;
-       }
-
-       gl_debug (DEBUG_PRINT, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  Path creation utilities.                                        */
-/*---------------------------------------------------------------------------*/
-static void
-create_rectangle_path (GnomePrintContext *pc,
-                      gdouble            x0,
-                      gdouble            y0,
-                      gdouble            w,
-                      gdouble            h)
-{
-       gl_debug (DEBUG_PRINT, "START");
+       cairo_new_path (cr);
 
-       gnome_print_newpath (pc);
-       gnome_print_moveto (pc, x0, y0);
-       gnome_print_lineto (pc, x0 + w, y0);
-       gnome_print_lineto (pc, x0 + w, y0 + h);
-       gnome_print_lineto (pc, x0, y0 + h);
-       gnome_print_lineto (pc, x0, y0);
-       gnome_print_closepath (pc);
+        cairo_arc_negative (cr, x0+r,   y0+r,   r, 3*M_PI/2, M_PI);
+        cairo_arc_negative (cr, x0+r,   y0+h-r, r, M_PI,     M_PI/2);
+        cairo_arc_negative (cr, x0+w-r, y0+h-r, r, M_PI/2,   0.);
+        cairo_arc_negative (cr, x0+w-r, y0+r,   r, 2*M_PI,   3*M_PI/2);
+       cairo_close_path (cr);
 
        gl_debug (DEBUG_PRINT, "END");
 }
 
 static void
-create_ellipse_path (GnomePrintContext *pc,
+create_ellipse_path (cairo_t           *cr,
                     gdouble            x0,
                     gdouble            y0,
                     gdouble            rx,
@@ -1593,234 +1433,50 @@ create_ellipse_path (GnomePrintContext *pc,
 
        gl_debug (DEBUG_PRINT, "START");
 
-       gnome_print_newpath (pc);
-       gnome_print_moveto (pc, x0 + rx, y0);
+       cairo_new_path (cr);
+       cairo_move_to (cr, x0 + rx, y0);
        for (i_theta = ARC_FINE; i_theta <= 360; i_theta += ARC_FINE) {
                x = x0 + rx * cos (i_theta * G_PI / 180.0);
                y = y0 + ry * sin (i_theta * G_PI / 180.0);
-               gnome_print_lineto (pc, x, y);
-       }
-       gnome_print_closepath (pc);
-
-       gl_debug (DEBUG_PRINT, "END");
-}
-
-static void
-create_rounded_rectangle_path (GnomePrintContext *pc,
-                              gdouble            x0,
-                              gdouble            y0,
-                              gdouble            w,
-                              gdouble            h,
-                              gdouble            r)
-{
-       gdouble x, y;
-       gint i_theta;
-
-       gl_debug (DEBUG_PRINT, "START");
-
-       gnome_print_newpath (pc);
-
-       gnome_print_moveto (pc, x0 + r, y0);
-       for (i_theta = ARC_COURSE; i_theta <= 90; i_theta += ARC_COURSE) {
-               x = x0 + r - r * sin (i_theta * G_PI / 180.0);
-               y = y0 + r - r * cos (i_theta * G_PI / 180.0);
-               gnome_print_lineto (pc, x, y);
-       }
-       for (i_theta = 0; i_theta <= 90; i_theta += ARC_COURSE) {
-               x = x0 + r - r * cos (i_theta * G_PI / 180.0);
-               y = y0 + (h - r) + r * sin (i_theta * G_PI / 180.0);
-               gnome_print_lineto (pc, x, y);
-       }
-       for (i_theta = 0; i_theta <= 90; i_theta += ARC_COURSE) {
-               x = x0 + (w - r) + r * sin (i_theta * G_PI / 180.0);
-               y = y0 + (h - r) + r * cos (i_theta * G_PI / 180.0);
-               gnome_print_lineto (pc, x, y);
+               cairo_line_to (cr, x, y);
        }
-       for (i_theta = 0; i_theta <= 90; i_theta += ARC_COURSE) {
-               x = x0 + (w - r) + r * cos (i_theta * G_PI / 180.0);
-               y = y0 + r - r * sin (i_theta * G_PI / 180.0);
-               gnome_print_lineto (pc, x, y);
-       }
-       gnome_print_lineto (pc, x0 + r, y0);
-
-       gnome_print_closepath (pc);
+       cairo_close_path (cr);
 
        gl_debug (DEBUG_PRINT, "END");
 }
 
 static void
-create_clipped_circle_path (GnomePrintContext *pc,
-                           gdouble            x0,
-                           gdouble            y0,
-                           gdouble            w,
-                           gdouble            h,
-                           gdouble            r)
+create_cd_path (cairo_t           *cr,
+                gdouble            x0,
+                gdouble            y0,
+                gdouble            w,
+                gdouble            h,
+                gdouble            r1,
+                gdouble            r2)
 {
-       gdouble x, y;
        gdouble theta1, theta2;
-       gint    i_theta;
 
        gl_debug (DEBUG_PRINT, "START");
 
-       theta1 = (180.0/G_PI) * acos (w / (2.0*r));
-       theta2 = (180.0/G_PI) * asin (h / (2.0*r));
-
-       gnome_print_newpath (pc);
-
-       x = x0 + r * cos (theta1 * G_PI / 180.0);
-       y = y0 + r * sin (theta1 * G_PI / 180.0);
-       gnome_print_moveto (pc, x, y);
-
-       for ( i_theta = theta1 + ARC_FINE; i_theta < theta2; i_theta +=ARC_FINE ) {
-               x = x0 + r * cos (i_theta * G_PI / 180.0);
-               y = y0 + r * sin (i_theta * G_PI / 180.0);
-               gnome_print_lineto (pc, x, y);
-       }
-
-       x = x0 + r * cos (theta2 * G_PI / 180.0);
-       y = y0 + r * sin (theta2 * G_PI / 180.0);
-       gnome_print_lineto (pc, x, y);
-
-       if ( fabs (theta2 - 90.0) > GNOME_CANVAS_EPSILON ) {
-               x = x0 + r * cos ((180-theta2) * G_PI / 180.0);
-               y = y0 + r * sin ((180-theta2) * G_PI / 180.0);
-               gnome_print_lineto (pc, x, y);
-       }
-
-       for ( i_theta = 180-theta2+ARC_FINE; i_theta < (180-theta1); i_theta +=ARC_FINE ) {
-               x = x0 + r * cos (i_theta * G_PI / 180.0);
-               y = y0 + r * sin (i_theta * G_PI / 180.0);
-               gnome_print_lineto (pc, x, y);
-       }
-
-       x = x0 + r * cos ((180-theta1) * G_PI / 180.0);
-       y = y0 + r * sin ((180-theta1) * G_PI / 180.0);
-       gnome_print_lineto (pc, x, y);
-
-       if ( fabs (theta1) > GNOME_CANVAS_EPSILON ) {
-               x = x0 + r * cos ((180+theta1) * G_PI / 180.0);
-               y = y0 + r * sin ((180+theta1) * G_PI / 180.0);
-               gnome_print_lineto (pc, x, y);
-       }
-
-       for ( i_theta = 180+theta1+ARC_FINE; i_theta < (180+theta2); i_theta +=ARC_FINE ) {
-               x = x0 + r * cos (i_theta * G_PI / 180.0);
-               y = y0 + r * sin (i_theta * G_PI / 180.0);
-               gnome_print_lineto (pc, x, y);
-       }
-
-       x = x0 + r * cos ((180+theta2) * G_PI / 180.0);
-       y = y0 + r * sin ((180+theta2) * G_PI / 180.0);
-       gnome_print_lineto (pc, x, y);
-
-       if ( fabs (theta2 - 90.0) > GNOME_CANVAS_EPSILON ) {
-               x = x0 + r * cos ((360-theta2) * G_PI / 180.0);
-               y = y0 + r * sin ((360-theta2) * G_PI / 180.0);
-               gnome_print_lineto (pc, x, y);
-       }
-
-       for ( i_theta = 360-theta2+ARC_FINE; i_theta < (360-theta1); i_theta +=ARC_FINE ) {
-               x = x0 + r * cos (i_theta * G_PI / 180.0);
-               y = y0 + r * sin (i_theta * G_PI / 180.0);
-               gnome_print_lineto (pc, x, y);
-       }
-
-       if ( fabs (theta1) > GNOME_CANVAS_EPSILON ) {
-               x = x0 + r * cos ((360-theta1) * G_PI / 180.0);
-               y = y0 + r * sin ((360-theta1) * G_PI / 180.0);
-               gnome_print_lineto (pc, x, y);
-       }
-
-       x = x0 + r * cos (theta1 * G_PI / 180.0);
-       y = y0 + r * sin (theta1 * G_PI / 180.0);
-       gnome_print_lineto (pc, x, y);
-
-       gnome_print_closepath (pc);
+        /*
+         * Outer radius.  (may be clipped)
+         */
+       theta1 = acos (w / (2.0*r1));
+       theta2 = asin (h / (2.0*r1));
+
+       cairo_new_path (cr);
+        cairo_arc (cr, x0, y0, r1, theta1,        theta2);
+        cairo_arc (cr, x0, y0, r1, M_PI-theta2,   M_PI-theta1);
+        cairo_arc (cr, x0, y0, r1, M_PI+theta1,   M_PI+theta2);
+        cairo_arc (cr, x0, y0, r1, 2*M_PI-theta2, 2*M_PI-theta1);
+       cairo_close_path (cr);
+
+        /*
+         * Inner radius.  (hole)
+         */
+        cairo_new_sub_path (cr);
+        cairo_arc (cr, x0, y0, r2, 0.0, 2*M_PI);
+       cairo_close_path (cr);
 
        gl_debug (DEBUG_PRINT, "END");
 }
-
-#ifndef NO_ALPHA_HACK
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  Extract a copy of rgba pixels, removing alpha by compositing    */
-/* with a white background.                                                  */
-/*                                                                           */
-/* This is currently needed due to the lousy job gnome-print does in         */
-/* rendering images with alpha channels to PS.  This sacrafices the ability  */
-/* to do compositing of images with other items in the background.           */
-/*---------------------------------------------------------------------------*/
-static guchar *
-get_pixels_as_rgb (const GdkPixbuf *pixbuf)
-{
-       gint             bits_per_sample, channels;
-       gboolean         has_alpha;
-       gint             width, height, rowstride;
-       gulong           bytes;
-       guchar          *buf_src, *buf_dest;
-       guchar          *p_src, *p_dest;
-       gint             ix, iy;
-       guchar           r, g, b, a;
-       gdouble          alpha, beta;
-
-       gl_debug (DEBUG_PRINT, "START");
-
-       g_return_val_if_fail (pixbuf && GDK_IS_PIXBUF (pixbuf), NULL);
-
-       /* extract pixels and parameters from pixbuf. */
-       buf_src         = gdk_pixbuf_get_pixels (pixbuf);
-       bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf);
-       channels        = gdk_pixbuf_get_n_channels (pixbuf);
-       has_alpha       = gdk_pixbuf_get_has_alpha (pixbuf);
-       width           = gdk_pixbuf_get_width (pixbuf);
-       height          = gdk_pixbuf_get_height (pixbuf);
-       rowstride       = gdk_pixbuf_get_rowstride (pixbuf);
-
-       /* validate assumptions about pixbuf. */
-        g_return_val_if_fail (buf_src, NULL);
-        g_return_val_if_fail (bits_per_sample == 8, NULL);
-        g_return_val_if_fail (channels == 4, NULL);
-       g_return_val_if_fail (has_alpha, NULL);
-        g_return_val_if_fail (width > 0, NULL);
-        g_return_val_if_fail (height > 0, NULL);
-        g_return_val_if_fail (rowstride > 0, NULL);
-
-       /* Allocate a destination buffer */
-       bytes = height * rowstride;
-       gl_debug (DEBUG_PRINT, "bytes = %d", bytes);
-       buf_dest = g_try_malloc (bytes);
-       if (!buf_dest) {
-               return NULL;
-       }
-       gl_debug (DEBUG_PRINT, "buf_dest = %x", buf_dest);
-
-       /* Copy pixels, transforming rgba to rgb by compositing with a white bg. */
-       p_src  = buf_src;
-       p_dest = buf_dest;
-       for ( iy=0; iy < height; iy++ ) {
-       
-               p_src  = buf_src + iy*rowstride;
-               p_dest = buf_dest + iy*rowstride;
-
-               for ( ix=0; ix < width; ix++ ) {
-
-                       r = *p_src++;
-                       g = *p_src++;
-                       b = *p_src++;
-                       a = *p_src++;
-
-                       alpha = a / 255.0;
-                       beta  = 1.0 - alpha;
-
-                       *p_dest++ = (guchar) (alpha*r + beta*255 + 0.5);
-                       *p_dest++ = (guchar) (alpha*g + beta*255 + 0.5);
-                       *p_dest++ = (guchar) (alpha*b + beta*255 + 0.5);
-
-               }
-
-       }
-
-       gl_debug (DEBUG_PRINT, "START");
-
-       return buf_dest;
-}
-#endif
index d19a385cb1a44f95f7f6d18cafd52509c7801afe..b4f46a1f0add83de3755b308f8b0345ce61700d3 100644 (file)
@@ -1,9 +1,11 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+
 /*
  *  (GLABELS) Label and Business Card Creation program for GNOME
  *
  *  print.h:  Print module header file
  *
- *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
+ *  Copyright (C) 2001-2007  Jim Evins <evins@snaught.com>.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #ifndef __PRINT_H__
 #define __PRINT_H__
 
-#include <libgnomeprint/gnome-print-job.h>
+#include <cairo/cairo.h>
 
 #include "label.h"
 
 G_BEGIN_DECLS
 
 typedef struct {
-       gboolean outline;
-       gboolean reverse;
-       gboolean crop_marks;
-} glPrintFlags;
-
-void gl_print_simple           (GnomePrintJob    *job,
-                               glLabel          *label,
-                               gint              n_sheets,
-                               gint              first,
-                               gint              last,
-                               glPrintFlags     *flags);
+       gint   i_copy;
+       GList *p_record;
+} glPrintState;
 
-void gl_print_merge_collated   (GnomePrintJob    *job,
-                               glLabel          *label,
-                               gint              n_copies,
-                               gint              first,
-                               glPrintFlags     *flags);
+void gl_print_simple_sheet           (glLabel          *label,
+                                     cairo_t          *cr,
+                                     gint              page,
+                                     gint              n_sheets,
+                                     gint              first,
+                                     gint              last,
+                                     gboolean          outline_flag,
+                                     gboolean          reverse_flag,
+                                     gboolean          crop_marks_flag);
 
-void gl_print_merge_uncollated (GnomePrintJob    *job,
-                               glLabel          *label,
-                               gint              n_copies,
-                               gint              first,
-                               glPrintFlags     *flags);
+void gl_print_collated_merge_sheet   (glLabel          *label,
+                                     cairo_t          *cr,
+                                     gint              page,
+                                     gint              n_copies,
+                                     gint              first,
+                                     gboolean          outline_flag,
+                                     gboolean          reverse_flag,
+                                     gboolean          crop_marks_flag,
+                                     glPrintState     *state);
 
-void gl_print_batch            (GnomePrintJob    *job,
-                               glLabel          *label,
-                               gint              n_sheets,
-                               gint              n_copies,
-                               gint              first,
-                               glPrintFlags     *flags);
+void gl_print_uncollated_merge_sheet (glLabel          *label,
+                                     cairo_t          *cr,
+                                     gint              page,
+                                     gint              n_copies,
+                                     gint              first,
+                                     gboolean          outline_flag,
+                                     gboolean          reverse_flag,
+                                     gboolean          crop_marks_flag,
+                                     glPrintState     *state);
 
 G_END_DECLS
 
index 236c75f29a717e53537a8d79d9b2e0126261549f..43a05fbc205132a35c1f61f68a5552632bd22aa6 100644 (file)
@@ -1496,9 +1496,12 @@ print_test_cb (glTemplateDesigner      *dlg)
        template = build_template (dlg);
        gl_label_set_template (GL_LABEL(label), template);
 
-       print_dialog = gl_print_dialog_new (GL_LABEL(label), NULL);
+       print_dialog = gl_print_dialog_new (GL_LABEL(label));
        gl_print_dialog_force_outline_flag (GL_PRINT_DIALOG(print_dialog));
-       gtk_widget_show (print_dialog);
+        gtk_print_operation_run (GTK_PRINT_OPERATION (print_dialog),
+                                 GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
+                                 GTK_WINDOW (dlg),
+                                 NULL);
 
        gl_template_free (template);
        g_object_unref (G_OBJECT(label));
index db85c54ddb09763bb0cb2ab30e0ff1b9eb602ddb..a7de525b51864383f0d1dc501e7cb1d1f8521a3d 100644 (file)
@@ -191,30 +191,19 @@ void
 gl_ui_cmd_file_print (GtkAction *action,
                       glWindow  *window)
 {
+        glPrintDialog *dialog;
+
         gl_debug (DEBUG_COMMANDS, "START");
 
         g_return_if_fail (action && GTK_IS_ACTION(action));
         g_return_if_fail (window && GL_IS_WINDOW(window));
 
-        if (window->print_dialog) {
-
-                gtk_window_present (GTK_WINDOW(window->print_dialog));
-                gtk_window_set_transient_for (GTK_WINDOW (window->print_dialog),
-                                              GTK_WINDOW (window));
-
-        } else {
-
-                window->print_dialog =
-                        g_object_ref (
-                                gl_print_dialog_new (GL_VIEW(window->view)->label,
-                                                     GTK_WINDOW(window)) );
+        dialog = gl_print_dialog_new (GL_VIEW(window->view)->label);
 
-                g_signal_connect (G_OBJECT(window->print_dialog), "destroy",
-                                  G_CALLBACK (gtk_widget_destroyed),
-                                  &window->print_dialog);
-
-                gtk_widget_show (GTK_WIDGET (window->print_dialog));
-        }
+        gtk_print_operation_run (GTK_PRINT_OPERATION (dialog),
+                                 GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
+                                 GTK_WINDOW (window),
+                                 NULL);
 
         gl_debug (DEBUG_COMMANDS, "END");
 }
index 1ecf8d6d67bb602551dc8c0a1d1c86a541837b3f..94d7d4ce6e710a0c12d0c4dfb1312c78a6339cdb 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "wdgt-print-merge.h"
 
+#include <math.h>
 #include <glib/gi18n.h>
 #include <gtk/gtktogglebutton.h>
 #include <gtk/gtkspinbutton.h>
@@ -305,10 +306,11 @@ preview_clicked (glWdgtMiniPreview *mini_preview,
 /* query selected range of labels within sheet or number of sheets.         */
 /****************************************************************************/
 void
-gl_wdgt_print_merge_get_copies (glWdgtPrintMerge * merge,
-                               gint * n_copies,
-                               gint * first_label,
-                               gboolean * collate_flag)
+gl_wdgt_print_merge_get_copies (glWdgtPrintMerge *merge,
+                               gint             *n_copies,
+                               gint             *first_label,
+                               gboolean         *collate_flag,
+                               gint             *n_sheets)
 {
        *n_copies =
            gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON
@@ -319,6 +321,8 @@ gl_wdgt_print_merge_get_copies (glWdgtPrintMerge * merge,
        *collate_flag =
            gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
                                          (merge->collate_check));
+
+       *n_sheets = ceil ( (double)(*first_label - 1 + (*n_copies * merge->n_records))/ (double)merge->labels_per_sheet );
 }
 
 /****************************************************************************/
index 378bae4a085ff87a5d5579cc0ec52e7420d5bfa8..5ff39dedb19668a15b1c930d61c3818ba4322e23 100644 (file)
@@ -66,7 +66,8 @@ GtkWidget *gl_wdgt_print_merge_new        (glLabel          *label);
 void       gl_wdgt_print_merge_get_copies (glWdgtPrintMerge *merge,
                                           gint             *n_copies,
                                           gint             *first_label,
-                                          gboolean         *collate_flag);
+                                          gboolean         *collate_flag,
+                                          gint             *n_sheets);
 
 void       gl_wdgt_print_merge_set_copies (glWdgtPrintMerge *merge,
                                           gint              n_copies,
index e76c19dbd43551247a5070bf0c01a1ffee412918..a72a77d10fe8922aa281a710fa9a4c540d3a6bad 100644 (file)
@@ -219,7 +219,6 @@ gl_window_init (glWindow *window)
        window->menu_tips_context_id =
                gtk_statusbar_get_context_id (GTK_STATUSBAR (window->status_bar), "menu_tips");
 
-       window->print_dialog = NULL;
        window->merge_dialog = NULL;
        window->context_menu = GTK_MENU (gtk_ui_manager_get_widget (ui, "/ContextMenu"));
        window->empty_selection_context_menu =
index 05802b66aeb8342cba8bd9aad628f93d64f43e81..44ccd19535b125d22d1e4ef49fbe9ec44e35dfff 100644 (file)
@@ -33,7 +33,6 @@
 #include "label.h"
 #include "ui-property-bar.h"
 #include "ui-sidebar.h"
-#include "print-dialog.h"
 #include "merge-properties-dialog.h"
 
 G_BEGIN_DECLS
@@ -71,7 +70,6 @@ struct _glWindow {
 
        guint                    menu_tips_context_id;
 
-       glPrintDialog           *print_dialog;
        glMergePropertiesDialog *merge_dialog;
        GtkMenu                 *context_menu;
        GtkMenu                 *empty_selection_context_menu;