]> git.sur5r.net Git - glabels/commitdiff
2004-07-18 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Sun, 18 Jul 2004 14:28:13 +0000 (14:28 +0000)
committerJim Evins <evins@snaught.com>
Sun, 18 Jul 2004 14:28:13 +0000 (14:28 +0000)
* 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

17 files changed:
glabels2/ChangeLog
glabels2/data/glabels-2.0.dtd
glabels2/src/bc.c
glabels2/src/bc.h
glabels2/src/label-barcode.c
glabels2/src/label-barcode.h
glabels2/src/object-editor-bc-page.c
glabels2/src/object-editor-data-page.c
glabels2/src/object-editor-private.h
glabels2/src/object-editor.c
glabels2/src/object-editor.glade
glabels2/src/object-editor.h
glabels2/src/print.c
glabels2/src/view-barcode.c
glabels2/src/xml-label-04.c
glabels2/src/xml-label-191.c
glabels2/src/xml-label.c

index d70d46a5bd814acfeea6c09d7ce0e886992f1067..2503762616693e9274e319936741df0038c5a2d9 100644 (file)
@@ -1,3 +1,35 @@
+2004-07-18  Jim Evins  <evins@snaught.com>
+
+       * 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  <evins@snaught.com>
 
        Various code cleanups.
index 556fb35e5dee3ed2e816c0482a573ef4197f9d8f..fb8fa47d583e18aa141cce6a6d206c228b9847be 100644 (file)
                  color           %UINT_TYPE;             #REQUIRED
                  data            %STRING_TYPE;           #IMPLIED
                  field           %STRING_TYPE;           #IMPLIED
+                 format          %UINT_TYPE;             #IMPLIED
                  %affine_attrs;
                  %shadow_attrs;
 >
index d818a9a25e5e592c627ef6d74887183611c13d63..0f8ebc875f14e7c588773abf69c97bfadd9658f6 100644 (file)
@@ -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.                                                    */
 /*****************************************************************************/
index 3f100424d31117e4ae70be1a632dee30041fd8d9..23ca14c88ace665978c62788b1781ebe821c8e31 100644 (file)
@@ -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);
 
index 636e0f12b9aeef1560e0192aebe51762e0e2a000..47b77350666f87dab893827f4e83e1d975f57904 100644 (file)
@@ -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,
index 7fa79742c988b8f835a40b6e74b3574c40013585..38bdf045083bca47c74ee9f8ab8e9a60b15f3a21 100644 (file)
@@ -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
 
index 872925be4786ff5ee113d723dcc86b13aaa358b5..84fc11fd7ea0a741caf2039da19c54eeb39bffd1 100644 (file)
@@ -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");
index cb0d7bed2e6b84505381150033414eef63fac9ec..87663a78f17cee04e4f98d78bb2a174a97afe428 100644 (file)
@@ -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;
 }
