From: Jim Evins Date: Sun, 18 Jul 2004 14:28:13 +0000 (+0000) Subject: 2004-07-18 Jim Evins X-Git-Tag: glabels-2_3_0~463 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e84ded9f15e286b712ea5d1f876eed9e5d45c563;p=glabels 2004-07-18 Jim Evins * data/glabels-2.0.dtd: * src/bc.c: (gl_barcode_default_digits), (gl_barcode_can_freeform), (gl_barcode_get_prefered_n): * src/bc.h: * src/label-barcode.c: (copy), (gl_label_barcode_set_props), (gl_label_barcode_get_props), (get_size): * src/label-barcode.h: * src/object-editor-bc-page.c: (gl_object_editor_prepare_bc_page), (style_changed_cb), (gl_object_editor_set_bc_style), (gl_object_editor_get_bc_style): * src/object-editor-data-page.c: (data_radio_toggled_cb), (gl_object_editor_set_data), (gl_object_editor_get_data): * src/object-editor-private.h: * src/object-editor.c: (gl_object_editor_set_key_names): * src/object-editor.glade: * src/object-editor.h: * src/print.c: (draw_barcode_object): * src/view-barcode.c: (update_object_from_editor_cb), (update_editor_from_object_cb), (gl_view_barcode_create_event_handler), (draw_barcode): * src/xml-label-04.c: (xml04_parse_barcode_props): * src/xml-label-191.c: (xml191_parse_barcode_props): * src/xml-label.c: (xml_parse_object_barcode), (xml_create_object_barcode): Added "format" attribute to barcode objects. This attribute is used to properly format freeform barcodes barcodes prior to merge data is applied, so that barcodes can be accurately layed out. This addresses remaining issues of feature request #824787. Also added an example of the format in the object editor. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@434 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index d70d46a5..25037626 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,35 @@ +2004-07-18 Jim Evins + + * data/glabels-2.0.dtd: + * src/bc.c: (gl_barcode_default_digits), (gl_barcode_can_freeform), + (gl_barcode_get_prefered_n): + * src/bc.h: + * src/label-barcode.c: (copy), (gl_label_barcode_set_props), + (gl_label_barcode_get_props), (get_size): + * src/label-barcode.h: + * src/object-editor-bc-page.c: (gl_object_editor_prepare_bc_page), + (style_changed_cb), (gl_object_editor_set_bc_style), + (gl_object_editor_get_bc_style): + * src/object-editor-data-page.c: (data_radio_toggled_cb), + (gl_object_editor_set_data), (gl_object_editor_get_data): + * src/object-editor-private.h: + * src/object-editor.c: (gl_object_editor_set_key_names): + * src/object-editor.glade: + * src/object-editor.h: + * src/print.c: (draw_barcode_object): + * src/view-barcode.c: (update_object_from_editor_cb), + (update_editor_from_object_cb), + (gl_view_barcode_create_event_handler), (draw_barcode): + * src/xml-label-04.c: (xml04_parse_barcode_props): + * src/xml-label-191.c: (xml191_parse_barcode_props): + * src/xml-label.c: (xml_parse_object_barcode), + (xml_create_object_barcode): + Added "format" attribute to barcode objects. This attribute is used + to properly format freeform barcodes barcodes prior to merge data is + applied, so that barcodes can be accurately layed out. This addresses + remaining issues of feature request #824787. Also added an example of + the format in the object editor. + 2004-07-12 Jim Evins Various code cleanups. diff --git a/glabels2/data/glabels-2.0.dtd b/glabels2/data/glabels-2.0.dtd index 556fb35e..fb8fa47d 100644 --- a/glabels2/data/glabels-2.0.dtd +++ b/glabels2/data/glabels-2.0.dtd @@ -273,6 +273,7 @@ color %UINT_TYPE; #REQUIRED data %STRING_TYPE; #IMPLIED field %STRING_TYPE; #IMPLIED + format %UINT_TYPE; #IMPLIED %affine_attrs; %shadow_attrs; > diff --git a/glabels2/src/bc.c b/glabels2/src/bc.c index d818a9a2..0f8ebc87 100644 --- a/glabels2/src/bc.c +++ b/glabels2/src/bc.c @@ -46,6 +46,8 @@ typedef struct { gboolean can_checksum; gboolean checksum_optional; gchar *default_digits; + gboolean can_freeform; + guint prefered_n; } Backend; @@ -56,90 +58,90 @@ typedef struct { Backend backends[] = { { "POSTNET", N_("POSTNET (any)"), gl_barcode_postnet_new, - FALSE, FALSE, TRUE, FALSE, "000000000"}, + FALSE, FALSE, TRUE, FALSE, "12345-6789-12", FALSE, 11}, { "POSTNET-5", N_("POSTNET-5 (ZIP only)"), gl_barcode_postnet_new, - FALSE, FALSE, TRUE, FALSE, "00000"}, + FALSE, FALSE, TRUE, FALSE, "12345", FALSE, 5}, { "POSTNET-9", N_("POSTNET-9 (ZIP+4)"), gl_barcode_postnet_new, - FALSE, FALSE, TRUE, FALSE, "000000000"}, + FALSE, FALSE, TRUE, FALSE, "12345-6789", FALSE, 9}, { "POSTNET-11", N_("POSTNET-11 (DPBC)"), gl_barcode_postnet_new, - FALSE, FALSE, TRUE, FALSE, "00000000000"}, + FALSE, FALSE, TRUE, FALSE, "12345-6789-12", FALSE, 11}, { "EAN", N_("EAN (any)"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, FALSE, "000000000000 00000"}, + TRUE, TRUE, TRUE, FALSE, "000000000000 00000", FALSE, 17}, { "EAN-8", N_("EAN-8"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, FALSE, "0000000"}, + TRUE, TRUE, TRUE, FALSE, "0000000", FALSE, 7}, { "EAN-8+2", N_("EAN-8 +2"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, FALSE, "0000000 00"}, + TRUE, TRUE, TRUE, FALSE, "0000000 00", FALSE, 9}, { "EAN-8+5", N_("EAN-8 +5"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, FALSE, "0000000 00000"}, + TRUE, TRUE, TRUE, FALSE, "0000000 00000", FALSE, 12}, { "EAN-13", N_("EAN-13"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, FALSE, "000000000000"}, + TRUE, TRUE, TRUE, FALSE, "000000000000", FALSE, 12}, { "EAN-13+2", N_("EAN-13 +2"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, FALSE, "000000000000 00"}, + TRUE, TRUE, TRUE, FALSE, "000000000000 00", FALSE, 14}, { "EAN-13+5", N_("EAN-13 +5"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, FALSE, "000000000000 00000"}, + TRUE, TRUE, TRUE, FALSE, "000000000000 00000", FALSE, 17}, { "UPC", N_("UPC (UPC-A or UPC-E)"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, FALSE, "00000000000 00000"}, + TRUE, TRUE, TRUE, FALSE, "00000000000 00000", FALSE, 16}, { "UPC-A", N_("UPC-A"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, FALSE, "00000000000"}, + TRUE, TRUE, TRUE, FALSE, "00000000000", FALSE, 11}, { "UPC-A+2", N_("UPC-A +2"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, FALSE, "00000000000 00"}, + TRUE, TRUE, TRUE, FALSE, "00000000000 00", FALSE, 13}, { "UPC-A+5", N_("UPC-A +5"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, FALSE, "00000000000 00000"}, + TRUE, TRUE, TRUE, FALSE, "00000000000 00000", FALSE, 16}, { "UPC-E", N_("UPC-E"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, FALSE, "000000"}, + TRUE, TRUE, TRUE, FALSE, "000000", FALSE, 6}, { "UPC-E+2", N_("UPC-E +2"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, FALSE, "000000 00"}, + TRUE, TRUE, TRUE, FALSE, "000000 00", FALSE, 8}, { "UPC-E+5", N_("UPC-E +5"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, FALSE, "000000 00000"}, + TRUE, TRUE, TRUE, FALSE, "000000 00000", FALSE, 11}, { "ISBN", N_("ISBN"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, TRUE, "0-00000-000-0"}, + TRUE, TRUE, TRUE, TRUE, "0-00000-000-0", FALSE, 10}, { "ISBN+5", N_("ISBN +5"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, TRUE, "0-00000-000-0 00000"}, + TRUE, TRUE, TRUE, TRUE, "0-00000-000-0 00000", FALSE, 15}, { "Code39", N_("Code 39"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, TRUE, "0000000000"}, + TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10}, { "Code128", N_("Code 128"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, TRUE, "0000000000"}, + TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10}, { "Code128C", N_("Code 128C"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, TRUE, "0000000000"}, + TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10}, { "Code128B", N_("Code 128B"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, TRUE, "0000000000"}, + TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10}, { "I25", N_("Interleaved 2 of 5"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, TRUE, "0000000000"}, + TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10}, { "CBR", N_("Codabar"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, TRUE, "0000000000"}, + TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10}, { "MSI", N_("MSI"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, TRUE, "0000000000"}, + TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10}, { "PLS", N_("Plessey"), gl_barcode_gnubarcode_new, - TRUE, TRUE, TRUE, TRUE, "0000000000"}, + TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10}, - { NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, NULL} + { NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, NULL, FALSE, 0} }; @@ -283,9 +285,22 @@ gl_barcode_free_styles_list (GList *styles_list) /* Return an appropriate set of digits for the given barcode style. */ /*****************************************************************************/ gchar * -gl_barcode_default_digits (const gchar *id) +gl_barcode_default_digits (const gchar *id, + guint n) { - return g_strdup (backends[id_to_index (id)].default_digits); + int i; + + i = id_to_index (id); + + if (backends[i].can_freeform) { + + return g_strnfill (n, '0'); + + } else { + + return g_strdup (backends[i].default_digits); + + } } /*****************************************************************************/ @@ -318,6 +333,25 @@ gl_barcode_csum_optional (const gchar *id) return backends[id_to_index (id)].checksum_optional; } + +/*****************************************************************************/ +/* Query if freeform input is allowed. */ +/*****************************************************************************/ +gboolean +gl_barcode_can_freeform (const gchar *id) +{ + return backends[id_to_index (id)].can_freeform; +} + +/*****************************************************************************/ +/* Query prefered number of digits of input. */ +/*****************************************************************************/ +guint +gl_barcode_get_prefered_n (const gchar *id) +{ + return backends[id_to_index (id)].prefered_n; +} + /*****************************************************************************/ /* Convert style to text. */ /*****************************************************************************/ diff --git a/glabels2/src/bc.h b/glabels2/src/bc.h index 3f100424..23ca14c8 100644 --- a/glabels2/src/bc.h +++ b/glabels2/src/bc.h @@ -65,7 +65,8 @@ void gl_barcode_free (glBarcode **bc); GList *gl_barcode_get_styles_list (void); void gl_barcode_free_styles_list (GList *styles_list); -gchar *gl_barcode_default_digits (const gchar *id); +gchar *gl_barcode_default_digits (const gchar *id, + guint n); gboolean gl_barcode_can_text (const gchar *id); gboolean gl_barcode_text_optional (const gchar *id); @@ -73,6 +74,9 @@ gboolean gl_barcode_text_optional (const gchar *id); gboolean gl_barcode_can_csum (const gchar *id); gboolean gl_barcode_csum_optional (const gchar *id); +gboolean gl_barcode_can_freeform (const gchar *id); +guint gl_barcode_get_prefered_n (const gchar *id); + const gchar *gl_barcode_id_to_name (const gchar *id); const gchar *gl_barcode_name_to_id (const gchar *name); diff --git a/glabels2/src/label-barcode.c b/glabels2/src/label-barcode.c index 636e0f12..47b77350 100644 --- a/glabels2/src/label-barcode.c +++ b/glabels2/src/label-barcode.c @@ -42,6 +42,7 @@ struct _glLabelBarcodePrivate { guint color; gboolean text_flag; gboolean checksum_flag; + guint format_digits; }; /*========================================================*/ @@ -169,6 +170,7 @@ copy (glLabelObject *dst_object, gboolean text_flag; gboolean checksum_flag; guint color; + guint format_digits; gl_debug (DEBUG_LABEL, "START"); @@ -176,11 +178,11 @@ copy (glLabelObject *dst_object, g_return_if_fail (new_lbc && GL_IS_LABEL_BARCODE (new_lbc)); text_node = gl_label_barcode_get_data (lbc); - gl_label_barcode_get_props (lbc, &id, &text_flag, &checksum_flag); + gl_label_barcode_get_props (lbc, &id, &text_flag, &checksum_flag, &format_digits); color = get_line_color (src_object); gl_label_barcode_set_data (new_lbc, text_node); - gl_label_barcode_set_props (new_lbc, id, text_flag, checksum_flag); + gl_label_barcode_set_props (new_lbc, id, text_flag, checksum_flag, format_digits); set_line_color (dst_object, color); gl_text_node_free (&text_node); @@ -217,7 +219,8 @@ void gl_label_barcode_set_props (glLabelBarcode *lbc, gchar *id, gboolean text_flag, - gboolean checksum_flag) + gboolean checksum_flag, + guint format_digits) { gl_debug (DEBUG_LABEL, "START"); @@ -226,11 +229,13 @@ gl_label_barcode_set_props (glLabelBarcode *lbc, if ( ((lbc->private->id == NULL) && (id != NULL)) || (g_strcasecmp (lbc->private->id, id) != 0) || (lbc->private->text_flag != text_flag) - || (lbc->private->checksum_flag != checksum_flag) ) { + || (lbc->private->checksum_flag != checksum_flag) + || (lbc->private->format_digits != format_digits)) { lbc->private->id = g_strdup (id); lbc->private->text_flag = text_flag; lbc->private->checksum_flag = checksum_flag; + lbc->private->format_digits = format_digits; gl_label_object_emit_changed (GL_LABEL_OBJECT(lbc)); @@ -255,13 +260,15 @@ void gl_label_barcode_get_props (glLabelBarcode *lbc, gchar **id, gboolean *text_flag, - gboolean *checksum_flag) + gboolean *checksum_flag, + guint *format_digits) { g_return_if_fail (lbc && GL_IS_LABEL_BARCODE (lbc)); *id = g_strdup (lbc->private->id); *text_flag = lbc->private->text_flag; *checksum_flag = lbc->private->checksum_flag; + *format_digits = lbc->private->format_digits; } /*---------------------------------------------------------------------------*/ @@ -285,7 +292,8 @@ get_size (glLabelObject *object, if (lbc->private->text_node->field_flag) { - data = gl_barcode_default_digits (lbc->private->id); + data = gl_barcode_default_digits (lbc->private->id, + lbc->private->format_digits); } else { data = gl_text_node_expand (lbc->private->text_node, NULL); } @@ -299,7 +307,8 @@ get_size (glLabelObject *object, if ( gbc == NULL ) { /* Try again with default digits. */ - data = gl_barcode_default_digits (lbc->private->id); + data = gl_barcode_default_digits (lbc->private->id, + lbc->private->format_digits); gbc = gl_barcode_new (lbc->private->id, lbc->private->text_flag, lbc->private->checksum_flag, diff --git a/glabels2/src/label-barcode.h b/glabels2/src/label-barcode.h index 7fa79742..38bdf045 100644 --- a/glabels2/src/label-barcode.h +++ b/glabels2/src/label-barcode.h @@ -63,13 +63,15 @@ void gl_label_barcode_set_data (glLabelBarcode *lbc, void gl_label_barcode_set_props (glLabelBarcode *lbc, gchar *id, gboolean text_flag, - gboolean checksum_flag); + gboolean checksum_flag, + guint format_digits); glTextNode *gl_label_barcode_get_data (glLabelBarcode *lbc); void gl_label_barcode_get_props (glLabelBarcode *lbc, gchar **id, gboolean *text_flag, - gboolean *checksum_flag); + gboolean *checksum_flag, + guint *format_digits); G_END_DECLS diff --git a/glabels2/src/object-editor-bc-page.c b/glabels2/src/object-editor-bc-page.c index 872925be..84fc11fd 100644 --- a/glabels2/src/object-editor-bc-page.c +++ b/glabels2/src/object-editor-bc-page.c @@ -75,6 +75,16 @@ gl_object_editor_prepare_bc_page (glObjectEditor *editor) glade_xml_get_widget (editor->priv->gui, "bc_cs_check"); editor->priv->bc_color_combo = glade_xml_get_widget (editor->priv->gui, "bc_color_combo"); + editor->priv->data_format_label = + glade_xml_get_widget (editor->priv->gui, "data_format_label"); + editor->priv->data_ex_label = + glade_xml_get_widget (editor->priv->gui, "data_ex_label"); + editor->priv->data_digits_label = + glade_xml_get_widget (editor->priv->gui, "data_digits_label"); + editor->priv->data_digits_spin = + glade_xml_get_widget (editor->priv->gui, "data_digits_spin"); + + editor->priv->data_format_fixed_flag = FALSE; /* Load barcode styles */ styles = gl_barcode_get_styles_list (); @@ -101,6 +111,10 @@ gl_object_editor_prepare_bc_page (glObjectEditor *editor) "color_changed", G_CALLBACK (gl_object_editor_changed_cb), G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->data_digits_spin), + "changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); gl_debug (DEBUG_EDITOR, "END"); } @@ -111,8 +125,10 @@ gl_object_editor_prepare_bc_page (glObjectEditor *editor) static void style_changed_cb (glObjectEditor *editor) { - gchar *style_string; + gchar *style_string = NULL; const gchar *id; + gchar *ex_string = NULL; + guint digits; style_string = gtk_editable_get_chars (GTK_EDITABLE(editor->priv->bc_style_entry), 0, -1); @@ -131,12 +147,37 @@ style_changed_cb (glObjectEditor *editor) gtk_widget_set_sensitive (editor->priv->bc_cs_check, gl_barcode_csum_optional (id)); + editor->priv->data_format_fixed_flag = !gl_barcode_can_freeform (id); + digits = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->data_digits_spin)); + if (editor->priv->data_format_fixed_flag) { + digits = gl_barcode_get_prefered_n(id); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->data_digits_spin), + digits); + } + ex_string = gl_barcode_default_digits (id, digits); + gtk_label_set_text (GTK_LABEL(editor->priv->data_ex_label), ex_string); + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->data_literal_radio))) { + gtk_widget_set_sensitive (editor->priv->data_format_label, FALSE); + gtk_widget_set_sensitive (editor->priv->data_ex_label, FALSE); + gtk_widget_set_sensitive (editor->priv->data_digits_label, FALSE); + gtk_widget_set_sensitive (editor->priv->data_digits_spin, FALSE); + } else { + gtk_widget_set_sensitive (editor->priv->data_format_label, TRUE); + gtk_widget_set_sensitive (editor->priv->data_ex_label, TRUE); + gtk_widget_set_sensitive (editor->priv->data_digits_label, + !editor->priv->data_format_fixed_flag); + gtk_widget_set_sensitive (editor->priv->data_digits_spin, + !editor->priv->data_format_fixed_flag); + } + /* Emit our "changed" signal */ g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0); } g_free (style_string); + g_free (ex_string); } /*****************************************************************************/ @@ -146,10 +187,12 @@ void gl_object_editor_set_bc_style (glObjectEditor *editor, gchar *id, gboolean text_flag, - gboolean checksum_flag) + gboolean checksum_flag, + guint format_digits) { const gchar *style_string; gint pos; + gchar *ex_string; gl_debug (DEBUG_EDITOR, "START"); @@ -162,6 +205,9 @@ gl_object_editor_set_bc_style (glObjectEditor *editor, g_signal_handlers_block_by_func (G_OBJECT(editor->priv->bc_cs_check), G_CALLBACK (gl_object_editor_changed_cb), editor); + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->data_digits_spin), + G_CALLBACK (gl_object_editor_changed_cb), + editor); style_string = gl_barcode_id_to_name (id); @@ -185,6 +231,33 @@ gl_object_editor_set_bc_style (glObjectEditor *editor, gtk_widget_set_sensitive (editor->priv->bc_cs_check, gl_barcode_csum_optional (id)); + editor->priv->data_format_fixed_flag = !gl_barcode_can_freeform (id); + + if (editor->priv->data_format_fixed_flag) { + format_digits = gl_barcode_get_prefered_n (id); + } + + ex_string = gl_barcode_default_digits (id, format_digits); + gtk_label_set_text (GTK_LABEL(editor->priv->data_ex_label), ex_string); + g_free (ex_string); + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->data_digits_spin), + format_digits); + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->data_literal_radio))) { + gtk_widget_set_sensitive (editor->priv->data_format_label, FALSE); + gtk_widget_set_sensitive (editor->priv->data_ex_label, FALSE); + gtk_widget_set_sensitive (editor->priv->data_digits_label, FALSE); + gtk_widget_set_sensitive (editor->priv->data_digits_spin, FALSE); + } else { + gtk_widget_set_sensitive (editor->priv->data_format_label, TRUE); + gtk_widget_set_sensitive (editor->priv->data_ex_label, TRUE); + gtk_widget_set_sensitive (editor->priv->data_digits_label, + !editor->priv->data_format_fixed_flag); + gtk_widget_set_sensitive (editor->priv->data_digits_spin, + !editor->priv->data_format_fixed_flag); + } + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->bc_style_entry), G_CALLBACK (style_changed_cb), editor); @@ -194,6 +267,9 @@ gl_object_editor_set_bc_style (glObjectEditor *editor, g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->bc_cs_check), G_CALLBACK (gl_object_editor_changed_cb), editor); + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->data_digits_spin), + G_CALLBACK (gl_object_editor_changed_cb), + editor); gl_debug (DEBUG_EDITOR, "END"); } @@ -205,7 +281,8 @@ void gl_object_editor_get_bc_style (glObjectEditor *editor, gchar **id, gboolean *text_flag, - gboolean *checksum_flag) + gboolean *checksum_flag, + guint *format_digits) { gchar *style_string; @@ -222,6 +299,10 @@ gl_object_editor_get_bc_style (glObjectEditor *editor, *checksum_flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->bc_cs_check)); + + *format_digits = + gtk_spin_button_get_value (GTK_SPIN_BUTTON(editor->priv->data_digits_spin)); + g_free (style_string); gl_debug (DEBUG_EDITOR, "END"); diff --git a/glabels2/src/object-editor-data-page.c b/glabels2/src/object-editor-data-page.c index cb0d7bed..87663a78 100644 --- a/glabels2/src/object-editor-data-page.c +++ b/glabels2/src/object-editor-data-page.c @@ -110,10 +110,20 @@ data_radio_toggled_cb (glObjectEditor *editor) if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->data_literal_radio))) { gtk_widget_set_sensitive (editor->priv->data_text_entry, TRUE); gtk_widget_set_sensitive (editor->priv->data_key_combo, FALSE); + gtk_widget_set_sensitive (editor->priv->data_format_label, FALSE); + gtk_widget_set_sensitive (editor->priv->data_ex_label, FALSE); + gtk_widget_set_sensitive (editor->priv->data_digits_label, FALSE); + gtk_widget_set_sensitive (editor->priv->data_digits_spin, FALSE); } else { gtk_widget_set_sensitive (editor->priv->data_text_entry, FALSE); gtk_widget_set_sensitive (editor->priv->data_key_combo, TRUE); - } + gtk_widget_set_sensitive (editor->priv->data_format_label, TRUE); + gtk_widget_set_sensitive (editor->priv->data_ex_label, TRUE); + gtk_widget_set_sensitive (editor->priv->data_digits_label, + !editor->priv->data_format_fixed_flag); + gtk_widget_set_sensitive (editor->priv->data_digits_spin, + !editor->priv->data_format_fixed_flag); + } /* Emit our "changed" signal */ g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0); @@ -148,6 +158,10 @@ gl_object_editor_set_data (glObjectEditor *editor, (editor->priv->data_literal_radio), TRUE); gtk_widget_set_sensitive (editor->priv->data_text_entry, TRUE); gtk_widget_set_sensitive (editor->priv->data_key_combo, FALSE); + gtk_widget_set_sensitive (editor->priv->data_format_label, FALSE); + gtk_widget_set_sensitive (editor->priv->data_ex_label, FALSE); + gtk_widget_set_sensitive (editor->priv->data_digits_spin, FALSE); + gtk_widget_set_sensitive (editor->priv->data_digits_label, FALSE); gtk_editable_delete_text (GTK_EDITABLE (editor->priv->data_text_entry), 0, -1); pos = 0; @@ -165,6 +179,12 @@ gl_object_editor_set_data (glObjectEditor *editor, gtk_widget_set_sensitive (editor->priv->data_text_entry, FALSE); gtk_widget_set_sensitive (editor->priv->data_key_combo, TRUE); + gtk_widget_set_sensitive (editor->priv->data_format_label, TRUE); + gtk_widget_set_sensitive (editor->priv->data_ex_label, TRUE); + gtk_widget_set_sensitive (editor->priv->data_digits_label, + !editor->priv->data_format_fixed_flag); + gtk_widget_set_sensitive (editor->priv->data_digits_spin, + !editor->priv->data_format_fixed_flag); gtk_editable_delete_text (GTK_EDITABLE (editor->priv->data_key_entry), 0, -1); pos = 0; @@ -216,4 +236,3 @@ gl_object_editor_get_data (glObjectEditor *editor) return text_node; } - diff --git a/glabels2/src/object-editor-private.h b/glabels2/src/object-editor-private.h index 77d01bfa..1cfe372d 100644 --- a/glabels2/src/object-editor-private.h +++ b/glabels2/src/object-editor-private.h @@ -119,7 +119,11 @@ struct _glObjectEditorPrivate { GtkWidget *data_text_entry; GtkWidget *data_key_entry; GtkWidget *data_key_combo; - + GtkWidget *data_format_label; + GtkWidget *data_ex_label; + GtkWidget *data_digits_label; + GtkWidget *data_digits_spin; + gboolean data_format_fixed_flag; }; enum { diff --git a/glabels2/src/object-editor.c b/glabels2/src/object-editor.c index 0de6051a..d35aae76 100644 --- a/glabels2/src/object-editor.c +++ b/glabels2/src/object-editor.c @@ -366,6 +366,7 @@ gl_object_editor_set_key_names (glObjectEditor *editor, { GList *keys; GtkWidget *combo; + gboolean fixed_flag; gl_debug (DEBUG_EDITOR, "START"); @@ -411,7 +412,23 @@ gl_object_editor_set_key_names (glObjectEditor *editor, } } - + fixed_flag = editor->priv->data_format_fixed_flag; + if (editor->priv->data_format_label) { + gtk_widget_set_sensitive (editor->priv->data_format_label, + (merge != NULL)); + } + if (editor->priv->data_ex_label) { + gtk_widget_set_sensitive (editor->priv->data_ex_label, + (merge != NULL)); + } + if (editor->priv->data_digits_label) { + gtk_widget_set_sensitive (editor->priv->data_digits_label, + (merge != NULL) && !fixed_flag); + } + if (editor->priv->data_digits_spin) { + gtk_widget_set_sensitive (editor->priv->data_digits_spin, + (merge != NULL) && !fixed_flag); + } keys = gl_merge_get_key_list (merge); if ( keys != NULL ) { diff --git a/glabels2/src/object-editor.glade b/glabels2/src/object-editor.glade index f9e019d7..797d2636 100644 --- a/glabels2/src/object-editor.glade +++ b/glabels2/src/object-editor.glade @@ -1282,7 +1282,7 @@ True - 2 + 3 2 False 12 @@ -1417,6 +1417,132 @@ fill + + + + True + 2 + 2 + False + 6 + 6 + + + + True + format: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + 00000000000 00000 + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + digits: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + False + 0 + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 1 100 1 10 10 + + + 0 + False + False + + + + + 1 + 2 + 1 + 2 + fill + fill + + + + + 1 + 2 + 2 + 3 + fill + fill + + 0 diff --git a/glabels2/src/object-editor.h b/glabels2/src/object-editor.h index f450c155..3cae2e90 100644 --- a/glabels2/src/object-editor.h +++ b/glabels2/src/object-editor.h @@ -228,12 +228,14 @@ void gl_object_editor_set_text_buffer (glObjectEditor *editor, void gl_object_editor_set_bc_style (glObjectEditor *editor, gchar *id, gboolean text_flag, - gboolean checksum_flag); + gboolean checksum_flag, + guint format_digits); void gl_object_editor_get_bc_style (glObjectEditor *editor, gchar **id, gboolean *text_flag, - gboolean *checksum_flag); + gboolean *checksum_flag, + guint *format_digits); void gl_object_editor_set_bc_color (glObjectEditor *editor, guint text_color); @@ -252,7 +254,6 @@ glTextNode *gl_object_editor_get_data (glObjectEditor *editor); - G_END_DECLS #endif diff --git a/glabels2/src/print.c b/glabels2/src/print.c index 65ff33b7..a7d29ac8 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -1048,13 +1048,14 @@ draw_barcode_object (PrintInfo *pi, gboolean text_flag; gboolean checksum_flag; guint color; + guint format_digits; gdouble w, h; gl_debug (DEBUG_PRINT, "START"); text_node = gl_label_barcode_get_data (object); gl_label_barcode_get_props (object, - &id, &text_flag, &checksum_flag); + &id, &text_flag, &checksum_flag, &format_digits); color = gl_label_object_get_line_color (GL_LABEL_OBJECT(object)); gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); diff --git a/glabels2/src/view-barcode.c b/glabels2/src/view-barcode.c index dca63b73..761dc99a 100644 --- a/glabels2/src/view-barcode.c +++ b/glabels2/src/view-barcode.c @@ -262,6 +262,7 @@ update_object_from_editor_cb (glObjectEditor *editor, gchar *id; gboolean text_flag, cs_flag; guint color; + guint format_digits; gl_debug (DEBUG_VIEW, "START"); @@ -283,10 +284,10 @@ update_object_from_editor_cb (glObjectEditor *editor, gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node); gl_text_node_free (&text_node); - gl_object_editor_get_bc_style (editor, &id, &text_flag, &cs_flag); + gl_object_editor_get_bc_style (editor, &id, &text_flag, &cs_flag, &format_digits); color = gl_object_editor_get_bc_color (editor); gl_label_barcode_set_props (GL_LABEL_BARCODE(object), - id, text_flag, cs_flag); + id, text_flag, cs_flag, format_digits); gl_label_object_set_line_color (object, color); g_free (id); @@ -313,6 +314,7 @@ update_editor_from_object_cb (glLabelObject *object, gboolean text_flag, cs_flag; guint color; glMerge *merge; + guint format_digits; gl_debug (DEBUG_VIEW, "START"); @@ -320,9 +322,9 @@ update_editor_from_object_cb (glLabelObject *object, gl_object_editor_set_size (editor, w, h); gl_label_barcode_get_props (GL_LABEL_BARCODE(object), - &id, &text_flag, &cs_flag); + &id, &text_flag, &cs_flag, &format_digits); color = gl_label_object_get_line_color (object); - gl_object_editor_set_bc_style (editor, id, text_flag, cs_flag); + gl_object_editor_set_bc_style (editor, id, text_flag, cs_flag, format_digits); gl_object_editor_set_bc_color (editor, color); g_free (id); @@ -452,7 +454,8 @@ gl_view_barcode_create_event_handler (GnomeCanvas *canvas, gl_label_barcode_set_props (GL_LABEL_BARCODE(object), "POSTNET", FALSE, - TRUE); + TRUE, + 0); gl_label_object_set_line_color (GL_LABEL_OBJECT(object), gl_color_set_opacity ( gl_view_get_default_line_color(view), @@ -481,7 +484,8 @@ gl_view_barcode_create_event_handler (GnomeCanvas *canvas, gl_label_barcode_set_props (GL_LABEL_BARCODE(object), "POSTNET", FALSE, - TRUE); + TRUE, + 0); gl_label_object_set_line_color (GL_LABEL_OBJECT(object), gl_view_get_default_line_color(view)); gl_view_unselect_all (view); @@ -536,18 +540,19 @@ draw_barcode (glViewBarcode *view_barcode) GnomeFont *font; GnomeGlyphList *glyphlist; gdouble y_offset; + guint format_digits; gl_debug (DEBUG_VIEW, "START"); /* Query label object and properties */ object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode)); gl_label_barcode_get_props (GL_LABEL_BARCODE(object), - &id, &text_flag, &checksum_flag); + &id, &text_flag, &checksum_flag, &format_digits); color = gl_label_object_get_line_color (object); gl_label_object_get_size (object, &w, &h); text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object)); if (text_node->field_flag) { - digits = gl_barcode_default_digits (id); + digits = gl_barcode_default_digits (id, format_digits); } else { digits = gl_text_node_expand (text_node, NULL); } diff --git a/glabels2/src/xml-label-04.c b/glabels2/src/xml-label-04.c index 3da7fc20..0e041b91 100644 --- a/glabels2/src/xml-label-04.c +++ b/glabels2/src/xml-label-04.c @@ -431,7 +431,7 @@ xml04_parse_barcode_props (xmlNodePtr node, if (scale == 0.0) { scale = 0.5; /* Set to a valid value */ } - gl_label_barcode_set_props (object, id, text_flag, TRUE); + gl_label_barcode_set_props (object, id, text_flag, TRUE, 0); gl_label_object_set_line_color (GL_LABEL_OBJECT(object), color); child = node->xmlChildrenNode; diff --git a/glabels2/src/xml-label-191.c b/glabels2/src/xml-label-191.c index bd922ecb..a6f9168e 100644 --- a/glabels2/src/xml-label-191.c +++ b/glabels2/src/xml-label-191.c @@ -546,7 +546,7 @@ xml191_parse_barcode_props (xmlNodePtr node, gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node); gl_label_barcode_set_props (GL_LABEL_BARCODE(object), - id, text_flag, checksum_flag); + id, text_flag, checksum_flag, 0); gl_label_object_set_line_color (GL_LABEL_OBJECT(object), color); gl_text_node_free (&text_node); diff --git a/glabels2/src/xml-label.c b/glabels2/src/xml-label.c index e18a4295..6bbfc9c7 100644 --- a/glabels2/src/xml-label.c +++ b/glabels2/src/xml-label.c @@ -687,6 +687,7 @@ xml_parse_object_barcode (xmlNodePtr node, gboolean text_flag; gboolean checksum_flag; guint color; + guint format_digits; gdouble affine[6]; gl_debug (DEBUG_XML, "START"); @@ -708,8 +709,9 @@ xml_parse_object_barcode (xmlNodePtr node, text_flag = gl_xml_get_prop_boolean (node, "text", FALSE); checksum_flag = gl_xml_get_prop_boolean (node, "checksum", TRUE); color = gl_xml_get_prop_uint (node, "color", 0); + format_digits = gl_xml_get_prop_uint (node, "format", 0); gl_label_barcode_set_props (GL_LABEL_BARCODE(object), - id, text_flag, checksum_flag); + id, text_flag, checksum_flag, format_digits); gl_label_object_set_line_color (GL_LABEL_OBJECT(object), color); g_free (id); @@ -1358,6 +1360,7 @@ xml_create_object_barcode (xmlNodePtr root, gboolean text_flag; gboolean checksum_flag; guint color; + guint format_digits; gdouble affine[6]; gl_debug (DEBUG_XML, "START"); @@ -1376,7 +1379,7 @@ xml_create_object_barcode (xmlNodePtr root, /* Barcode properties attrs */ gl_label_barcode_get_props (GL_LABEL_BARCODE(object), - &id, &text_flag, &checksum_flag); + &id, &text_flag, &checksum_flag, &format_digits); color = gl_label_object_get_line_color (GL_LABEL_OBJECT(object)); xmlSetProp (node, "style", id); gl_xml_set_prop_boolean (node, "text", text_flag); @@ -1388,6 +1391,7 @@ xml_create_object_barcode (xmlNodePtr root, text_node = gl_label_barcode_get_data (GL_LABEL_BARCODE(object)); if (text_node->field_flag) { xmlSetProp (node, "field", text_node->data); + gl_xml_set_prop_int (node, "format", format_digits); } else { xmlSetProp (node, "data", text_node->data); }