From: Jim Evins Date: Sun, 13 Sep 2009 05:00:03 +0000 (+0000) Subject: 2009-09-13 Jim Evins X-Git-Tag: glabels-2_3_0~194 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a1f61988eb85f9133482e6f8fa6232600f897b1c;p=glabels 2009-09-13 Jim Evins Refactored print operation subsystem. * src/print-op.c: * src/print-op.h: Basic GtkPrintOperation based class. Does not instantiate custom widgets, so it can be used by glabels-batch without the additional overhead. * src/print-op-dialog.c: * src/print-op-dialog.h: New object derived from glPrintOp. This one is intended to be used as a dialog and installs custom widgets. glWdgtPrintCopies and glWdgtPrintMerge have been merged into this object. * src/wdgt-print-copies.c: * src/wdgt-print-copies.h: * src/wdgt-print-merge.c: * src/wdgt-print-merge.h: Deleted. * src/Makefile.am: Modified to reflect above additions and deletions. * src/mini-preview.c: (gl_mini_preview_construct), (gl_mini_preview_set_template), (set_transform_and_get_scale), (button_press_event_cb), (motion_notify_event_cb), (draw): Now scales with allocation. * src/glabels-batch.c: (main): * src/template-designer.c: (print_test_cb): * src/ui-commands.c: (gl_ui_cmd_file_print): Use above modifications. * data/builder/print-op-dialog-custom-widget.builder: New builder file for glPrintOpDialog custom widgets. * data/builder/print-custom-widget.builder: Deleted. * data/builder/Makefile.am: Modified to reflect above addition and deletion. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@883 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index c28d00e2..75999dfa 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,40 @@ +2009-09-13 Jim Evins + + Refactored print operation subsystem. + + * src/print-op.c: + * src/print-op.h: + Basic GtkPrintOperation based class. Does not instantiate + custom widgets, so it can be used by glabels-batch without + the additional overhead. + * src/print-op-dialog.c: + * src/print-op-dialog.h: + New object derived from glPrintOp. This one is intended + to be used as a dialog and installs custom widgets. + glWdgtPrintCopies and glWdgtPrintMerge have been merged + into this object. + * src/wdgt-print-copies.c: + * src/wdgt-print-copies.h: + * src/wdgt-print-merge.c: + * src/wdgt-print-merge.h: + Deleted. + * src/Makefile.am: + Modified to reflect above additions and deletions. + * src/mini-preview.c: (gl_mini_preview_construct), + (gl_mini_preview_set_template), (set_transform_and_get_scale), + (button_press_event_cb), (motion_notify_event_cb), (draw): + Now scales with allocation. + * src/glabels-batch.c: (main): + * src/template-designer.c: (print_test_cb): + * src/ui-commands.c: (gl_ui_cmd_file_print): + Use above modifications. + * data/builder/print-op-dialog-custom-widget.builder: + New builder file for glPrintOpDialog custom widgets. + * data/builder/print-custom-widget.builder: + Deleted. + * data/builder/Makefile.am: + Modified to reflect above addition and deletion. + 2009-09-10 Jim Evins * src/Makefile.am: diff --git a/glabels2/data/builder/Makefile.am b/glabels2/data/builder/Makefile.am index 9fb6fc93..1f057753 100644 --- a/glabels2/data/builder/Makefile.am +++ b/glabels2/data/builder/Makefile.am @@ -4,7 +4,7 @@ builderdir = $(datadir)/glabels/builder/ builder_DATA = \ property-bar.builder \ - print-custom-widget.builder \ + print-op-dialog-custom-widget.builder \ wdgt-media-select.builder \ merge-properties-dialog.builder \ new-label-dialog.builder \ diff --git a/glabels2/data/builder/print-custom-widget.builder b/glabels2/data/builder/print-custom-widget.builder deleted file mode 100644 index 1c01824b..00000000 --- a/glabels2/data/builder/print-custom-widget.builder +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - True - window1 - - - True - 12 - 12 - - - True - - - True - 0 - none - - - True - 12 - - - True - - - - - - - - - - True - <b>Print control (Simple)</b> - True - - - - - 0 - - - - - True - 0 - none - - - True - 12 - - - True - - - - - - - - - - True - <b>Print control (Merge)</b> - True - - - - - 1 - - - - - False - False - 0 - - - - - True - 0 - none - - - True - 12 - - - True - - - print outlines (to test printer alignment) - True - True - False - True - True - - - False - False - 0 - - - - - print in reverse (i.e. a mirror image) - True - True - False - True - True - - - False - False - 1 - - - - - print crop marks - True - True - False - True - True - - - False - False - 2 - - - - - - - - - True - <b>Options</b> - True - - - - - 1 - - - - - - diff --git a/glabels2/data/builder/print-op-dialog-custom-widget.builder b/glabels2/data/builder/print-op-dialog-custom-widget.builder new file mode 100644 index 00000000..59afddbb --- /dev/null +++ b/glabels2/data/builder/print-op-dialog-custom-widget.builder @@ -0,0 +1,467 @@ + + + + + + True + window1 + + + True + 12 + 3 + + + + + + True + vertical + 12 + + + True + vertical + 12 + + + True + 0 + none + + + True + 12 + + + True + vertical + 6 + + + True + 6 + + + Sheets: + True + True + False + True + True + + + False + False + 0 + + + + + True + True + + adjustment1 + + + False + False + 1 + + + + + 0 + + + + + True + 6 + + + Labels + True + True + False + True + True + simple_sheets_radio + + + False + False + 0 + + + + + True + 3 + + + True + from: + + + False + False + 0 + + + + + True + True + + adjustment2 + + + False + False + 1 + + + + + False + False + 3 + 1 + + + + + True + 3 + + + True + to: + + + False + False + 0 + + + + + True + True + + adjustment3 + + + False + False + 1 + + + + + False + False + 3 + 2 + + + + + 1 + + + + + + + + + True + <b>Copies</b> + True + + + + + False + False + 0 + + + + + True + 0 + none + + + True + 12 + + + True + vertical + 6 + + + True + 6 + + + True + Start on label + + + False + False + 0 + + + + + True + True + + adjustment4 + + + False + False + 1 + + + + + True + on 1st sheet + + + False + False + 2 + + + + + False + False + 0 + + + + + True + 6 + + + True + Copies: + + + False + False + 0 + + + + + True + True + + adjustment5 + + + False + False + 1 + + + + + True + 12 + + + Collate + True + True + False + True + + + False + False + 0 + + + + + True + gtk-missing-image + + + 1 + + + + + False + False + 12 + 2 + + + + + 1 + + + + + + + + + True + <b>Merge Control</b> + True + + + + + False + False + 1 + + + + + False + False + 0 + + + + + True + 0 + none + + + True + 12 + + + True + vertical + + + print outlines (to test printer alignment) + True + True + False + True + True + + + False + False + 0 + + + + + print in reverse (i.e. a mirror image) + True + True + False + True + True + + + False + False + 1 + + + + + print crop marks + True + True + False + True + True + + + False + False + 2 + + + + + + + + + True + <b>Options</b> + True + + + + + False + False + 1 + + + + + False + False + end + 0 + + + + + + + 1 + 1 + 100 + 1 + 10 + + + 1 + 1 + 100 + 1 + 10 + + + 1 + 1 + 100 + 1 + 10 + + + 1 + 1 + 100 + 1 + 10 + + + 1 + 1 + 100 + 1 + 10 + + diff --git a/glabels2/src/Makefile.am b/glabels2/src/Makefile.am index 7baaf2a1..fa5161b8 100644 --- a/glabels2/src/Makefile.am +++ b/glabels2/src/Makefile.am @@ -115,6 +115,8 @@ glabels_SOURCES = \ print.h \ print-op.c \ print-op.h \ + print-op-dialog.c \ + print-op-dialog.h \ template-designer.c \ template-designer.h \ bc.c \ @@ -165,10 +167,6 @@ glabels_SOURCES = \ mini-preview-pixbuf.h \ mini-preview-pixbuf-cache.c \ mini-preview-pixbuf-cache.h \ - wdgt-print-copies.c \ - wdgt-print-copies.h \ - wdgt-print-merge.c \ - wdgt-print-merge.h \ wdgt-media-select.c \ wdgt-media-select.h \ mini-preview.c \ @@ -280,12 +278,6 @@ glabels_batch_SOURCES = \ color.h \ debug.c \ debug.h \ - wdgt-print-copies.c \ - wdgt-print-copies.h \ - wdgt-print-merge.c \ - wdgt-print-merge.h \ - mini-preview.c \ - mini-preview.h \ hig.h \ cairo-label-path.c \ cairo-label-path.h \ diff --git a/glabels2/src/glabels-batch.c b/glabels2/src/glabels-batch.c index 32e46bae..e4cb2c4d 100644 --- a/glabels2/src/glabels-batch.c +++ b/glabels2/src/glabels-batch.c @@ -1,25 +1,21 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - /* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * glabels.c: main program module + * glabels-batch.c + * Copyright (C) 2001-2009 Jim Evins . * - * Copyright (C) 2001 Jim Evins . + * This file is part of gLabels. * - * This program is free software; you can redistribute it and/or modify + * gLabels is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * gLabels is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with gLabels. If not, see . */ #include @@ -32,6 +28,7 @@ #include "print-op.h" #include #include "util.h" +#include #include "prefs.h" #include "debug.h" @@ -83,6 +80,7 @@ main (int argc, char **argv) gchar *abs_fn; glLabel *label = NULL; glMerge *merge = NULL; + lglTemplateFrame *frame; glXMLLabelStatus status; glPrintOp *print_op; gchar *utf8_filename; @@ -137,8 +135,8 @@ main (int argc, char **argv) if ( status == XML_LABEL_OK ) { + merge = gl_label_get_merge (label); if (input != NULL) { - merge = gl_label_get_merge (label); if (merge != NULL) { gl_merge_set_src(merge, input); gl_label_set_merge(label, merge); @@ -149,15 +147,27 @@ main (int argc, char **argv) } } abs_fn = gl_util_make_absolute ( output ); - print_op = gl_print_op_new_batch (label, - abs_fn, - n_sheets, - n_copies, - first, - outline_flag, - reverse_flag, - crop_marks_flag); - + frame = (lglTemplateFrame *)label->template->frames->data; + + print_op = gl_print_op_new (label); + gl_print_op_set_filename (print_op, abs_fn); + gl_print_op_set_n_copies (print_op, n_copies); + gl_print_op_set_first (print_op, first); + gl_print_op_set_outline_flag (print_op, outline_flag); + gl_print_op_set_reverse_flag (print_op, reverse_flag); + gl_print_op_set_crop_marks_flag (print_op, crop_marks_flag); + if (merge) + { + gl_print_op_set_n_sheets (print_op, + ceil ((double)(first-1 + n_copies * gl_merge_get_record_count(merge)) + / lgl_template_frame_get_n_labels (frame))); + } + else + { + gl_print_op_set_n_sheets (print_op, n_sheets); + gl_print_op_set_last (print_op, + lgl_template_frame_get_n_labels (frame)); + } gtk_print_operation_run (GTK_PRINT_OPERATION (print_op), GTK_PRINT_OPERATION_ACTION_EXPORT, NULL, @@ -176,3 +186,14 @@ main (int argc, char **argv) return 0; } + + + +/* + * Local Variables: -- emacs + * mode: C -- emacs + * c-basic-offset: 8 -- emacs + * tab-width: 8 -- emacs + * indent-tabs-mode: nil -- emacs + * End: -- emacs + */ diff --git a/glabels2/src/mini-preview.c b/glabels2/src/mini-preview.c index 5af8b9fa..9034ed7b 100644 --- a/glabels2/src/mini-preview.c +++ b/glabels2/src/mini-preview.c @@ -36,7 +36,7 @@ /* Private macros and constants. */ /*===========================================*/ -#define MARGIN +#define MARGIN 2 #define SHADOW_OFFSET 3 @@ -59,13 +59,7 @@ struct _glMiniPreviewPrivate { GtkWidget *canvas; - gint height; - gint width; - lglTemplate *template; - gdouble scale; - gdouble offset_x; - gdouble offset_y; gint labels_per_sheet; LabelCenter *centers; @@ -135,6 +129,9 @@ static gint find_closest_label (glMiniPreview *this, gdouble x, gdouble y); +static gdouble set_transform_and_get_scale (glMiniPreview *this, + cairo_t *cr); + /****************************************************************************/ /* Object infrastructure. */ @@ -266,9 +263,6 @@ gl_mini_preview_construct (glMiniPreview *this, { gl_debug (DEBUG_MINI_PREVIEW, "START"); - this->priv->height = height; - this->priv->width = width; - gtk_widget_set_size_request (GTK_WIDGET (this->priv->canvas), width, height); gl_debug (DEBUG_MINI_PREVIEW, "END"); @@ -319,19 +313,6 @@ gl_mini_preview_set_template (glMiniPreview *this, lgl_template_free (this->priv->template); this->priv->template = lgl_template_dup (template); - /* - * Set scale and offsets - */ - w = this->priv->width - 2*MARGIN - 2*SHADOW_OFFSET; - h = this->priv->height - 2*MARGIN - 2*SHADOW_OFFSET; - if ( (w/template->page_width) > (h/template->page_height) ) { - this->priv->scale = h / template->page_height; - } else { - this->priv->scale = w / template->page_width; - } - this->priv->offset_x = (this->priv->width/this->priv->scale - template->page_width) / 2.0; - this->priv->offset_y = (this->priv->height/this->priv->scale - template->page_height) / 2.0; - /* * Set labels per sheet */ @@ -379,6 +360,39 @@ gl_mini_preview_highlight_range (glMiniPreview *this, } +/*--------------------------------------------------------------------------*/ +/* Set transformation and return scale. */ +/*--------------------------------------------------------------------------*/ +static gdouble +set_transform_and_get_scale (glMiniPreview *this, + cairo_t *cr) +{ + lglTemplate *template = this->priv->template; + gdouble w, h; + gdouble w1, h1; + gdouble scale; + gdouble offset_x, offset_y; + + /* Establish scale and origin. */ + w = GTK_WIDGET (this)->allocation.width; + h = GTK_WIDGET (this)->allocation.height; + + /* establish scale. */ + scale = MIN( (w - 2*MARGIN - 2*SHADOW_OFFSET)/template->page_width, + (h - 2*MARGIN - 2*SHADOW_OFFSET)/template->page_height ); + + /* Find offset to center preview. */ + offset_x = (w/scale - template->page_width) / 2.0; + offset_y = (h/scale - template->page_height) / 2.0; + + /* Set transformation. */ + cairo_scale (cr, scale, scale); + cairo_translate (cr, offset_x, offset_y); + + return scale; +} + + /*--------------------------------------------------------------------------*/ /* Button press event handler */ /*--------------------------------------------------------------------------*/ @@ -388,6 +402,7 @@ button_press_event_cb (GtkWidget *widget, { glMiniPreview *this = GL_MINI_PREVIEW (widget); cairo_t *cr; + gdouble scale; gdouble x, y; gint i; @@ -397,9 +412,7 @@ button_press_event_cb (GtkWidget *widget, { cr = gdk_cairo_create (GTK_WIDGET (this->priv->canvas)->window); - /* Set transformation. */ - cairo_scale (cr, this->priv->scale, this->priv->scale); - cairo_translate (cr, this->priv->offset_x, this->priv->offset_y); + scale = set_transform_and_get_scale (this, cr); x = event->x; y = event->y; @@ -437,6 +450,7 @@ motion_notify_event_cb (GtkWidget *widget, { glMiniPreview *this = GL_MINI_PREVIEW (widget); cairo_t *cr; + gdouble scale; gdouble x, y; gint i; @@ -446,9 +460,7 @@ motion_notify_event_cb (GtkWidget *widget, { cr = gdk_cairo_create (GTK_WIDGET (this->priv->canvas)->window); - /* Set transformation. */ - cairo_scale (cr, this->priv->scale, this->priv->scale); - cairo_translate (cr, this->priv->offset_x, this->priv->offset_y); + scale = set_transform_and_get_scale (this, cr); x = event->x; y = event->y; @@ -610,21 +622,20 @@ draw (glMiniPreview *this, cairo_t *cr) { lglTemplate *template = this->priv->template; + gdouble scale; gdouble shadow_x, shadow_y; + gl_debug (DEBUG_MINI_PREVIEW, "START"); if (template) { - /* Set transformation. */ - cairo_scale (cr, this->priv->scale, this->priv->scale); - cairo_translate (cr, this->priv->offset_x, this->priv->offset_y); - + scale = set_transform_and_get_scale (this, cr); /* update shadow */ - shadow_x = SHADOW_OFFSET/this->priv->scale; - shadow_y = SHADOW_OFFSET/this->priv->scale; + shadow_x = SHADOW_OFFSET/scale; + shadow_y = SHADOW_OFFSET/scale; draw_shadow (this, cr, shadow_x, shadow_y, @@ -632,9 +643,9 @@ draw (glMiniPreview *this, draw_paper (this, cr, template->page_width, template->page_height, - 1.0/this->priv->scale); + 1.0/scale); - draw_labels (this, cr, template, 1.0/this->priv->scale); + draw_labels (this, cr, template, 1.0/scale); } diff --git a/glabels2/src/print-op-dialog.c b/glabels2/src/print-op-dialog.c new file mode 100644 index 00000000..46a25c2c --- /dev/null +++ b/glabels2/src/print-op-dialog.c @@ -0,0 +1,676 @@ +/* + * print-op-dialog.c + * Copyright (C) 2001-2009 Jim Evins . + * + * This file is part of gLabels. + * + * gLabels is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels. If not, see . + */ + +#include + +#include "print-op-dialog.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "mini-preview.h" +#include "label.h" +#include "util.h" + +#include "pixmaps/collate.xpm" +#include "pixmaps/nocollate.xpm" + +#include "debug.h" + + +#define MINI_PREVIEW_MIN_HEIGHT 175 +#define MINI_PREVIEW_MIN_WIDTH 150 + + +/*===========================================*/ +/* Private data types */ +/*===========================================*/ + +struct _glPrintOpDialogPrivate { + + GtkBuilder *builder; + + GtkWidget *simple_frame; + GtkWidget *simple_sheets_radio; + GtkWidget *simple_sheets_spin; + GtkWidget *simple_labels_radio; + GtkWidget *simple_first_spin; + GtkWidget *simple_last_spin; + + GtkWidget *merge_frame; + GtkWidget *merge_first_spin; + GtkWidget *merge_copies_spin; + GtkWidget *merge_collate_check; + GtkWidget *merge_collate_image; + + GtkWidget *outline_check; + GtkWidget *reverse_check; + GtkWidget *crop_marks_check; + + GtkWidget *preview; + + gboolean force_outline_flag; + + gint labels_per_sheet; + gboolean merge_flag; + gint n_records; + +}; + + +/*===========================================*/ +/* Private globals */ +/*===========================================*/ + + +/*===========================================*/ +/* Local function prototypes */ +/*===========================================*/ + +static void gl_print_op_dialog_finalize (GObject *object); + +static void gl_print_op_dialog_construct (glPrintOpDialog *op, + glLabel *label); + +static GObject *create_custom_widget_cb (GtkPrintOperation *operation, + glLabel *label); + +static void custom_widget_apply_cb (GtkPrintOperation *operation, + GtkWidget *widget, + glLabel *label); + +static void simple_sheets_radio_cb (GtkToggleButton *togglebutton, + glPrintOpDialog *op); + +static void simple_first_spin_cb (GtkSpinButton *spinbutton, + glPrintOpDialog *op); + +static void simple_last_spin_cb (GtkSpinButton *spinbutton, + glPrintOpDialog *op); + +static void preview_pressed_cb (glMiniPreview *preview, + gint first, + gint last, + glPrintOpDialog *op); + +static void merge_spin_cb (GtkSpinButton *spinbutton, + glPrintOpDialog *op); + +static void merge_collate_check_cb (GtkToggleButton *togglebutton, + glPrintOpDialog *op); + +static void preview_clicked_cb (glMiniPreview *preview, + gint first, + glPrintOpDialog *op); + + +/*****************************************************************************/ +/* Boilerplate object stuff. */ +/*****************************************************************************/ +G_DEFINE_TYPE (glPrintOpDialog, gl_print_op_dialog, GL_TYPE_PRINT_OP); + + +static void +gl_print_op_dialog_class_init (glPrintOpDialogClass *class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (class); + + gl_debug (DEBUG_PRINT, ""); + + gl_print_op_dialog_parent_class = g_type_class_peek_parent (class); + + object_class->finalize = gl_print_op_dialog_finalize; +} + + +static void +gl_print_op_dialog_init (glPrintOpDialog *op) +{ + gl_debug (DEBUG_PRINT, ""); + + gtk_print_operation_set_use_full_page (GTK_PRINT_OPERATION (op), TRUE); + + gtk_print_operation_set_unit (GTK_PRINT_OPERATION (op), GTK_UNIT_POINTS); + + op->priv = g_new0 (glPrintOpDialogPrivate, 1); + +} + + +static void +gl_print_op_dialog_finalize (GObject *object) +{ + glPrintOpDialog *op = GL_PRINT_OP_DIALOG (object); + + gl_debug (DEBUG_PRINT, ""); + + g_return_if_fail (object != NULL); + g_return_if_fail (GL_IS_PRINT_OP (op)); + g_return_if_fail (op->priv != NULL); + + g_object_unref (G_OBJECT(op->priv->builder)); + g_free (op->priv); + + G_OBJECT_CLASS (gl_print_op_dialog_parent_class)->finalize (object); + + g_free (op->priv); +} + + +/*****************************************************************************/ +/* NEW print op. */ +/*****************************************************************************/ +glPrintOpDialog * +gl_print_op_dialog_new (glLabel *label) +{ + glPrintOpDialog *op; + + gl_debug (DEBUG_PRINT, ""); + + op = GL_PRINT_OP_DIALOG (g_object_new (GL_TYPE_PRINT_OP_DIALOG, NULL)); + + gl_print_op_dialog_construct (GL_PRINT_OP_DIALOG(op), label); + + return op; +} + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Construct op. */ +/*--------------------------------------------------------------------------*/ +static void +gl_print_op_dialog_construct (glPrintOpDialog *op, + glLabel *label) +{ + + gl_print_op_construct(GL_PRINT_OP (op), label); + + gtk_print_operation_set_custom_tab_label ( GTK_PRINT_OPERATION (op), + _("Labels")); + + g_signal_connect (G_OBJECT (op), "create-custom-widget", + G_CALLBACK (create_custom_widget_cb), label); + + g_signal_connect (G_OBJECT (op), "custom-widget-apply", + G_CALLBACK (custom_widget_apply_cb), label); + +} + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. "Create custom widget" callback */ +/*--------------------------------------------------------------------------*/ +static GObject * +create_custom_widget_cb (GtkPrintOperation *operation, + glLabel *label) +{ + GtkBuilder *builder; + static gchar *object_ids[] = { "print_custom_widget_hbox", + "adjustment1", "adjustment2", + "adjustment3", "adjustment4", + "adjustment5", + NULL }; + GError *error = NULL; + glPrintOpDialog *op = GL_PRINT_OP_DIALOG (operation); + const lglTemplateFrame *frame; + GtkWidget *hbox; + glMerge *merge = NULL; + GdkPixbuf *pixbuf; + + + frame = (lglTemplateFrame *)label->template->frames->data; + op->priv->labels_per_sheet = lgl_template_frame_get_n_labels (frame); + + builder = gtk_builder_new (); + gtk_builder_add_objects_from_file (builder, + GLABELS_BUILDER_DIR "print-op-dialog-custom-widget.builder", + object_ids, + &error); + if (error) { + g_critical ("%s\n\ngLabels may not be installed correctly!", error->message); + g_error_free (error); + return NULL; + } + + gl_util_get_builder_widgets (builder, + "print_custom_widget_hbox", &hbox, + "simple_frame", &op->priv->simple_frame, + "simple_sheets_radio", &op->priv->simple_sheets_radio, + "simple_sheets_spin", &op->priv->simple_sheets_spin, + "simple_labels_radio", &op->priv->simple_labels_radio, + "simple_first_spin", &op->priv->simple_first_spin, + "simple_last_spin", &op->priv->simple_last_spin, + "merge_frame", &op->priv->merge_frame, + "merge_first_spin", &op->priv->merge_first_spin, + "merge_copies_spin", &op->priv->merge_copies_spin, + "merge_collate_check", &op->priv->merge_collate_check, + "merge_collate_image", &op->priv->merge_collate_image, + "outline_check", &op->priv->outline_check, + "reverse_check", &op->priv->reverse_check, + "crop_marks_check", &op->priv->crop_marks_check, + NULL); + + op->priv->builder = builder; + + /* ---- Install preview. ---- */ + op->priv->preview = gl_mini_preview_new (MINI_PREVIEW_MIN_HEIGHT, MINI_PREVIEW_MIN_WIDTH); + gl_mini_preview_set_template (GL_MINI_PREVIEW(op->priv->preview), label->template); + gtk_box_pack_start (GTK_BOX(hbox), op->priv->preview, TRUE, TRUE, 0); + gtk_widget_show_all (op->priv->preview); + + + /* ---- Activate either simple or merge print control widgets. ---- */ + merge = gl_label_get_merge (label); + op->priv->merge_flag = (merge != NULL); + if (!op->priv->merge_flag) { + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (op->priv->simple_sheets_radio), + TRUE); + gtk_widget_set_sensitive (op->priv->simple_first_spin, FALSE); + gtk_widget_set_sensitive (op->priv->simple_last_spin, FALSE); + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (op->priv->simple_sheets_spin), + gl_print_op_get_n_sheets (GL_PRINT_OP(op))); + + gtk_spin_button_set_range (GTK_SPIN_BUTTON (op->priv->simple_first_spin), + 1, op->priv->labels_per_sheet); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (op->priv->simple_first_spin), + 1); + + gtk_spin_button_set_range (GTK_SPIN_BUTTON (op->priv->simple_last_spin), + 1, op->priv->labels_per_sheet); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (op->priv->simple_last_spin), + op->priv->labels_per_sheet); + + /* Update preview. */ + gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview), + 1, op->priv->labels_per_sheet); + + gtk_widget_show_all (op->priv->simple_frame); + gtk_widget_hide_all (op->priv->merge_frame); + + g_signal_connect (G_OBJECT (op->priv->simple_sheets_radio), "toggled", + G_CALLBACK (simple_sheets_radio_cb), op); + g_signal_connect (G_OBJECT (op->priv->simple_first_spin), "changed", + G_CALLBACK (simple_first_spin_cb), op); + g_signal_connect (G_OBJECT (op->priv->simple_last_spin), "changed", + G_CALLBACK (simple_last_spin_cb), op); + g_signal_connect (G_OBJECT (op->priv->preview), "pressed", + G_CALLBACK (preview_pressed_cb), op); + + } else { + + op->priv->n_records = gl_merge_get_record_count (merge); + + gtk_spin_button_set_range (GTK_SPIN_BUTTON (op->priv->merge_first_spin), + 1, op->priv->labels_per_sheet); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (op->priv->merge_first_spin), + gl_print_op_get_first (GL_PRINT_OP(op))); + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (op->priv->merge_copies_spin), + gl_print_op_get_n_copies (GL_PRINT_OP(op))); + + gtk_widget_set_sensitive (op->priv->merge_collate_check, + (gl_print_op_get_n_copies (GL_PRINT_OP(op)) > 1)); + gtk_widget_set_sensitive (op->priv->merge_collate_image, + (gl_print_op_get_n_copies (GL_PRINT_OP(op)) > 1)); + + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (op->priv->simple_sheets_radio), + gl_print_op_get_collate_flag (GL_PRINT_OP(op))); + + if ( gl_print_op_get_collate_flag (GL_PRINT_OP(op)) ) + { + pixbuf = gdk_pixbuf_new_from_xpm_data ( (const char **)collate_xpm); + } + else + { + pixbuf = gdk_pixbuf_new_from_xpm_data ( (const char **)nocollate_xpm); + } + + gtk_image_set_from_pixbuf (GTK_IMAGE (op->priv->merge_collate_image), pixbuf); + + /* Update preview. */ + gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview), + gl_print_op_get_first (GL_PRINT_OP(op)), + gl_print_op_get_first (GL_PRINT_OP(op)) + op->priv->n_records - 1); + + gtk_widget_hide_all (op->priv->simple_frame); + gtk_widget_show_all (op->priv->merge_frame); + + g_signal_connect (G_OBJECT (op->priv->merge_first_spin), "changed", + G_CALLBACK (merge_spin_cb), op); + g_signal_connect (G_OBJECT (op->priv->merge_copies_spin), "changed", + G_CALLBACK (merge_spin_cb), op); + g_signal_connect (G_OBJECT (op->priv->merge_collate_check), "toggled", + G_CALLBACK (merge_collate_check_cb), op); + g_signal_connect (G_OBJECT (op->priv->preview), "clicked", + G_CALLBACK (preview_clicked_cb), op); + + g_object_unref (G_OBJECT(merge)); + + } + + /* --- Set options --- */ + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (op->priv->outline_check), + gl_print_op_get_outline_flag (GL_PRINT_OP(op))); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (op->priv->reverse_check), + gl_print_op_get_reverse_flag (GL_PRINT_OP(op))); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (op->priv->crop_marks_check), + gl_print_op_get_crop_marks_flag (GL_PRINT_OP(op))); + + /* --- Do we need to force the outline flag --- */ + if (gl_print_op_is_outline_forced (GL_PRINT_OP (op))) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(op->priv->outline_check), + TRUE); + + gtk_widget_set_sensitive (op->priv->outline_check, FALSE); + gtk_widget_set_sensitive (op->priv->reverse_check, FALSE); + gtk_widget_set_sensitive (op->priv->crop_marks_check, FALSE); + } + + return G_OBJECT (hbox); +} + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. "Custom widget apply" callback */ +/*--------------------------------------------------------------------------*/ +static void +custom_widget_apply_cb (GtkPrintOperation *operation, + GtkWidget *widget, + glLabel *label) +{ + glPrintOpDialog *op = GL_PRINT_OP_DIALOG (operation); + glMerge *merge = NULL; + gint n_records; + gint n_sheets, first, last, n_copies; + gboolean collate_flag; + + gl_print_op_set_outline_flag (GL_PRINT_OP (op), + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON + (op->priv->outline_check))); + gl_print_op_set_reverse_flag (GL_PRINT_OP (op), + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON + (op->priv->reverse_check))); + gl_print_op_set_crop_marks_flag (GL_PRINT_OP (op), + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON + (op->priv->crop_marks_check))); + + + if (!op->priv->merge_flag) + { + + n_sheets = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->simple_sheets_spin)); + gl_print_op_set_n_sheets (GL_PRINT_OP (op), n_sheets); + + first = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->simple_first_spin)); + gl_print_op_set_first (GL_PRINT_OP (op), first); + + last = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->simple_last_spin)); + gl_print_op_set_last (GL_PRINT_OP (op), last); + + } + else + { + + merge = gl_label_get_merge (label); + + n_copies = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->merge_copies_spin)); + gl_print_op_set_n_copies (GL_PRINT_OP (op), n_copies); + + first = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->merge_first_spin)); + gl_print_op_set_first (GL_PRINT_OP (op), first); + + collate_flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (op->priv->merge_collate_check)); + gl_print_op_set_collate_flag (GL_PRINT_OP (op), collate_flag); + + n_records = gl_merge_get_record_count (merge); + n_sheets = ceil (first - 1 + (n_copies * n_records)/(double)op->priv->labels_per_sheet); + gl_print_op_set_n_sheets (GL_PRINT_OP (op), n_sheets); + + g_object_unref (G_OBJECT(merge)); + + } + + +} + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Simple sheets radio "toggled" callback */ +/*--------------------------------------------------------------------------*/ +static void +simple_sheets_radio_cb (GtkToggleButton *togglebutton, + glPrintOpDialog *op) +{ + gint first, last; + + if (gtk_toggle_button_get_active (togglebutton)) { + + gtk_widget_set_sensitive (op->priv->simple_sheets_spin, TRUE); + gtk_widget_set_sensitive (op->priv->simple_first_spin, FALSE); + gtk_widget_set_sensitive (op->priv->simple_last_spin, FALSE); + + gtk_spin_button_set_range (GTK_SPIN_BUTTON (op->priv->simple_first_spin), + 1, op->priv->labels_per_sheet); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (op->priv->simple_first_spin), + 1); + + gtk_spin_button_set_range (GTK_SPIN_BUTTON (op->priv->simple_last_spin), + 1, op->priv->labels_per_sheet); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (op->priv->simple_last_spin), + op->priv->labels_per_sheet); + + gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview), + 1, op->priv->labels_per_sheet); + + } else { + + gtk_widget_set_sensitive (op->priv->simple_sheets_spin, FALSE); + gtk_widget_set_sensitive (op->priv->simple_first_spin, TRUE); + gtk_widget_set_sensitive (op->priv->simple_last_spin, TRUE); + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (op->priv->simple_sheets_spin), 1); + + first = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->simple_first_spin)); + last = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->simple_last_spin)); + + gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview), first, last); + } +} + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Simple first label spinbutton "changed" callback */ +/*--------------------------------------------------------------------------*/ +static void +simple_first_spin_cb (GtkSpinButton *spinbutton, + glPrintOpDialog *op) +{ + gint first, last; + + first = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->simple_first_spin)); + last = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->simple_last_spin)); + + /* Adjust range of last spin button. */ + gtk_spin_button_set_range (GTK_SPIN_BUTTON (op->priv->simple_last_spin), + first, op->priv->labels_per_sheet); + + /* Update preview. */ + gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview), first, last); + +} + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Simple last label spinbutton "changed" callback */ +/*--------------------------------------------------------------------------*/ +static void +simple_last_spin_cb (GtkSpinButton *spinbutton, + glPrintOpDialog *op) +{ + gint first, last; + + first = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->simple_first_spin)); + last = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->simple_last_spin)); + + /* Adjust range of first spin button. */ + gtk_spin_button_set_range (GTK_SPIN_BUTTON (op->priv->simple_first_spin), + 1, last); + + /* Update preview. */ + gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview), first, last); + +} + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Preview "pressed" callback */ +/*--------------------------------------------------------------------------*/ +static void +preview_pressed_cb (glMiniPreview *preview, + gint first, + gint last, + glPrintOpDialog *op) +{ + gint old_first; + + if ( !op->priv->merge_flag ) + { + + /* Update controls. */ + old_first = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->simple_first_spin)); + if ( first > old_first ) + { + gtk_spin_button_set_value (GTK_SPIN_BUTTON (op->priv->simple_last_spin), last); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (op->priv->simple_first_spin), first); + } + else + { + gtk_spin_button_set_value (GTK_SPIN_BUTTON (op->priv->simple_first_spin), first); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (op->priv->simple_last_spin), last); + } + if ( (first == 1) && (last == op->priv->labels_per_sheet) ) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (op->priv->simple_sheets_radio), TRUE); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (op->priv->simple_sheets_spin), 1); + } + else + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (op->priv->simple_labels_radio), TRUE); + } + + /* Update preview. */ + gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview), first, last); + + } +} + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. "changed" callback for merge first and copies spin buttons. */ +/*--------------------------------------------------------------------------*/ +static void +merge_spin_cb (GtkSpinButton *spinbutton, + glPrintOpDialog *op) +{ + gint first, last, n_copies; + + first = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->merge_first_spin)); + + n_copies = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->merge_copies_spin)); + last = first + (n_copies * op->priv->n_records) - 1; + + gl_mini_preview_highlight_range (GL_MINI_PREVIEW(op->priv->preview), first, last ); + + gtk_widget_set_sensitive (op->priv->merge_collate_check, (n_copies > 1)); + gtk_widget_set_sensitive (op->priv->merge_collate_image, (n_copies > 1)); +} + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Merge first collate check "toggled" callback */ +/*--------------------------------------------------------------------------*/ +static void +merge_collate_check_cb (GtkToggleButton *togglebutton, + glPrintOpDialog *op) +{ + GdkPixbuf *pixbuf; + + if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (op->priv->merge_collate_check)) ) + { + pixbuf = gdk_pixbuf_new_from_xpm_data ( (const char **)collate_xpm); + } + else + { + pixbuf = gdk_pixbuf_new_from_xpm_data ( (const char **)nocollate_xpm); + } + + gtk_image_set_from_pixbuf (GTK_IMAGE (op->priv->merge_collate_image), pixbuf); +} + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Preview "clicked" callback */ +/*--------------------------------------------------------------------------*/ +static void +preview_clicked_cb (glMiniPreview *preview, + gint first, + glPrintOpDialog *op) +{ + gint n_copies; + gint last; + + if ( op->priv->merge_flag ) + { + + /* Update controls. */ + gtk_spin_button_set_value (GTK_SPIN_BUTTON (op->priv->merge_first_spin), first); + + n_copies = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (op->priv->merge_copies_spin)); + gtk_widget_set_sensitive (op->priv->merge_collate_check, (n_copies > 1)); + gtk_widget_set_sensitive (op->priv->merge_collate_image, (n_copies > 1)); + + + /* Update preview. */ + last = first + (n_copies * op->priv->n_records) - 1; + gl_mini_preview_highlight_range (GL_MINI_PREVIEW (op->priv->preview), first, last); + + } +} + + + + +/* + * Local Variables: -- emacs + * mode: C -- emacs + * c-basic-offset: 8 -- emacs + * tab-width: 8 -- emacs + * indent-tabs-mode: nil -- emacs + * End: -- emacs + */ diff --git a/glabels2/src/print-op-dialog.h b/glabels2/src/print-op-dialog.h new file mode 100644 index 00000000..d6469bf2 --- /dev/null +++ b/glabels2/src/print-op-dialog.h @@ -0,0 +1,83 @@ +/* + * print-op-dialog.h + * Copyright (C) 2001-2009 Jim Evins . + * + * This file is part of gLabels. + * + * gLabels is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels. If not, see . + */ + +#ifndef __PRINT_OP_DIALOG_H__ +#define __PRINT_OP_DIALOG_H__ + +#include "print-op.h" + +G_BEGIN_DECLS + +#define GL_TYPE_PRINT_OP_DIALOG (gl_print_op_dialog_get_type ()) +#define GL_PRINT_OP_DIALOG(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), GL_TYPE_PRINT_OP_DIALOG, glPrintOpDialog)) +#define GL_PRINT_OP_DIALOG_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), GL_TYPE_PRINT_OP_DIALOG, glPrintOpDialogClass)) +#define GL_IS_PRINT_OP_DIALOG(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GL_TYPE_PRINT_OP_DIALOG)) +#define GL_IS_PRINT_OP_DIALOG_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), GL_TYPE_PRINT_OP_DIALOG)) +#define GL_PRINT_OP_DIALOG_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), GL_TYPE_PRINT_OP_DIALOG, glPrintOpDialogClass)) + + +typedef struct _glPrintOpDialog glPrintOpDialog; +typedef struct _glPrintOpDialogClass glPrintOpDialogClass; + +typedef struct _glPrintOpDialogPrivate glPrintOpDialogPrivate; + +struct _glPrintOpDialog +{ + glPrintOp parent_instance; + + glPrintOpDialogPrivate *priv; + +}; + +struct _glPrintOpDialogClass +{ + glPrintOpClass parent_class; +}; + + +typedef struct _glPrintOpDialogSettings glPrintOpDialogSettings; + + + +GType gl_print_op_dialog_get_type (void) G_GNUC_CONST; + +glPrintOpDialog *gl_print_op_dialog_new (glLabel *label); + + + +G_END_DECLS + +#endif + + + +/* + * Local Variables: -- emacs + * mode: C -- emacs + * c-basic-offset: 8 -- emacs + * tab-width: 8 -- emacs + * indent-tabs-mode: nil -- emacs + * End: -- emacs + */ diff --git a/glabels2/src/print-op.c b/glabels2/src/print-op.c index e7771759..d13d1a5e 100644 --- a/glabels2/src/print-op.c +++ b/glabels2/src/print-op.c @@ -23,7 +23,6 @@ #include "print-op.h" #include -#include #include #include #include @@ -32,10 +31,6 @@ #include #include "print.h" #include "label.h" -#include "util.h" - -#include "wdgt-print-copies.h" -#include "wdgt-print-merge.h" #include "debug.h" @@ -48,20 +43,6 @@ struct _glPrintOpPrivate { glLabel *label; - GtkBuilder *builder; - - 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; - gboolean force_outline_flag; gchar *filename; @@ -107,32 +88,11 @@ struct _glPrintOpSettings /* Local function prototypes */ /*===========================================*/ -static void gl_print_op_finalize (GObject *object); - -static void gl_print_op_construct (glPrintOp *op, - glLabel *label); - -static void gl_print_op_construct_batch (glPrintOp *op, - glLabel *label, - gchar *filename, - gint n_sheets, - gint n_copies, - gint first, - gboolean outline_flag, - gboolean reverse_flag, - gboolean crop_marks_flag); - +static void gl_print_op_finalize (GObject *object); static void set_page_size (glPrintOp *op, glLabel *label); -static GObject *create_custom_widget_cb (GtkPrintOperation *operation, - gpointer user_data); - -static void custom_widget_apply_cb (GtkPrintOperation *operation, - GtkWidget *widget, - gpointer user_data); - static void begin_print_cb (GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data); @@ -187,12 +147,7 @@ gl_print_op_finalize (GObject *object) g_return_if_fail (GL_IS_PRINT_OP (op)); g_return_if_fail (op->priv != NULL); - if (op->priv->label) { - g_object_unref (G_OBJECT(op->priv->label)); - } - if (op->priv->builder) { - g_object_unref (G_OBJECT(op->priv->builder)); - } + g_object_unref (G_OBJECT(op->priv->label)); g_free (op->priv->filename); g_free (op->priv); @@ -220,20 +175,23 @@ gl_print_op_new (glLabel *label) } -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Construct op. */ -/*--------------------------------------------------------------------------*/ -static void +/*****************************************************************************/ +/* Construct print op. */ +/*****************************************************************************/ +void gl_print_op_construct (glPrintOp *op, glLabel *label) { + glMerge *merge = NULL; const lglTemplateFrame *frame; op->priv->label = label; op->priv->force_outline_flag = FALSE; + merge = gl_label_get_merge (label); frame = (lglTemplateFrame *)label->template->frames->data; + op->priv->merge_flag = (merge != NULL); op->priv->n_sheets = 1; op->priv->first = 1; op->priv->last = lgl_template_frame_get_n_labels (frame); @@ -244,12 +202,6 @@ gl_print_op_construct (glPrintOp *op, gtk_print_operation_set_custom_tab_label ( GTK_PRINT_OPERATION (op), _("Labels")); - g_signal_connect (G_OBJECT (op), "create-custom-widget", - G_CALLBACK (create_custom_widget_cb), label); - - g_signal_connect (G_OBJECT (op), "custom-widget-apply", - G_CALLBACK (custom_widget_apply_cb), label); - g_signal_connect (G_OBJECT (op), "begin-print", G_CALLBACK (begin_print_cb), label); @@ -259,174 +211,170 @@ gl_print_op_construct (glPrintOp *op, /*****************************************************************************/ -/* NEW batch print operation. */ +/* Set outline flag/checkbox. */ /*****************************************************************************/ -glPrintOp * -gl_print_op_new_batch (glLabel *label, - gchar *filename, - gint n_sheets, - gint n_copies, - gint first, - gboolean outline_flag, - gboolean reverse_flag, - gboolean crop_marks_flag) +void +gl_print_op_force_outline (glPrintOp *op) { - glPrintOp *op; - - gl_debug (DEBUG_PRINT, ""); - - op = GL_PRINT_OP (g_object_new (GL_TYPE_PRINT_OP, NULL)); + op->priv->force_outline_flag = TRUE; +} - gl_print_op_construct_batch (GL_PRINT_OP(op), - label, - filename, - n_sheets, - n_copies, - first, - outline_flag, - reverse_flag, - crop_marks_flag); - return op; +/*****************************************************************************/ +/* Set outline flag/checkbox. */ +/*****************************************************************************/ +gboolean +gl_print_op_is_outline_forced (glPrintOp *op) +{ + return op->priv->force_outline_flag; } /*****************************************************************************/ -/* Get print operation settings. */ +/* Set job parameters. */ /*****************************************************************************/ -glPrintOpSettings * -gl_print_op_get_settings (glPrintOp *print_op) +void +gl_print_op_set_filename (glPrintOp *op, + gchar *filename) { - glPrintOpSettings *settings; + gtk_print_operation_set_export_filename (GTK_PRINT_OPERATION (op), + filename); +} - settings = g_new0 (glPrintOpSettings, 1); - if ( settings ) - { - settings->gtk_settings = - gtk_print_operation_get_print_settings (GTK_PRINT_OPERATION (print_op)); +void +gl_print_op_set_n_sheets (glPrintOp *op, + gint n_sheets) +{ + op->priv->n_sheets = n_sheets; +} - settings->outline_flag = print_op->priv->outline_flag; - settings->reverse_flag = print_op->priv->reverse_flag; - settings->crop_marks_flag = print_op->priv->crop_marks_flag; - settings->collate_flag = print_op->priv->collate_flag; - settings->first = print_op->priv->first; - settings->last = print_op->priv->last; - settings->n_sheets = print_op->priv->n_sheets; - settings->n_copies = print_op->priv->n_copies; - } +void +gl_print_op_set_n_copies (glPrintOp *op, + gint n_copies) +{ + op->priv->n_copies = n_copies; +} - return settings; + +void +gl_print_op_set_first (glPrintOp *op, + gint first) +{ + op->priv->first = first; } -/*****************************************************************************/ -/* Set print operation settings. */ -/*****************************************************************************/ void -gl_print_op_set_settings (glPrintOp *print_op, - glPrintOpSettings *settings) +gl_print_op_set_last (glPrintOp *op, + gint last) { + op->priv->last = last; +} - if ( settings ) - { - gtk_print_operation_set_print_settings (GTK_PRINT_OPERATION (print_op), - settings->gtk_settings); - print_op->priv->outline_flag = settings->outline_flag; - print_op->priv->reverse_flag = settings->reverse_flag; - print_op->priv->crop_marks_flag = settings->crop_marks_flag; - print_op->priv->collate_flag = settings->collate_flag; +void +gl_print_op_set_collate_flag (glPrintOp *op, + gboolean collate_flag) +{ + op->priv->collate_flag = collate_flag; +} + + +void +gl_print_op_set_outline_flag (glPrintOp *op, + gboolean outline_flag) +{ + op->priv->outline_flag = outline_flag; +} + + +void +gl_print_op_set_reverse_flag (glPrintOp *op, + gboolean reverse_flag) +{ + op->priv->reverse_flag = reverse_flag; +} - print_op->priv->first = settings->first; - print_op->priv->last = settings->last; - print_op->priv->n_sheets = settings->n_sheets; - print_op->priv->n_copies = settings->n_copies; - } +void +gl_print_op_set_crop_marks_flag (glPrintOp *op, + gboolean crop_marks_flag) +{ + op->priv->crop_marks_flag = crop_marks_flag; } /*****************************************************************************/ -/* Free print operation settings structure. */ +/* Get job parameters. */ /*****************************************************************************/ -void -gl_print_op_free_settings(glPrintOpSettings *settings) +gchar * +gl_print_op_get_filename (glPrintOp *op) { - - if ( settings ) - { - if ( settings->gtk_settings ) - { - g_object_unref (settings->gtk_settings); - } + gchar *filename; - g_free (settings); - } + g_object_get (G_OBJECT (op), + "export_filename", filename, + NULL); + + return filename; } -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Construct op. */ -/*--------------------------------------------------------------------------*/ -static void -gl_print_op_construct_batch (glPrintOp *op, - glLabel *label, - gchar *filename, - gint n_sheets, - gint n_copies, - gint first, - gboolean outline_flag, - gboolean reverse_flag, - gboolean crop_marks_flag) +gint +gl_print_op_get_n_sheets (glPrintOp *op) +{ + return op->priv->n_sheets; +} + +gint +gl_print_op_get_n_copies (glPrintOp *op) { - glMerge *merge = NULL; - const lglTemplateFrame *frame = NULL; + return op->priv->n_copies; +} - op->priv->label = label; - op->priv->force_outline_flag = FALSE; - op->priv->filename = g_strdup (filename); - op->priv->n_sheets = n_sheets; - op->priv->n_copies = n_copies; - op->priv->first = first; - op->priv->outline_flag = outline_flag; - op->priv->reverse_flag = reverse_flag; - op->priv->crop_marks_flag = crop_marks_flag; - merge = gl_label_get_merge (label); +gint +gl_print_op_get_first (glPrintOp *op) +{ + return op->priv->first; +} - frame = (lglTemplateFrame *)label->template->frames->data; - if (merge == NULL) - { - op->priv->merge_flag = FALSE; - op->priv->last = lgl_template_frame_get_n_labels (frame); +gint +gl_print_op_get_last (glPrintOp *op) +{ + return op->priv->last; +} - } - else - { - op->priv->merge_flag = TRUE; - op->priv->n_sheets = - ceil ((double)(first-1 + n_copies * gl_merge_get_record_count(merge)) - / lgl_template_frame_get_n_labels (frame));; +gboolean +gl_print_op_get_collate_flag (glPrintOp *op) +{ + return op->priv->collate_flag; +} - g_object_unref (G_OBJECT(merge)); - } +gboolean +gl_print_op_get_outline_flag (glPrintOp *op) +{ + return op->priv->outline_flag; +} - set_page_size (op, label); - gtk_print_operation_set_export_filename (GTK_PRINT_OPERATION (op), - filename); +gboolean +gl_print_op_get_reverse_flag (glPrintOp *op) +{ + return op->priv->reverse_flag; +} - g_signal_connect (G_OBJECT (op), "begin-print", - G_CALLBACK (begin_print_cb), label); - g_signal_connect (G_OBJECT (op), "draw-page", - G_CALLBACK (draw_page_cb), label); +gboolean +gl_print_op_get_crop_marks_flag (glPrintOp *op) +{ + return op->priv->crop_marks_flag; } @@ -484,151 +432,79 @@ set_page_size (glPrintOp *op, } -/*--------------------------------------------------------------------------*/ -/* PRIVATE. "Create custom widget" callback */ -/*--------------------------------------------------------------------------*/ -static GObject * -create_custom_widget_cb (GtkPrintOperation *operation, - gpointer user_data) -{ - GtkBuilder *builder; - static gchar *object_ids[] = { "print_custom_widget_vbox", NULL }; - GError *error = NULL; - glPrintOp *op = GL_PRINT_OP (operation); - glLabel *label = GL_LABEL (user_data); - GtkWidget *vbox; - glMerge *merge = NULL; - - builder = gtk_builder_new (); - gtk_builder_add_objects_from_file (builder, - GLABELS_BUILDER_DIR "print-custom-widget.builder", - object_ids, - &error); - if (error) { - g_critical ("%s\n\ngLabels may not be installed correctly!", error->message); - g_error_free (error); - return NULL; - } - - gl_util_get_builder_widgets (builder, - "print_custom_widget_vbox", &vbox, - "simple_frame", &op->priv->simple_frame, - "copies_vbox", &op->priv->copies_vbox, - "merge_frame", &op->priv->merge_frame, - "prmerge_vbox", &op->priv->prmerge_vbox, - "outline_check", &op->priv->outline_check, - "reverse_check", &op->priv->reverse_check, - "crop_marks_check", &op->priv->crop_marks_check, - NULL); - - /* ----- Simple print control ----- */ - op->priv->copies = gl_wdgt_print_copies_new (label); - gtk_box_pack_start (GTK_BOX(op->priv->copies_vbox), - op->priv->copies, FALSE, FALSE, 0); - - /* ----- Merge print control ----- */ - op->priv->prmerge = gl_wdgt_print_merge_new (label); - gtk_box_pack_start (GTK_BOX(op->priv->prmerge_vbox), - op->priv->prmerge, FALSE, FALSE, 0); - - - op->priv->builder = builder; +/*****************************************************************************/ +/* Get print operation settings. */ +/*****************************************************************************/ +glPrintOpSettings * +gl_print_op_get_settings (glPrintOp *print_op) +{ + glPrintOpSettings *settings; - - /* ---- Activate either simple or merge print control widgets. ---- */ - merge = gl_label_get_merge (op->priv->label); - if (merge == NULL) { - - gl_wdgt_print_copies_set_range (GL_WDGT_PRINT_COPIES (op->priv->copies), - op->priv->n_sheets, - op->priv->first, - op->priv->last); - - gtk_widget_show_all (op->priv->simple_frame); - gtk_widget_hide_all (op->priv->merge_frame); - - } else { - - gint n_records = gl_merge_get_record_count( merge ); - gl_wdgt_print_merge_set_copies (GL_WDGT_PRINT_MERGE (op->priv->prmerge), - op->priv->n_copies, - op->priv->first, - n_records, - op->priv->collate_flag); - g_object_unref (G_OBJECT(merge)); - - gtk_widget_hide_all (op->priv->simple_frame); - gtk_widget_show_all (op->priv->merge_frame); - } - - /* --- Set options --- */ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (op->priv->outline_check), - op->priv->outline_flag); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (op->priv->reverse_check), - op->priv->reverse_flag); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (op->priv->crop_marks_check), - op->priv->crop_marks_flag); - - /* --- Do we need to force the outline flag --- */ - if (op->priv->force_outline_flag) + settings = g_new0 (glPrintOpSettings, 1); + + if ( settings ) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(op->priv->outline_check), - TRUE); + settings->gtk_settings = + gtk_print_operation_get_print_settings (GTK_PRINT_OPERATION (print_op)); - gtk_widget_set_sensitive (op->priv->outline_check, FALSE); - gtk_widget_set_sensitive (op->priv->reverse_check, FALSE); - gtk_widget_set_sensitive (op->priv->crop_marks_check, FALSE); + settings->outline_flag = print_op->priv->outline_flag; + settings->reverse_flag = print_op->priv->reverse_flag; + settings->crop_marks_flag = print_op->priv->crop_marks_flag; + settings->collate_flag = print_op->priv->collate_flag; + + settings->first = print_op->priv->first; + settings->last = print_op->priv->last; + settings->n_sheets = print_op->priv->n_sheets; + settings->n_copies = print_op->priv->n_copies; } - return G_OBJECT (vbox); + return settings; } -/*--------------------------------------------------------------------------*/ -/* PRIVATE. "Custom widget apply" callback */ -/*--------------------------------------------------------------------------*/ -static void -custom_widget_apply_cb (GtkPrintOperation *operation, - GtkWidget *widget, - gpointer user_data) +/*****************************************************************************/ +/* Set print operation settings. */ +/*****************************************************************************/ +void +gl_print_op_set_settings (glPrintOp *print_op, + glPrintOpSettings *settings) { - glPrintOp *op = GL_PRINT_OP (operation); - glMerge *merge = NULL; + if ( settings ) + { + gtk_print_operation_set_print_settings (GTK_PRINT_OPERATION (print_op), + settings->gtk_settings); + + print_op->priv->outline_flag = settings->outline_flag; + print_op->priv->reverse_flag = settings->reverse_flag; + print_op->priv->crop_marks_flag = settings->crop_marks_flag; + print_op->priv->collate_flag = settings->collate_flag; - op->priv->outline_flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON - (op->priv->outline_check)); - op->priv->reverse_flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON - (op->priv->reverse_check)); - op->priv->crop_marks_flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON - (op->priv->crop_marks_check)); + print_op->priv->first = settings->first; + print_op->priv->last = settings->last; + print_op->priv->n_sheets = settings->n_sheets; + print_op->priv->n_copies = settings->n_copies; + } - merge = gl_label_get_merge (op->priv->label); +} - if (merge == NULL) - { - op->priv->merge_flag = FALSE; - gl_wdgt_print_copies_get_range (GL_WDGT_PRINT_COPIES (op->priv->copies), - &op->priv->n_sheets, - &op->priv->first, - &op->priv->last); - } - else +/*****************************************************************************/ +/* Free print operation settings structure. */ +/*****************************************************************************/ +void +gl_print_op_free_settings(glPrintOpSettings *settings) +{ + + if ( settings ) { + if ( settings->gtk_settings ) + { + g_object_unref (settings->gtk_settings); + } - op->priv->merge_flag = TRUE; - gl_wdgt_print_merge_get_copies (GL_WDGT_PRINT_MERGE (op->priv->prmerge), - &op->priv->n_copies, - &op->priv->first, - &op->priv->collate_flag, - &op->priv->n_sheets); - g_object_unref (G_OBJECT(merge)); + g_free (settings); } - } @@ -703,15 +579,6 @@ draw_page_cb (GtkPrintOperation *operation, } -/*****************************************************************************/ -/* Set outline flag/checkbox. */ -/*****************************************************************************/ -void -gl_print_op_force_outline_flag (glPrintOp *op) -{ - op->priv->force_outline_flag = TRUE; -} - /* diff --git a/glabels2/src/print-op.h b/glabels2/src/print-op.h index 5485386e..0ee7a725 100644 --- a/glabels2/src/print-op.h +++ b/glabels2/src/print-op.h @@ -1,26 +1,23 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - /* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * print-op.h: Print operation module header file + * print-op.h + * Copyright (C) 2001-2009 Jim Evins . * - * Copyright (C) 2001-2007 Jim Evins . + * This file is part of gLabels. * - * This program is free software; you can redistribute it and/or modify + * gLabels is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * gLabels is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with gLabels. If not, see . */ + #ifndef __PRINT_OP_H__ #define __PRINT_OP_H__ @@ -65,29 +62,62 @@ typedef struct _glPrintOpSettings glPrintOpSettings; -GType gl_print_op_get_type (void) G_GNUC_CONST; - -glPrintOp *gl_print_op_new (glLabel *label); - -void gl_print_op_force_outline_flag (glPrintOp *print_op); - -glPrintOpSettings *gl_print_op_get_settings (glPrintOp *print_op); -void gl_print_op_set_settings (glPrintOp *print_op, - glPrintOpSettings *settings); -void gl_print_op_free_settings (glPrintOpSettings *settings); +GType gl_print_op_get_type (void) G_GNUC_CONST; + +glPrintOp *gl_print_op_new (glLabel *label); + +void gl_print_op_construct (glPrintOp *print_op, + glLabel *label); + +void gl_print_op_set_filename (glPrintOp *print_op, + gchar *filename); +void gl_print_op_set_n_sheets (glPrintOp *print_op, + gint n_sheets); +void gl_print_op_set_n_copies (glPrintOp *print_op, + gint n_copies); +void gl_print_op_set_first (glPrintOp *print_op, + gint first); +void gl_print_op_set_last (glPrintOp *print_op, + gint last); +void gl_print_op_set_collate_flag (glPrintOp *print_op, + gboolean collate_flag); +void gl_print_op_set_outline_flag (glPrintOp *print_op, + gboolean outline_flag); +void gl_print_op_set_reverse_flag (glPrintOp *print_op, + gboolean reverse_flag); +void gl_print_op_set_crop_marks_flag (glPrintOp *print_op, + gboolean crop_marks_flag); + +gchar *gl_print_op_get_filename (glPrintOp *print_op); +gint gl_print_op_get_n_sheets (glPrintOp *print_op); +gint gl_print_op_get_n_copies (glPrintOp *print_op); +gint gl_print_op_get_first (glPrintOp *print_op); +gint gl_print_op_get_last (glPrintOp *print_op); +gboolean gl_print_op_get_collate_flag (glPrintOp *print_op); +gboolean gl_print_op_get_outline_flag (glPrintOp *print_op); +gboolean gl_print_op_get_reverse_flag (glPrintOp *print_op); +gboolean gl_print_op_get_crop_marks_flag (glPrintOp *print_op); + +void gl_print_op_force_outline (glPrintOp *print_op); +gboolean gl_print_op_is_outline_forced (glPrintOp *print_op); + +glPrintOpSettings *gl_print_op_get_settings (glPrintOp *print_op); +void gl_print_op_set_settings (glPrintOp *print_op, + glPrintOpSettings *settings); +void gl_print_op_free_settings (glPrintOpSettings *settings); -/* - * Batch print operation - */ -glPrintOp *gl_print_op_new_batch (glLabel *label, - gchar *filename, - gint n_sheets, - gint n_copies, - gint first, - gboolean outline_flag, - gboolean reverse_flag, - gboolean crop_marks_flag); G_END_DECLS #endif + + + +/* + * Local Variables: -- emacs + * mode: C -- emacs + * c-basic-offset: 8 -- emacs + * tab-width: 8 -- emacs + * indent-tabs-mode: nil -- emacs + * End: -- emacs + */ diff --git a/glabels2/src/template-designer.c b/glabels2/src/template-designer.c index 0848cc9e..2d34a11c 100644 --- a/glabels2/src/template-designer.c +++ b/glabels2/src/template-designer.c @@ -35,7 +35,7 @@ #include #include "mini-preview.h" #include "mini-preview-pixbuf-cache.h" -#include "print-op.h" +#include "print-op-dialog.h" #include "util.h" #include "debug.h" @@ -1610,17 +1610,17 @@ layout_page_changed_cb (glTemplateDesigner *dialog) static void print_test_cb (glTemplateDesigner *dialog) { - GObject *label; - lglTemplate *template; - glPrintOp *print_op; + GObject *label; + lglTemplate *template; + glPrintOpDialog *print_op; label = gl_label_new (); template = build_template (dialog); gl_label_set_template (GL_LABEL(label), template); - print_op = gl_print_op_new (GL_LABEL(label)); - gl_print_op_force_outline_flag (print_op); + print_op = gl_print_op_dialog_new (GL_LABEL(label)); + gl_print_op_force_outline (GL_PRINT_OP (print_op)); gtk_print_operation_run (GTK_PRINT_OPERATION (print_op), GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, GTK_WINDOW (dialog), diff --git a/glabels2/src/ui-commands.c b/glabels2/src/ui-commands.c index bc01a65b..80f5f794 100644 --- a/glabels2/src/ui-commands.c +++ b/glabels2/src/ui-commands.c @@ -32,7 +32,7 @@ #include "view.h" #include "file.h" #include "template-designer.h" -#include "print-op.h" +#include "print-op-dialog.h" #include "prefs.h" #include "prefs-dialog.h" #include "recent.h" @@ -182,7 +182,7 @@ void gl_ui_cmd_file_print (GtkAction *action, glWindow *window) { - glPrintOp *op; + glPrintOpDialog *op; GtkPrintOperationResult result; gl_debug (DEBUG_COMMANDS, "START"); @@ -190,11 +190,11 @@ gl_ui_cmd_file_print (GtkAction *action, g_return_if_fail (action && GTK_IS_ACTION(action)); g_return_if_fail (window && GL_IS_WINDOW(window)); - op = gl_print_op_new (GL_VIEW(window->view)->label); + op = gl_print_op_dialog_new (GL_VIEW(window->view)->label); if (window->print_settings) { - gl_print_op_set_settings (op, window->print_settings); + gl_print_op_set_settings (GL_PRINT_OP (op), window->print_settings); } result = gtk_print_operation_run (GTK_PRINT_OPERATION (op), @@ -205,7 +205,7 @@ gl_ui_cmd_file_print (GtkAction *action, if ( result == GTK_PRINT_OPERATION_RESULT_APPLY ) { gl_print_op_free_settings (window->print_settings); - window->print_settings = gl_print_op_get_settings (op); + window->print_settings = gl_print_op_get_settings (GL_PRINT_OP (op)); } gl_debug (DEBUG_COMMANDS, "END"); diff --git a/glabels2/src/wdgt-print-copies.c b/glabels2/src/wdgt-print-copies.c deleted file mode 100644 index 0a7b7703..00000000 --- a/glabels2/src/wdgt-print-copies.c +++ /dev/null @@ -1,368 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_print_copies.c: custom print copies widget module - * - * Copyright (C) 2001 Jim Evins . - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#include "wdgt-print-copies.h" - -#include -#include -#include -#include -#include -#include - -#include "hig.h" -#include "mini-preview.h" -#include "marshal.h" - -#include "debug.h" - -#define MINI_PREVIEW_HEIGHT 175 -#define MINI_PREVIEW_WIDTH 150 - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_wdgt_print_copies_finalize (GObject * object); - -static void gl_wdgt_print_copies_construct (glWdgtPrintCopies * copies, - glLabel * label); - -static void sheets_radio_cb (GtkToggleButton * togglebutton, - gpointer user_data); -static void first_spin_cb (GtkSpinButton * spinbutton, - gpointer user_data); -static void last_spin_cb (GtkSpinButton * spinbutton, - gpointer user_data); - -static void -preview_pressed (glMiniPreview *mini_preview, - gint first, gint last, gpointer user_data); - - -/****************************************************************************/ -/* Boilerplate Object stuff. */ -/****************************************************************************/ -G_DEFINE_TYPE (glWdgtPrintCopies, gl_wdgt_print_copies, GTK_TYPE_HBOX); - -static void -gl_wdgt_print_copies_class_init (glWdgtPrintCopiesClass * class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - - gl_wdgt_print_copies_parent_class = g_type_class_peek_parent (class); - - object_class->finalize = gl_wdgt_print_copies_finalize; -} - -static void -gl_wdgt_print_copies_init (glWdgtPrintCopies * copies) -{ - copies->labels_per_sheet = 0; - - copies->mini_preview = NULL; - - copies->sheets_radio = NULL; - copies->sheets_spin = NULL; - - copies->labels_radio = NULL; - copies->first_spin = NULL; - copies->last_spin = NULL; -} - -static void -gl_wdgt_print_copies_finalize (GObject * object) -{ - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_WDGT_PRINT_COPIES (object)); - - G_OBJECT_CLASS (gl_wdgt_print_copies_parent_class)->finalize (object); -} - -GtkWidget * -gl_wdgt_print_copies_new (glLabel * label) -{ - glWdgtPrintCopies *copies; - - copies = g_object_new (gl_wdgt_print_copies_get_type (), NULL); - - gl_wdgt_print_copies_construct (copies, label); - - return GTK_WIDGET (copies); -} - -/*--------------------------------------------------------------------------*/ -/* Construct composite widget. */ -/*--------------------------------------------------------------------------*/ -static void -gl_wdgt_print_copies_construct (glWdgtPrintCopies *copies, - glLabel *label) -{ - const lglTemplateFrame *frame; - GtkWidget *whbox, *wvbox, *whbox1; - GSList *radio_group = NULL; - GtkObject *adjust; - - whbox = GTK_WIDGET (copies); - - frame = (lglTemplateFrame *)label->template->frames->data; - - copies->labels_per_sheet = lgl_template_frame_get_n_labels (frame); - - /* mini_preview canvas */ - copies->mini_preview = gl_mini_preview_new (MINI_PREVIEW_HEIGHT, - MINI_PREVIEW_WIDTH); - gl_mini_preview_set_template (GL_MINI_PREVIEW(copies->mini_preview), - label->template); - gtk_box_pack_start (GTK_BOX(whbox), copies->mini_preview, FALSE, FALSE, 0); - - wvbox = gtk_vbox_new (FALSE, GL_HIG_PAD1); - gtk_box_pack_start (GTK_BOX(whbox), wvbox, FALSE, FALSE, 0); - - /* Sheet controls */ - whbox1 = gtk_hbox_new (FALSE, GL_HIG_PAD2); - gtk_box_pack_start (GTK_BOX(wvbox), whbox1, FALSE, FALSE, 0); - copies->sheets_radio = - gtk_radio_button_new_with_label (radio_group, _("Sheets:")); - gtk_box_pack_start (GTK_BOX(whbox1), copies->sheets_radio, FALSE, FALSE, 0); - adjust = gtk_adjustment_new (1, 1.0, 10.0, 1.0, 10.0, 0.0); - copies->sheets_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust), - 1.0, 0); - gtk_box_pack_start (GTK_BOX(whbox1), copies->sheets_spin, FALSE, FALSE, 0); - gl_mini_preview_highlight_range (GL_MINI_PREVIEW(copies->mini_preview), - 1, copies->labels_per_sheet); - - /* Blank line */ - gtk_box_pack_start (GTK_BOX(wvbox), gtk_label_new (""), FALSE, FALSE, 0); - - /* Label controls */ - whbox1 = gtk_hbox_new (FALSE, GL_HIG_PAD2); - gtk_box_pack_start (GTK_BOX(wvbox), whbox1, FALSE, FALSE, 0); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (copies->sheets_radio)); - copies->labels_radio = - gtk_radio_button_new_with_label (radio_group, _("Labels")); - gtk_box_pack_start (GTK_BOX(whbox1), copies->labels_radio, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX(whbox1), gtk_label_new (_("from:")), FALSE, FALSE, 0); - adjust = gtk_adjustment_new (1, 1.0, copies->labels_per_sheet, - 1.0, 10.0, 0.0); - copies->first_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust), - 1.0, 0); - gtk_box_pack_start (GTK_BOX(whbox1), copies->first_spin, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX(whbox1), gtk_label_new (_("to:")), FALSE, FALSE, 0); - adjust = gtk_adjustment_new (copies->labels_per_sheet, - 1.0, copies->labels_per_sheet, - 1.0, 10.0, 0.0); - copies->last_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust), - 1.0, 0); - gtk_box_pack_start (GTK_BOX(whbox1), copies->last_spin, FALSE, FALSE, 0); - gtk_widget_set_sensitive (copies->first_spin, FALSE); - gtk_widget_set_sensitive (copies->last_spin, FALSE); - - /* Connect signals to controls */ - g_signal_connect (G_OBJECT (copies->mini_preview), "pressed", - G_CALLBACK (preview_pressed), copies); - g_signal_connect (G_OBJECT (copies->sheets_radio), "toggled", - G_CALLBACK (sheets_radio_cb), copies); - g_signal_connect (G_OBJECT (copies->first_spin), "changed", - G_CALLBACK (first_spin_cb), copies); - g_signal_connect (G_OBJECT (copies->last_spin), "changed", - G_CALLBACK (last_spin_cb), copies); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Enable/Disable appropriate controls due to radio button toggle.*/ -/*--------------------------------------------------------------------------*/ -static void -sheets_radio_cb (GtkToggleButton * togglebutton, - gpointer user_data) -{ - glWdgtPrintCopies *copies = GL_WDGT_PRINT_COPIES (user_data); - gint first, last; - - if (gtk_toggle_button_get_active (togglebutton)) { - - gtk_widget_set_sensitive (copies->sheets_spin, TRUE); - gtk_widget_set_sensitive (copies->first_spin, FALSE); - gtk_widget_set_sensitive (copies->last_spin, FALSE); - - gl_mini_preview_highlight_range (GL_MINI_PREVIEW(copies->mini_preview), - 1, copies->labels_per_sheet); - - } else { - - gtk_widget_set_sensitive (copies->sheets_spin, FALSE); - gtk_widget_set_sensitive (copies->first_spin, TRUE); - gtk_widget_set_sensitive (copies->last_spin, TRUE); - - first = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->first_spin)); - last = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->last_spin)); - gl_mini_preview_highlight_range (GL_MINI_PREVIEW(copies->mini_preview), - first, last); - - } -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. modify widget due to change of first spin button */ -/*--------------------------------------------------------------------------*/ -static void -first_spin_cb (GtkSpinButton * spinbutton, - gpointer user_data) -{ - glWdgtPrintCopies *copies = GL_WDGT_PRINT_COPIES (user_data); - gint first, last; - - first = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->first_spin)); - last = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->last_spin)); - - gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (copies->last_spin))-> - lower = first; - - gl_mini_preview_highlight_range (GL_MINI_PREVIEW(copies->mini_preview), - first, last); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. modify widget due to change of last spin button */ -/*--------------------------------------------------------------------------*/ -static void -last_spin_cb (GtkSpinButton * spinbutton, - gpointer user_data) -{ - glWdgtPrintCopies *copies = GL_WDGT_PRINT_COPIES (user_data); - gint first, last; - - first = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->first_spin)); - last = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->last_spin)); - - gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (copies->first_spin))-> - upper = last; - - gl_mini_preview_highlight_range (GL_MINI_PREVIEW(copies->mini_preview), - first, last); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Canvas event handler, select first and last items. */ -/*--------------------------------------------------------------------------*/ -static void -preview_pressed (glMiniPreview *mini_preview, - gint first, - gint last, - gpointer user_data) -{ - glWdgtPrintCopies *copies = GL_WDGT_PRINT_COPIES (user_data); - - gl_wdgt_print_copies_set_range (copies, 1, first, last); -} - -/****************************************************************************/ -/* query selected range of labels within sheet or number of sheets. */ -/****************************************************************************/ -void -gl_wdgt_print_copies_get_range (glWdgtPrintCopies * copies, - gint * n_sheets, - gint * first_label, - gint * last_label) -{ - gboolean sheets_active; - - sheets_active = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON - (copies->sheets_radio)); - - if (sheets_active) { - *n_sheets = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->sheets_spin)); - *first_label = 1; - *last_label = copies->labels_per_sheet; - } else { - *n_sheets = 1; - *first_label = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->first_spin)); - *last_label = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->last_spin)); - } -} - -/****************************************************************************/ -/* set range of labels within sheet or number of sheets */ -/****************************************************************************/ -void -gl_wdgt_print_copies_set_range (glWdgtPrintCopies * copies, - gint n_sheets, - gint first_label, - gint last_label) -{ - gint old_first_label; - - old_first_label = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->first_spin)); - - if (first_label > old_first_label) { - gtk_spin_button_set_value (GTK_SPIN_BUTTON (copies->last_spin), - last_label); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (copies->first_spin), - first_label); - } else { - gtk_spin_button_set_value (GTK_SPIN_BUTTON (copies->first_spin), - first_label); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (copies->last_spin), - last_label); - } - if ((first_label == 1) && (last_label == copies->labels_per_sheet)) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (copies->sheets_radio), TRUE); - gtk_spin_button_set_value (GTK_SPIN_BUTTON - (copies->sheets_spin), n_sheets); - } else { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (copies->labels_radio), TRUE); - gtk_spin_button_set_value (GTK_SPIN_BUTTON - (copies->sheets_spin), 1.0); - } -} diff --git a/glabels2/src/wdgt-print-copies.h b/glabels2/src/wdgt-print-copies.h deleted file mode 100644 index ffae2f11..00000000 --- a/glabels2/src/wdgt-print-copies.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_print_copies.h: custom print copies widget module header file - * - * Copyright (C) 2001-2002 Jim Evins . - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __WDGT_PRINT_COPIES_H__ -#define __WDGT_PRINT_COPIES_H__ - -#include "label.h" -#include - -G_BEGIN_DECLS - -#define GL_TYPE_WDGT_PRINT_COPIES (gl_wdgt_print_copies_get_type ()) -#define GL_WDGT_PRINT_COPIES(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), GL_TYPE_WDGT_PRINT_COPIES, glWdgtPrintCopies )) -#define GL_WDGT_PRINT_COPIES_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), GL_TYPE_WDGT_PRINT_COPIES, glWdgtPrintCopiesClass)) -#define GL_IS_WDGT_PRINT_COPIES(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GL_TYPE_WDGT_PRINT_COPIES)) -#define GL_IS_WDGT_PRINT_COPIES_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), GL_TYPE_WDGT_PRINT_COPIES)) - -typedef struct _glWdgtPrintCopies glWdgtPrintCopies; -typedef struct _glWdgtPrintCopiesClass glWdgtPrintCopiesClass; - -struct _glWdgtPrintCopies { - GtkHBox parent_widget; - - gint labels_per_sheet; - - GtkWidget *mini_preview; - - GtkWidget *sheets_radio; - GtkWidget *sheets_spin; - - GtkWidget *labels_radio; - GtkWidget *first_spin; - GtkWidget *last_spin; -}; - -struct _glWdgtPrintCopiesClass { - GtkHBoxClass parent_class; -}; - -GType gl_wdgt_print_copies_get_type (void) G_GNUC_CONST; - -GtkWidget *gl_wdgt_print_copies_new (glLabel *label); - -void gl_wdgt_print_copies_get_range (glWdgtPrintCopies *copies, - gint *n_sheets, - gint *first_label, - gint *last_label); - -void gl_wdgt_print_copies_set_range (glWdgtPrintCopies *copies, - gint n_sheets, - gint first_label, - gint last_label); - -G_END_DECLS - -#endif diff --git a/glabels2/src/wdgt-print-merge.c b/glabels2/src/wdgt-print-merge.c deleted file mode 100644 index c5e0b97f..00000000 --- a/glabels2/src/wdgt-print-merge.c +++ /dev/null @@ -1,316 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_print_merge.c: print merge widget module - * - * Copyright (C) 2001 Jim Evins . - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#include "wdgt-print-merge.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "hig.h" -#include "mini-preview.h" -#include "marshal.h" - -#include "pixmaps/collate.xpm" -#include "pixmaps/nocollate.xpm" - -#include "debug.h" - -#define MINI_PREVIEW_HEIGHT 175 -#define MINI_PREVIEW_WIDTH 150 - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_wdgt_print_merge_finalize (GObject * object); - -static void gl_wdgt_print_merge_construct (glWdgtPrintMerge * merge, - glLabel * label); - -static void preview_clicked (glMiniPreview *mini_preview, - gint i_label, - gpointer user_data); - -static void collate_check_cb (GtkToggleButton * togglebutton, - gpointer user_data); -static void spin_cb (GtkSpinButton * spinbutton, - gpointer user_data); - - -/****************************************************************************/ -/* Boilerplate Object stuff. */ -/****************************************************************************/ -G_DEFINE_TYPE (glWdgtPrintMerge, gl_wdgt_print_merge, GTK_TYPE_HBOX); - - -static void -gl_wdgt_print_merge_class_init (glWdgtPrintMergeClass * class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - - gl_wdgt_print_merge_parent_class = g_type_class_peek_parent (class); - - object_class->finalize = gl_wdgt_print_merge_finalize; -} - -static void -gl_wdgt_print_merge_init (glWdgtPrintMerge * merge) -{ - merge->mini_preview = NULL; - - merge->copies_spin = NULL; - merge->first_spin = NULL; - merge->collate_image = NULL; - merge->collate_check = NULL; -} - -static void -gl_wdgt_print_merge_finalize (GObject * object) -{ - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_WDGT_PRINT_MERGE (object)); - - G_OBJECT_CLASS (gl_wdgt_print_merge_parent_class)->finalize (object); -} - -GtkWidget * -gl_wdgt_print_merge_new (glLabel * label) -{ - glWdgtPrintMerge *merge; - - merge = g_object_new (gl_wdgt_print_merge_get_type (), NULL); - - gl_wdgt_print_merge_construct (merge, label); - - return GTK_WIDGET (merge); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*--------------------------------------------------------------------------*/ -static void -gl_wdgt_print_merge_construct (glWdgtPrintMerge * merge, - glLabel * label) -{ - const lglTemplateFrame *frame; - GtkWidget *whbox, *wvbox, *whbox1; - GtkObject *adjust; - GdkPixbuf *pixbuf; - - whbox = GTK_WIDGET (merge); - - frame = (lglTemplateFrame *)label->template->frames->data; - - merge->labels_per_sheet = lgl_template_frame_get_n_labels (frame); - - /* mini_preview canvas */ - merge->mini_preview = gl_mini_preview_new (MINI_PREVIEW_HEIGHT, - MINI_PREVIEW_WIDTH); - gl_mini_preview_set_template( GL_MINI_PREVIEW (merge->mini_preview), - label->template ); - gtk_box_pack_start (GTK_BOX(whbox), merge->mini_preview, FALSE, FALSE, 0); - gl_mini_preview_highlight_range (GL_MINI_PREVIEW(merge->mini_preview), - 1, 1); - - wvbox = gtk_vbox_new (FALSE, GL_HIG_PAD1); - gtk_box_pack_start (GTK_BOX(whbox), wvbox, FALSE, FALSE, 0); - - /* First Label controls */ - whbox1 = gtk_hbox_new (FALSE, GL_HIG_PAD2); - gtk_box_pack_start (GTK_BOX(wvbox), whbox1, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX(whbox1), - gtk_label_new (_("Start on label")), FALSE, FALSE, 0); - adjust = - gtk_adjustment_new (1, 1.0, merge->labels_per_sheet, 1.0, 10.0, 0.0); - merge->first_spin = - gtk_spin_button_new (GTK_ADJUSTMENT (adjust), 1.0, 0); - gtk_box_pack_start (GTK_BOX(whbox1), merge->first_spin, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX(whbox1), - gtk_label_new (_("on 1st sheet")), FALSE, FALSE, 0); - - /* Blank line */ - gtk_box_pack_start (GTK_BOX(wvbox), gtk_label_new (""), FALSE, FALSE, 0); - - /* Copy & collate controls*/ - whbox1 = gtk_hbox_new (FALSE, GL_HIG_PAD2); - gtk_box_pack_start (GTK_BOX(wvbox), whbox1, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX(whbox1), - gtk_label_new (_("Copies:")), FALSE, FALSE, 0); - adjust = gtk_adjustment_new (1, 1.0, 10.0, 1.0, 10.0, 0.0); - merge->copies_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust), - 1.0, 0); - gtk_box_pack_start (GTK_BOX(whbox1), merge->copies_spin, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX(whbox1), gtk_label_new (" "), FALSE, FALSE, 0); - merge->collate_check = gtk_check_button_new_with_label (_("Collate")); - gtk_box_pack_start (GTK_BOX(whbox1), merge->collate_check, FALSE, FALSE, 0); - pixbuf = gdk_pixbuf_new_from_xpm_data ( (const char **)nocollate_xpm); - merge->collate_image = gtk_image_new_from_pixbuf(pixbuf); - gtk_widget_set_sensitive (merge->collate_check, FALSE); - gtk_widget_set_sensitive (merge->collate_image, FALSE); - - gtk_box_pack_start (GTK_BOX(whbox1), merge->collate_image, FALSE, FALSE, 0); - - /* Connect signals to controls */ - g_signal_connect (G_OBJECT (merge->mini_preview), "clicked", - G_CALLBACK (preview_clicked), merge); - g_signal_connect (G_OBJECT (merge->collate_check), "toggled", - G_CALLBACK (collate_check_cb), merge); - g_signal_connect (G_OBJECT (merge->copies_spin), "changed", - G_CALLBACK (spin_cb), merge); - g_signal_connect (G_OBJECT (merge->first_spin), "changed", - G_CALLBACK (spin_cb), merge); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Enable/Disable appropriate controls due to radio button toggle.*/ -/*--------------------------------------------------------------------------*/ -static void -collate_check_cb (GtkToggleButton * togglebutton, - gpointer user_data) -{ - glWdgtPrintMerge *merge = GL_WDGT_PRINT_MERGE (user_data); - GdkPixbuf *pixbuf; - - if (gtk_toggle_button_get_active (togglebutton)) { - - pixbuf = - gdk_pixbuf_new_from_xpm_data ( (const char **)collate_xpm); - - } else { - - pixbuf = - gdk_pixbuf_new_from_xpm_data ( (const char **)nocollate_xpm); - - } - gtk_image_set_from_pixbuf (GTK_IMAGE (merge->collate_image), - pixbuf); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. modify widget due to change of first spin button */ -/*--------------------------------------------------------------------------*/ -static void -spin_cb (GtkSpinButton * spinbutton, - gpointer user_data) -{ - glWdgtPrintMerge *merge = GL_WDGT_PRINT_MERGE (user_data); - gint first, last, n_copies; - - first = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (merge->first_spin)); - - n_copies = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (merge->copies_spin)); - last = first + (n_copies * merge->n_records) - 1; - gl_mini_preview_highlight_range (GL_MINI_PREVIEW(merge->mini_preview), - first, last ); - - gtk_widget_set_sensitive (merge->collate_check, (n_copies > 1)); - gtk_widget_set_sensitive (merge->collate_image, (n_copies > 1)); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Canvas event handler, select first and last items. */ -/*--------------------------------------------------------------------------*/ -static void -preview_clicked (glMiniPreview *mini_preview, - gint first, - gpointer user_data) -{ - glWdgtPrintMerge *merge = GL_WDGT_PRINT_MERGE (user_data); - gint n_copies, last; - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (merge->first_spin), - first); - - n_copies = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (merge->copies_spin)); - last = first + (n_copies * merge->n_records) - 1; - gl_mini_preview_highlight_range (GL_MINI_PREVIEW (merge->mini_preview), - first, last); - -} - -/****************************************************************************/ -/* 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, - gint *n_sheets) -{ - *n_copies = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (merge->copies_spin)); - *first_label = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (merge->first_spin)); - *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 ); -} - -/****************************************************************************/ -/* set range of labels within sheet or number of sheets */ -/****************************************************************************/ -void -gl_wdgt_print_merge_set_copies (glWdgtPrintMerge * merge, - gint n_copies, - gint first_label, - gint n_records, - gboolean collate_flag) -{ - gint last_label; - - merge->n_records = n_records; - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (merge->copies_spin), - n_copies); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (merge->first_spin), - first_label); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (merge->collate_check), - collate_flag); - - last_label = first_label + (n_copies * n_records) - 1; - gl_mini_preview_highlight_range (GL_MINI_PREVIEW (merge->mini_preview), - first_label, last_label ); -} diff --git a/glabels2/src/wdgt-print-merge.h b/glabels2/src/wdgt-print-merge.h deleted file mode 100644 index 1b16bf89..00000000 --- a/glabels2/src/wdgt-print-merge.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_print_merge.h: print merge widget module header file - * - * Copyright (C) 2001-2002 Jim Evins . - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __WDGT_PRINT_MERGE_H__ -#define __WDGT_PRINT_MERGE_H__ - -#include "label.h" -#include - -G_BEGIN_DECLS - -#define GL_TYPE_WDGT_PRINT_MERGE (gl_wdgt_print_merge_get_type ()) -#define GL_WDGT_PRINT_MERGE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), GL_TYPE_WDGT_PRINT_MERGE, glWdgtPrintMerge )) -#define GL_WDGT_PRINT_MERGE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), GL_TYPE_WDGT_PRINT_MERGE, glWdgtPrintMergeClass)) -#define GL_IS_WDGT_PRINT_MERGE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GL_TYPE_WDGT_PRINT_MERGE)) -#define GL_IS_WDGT_PRINT_MERGE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), GL_TYPE_WDGT_PRINT_MERGE)) - -typedef struct _glWdgtPrintMerge glWdgtPrintMerge; -typedef struct _glWdgtPrintMergeClass glWdgtPrintMergeClass; - -struct _glWdgtPrintMerge { - GtkHBox parent_widget; - - gint labels_per_sheet; - GtkWidget *mini_preview; - - gint n_records; - - GtkWidget *copies_spin; - GtkWidget *first_spin; - GtkWidget *collate_image; - GtkWidget *collate_check; -}; - -struct _glWdgtPrintMergeClass { - GtkHBoxClass parent_class; -}; - -GType gl_wdgt_print_merge_get_type (void) G_GNUC_CONST; - -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, - gint *n_sheets); - -void gl_wdgt_print_merge_set_copies (glWdgtPrintMerge *merge, - gint n_copies, - gint first_label, - gint n_records, - gboolean collate_flag); - -G_END_DECLS - -#endif