-
index 77d01bfaeeae771c534bd7e42ef82c661231bc35..1cfe372d4efd352a2fdaffa0629d701db4e9d61c 100644 (file)
@@ -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 {
index 0de6051ae50eb080dc45b0cdec3512071f473810..d35aae7684aa15f2464535abdfe5ecf79a44dd67 100644 (file)
@@ -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 ) {
index f9e019d7a2b63790d079e7c9f31bc1d83702bc98..797d2636b42ba30a30d3a0df6334a051292c0948 100644 (file)
                  <child>
                    <widget class="GtkTable" id="table4">
                      <property name="visible">True</property>
-                     <property name="n_rows">2</property>
+                     <property name="n_rows">3</property>
                      <property name="n_columns">2</property>
                      <property name="homogeneous">False</property>
                      <property name="row_spacing">12</property>
                          <property name="y_options">fill</property>
                        </packing>
                      </child>
+
+                     <child>
+                       <widget class="GtkTable" id="table9">
+                         <property name="visible">True</property>
+                         <property name="n_rows">2</property>
+                         <property name="n_columns">2</property>
+                         <property name="homogeneous">False</property>
+                         <property name="row_spacing">6</property>
+                         <property name="column_spacing">6</property>
+
+                         <child>
+                           <widget class="GtkLabel" id="data_format_label">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">format:</property>
+                             <property name="use_underline">False</property>
+                             <property name="use_markup">False</property>
+                             <property name="justify">GTK_JUSTIFY_LEFT</property>
+                             <property name="wrap">False</property>
+                             <property name="selectable">False</property>
+                             <property name="xalign">0</property>
+                             <property name="yalign">0.5</property>
+                             <property name="xpad">0</property>
+                             <property name="ypad">0</property>
+                           </widget>
+                           <packing>
+                             <property name="left_attach">0</property>
+                             <property name="right_attach">1</property>
+                             <property name="top_attach">0</property>
+                             <property name="bottom_attach">1</property>
+                             <property name="x_options">fill</property>
+                             <property name="y_options"></property>
+                           </packing>
+                         </child>
+
+                         <child>
+                           <widget class="GtkLabel" id="data_ex_label">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">00000000000 00000</property>
+                             <property name="use_underline">False</property>
+                             <property name="use_markup">False</property>
+                             <property name="justify">GTK_JUSTIFY_LEFT</property>
+                             <property name="wrap">False</property>
+                             <property name="selectable">False</property>
+                             <property name="xalign">0</property>
+                             <property name="yalign">0.5</property>
+                             <property name="xpad">0</property>
+                             <property name="ypad">0</property>
+                           </widget>
+                           <packing>
+                             <property name="left_attach">1</property>
+                             <property name="right_attach">2</property>
+                             <property name="top_attach">0</property>
+                             <property name="bottom_attach">1</property>
+                             <property name="x_options">fill</property>
+                             <property name="y_options"></property>
+                           </packing>
+                         </child>
+
+                         <child>
+                           <widget class="GtkLabel" id="data_digits_label">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">digits:</property>
+                             <property name="use_underline">False</property>
+                             <property name="use_markup">False</property>
+                             <property name="justify">GTK_JUSTIFY_LEFT</property>
+                             <property name="wrap">False</property>
+                             <property name="selectable">False</property>
+                             <property name="xalign">0</property>
+                             <property name="yalign">0.5</property>
+                             <property name="xpad">0</property>
+                             <property name="ypad">0</property>
+                           </widget>
+                           <packing>
+                             <property name="left_attach">0</property>
+                             <property name="right_attach">1</property>
+                             <property name="top_attach">1</property>
+                             <property name="bottom_attach">2</property>
+                             <property name="x_options">fill</property>
+                             <property name="y_options"></property>
+                           </packing>
+                         </child>
+
+                         <child>
+                           <widget class="GtkHBox" id="hbox32">
+                             <property name="visible">True</property>
+                             <property name="homogeneous">False</property>
+                             <property name="spacing">0</property>
+
+                             <child>
+                               <widget class="GtkSpinButton" id="data_digits_spin">
+                                 <property name="visible">True</property>
+                                 <property name="can_focus">True</property>
+                                 <property name="climb_rate">1</property>
+                                 <property name="digits">0</property>
+                                 <property name="numeric">True</property>
+                                 <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+                                 <property name="snap_to_ticks">False</property>
+                                 <property name="wrap">False</property>
+                                 <property name="adjustment">1 1 100 1 10 10</property>
+                               </widget>
+                               <packing>
+                                 <property name="padding">0</property>
+                                 <property name="expand">False</property>
+                                 <property name="fill">False</property>
+                               </packing>
+                             </child>
+                           </widget>
+                           <packing>
+                             <property name="left_attach">1</property>
+                             <property name="right_attach">2</property>
+                             <property name="top_attach">1</property>
+                             <property name="bottom_attach">2</property>
+                             <property name="x_options">fill</property>
+                             <property name="y_options">fill</property>
+                           </packing>
+                         </child>
+                       </widget>
+                       <packing>
+                         <property name="left_attach">1</property>
+                         <property name="right_attach">2</property>
+                         <property name="top_attach">2</property>
+                         <property name="bottom_attach">3</property>
+                         <property name="x_options">fill</property>
+                         <property name="y_options">fill</property>
+                       </packing>
+                     </child>
                    </widget>
                    <packing>
                      <property name="padding">0</property>
index f450c1556df47412af6584c7000231906e12700f..3cae2e908c2cd033474ddc919188d4b3bd56fab1 100644 (file)
@@ -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
index 65ff33b72427f2d7ed72d7cffbd5e6bbc0aa37d3..a7d29ac857ab48f15619815e90ef73f63a584248 100644 (file)
@@ -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);
 
index dca63b737f4ed7fac5079e7b7ec6678795fafb88..761dc99aa93a42c323c918288636e1810de639c9 100644 (file)
@@ -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);
        }
index 3da7fc202a5e1b34e9703d81bd55a42ba4171add..0e041b913427c7ba6709e62fe4f2049e34562363 100644 (file)
@@ -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;
index bd922ecb1e77140fef7458fd81c7a2d3c3359026..a6f9168e58c6190c84a4b7a5f980a6ae21097cba 100644 (file)
@@ -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);
index e18a4295d1d2fb11a9001d4541449cb28cfb10a7..6bbfc9c7f3ef3e062fedff486160d0f9ef1b98f2 100644 (file)
@@ -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);
        }