]> git.sur5r.net Git - glabels/commitdiff
2004-02-15 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Sun, 15 Feb 2004 16:28:39 +0000 (16:28 +0000)
committerJim Evins <evins@snaught.com>
Sun, 15 Feb 2004 16:28:39 +0000 (16:28 +0000)
* data/glabels-2.0.dtd:
Added specific subtypes for various barcode types.

* src/bc.h:
* src/bc.c: (id_to_index), (name_to_index), (gl_barcode_new),
(gl_barcode_get_styles_list), (gl_barcode_default_digits),
(gl_barcode_can_text), (gl_barcode_text_optional),
(gl_barcode_can_csum), (gl_barcode_csum_optional),
(gl_barcode_id_to_name), (gl_barcode_name_to_id):
Changed API to use a string id, rather than a fixed enumeration.  Id and
name are separate strings.  Added entries to backend table for specific
subtypes for various barcode types.

* src/bc-postnet.h:
* src/bc-postnet.c: (gl_barcode_postnet_new), (postnet_code),
(is_length_valid):
Modified to conform to above API.  Now more stringent with data length
for various subtypes.

* src/bc-gnubarcode.h:
* src/bc-gnubarcode.c: (gl_barcode_gnubarcode_new),
(is_length_valid), (is_length1_valid), (is_length2_valid):
Modified to conform to above API.  Now more stringent with data length
for various subtypes.

* src/label-barcode.h:
* src/label-barcode.c: (copy), (gl_label_barcode_set_props),
(gl_label_barcode_get_props), (get_size):
Modified to use above API for storing barcode type.

* src/object-editor.h:
* src/object-editor-bc-page.c: (style_changed_cb),
(gl_object_editor_set_bc_style), (gl_object_editor_get_bc_style):
Modified to use above API for storing barcode type.

* src/object-editor-size-page.c:
(gl_object_editor_prepare_size_page), (aspect_toggle_cb),
(w_spin_cb), (h_spin_cb), (size_reset_cb):
Added debug markers.

* src/object-editor.glade:
Made barcode style combo's text entry  non-editable.

* src/print.c: (draw_barcode_object):
Modified to use above API for barcode type.

* src/view-barcode.c: (update_object_from_editor_cb),
(update_editor_from_object_cb),
(gl_view_barcode_create_event_handler), (draw_barcode):
Modified to use above API for barcode type.

* 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):
Modified to use above API for barcode type.

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

19 files changed:
glabels2/ChangeLog
glabels2/data/glabels-2.0.dtd
glabels2/src/bc-gnubarcode.c
glabels2/src/bc-gnubarcode.h
glabels2/src/bc-postnet.c
glabels2/src/bc-postnet.h
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-size-page.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 41a4a8e802f6f7697307ec96ee60d2ab988132d4..f6ac66c0e470eba0af160043eb17b03eb2db1270 100644 (file)
@@ -1,3 +1,62 @@
+2004-02-15  Jim Evins  <evins@snaught.com>
+
+       * data/glabels-2.0.dtd:
+               Added specific subtypes for various barcode types.
+       
+       * src/bc.h:
+       * src/bc.c: (id_to_index), (name_to_index), (gl_barcode_new),
+       (gl_barcode_get_styles_list), (gl_barcode_default_digits),
+       (gl_barcode_can_text), (gl_barcode_text_optional),
+       (gl_barcode_can_csum), (gl_barcode_csum_optional),
+       (gl_barcode_id_to_name), (gl_barcode_name_to_id):
+               Changed API to use a string id, rather than a fixed enumeration.  Id and
+               name are separate strings.  Added entries to backend table for specific
+               subtypes for various barcode types.
+       
+       * src/bc-postnet.h:
+       * src/bc-postnet.c: (gl_barcode_postnet_new), (postnet_code),
+       (is_length_valid):
+               Modified to conform to above API.  Now more stringent with data length
+               for various subtypes.
+       
+       * src/bc-gnubarcode.h:
+       * src/bc-gnubarcode.c: (gl_barcode_gnubarcode_new),
+       (is_length_valid), (is_length1_valid), (is_length2_valid):
+               Modified to conform to above API.  Now more stringent with data length
+               for various subtypes.
+
+       * src/label-barcode.h:
+       * src/label-barcode.c: (copy), (gl_label_barcode_set_props),
+       (gl_label_barcode_get_props), (get_size):
+               Modified to use above API for storing barcode type.
+       
+       * src/object-editor.h:
+       * src/object-editor-bc-page.c: (style_changed_cb),
+       (gl_object_editor_set_bc_style), (gl_object_editor_get_bc_style):
+               Modified to use above API for storing barcode type.
+       
+       * src/object-editor-size-page.c:
+       (gl_object_editor_prepare_size_page), (aspect_toggle_cb),
+       (w_spin_cb), (h_spin_cb), (size_reset_cb):
+               Added debug markers.
+       
+       * src/object-editor.glade:
+               Made barcode style combo's text entry  non-editable.
+       
+       * src/print.c: (draw_barcode_object):
+               Modified to use above API for barcode type.
+
+       * src/view-barcode.c: (update_object_from_editor_cb),
+       (update_editor_from_object_cb),
+       (gl_view_barcode_create_event_handler), (draw_barcode):
+               Modified to use above API for barcode type.
+       
+       * 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):
+               Modified to use above API for barcode type.
+
 2004-02-07  Jim Evins  <evins@snaught.com>
 
        * src/stock-pixmaps/Makefile.am:
index 287dfd3a2c657e1242e8ed975dd7a921059d1039..872e33170fd133f194d2d9276341297d424891bb 100644 (file)
 <!ENTITY % FONT_WEIGHT_TYPE   "(Regular | Bold)">
 
 <!-- Barcode related enumerations/types -->
-<!ENTITY % BC_STYLE_TYPE      "(POSTNET  |
-                                EAN      |
-                                UPC      |
-                                ISBN     |
-                                Code39   |
-                                Code128  |
-                                Code128C |
-                                Code128B |
-                                I25      |
-                                CBR      |
-                                MSI      |
+<!ENTITY % BC_STYLE_TYPE      "(POSTNET    |
+                                POSTNET-5  |
+                                POSTNET-9  |
+                                POSTNET-11 |
+                                EAN        |
+                                EAN-8      |
+                                EAN-8+2    |
+                                EAN-8+5    |
+                                EAN-13     |
+                                EAN-13+2   |
+                                EAN-13+5   |
+                                UPC        |
+                                UPC-A      |
+                                UPC-A+2    |
+                                UPC-A+5    |
+                                UPC-E      |
+                                UPC-E+2    |
+                                UPC-E+5    |
+                                ISBN       |
+                                ISBN+5     |
+                                Code39     |
+                                Code128    |
+                                Code128C   |
+                                Code128B   |
+                                I25        |
+                                CBR        |
+                                MSI        |
                                 PLS)"
 >
 
index 2bacb0d743b951fbc8728eb931c5cc0e036d8d64..2ea7798b5ca377e5123b9ce266d244c1b8cb6b4f 100644 (file)
 /*===========================================*/
 /* Local function prototypes                 */
 /*===========================================*/
-static glBarcode *render_pass1 (struct Barcode_Item *bci,
-                               gint                 flags);
+static glBarcode *render_pass1     (struct Barcode_Item *bci,
+                                   gint                 flags);
+
+static gboolean   is_length_valid  (const gchar         *digits,
+                                   gint                 n1,
+                                   gint                 n2);
+
+static gboolean   is_length1_valid (const gchar         *digits,
+                                   gint                 n1,
+                                   gint                 n2);
+
+static gboolean   is_length2_valid (const gchar         *digits,
+                                   gint                 n1,
+                                   gint                 n2);
 
 \f
 /*****************************************************************************/
 /* Generate intermediate representation of barcode.                          */
 /*****************************************************************************/
 glBarcode *
-gl_barcode_gnubarcode_new (glBarcodeStyle  style,
+gl_barcode_gnubarcode_new (const gchar    *id,
                           gboolean        text_flag,
                           gboolean        checksum_flag,
                           gdouble         w,
                           gdouble         h,
-                          gchar          *digits)
+                          const gchar    *digits)
 {
        glBarcode           *gbc;
        struct Barcode_Item *bci;
        gint                 flags;
 
-       bci = Barcode_Create (digits);
-
-       /* First encode using GNU Barcode library */
-       switch (style) {
-       case GL_BARCODE_STYLE_EAN:
+       /* Assign type flag.  Pre-filter by length for subtypes. */
+       if (g_strcasecmp (id, "EAN") == 0) {
+               flags = BARCODE_EAN;
+       } else if (g_strcasecmp (id, "EAN-8") == 0) {
+               if (!is_length_valid (digits, 7, 8)) {
+                       return NULL;
+               }
+               flags = BARCODE_EAN;
+       } else if (g_strcasecmp (id, "EAN-8+2") == 0) {
+               if (!is_length1_valid (digits, 7, 8) || !is_length2_valid (digits, 2, 2)) {
+                       return NULL;
+               }
+               flags = BARCODE_EAN;
+       } else if (g_strcasecmp (id, "EAN-8+5") == 0) {
+               if (!is_length1_valid (digits, 7, 8) || !is_length2_valid (digits, 5, 5)) {
+                       return NULL;
+               }
+               flags = BARCODE_EAN;
+       } else if (g_strcasecmp (id, "EAN-13") == 0) {
+               if (!is_length_valid (digits, 12, 13)) {
+                       return NULL;
+               }
+               flags = BARCODE_EAN;
+       } else if (g_strcasecmp (id, "EAN-13+2") == 0) {
+               if (!is_length1_valid (digits, 12,13) || !is_length2_valid (digits, 2,2)) {
+                       return NULL;
+               }
+               flags = BARCODE_EAN;
+       } else if (g_strcasecmp (id, "EAN-13+5") == 0) {
+               if (!is_length1_valid (digits, 12,13) || !is_length2_valid (digits, 5,5)) {
+                       return NULL;
+               }
                flags = BARCODE_EAN;
-               break;
-       case GL_BARCODE_STYLE_UPC:
+       } else if (g_strcasecmp (id, "UPC") == 0) {
                flags = BARCODE_UPC;
-               break;
-       case GL_BARCODE_STYLE_ISBN:
+       } else if (g_strcasecmp (id, "UPC-A") == 0) {
+               if (!is_length_valid (digits, 11, 12)) {
+                       return NULL;
+               }
+               flags = BARCODE_UPC;
+       } else if (g_strcasecmp (id, "UPC-A+2") == 0) {
+               if (!is_length1_valid (digits, 11,12) || !is_length2_valid (digits, 2,2)) {
+                       return NULL;
+               }
+               flags = BARCODE_UPC;
+       } else if (g_strcasecmp (id, "UPC-A+5") == 0) {
+               if (!is_length1_valid (digits, 11,12) || !is_length2_valid (digits, 5,5)) {
+                       return NULL;
+               }
+               flags = BARCODE_UPC;
+       } else if (g_strcasecmp (id, "UPC-E") == 0) {
+               if (!is_length_valid (digits, 6, 8)) {
+                       return NULL;
+               }
+               flags = BARCODE_UPC;
+       } else if (g_strcasecmp (id, "UPC-E+2") == 0) {
+               if (!is_length1_valid (digits, 6, 8) || !is_length2_valid (digits, 2,2)) {
+                       return NULL;
+               }
+               flags = BARCODE_UPC;
+       } else if (g_strcasecmp (id, "UPC-E+5") == 0) {
+               if (!is_length1_valid (digits, 6, 8) || !is_length2_valid (digits, 5,5)) {
+                       return NULL;
+               }
+               flags = BARCODE_UPC;
+       } else if (g_strcasecmp (id, "ISBN") == 0) {
+               if (!is_length_valid (digits, 9, 10)) {
+                       return NULL;
+               }
                flags = BARCODE_ISBN;
-               break;
-       case GL_BARCODE_STYLE_39:
+       } else if (g_strcasecmp (id, "ISBN+5") == 0) {
+               if (!is_length1_valid (digits, 9, 10) || !is_length2_valid (digits, 5,5)) {
+                       return NULL;
+               }
+               flags = BARCODE_ISBN;
+       } else if (g_strcasecmp (id, "Code39") == 0) {
                flags = BARCODE_39;
-               break;
-       case GL_BARCODE_STYLE_128:
+       } else if (g_strcasecmp (id, "Code128") == 0) {
                flags = BARCODE_128;
-               break;
-       case GL_BARCODE_STYLE_128C:
+       } else if (g_strcasecmp (id, "Code128C") == 0) {
                flags = BARCODE_128C;
-               break;
-       case GL_BARCODE_STYLE_128B:
+       } else if (g_strcasecmp (id, "Code128B") == 0) {
                flags = BARCODE_128B;
-               break;
-       case GL_BARCODE_STYLE_I25:
+       } else if (g_strcasecmp (id, "I25") == 0) {
                flags = BARCODE_I25;
-               break;
-       case GL_BARCODE_STYLE_CBR:
+       } else if (g_strcasecmp (id, "CBR") == 0) {
                flags = BARCODE_CBR;
-               break;
-       case GL_BARCODE_STYLE_MSI:
+       } else if (g_strcasecmp (id, "MSI") == 0) {
                flags = BARCODE_MSI;
-               break;
-       case GL_BARCODE_STYLE_PLS:
+       } else if (g_strcasecmp (id, "PLS") == 0) {
                flags = BARCODE_PLS;
-               break;
-       default:
-               g_warning( "Illegal barcode style %d", style );
+       } else {
+               g_warning( "Illegal barcode id %s", id );
                flags = BARCODE_ANY;
-               break;
        }
 
+
+       bci = Barcode_Create ((char *)digits);
+
+       /* First encode using GNU Barcode library */
        if (!text_flag) {
                flags |= BARCODE_NO_ASCII;
        }
@@ -307,3 +376,80 @@ render_pass1 (struct Barcode_Item *bci,
 
        return gbc;
 }
+
+/*--------------------------------------------------------------------------*/
+/* Validate specific length of string (for subtypes).                       */
+/*--------------------------------------------------------------------------*/
+static gboolean
+is_length_valid (const gchar *digits,
+                gint         n1,
+                gint         n2)
+{
+       gchar *p;
+       gint   i;
+
+       if (!digits) {
+               return FALSE;
+       }
+
+       for (p = (gchar *)digits, i=0; *p != 0; p++) {
+               if (g_ascii_isdigit (*p)) {
+                       i++;
+               }
+       }
+
+       return (i >= n1) && (i <= n2);
+}
+
+/*--------------------------------------------------------------------------*/
+/* Validate specific length of string (for subtypes).                       */
+/*--------------------------------------------------------------------------*/
+static gboolean
+is_length1_valid (const gchar *digits,
+                 gint         n1,
+                 gint         n2)
+{
+       gchar *p;
+       gint   i;
+
+       if (!digits) {
+               return FALSE;
+       }
+
+       for (p = (gchar *)digits, i=0; !g_ascii_isspace (*p) && *p != 0; p++) {
+               if (g_ascii_isdigit (*p)) {
+                       i++;
+               }
+       }
+
+       return (i >= n1) && (i <= n2);
+}
+
+/*--------------------------------------------------------------------------*/
+/* Validate specific length of second string (for subtypes).                */
+/*--------------------------------------------------------------------------*/
+static gboolean
+is_length2_valid (const gchar *digits,
+                 gint         n1,
+                 gint         n2)
+{
+       gchar *p;
+       gint   i;
+
+       if (!digits) {
+               return FALSE;
+       }
+
+       for (p = (gchar *)digits; !g_ascii_isspace (*p) && (*p != 0); p++) {
+               /* Skip over 1st string */
+       }
+
+       for (i=0; *p != 0; p++) {
+               if (g_ascii_isdigit (*p)) {
+                       i++;
+               }
+       }
+
+       return (i >= n1) && (i <= n2);
+}
+
index ab186eedc28b80fdeed739e6ad5e604bcbd6785a..136d097896b534a739c48745fa1bebbb7ab78bb7 100644 (file)
 
 G_BEGIN_DECLS
 
-glBarcode *gl_barcode_gnubarcode_new (glBarcodeStyle  style,
+glBarcode *gl_barcode_gnubarcode_new (const gchar    *id,
                                      gboolean        text_flag,
                                      gboolean        checksum_flag,
                                      gdouble         w,
                                      gdouble         h,
-                                     gchar          *digits);
+                                     const gchar    *digits);
 
 G_END_DECLS
 
index c333b2d19e75fd2de3f45af3a90eb041b53f6d70..b0be19daf1c8a5638d309c47029ff53dacda8256 100644 (file)
@@ -65,26 +65,51 @@ static gchar *frame_symbol = "1";
 /*===========================================*/
 /* Local function prototypes                 */
 /*===========================================*/
-static gchar *postnet_code (gchar *digits);
+static gchar    *postnet_code    (const gchar *digits);
+
+static gboolean  is_length_valid (const gchar *digits,
+                                 gint         n);
 
 \f
 /****************************************************************************/
 /* Generate list of lines that form the barcode for the given digits.       */
 /****************************************************************************/
 glBarcode *
-gl_barcode_postnet_new (glBarcodeStyle  style,
+gl_barcode_postnet_new (const gchar    *id,
                        gboolean        text_flag,
                        gboolean        checksum_flag,
                        gdouble         w,
                        gdouble         h,
-                       gchar          *digits)
+                       const gchar    *digits)
 {
        gchar         *code, *p;
        glBarcode     *gbc;
        glBarcodeLine *line;
        gdouble        x;
 
-       gbc = g_new0 (glBarcode, 1);
+       /* Validate code length for all subtypes. */
+       if ( (g_strcasecmp (id, "POSTNET") == 0) ) {
+               if (!is_length_valid (digits, 5) &&
+                   !is_length_valid (digits, 9) &&
+                   !is_length_valid (digits, 11)) {
+                       return NULL;
+               }
+       }
+       if ( (g_strcasecmp (id, "POSTNET-5") == 0) ) {
+               if (!is_length_valid (digits, 5)) {
+                       return NULL;
+               }
+       }
+       if ( (g_strcasecmp (id, "POSTNET-9") == 0) ) {
+               if (!is_length_valid (digits, 9)) {
+                       return NULL;
+               }
+       }
+       if ( (g_strcasecmp (id, "POSTNET-11") == 0) ) {
+               if (!is_length_valid (digits, 11)) {
+                       return NULL;
+               }
+       }
 
        /* First get code string */
        code = postnet_code (digits);
@@ -92,6 +117,8 @@ gl_barcode_postnet_new (glBarcodeStyle  style,
                return NULL;
        }
 
+       gbc = g_new0 (glBarcode, 1);
+
        /* Now traverse the code string and create a list of lines */
        x = POSTNET_HORIZ_MARGIN;
        for (p = code; *p != 0; p++) {
@@ -126,7 +153,7 @@ gl_barcode_postnet_new (glBarcodeStyle  style,
 /* PRIVATE.  Generate string of symbols, representing barcode.              */
 /*--------------------------------------------------------------------------*/
 static gchar *
-postnet_code (gchar *digits)
+postnet_code (const gchar *digits)
 {
        gchar   *p;
        gint     len;
@@ -138,8 +165,8 @@ postnet_code (gchar *digits)
        code = g_string_new (frame_symbol);
 
        sum = 0;
-       for (p = digits, len = 0; (*p != 0) && (len < 11); p++) {
-               if (isdigit (*p)) {
+       for (p = (gchar *)digits, len = 0; (*p != 0) && (len < 11); p++) {
+               if (g_ascii_isdigit (*p)) {
                        /* Only translate valid characters (0-9) */
                        d = (*p) - '0';
                        sum += d;
@@ -163,3 +190,27 @@ postnet_code (gchar *digits)
 
        return ret;
 }
+
+/*--------------------------------------------------------------------------*/
+/* Validate specific length of string (for subtypes).                       */
+/*--------------------------------------------------------------------------*/
+static gboolean
+is_length_valid (const gchar *digits,
+                gint         n)
+{
+       gchar *p;
+       gint   i;
+
+       if (!digits) {
+               return FALSE;
+       }
+
+       for (p = (gchar *)digits, i=0; *p != 0; p++) {
+               if (g_ascii_isdigit (*p)) {
+                       i++;
+               }
+       }
+
+       return (i == n);
+}
+
index 717f1043f8bcaf684cd12b9383bfab816a7ecc35..0753290aeb8950d50d739cd7fe0a20dc33365662 100644 (file)
 
 G_BEGIN_DECLS
 
-glBarcode *gl_barcode_postnet_new (glBarcodeStyle  style,
+glBarcode *gl_barcode_postnet_new (const gchar    *id,
                                   gboolean        text_flag,
                                   gboolean        checksum_flag,
                                   gdouble         w,
                                   gdouble         h,
-                                  gchar          *digits);
+                                  const gchar    *digits);
 
 G_END_DECLS
 
index 8c431f1ba3527357d068463368b5a709973343f4..d818a9a25e5e592c627ef6d74887183611c13d63 100644 (file)
@@ -21,6 +21,8 @@
  */
 #include <config.h>
 
+#include <libgnome/libgnome.h>
+
 #include "bc.h"
 #include "bc-postnet.h"
 #include "bc-gnubarcode.h"
@@ -36,6 +38,7 @@
 /*========================================================*/
 
 typedef struct {
+       gchar            *id;
        gchar            *name;
        glBarcodeNewFunc  new;
        gboolean          can_text;
@@ -50,44 +53,94 @@ typedef struct {
 /* Private globals.                                       */
 /*========================================================*/
 
-Backend backends[GL_BARCODE_N_STYLES] = {
+Backend backends[] = {
+
+       { "POSTNET", N_("POSTNET (any)"), gl_barcode_postnet_new,
+         FALSE, FALSE, TRUE, FALSE, "000000000"},
+
+       { "POSTNET-5", N_("POSTNET-5 (ZIP only)"), gl_barcode_postnet_new,
+         FALSE, FALSE, TRUE, FALSE, "00000"},
 
-       { "POSTNET", gl_barcode_postnet_new,
+       { "POSTNET-9", N_("POSTNET-9 (ZIP+4)"), gl_barcode_postnet_new,
          FALSE, FALSE, TRUE, FALSE, "000000000"},
 
-       { "EAN", gl_barcode_gnubarcode_new,
+       { "POSTNET-11", N_("POSTNET-11 (DPBC)"), gl_barcode_postnet_new,
+         FALSE, FALSE, TRUE, FALSE, "00000000000"},
+
+       { "EAN", N_("EAN (any)"), gl_barcode_gnubarcode_new,
          TRUE, TRUE, TRUE, FALSE, "000000000000 00000"},
 
-       { "UPC", gl_barcode_gnubarcode_new,
+       { "EAN-8", N_("EAN-8"), gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, FALSE, "0000000"},
+
+       { "EAN-8+2", N_("EAN-8 +2"), gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, FALSE, "0000000 00"},
+
+       { "EAN-8+5", N_("EAN-8 +5"), gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, FALSE, "0000000 00000"},
+
+       { "EAN-13", N_("EAN-13"), gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, FALSE, "000000000000"},
+
+       { "EAN-13+2", N_("EAN-13 +2"), gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, FALSE, "000000000000 00"},
+
+       { "EAN-13+5", N_("EAN-13 +5"), gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, FALSE, "000000000000 00000"},
+
+       { "UPC", N_("UPC (UPC-A or UPC-E)"), gl_barcode_gnubarcode_new,
          TRUE, TRUE, TRUE, FALSE, "00000000000 00000"},
 
-       { "ISBN", gl_barcode_gnubarcode_new,
+       { "UPC-A", N_("UPC-A"), gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, FALSE, "00000000000"},
+
+       { "UPC-A+2", N_("UPC-A +2"), gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, FALSE, "00000000000 00"},
+
+       { "UPC-A+5", N_("UPC-A +5"), gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, FALSE, "00000000000 00000"},
+
+       { "UPC-E", N_("UPC-E"), gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, FALSE, "000000"},
+
+       { "UPC-E+2", N_("UPC-E +2"), gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, FALSE, "000000 00"},
+
+       { "UPC-E+5", N_("UPC-E +5"), gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, FALSE, "000000 00000"},
+
+       { "ISBN", N_("ISBN"), gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, TRUE, "0-00000-000-0"},
+
+       { "ISBN+5", N_("ISBN +5"), gl_barcode_gnubarcode_new,
          TRUE, TRUE, TRUE, TRUE, "0-00000-000-0 00000"},
 
-       { "Code39", gl_barcode_gnubarcode_new,
+       { "Code39", N_("Code 39"), gl_barcode_gnubarcode_new,
          TRUE, TRUE, TRUE, TRUE, "0000000000"},
 
-       { "Code128", gl_barcode_gnubarcode_new,
+       { "Code128", N_("Code 128"), gl_barcode_gnubarcode_new,
          TRUE, TRUE, TRUE, TRUE, "0000000000"},
 
-       { "Code128C", gl_barcode_gnubarcode_new,
+       { "Code128C", N_("Code 128C"), gl_barcode_gnubarcode_new,
          TRUE, TRUE, TRUE, TRUE, "0000000000"},
 
-       { "Code128B", gl_barcode_gnubarcode_new,
+       { "Code128B", N_("Code 128B"), gl_barcode_gnubarcode_new,
          TRUE, TRUE, TRUE, TRUE, "0000000000"},
 
-       { "I25", gl_barcode_gnubarcode_new,
+       { "I25", N_("Interleaved 2 of 5"), gl_barcode_gnubarcode_new,
          TRUE, TRUE, TRUE, TRUE, "0000000000"},
 
-       { "CBR", gl_barcode_gnubarcode_new,
+       { "CBR", N_("Codabar"), gl_barcode_gnubarcode_new,
          TRUE, TRUE, TRUE, TRUE, "0000000000"},
 
-       { "MSI", gl_barcode_gnubarcode_new,
+       { "MSI", N_("MSI"), gl_barcode_gnubarcode_new,
          TRUE, TRUE, TRUE, TRUE, "0000000000"},
 
-       { "PLS", gl_barcode_gnubarcode_new,
+       { "PLS", N_("Plessey"), gl_barcode_gnubarcode_new,
          TRUE, TRUE, TRUE, TRUE, "0000000000"},
 
+       { NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, NULL}
+
 };
 
 /*========================================================*/
@@ -95,28 +148,71 @@ Backend backends[GL_BARCODE_N_STYLES] = {
 /*========================================================*/
 
 \f
+/*---------------------------------------------------------------------------*/
+/* Convert id to index into above table.                                     */
+/*---------------------------------------------------------------------------*/
+static gint
+id_to_index (const gchar *id)
+{
+       gint i;
+
+       if (id == 0) {
+               return 0; /* NULL request default. I.e., the first element. */
+       }
+
+       for (i=0; backends[i].id != NULL; i++) {
+               if (g_strcasecmp (id, backends[i].id) == 0) {
+                       return i;
+               }
+       }
+
+       g_warning( "Unknown barcode id \"%s\"", id );
+       return 0;
+}
+
+/*---------------------------------------------------------------------------*/
+/* Convert name to index into above table.                                   */
+/*---------------------------------------------------------------------------*/
+static gint
+name_to_index (const gchar *name)
+{
+       gint i;
+
+       g_return_val_if_fail (name!=NULL, 0);
+
+       for (i=0; backends[i].id != NULL; i++) {
+               if (g_strcasecmp (name, backends[i].name) == 0) {
+                       return i;
+               }
+       }
+
+       g_warning( "Unknown barcode name \"%s\"", name );
+       return 0;
+}
+
 /*****************************************************************************/
 /* Call appropriate barcode backend to create barcode in intermediate format.*/
 /*****************************************************************************/
 glBarcode *
-gl_barcode_new (glBarcodeStyle  style,
+gl_barcode_new (const gchar    *id,
                gboolean        text_flag,
                gboolean        checksum_flag,
                gdouble         w,
                gdouble         h,
-               gchar          *digits)
+               const gchar    *digits)
 {
        glBarcode *gbc;
+       gint       i;
 
-       g_return_val_if_fail ((style>=0) && (style<GL_BARCODE_N_STYLES), NULL);
        g_return_val_if_fail (digits!=NULL, NULL);
 
-       gbc = backends[style].new (style,
-                                  text_flag,
-                                  checksum_flag,
-                                  w,
-                                  h,
-                                  digits);
+       i = id_to_index (id);
+       gbc = backends[i].new (backends[i].id,
+                              text_flag,
+                              checksum_flag,
+                              w,
+                              h,
+                              digits);
 
        return gbc;
 }
@@ -156,11 +252,11 @@ gl_barcode_free (glBarcode **gbc)
 GList *
 gl_barcode_get_styles_list  (void)
 {
-       glBarcodeStyle  style;
-       GList          *list = NULL;
+       gint   i;
+       GList *list = NULL;
 
-       for (style=0; style <GL_BARCODE_N_STYLES; style++) {
-               list = g_list_append (list, g_strdup (backends[style].name));
+       for (i=0; backends[i].id != NULL; i++) {
+               list = g_list_append (list, g_strdup (backends[i].name));
        }
 
        return list;
@@ -187,77 +283,57 @@ gl_barcode_free_styles_list (GList *styles_list)
 /* Return an appropriate set of digits for the given barcode style.          */
 /*****************************************************************************/
 gchar *
-gl_barcode_default_digits (glBarcodeStyle style)
+gl_barcode_default_digits (const gchar *id)
 {
-       g_return_val_if_fail ((style>=0) && (style<GL_BARCODE_N_STYLES), "0");
-
-       return g_strdup (backends[style].default_digits);
+       return g_strdup (backends[id_to_index (id)].default_digits);
 }
 
 /*****************************************************************************/
 /* Query text capabilities.                                                  */
 /*****************************************************************************/
 gboolean
-gl_barcode_can_text (glBarcodeStyle  style)
+gl_barcode_can_text (const gchar *id)
 {
-       g_return_val_if_fail ((style>=0) && (style<GL_BARCODE_N_STYLES), FALSE);
-
-       return backends[style].can_text;
+       return backends[id_to_index (id)].can_text;
 }
 
 gboolean
-gl_barcode_text_optional (glBarcodeStyle  style)
+gl_barcode_text_optional (const gchar *id)
 {
-       g_return_val_if_fail ((style>=0) && (style<GL_BARCODE_N_STYLES), FALSE);
-
-       return backends[style].text_optional;
+       return backends[id_to_index (id)].text_optional;
 }
 
 /*****************************************************************************/
 /* Query checksum capabilities.                                              */
 /*****************************************************************************/
 gboolean
-gl_barcode_can_csum (glBarcodeStyle  style)
+gl_barcode_can_csum (const gchar *id)
 {
-       g_return_val_if_fail ((style>=0) && (style<GL_BARCODE_N_STYLES), FALSE);
-
-       return backends[style].can_checksum;
+       return backends[id_to_index (id)].can_checksum;
 }
 
 gboolean
-gl_barcode_csum_optional (glBarcodeStyle  style)
+gl_barcode_csum_optional (const gchar *id)
 {
-       g_return_val_if_fail ((style>=0) && (style<GL_BARCODE_N_STYLES), FALSE);
-
-       return backends[style].checksum_optional;
+       return backends[id_to_index (id)].checksum_optional;
 }
 
 /*****************************************************************************/
 /* Convert style to text.                                                    */
 /*****************************************************************************/
 const gchar *
-gl_barcode_style_to_text (glBarcodeStyle style)
+gl_barcode_id_to_name (const gchar *id)
 {
-       g_return_val_if_fail ((style>=0) && (style<GL_BARCODE_N_STYLES), NULL);
-
-       return backends[style].name;
+       return backends[id_to_index (id)].name;
 }
 
 /*****************************************************************************/
-/* Convert text to style.                                                    */
+/* Convert name to style.                                                    */
 /*****************************************************************************/
-glBarcodeStyle
-gl_barcode_text_to_style (const gchar *text)
+const gchar *
+gl_barcode_name_to_id (const gchar *name)
 {
+       g_return_val_if_fail (name!=NULL, backends[0].id);
 
-       glBarcodeStyle  style;
-
-       for (style=0; style <GL_BARCODE_N_STYLES; style++) {
-               if (g_strcasecmp (text, backends[style].name) == 0) {
-                       return style;
-               }
-       }
-
-       g_warning( "Unknown barcode style text \"%s\"", text );
-       return GL_BARCODE_STYLE_POSTNET;
+       return backends[name_to_index (name)].id;
 }
index 058decc22878f575c06d5ef400b364084ba5df0d..3f100424d31117e4ae70be1a632dee30041fd8d9 100644 (file)
 
 G_BEGIN_DECLS
 
-typedef enum {
-       GL_BARCODE_STYLE_POSTNET,
-       GL_BARCODE_STYLE_EAN,
-       GL_BARCODE_STYLE_UPC,
-       GL_BARCODE_STYLE_ISBN,
-       GL_BARCODE_STYLE_39,
-       GL_BARCODE_STYLE_128,
-       GL_BARCODE_STYLE_128C,
-       GL_BARCODE_STYLE_128B,
-       GL_BARCODE_STYLE_I25,
-       GL_BARCODE_STYLE_CBR,
-       GL_BARCODE_STYLE_MSI,
-       GL_BARCODE_STYLE_PLS,
-
-       GL_BARCODE_N_STYLES
-} glBarcodeStyle;
-
 typedef struct {
        gdouble x, y, length, width;
 } glBarcodeLine;
@@ -58,40 +41,40 @@ typedef struct {
        GList *chars;           /* List of glBarcodeChar */
 } glBarcode;
 
-typedef glBarcode *(*glBarcodeNewFunc) (glBarcodeStyle  style,
+typedef glBarcode *(*glBarcodeNewFunc) (const gchar    *id,
                                        gboolean        text_flag,
                                        gboolean        checksum_flag,
                                        gdouble         w,
                                        gdouble         h,
-                                       gchar          *digits);
+                                       const gchar    *digits);
 
 
 #define GL_BARCODE_FONT_FAMILY      "Sans"
 #define GL_BARCODE_FONT_WEIGHT      GNOME_FONT_BOOK
 
 
-glBarcode       *gl_barcode_new              (glBarcodeStyle  style,
+glBarcode       *gl_barcode_new              (const gchar    *id,
                                              gboolean        text_flag,
                                              gboolean        checksum_flag,
                                              gdouble         w,
                                              gdouble         h,
-                                             gchar          *digits);
+                                             const gchar    *digits);
 
 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   (glBarcodeStyle  style);
+gchar           *gl_barcode_default_digits   (const gchar    *id);
 
-gboolean         gl_barcode_can_text         (glBarcodeStyle  style);
-gboolean         gl_barcode_text_optional    (glBarcodeStyle  style);
+gboolean         gl_barcode_can_text         (const gchar    *id);
+gboolean         gl_barcode_text_optional    (const gchar    *id);
 
-gboolean         gl_barcode_can_csum         (glBarcodeStyle  style);
-gboolean         gl_barcode_csum_optional    (glBarcodeStyle  style);
+gboolean         gl_barcode_can_csum         (const gchar    *id);
+gboolean         gl_barcode_csum_optional    (const gchar    *id);
 
-const gchar     *gl_barcode_style_to_text    (glBarcodeStyle  style);
-glBarcodeStyle   gl_barcode_text_to_style    (const gchar    *text);
+const gchar     *gl_barcode_id_to_name       (const gchar    *id);
+const gchar     *gl_barcode_name_to_id       (const gchar    *name);
 
 G_END_DECLS
 
index b9c767dae51d705376338321169ae5267637e420..c2cb91e736ff2d37b2a9adb491ccd1e9007c5b44 100644 (file)
@@ -39,7 +39,7 @@
 
 struct _glLabelBarcodePrivate {
        glTextNode     *text_node;
-       glBarcodeStyle  style;
+       gchar          *id;
        guint           color;
        gboolean        text_flag;
        gboolean        checksum_flag;
@@ -165,7 +165,7 @@ copy (glLabelObject *dst_object,
        glLabelBarcode      *lbc     = (glLabelBarcode *)src_object;
        glLabelBarcode      *new_lbc = (glLabelBarcode *)dst_object;
        glTextNode          *text_node;
-       glBarcodeStyle       style;
+       gchar               *id;
        gboolean             text_flag;
        gboolean             checksum_flag;
        guint                color;
@@ -176,14 +176,15 @@ 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, &style, &text_flag, &checksum_flag);
+       gl_label_barcode_get_props (lbc, &id, &text_flag, &checksum_flag);
        color = get_line_color (src_object);
 
        gl_label_barcode_set_data (new_lbc, text_node);
-       gl_label_barcode_set_props (new_lbc,style, text_flag, checksum_flag);
+       gl_label_barcode_set_props (new_lbc, id, text_flag, checksum_flag);
        set_line_color (dst_object, color);
 
        gl_text_node_free (&text_node);
+       g_free (id);
 
        gl_debug (DEBUG_LABEL, "END");
 }
@@ -210,7 +211,7 @@ gl_label_barcode_set_data (glLabelBarcode *lbc,
 
 void
 gl_label_barcode_set_props (glLabelBarcode *lbc,
-                           glBarcodeStyle  style,
+                           gchar          *id,
                            gboolean        text_flag,
                            gboolean        checksum_flag)
 {
@@ -218,7 +219,7 @@ gl_label_barcode_set_props (glLabelBarcode *lbc,
 
        g_return_if_fail (lbc && GL_IS_LABEL_BARCODE (lbc));
 
-       lbc->private->style            = style;
+       lbc->private->id               = g_strdup (id);
        lbc->private->text_flag        = text_flag;
        lbc->private->checksum_flag    = checksum_flag;
 
@@ -241,13 +242,13 @@ gl_label_barcode_get_data (glLabelBarcode *lbc)
 
 void
 gl_label_barcode_get_props (glLabelBarcode *lbc,
-                           glBarcodeStyle *style,
+                           gchar          **id,
                            gboolean       *text_flag,
                            gboolean       *checksum_flag)
 {
        g_return_if_fail (lbc && GL_IS_LABEL_BARCODE (lbc));
 
-       *style            = lbc->private->style;
+       *id               = g_strdup (lbc->private->id);
        *text_flag        = lbc->private->text_flag;
        *checksum_flag    = lbc->private->checksum_flag;
 }
@@ -273,12 +274,12 @@ get_size (glLabelObject *object,
 
 
        if (lbc->private->text_node->field_flag) {
-               data = gl_barcode_default_digits (lbc->private->style);
+               data = gl_barcode_default_digits (lbc->private->id);
        } else {
                data = gl_text_node_expand (lbc->private->text_node, NULL);
        }
 
-       gbc = gl_barcode_new (lbc->private->style,
+       gbc = gl_barcode_new (lbc->private->id,
                              lbc->private->text_flag,
                              lbc->private->checksum_flag,
                              w_parent,
@@ -287,8 +288,8 @@ get_size (glLabelObject *object,
 
        if ( gbc == NULL ) {
                /* Try again with default digits. */
-               data = gl_barcode_default_digits (lbc->private->style);
-               gbc = gl_barcode_new (lbc->private->style,
+               data = gl_barcode_default_digits (lbc->private->id);
+               gbc = gl_barcode_new (lbc->private->id,
                                      lbc->private->text_flag,
                                      lbc->private->checksum_flag,
                                      w_parent,
index b89553458ff47e5363c8200d5064dd38d2942b5e..d2fda7170691c1bf55fe948ce0afe8a287f59a0c 100644 (file)
@@ -61,13 +61,13 @@ GObject        *gl_label_barcode_new       (glLabel        *label);
 void            gl_label_barcode_set_data  (glLabelBarcode *lbc,
                                            glTextNode     *text_node);
 void            gl_label_barcode_set_props (glLabelBarcode *lbc,
-                                           glBarcodeStyle  style,
+                                           gchar          *id,
                                            gboolean        text_flag,
                                            gboolean        checksum_flag);
 
 glTextNode     *gl_label_barcode_get_data  (glLabelBarcode *lbc);
 void            gl_label_barcode_get_props (glLabelBarcode *lbc,
-                                           glBarcodeStyle *style,
+                                           gchar         **id,
                                            gboolean       *text_flag,
                                            gboolean       *checksum_flag);
 
index a4659e9dd74cc80436e5a963e80c0cdf73f9cebb..ea31d23eff3370f7c235aaabfbd06e39ad8d7058 100644 (file)
@@ -121,24 +121,24 @@ static void
 style_changed_cb (glObjectEditor       *editor)
 {
         gchar          *style_string;
-        glBarcodeStyle  style;
+       const gchar    *id;
                                                                                 
         style_string =
                 gtk_editable_get_chars (GTK_EDITABLE(editor->priv->bc_style_entry), 0, -1);
                                                                                 
         /* Don't emit if entry is empty. */
         if ( *style_string != 0 ) {
-                style = gl_barcode_text_to_style (style_string);
+                id = gl_barcode_name_to_id (style_string);
                                                                                 
                 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(editor->priv->bc_text_check),
-                                             gl_barcode_can_text (style));
+                                             gl_barcode_can_text (id));
                 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(editor->priv->bc_cs_check),
-                                             gl_barcode_can_csum (style));
+                                             gl_barcode_can_csum (id));
                                                                                 
                 gtk_widget_set_sensitive (editor->priv->bc_text_check,
-                                          gl_barcode_text_optional (style));
+                                          gl_barcode_text_optional (id));
                 gtk_widget_set_sensitive (editor->priv->bc_cs_check,
-                                          gl_barcode_csum_optional (style));
+                                          gl_barcode_csum_optional (id));
                                                                                 
                                                                                 
                 /* Emit our "changed" signal */
@@ -153,7 +153,7 @@ style_changed_cb (glObjectEditor       *editor)
 /*****************************************************************************/
 void
 gl_object_editor_set_bc_style (glObjectEditor      *editor,
-                              glBarcodeStyle       style,
+                              gchar               *id,
                               gboolean             text_flag,
                               gboolean             checksum_flag)
 {
@@ -172,7 +172,7 @@ gl_object_editor_set_bc_style (glObjectEditor      *editor,
                                          G_CALLBACK (gl_object_editor_changed_cb),
                                          editor);
 
-        style_string = gl_barcode_style_to_text (style);
+        style_string = gl_barcode_id_to_name (id);
  
         gtk_editable_delete_text (GTK_EDITABLE (editor->priv->bc_style_entry),
                                   0, -1);
@@ -190,9 +190,9 @@ gl_object_editor_set_bc_style (glObjectEditor      *editor,
                                       checksum_flag);
 
        gtk_widget_set_sensitive (editor->priv->bc_text_check,
-                                 gl_barcode_text_optional (style));
+                                 gl_barcode_text_optional (id));
        gtk_widget_set_sensitive (editor->priv->bc_cs_check,
-                                 gl_barcode_csum_optional (style));
+                                 gl_barcode_csum_optional (id));
 
         g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->bc_style_entry),
                                           G_CALLBACK (style_changed_cb),
@@ -212,7 +212,7 @@ gl_object_editor_set_bc_style (glObjectEditor      *editor,
 /*****************************************************************************/
 void
 gl_object_editor_get_bc_style (glObjectEditor      *editor,
-                              glBarcodeStyle      *style,
+                              gchar              **id,
                               gboolean            *text_flag,
                               gboolean            *checksum_flag)
 {
@@ -223,7 +223,7 @@ gl_object_editor_get_bc_style (glObjectEditor      *editor,
         style_string =
                 gtk_editable_get_chars (GTK_EDITABLE(editor->priv->bc_style_entry),
                                         0, -1);
-        *style = gl_barcode_text_to_style (style_string);
+        *id = g_strdup (gl_barcode_name_to_id (style_string));
                                                                                 
         *text_flag =
             gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->bc_text_check));
index e31815d54af88e29961aa48ae1d272cc1e3cc449..aec58954a44a6645390a6613a09f9bb4b2b530c3 100644 (file)
@@ -120,11 +120,11 @@ gl_object_editor_prepare_size_page (glObjectEditor       *editor,
                                  G_CALLBACK (aspect_toggle_cb),
                                  G_OBJECT (editor));
        g_signal_connect_swapped (G_OBJECT (editor->priv->size_w_spin),
-                                 "changed",
+                                 "value-changed",
                                  G_CALLBACK (w_spin_cb),
                                  G_OBJECT (editor));
        g_signal_connect_swapped (G_OBJECT (editor->priv->size_h_spin),
-                                 "changed",
+                                 "value-changed",
                                  G_CALLBACK (h_spin_cb),
                                  G_OBJECT (editor));
 
@@ -147,6 +147,8 @@ aspect_toggle_cb (glObjectEditor *editor)
         glWdgtChainButton *toggle;
        gdouble            w, h;
 
+       gl_debug (DEBUG_EDITOR, "START");
+
        toggle = GL_WDGT_CHAIN_BUTTON (editor->priv->size_aspect_checkbutton);
 
         if (gl_wdgt_chain_button_get_active (toggle)) {
@@ -157,6 +159,8 @@ aspect_toggle_cb (glObjectEditor *editor)
                 editor->priv->size_aspect_ratio = h / w;
                                                                                 
         }
+
+       gl_debug (DEBUG_EDITOR, "END");
 }
 
 /*--------------------------------------------------------------------------*/
@@ -168,6 +172,8 @@ w_spin_cb (glObjectEditor *editor)
        gdouble            w, h;
         glWdgtChainButton *toggle;
 
+       gl_debug (DEBUG_EDITOR, "START");
+
        toggle = GL_WDGT_CHAIN_BUTTON (editor->priv->size_aspect_checkbutton);
 
         if (gl_wdgt_chain_button_get_active (toggle)) {
@@ -190,6 +196,7 @@ w_spin_cb (glObjectEditor *editor)
         g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0);
         g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[SIZE_CHANGED], 0);
                                                                                 
+       gl_debug (DEBUG_EDITOR, "END");
 }
 
 /*--------------------------------------------------------------------------*/
@@ -198,9 +205,12 @@ w_spin_cb (glObjectEditor *editor)
 static void
 h_spin_cb (glObjectEditor *editor)
 {
-       gdouble w, h;
+       gdouble            w, h;
+        glWdgtChainButton *toggle;
+
+       gl_debug (DEBUG_EDITOR, "START");
 
-        glWdgtChainButton *toggle = GL_WDGT_CHAIN_BUTTON (editor->priv->size_aspect_checkbutton);
+        toggle = GL_WDGT_CHAIN_BUTTON (editor->priv->size_aspect_checkbutton);
                                                                                 
         if (gl_wdgt_chain_button_get_active (toggle)) {
 
@@ -222,6 +232,7 @@ h_spin_cb (glObjectEditor *editor)
         g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0);
         g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[SIZE_CHANGED], 0);
                                                                                 
+       gl_debug (DEBUG_EDITOR, "END");
 }
 
 /*--------------------------------------------------------------------------*/
@@ -234,6 +245,8 @@ size_reset_cb (glObjectEditor *editor)
        gdouble w_max, h_max;
        gdouble aspect_ratio;
 
+       gl_debug (DEBUG_EDITOR, "START");
+
        g_signal_handlers_block_by_func (G_OBJECT (editor->priv->size_w_spin),
                                         G_CALLBACK (w_spin_cb),
                                         editor);
@@ -278,6 +291,8 @@ size_reset_cb (glObjectEditor *editor)
         /* Emit our "changed" signal */
         g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0);
         g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[SIZE_CHANGED], 0);
+
+       gl_debug (DEBUG_EDITOR, "END");
 }
 
 /*****************************************************************************/
index 44c3f1b52fe2d65f7db33f4275e004734ea4e61a..c85236c1852db6100a4c218998f8343fee394450 100644 (file)
                          <child>
                            <widget class="GtkCombo" id="bc_style_combo">
                              <property name="visible">True</property>
-                             <property name="value_in_list">False</property>
+                             <property name="value_in_list">True</property>
                              <property name="allow_empty">True</property>
                              <property name="case_sensitive">False</property>
                              <property name="enable_arrow_keys">True</property>
                                <widget class="GtkEntry" id="bc_style_entry">
                                  <property name="visible">True</property>
                                  <property name="can_focus">True</property>
-                                 <property name="editable">True</property>
+                                 <property name="editable">False</property>
                                  <property name="visibility">True</property>
                                  <property name="max_length">0</property>
                                  <property name="text" translatable="yes"></property>
index bf9273f45f4754b4148527d278bfae2075da7b2d..ff47e423dde6b07e528250315d527f85faf7daec 100644 (file)
@@ -221,12 +221,12 @@ void        gl_object_editor_set_text_buffer      (glObjectEditor      *editor,
  * Barcode Page
  */
 void        gl_object_editor_set_bc_style         (glObjectEditor      *editor,
-                                                  glBarcodeStyle       style,
+                                                  gchar               *id,
                                                   gboolean             text_flag,
                                                   gboolean             checksum_flag);
 
 void        gl_object_editor_get_bc_style         (glObjectEditor      *editor,
-                                                  glBarcodeStyle      *style,
+                                                  gchar              **id,
                                                   gboolean            *text_flag,
                                                   gboolean            *checksum_flag);
 
index 769cac6badcc456e6ab6c4ad28eea172634f62f1..19429bee96da85f6b930d50f47f9f18da8caa51c 100644 (file)
@@ -992,15 +992,15 @@ draw_barcode_object (PrintInfo      *pi,
                     glLabelBarcode *object,
                     glMergeRecord  *record)
 {
-       glBarcode *gbc;
-       glBarcodeLine *line;
-       glBarcodeChar *bchar;
-       GList *li;
-       gdouble y_offset;
-       GnomeFont *font;
-       gchar *text, *cstring;
-       glTextNode          *text_node;
-       glBarcodeStyle      style;
+       glBarcode          *gbc;
+       glBarcodeLine      *line;
+       glBarcodeChar      *bchar;
+       GList              *li;
+       gdouble             y_offset;
+       GnomeFont          *font;
+       gchar              *text, *cstring;
+       glTextNode         *text_node;
+       gchar              *id;
        gboolean            text_flag;
        gboolean            checksum_flag;
        guint               color;
@@ -1010,14 +1010,15 @@ draw_barcode_object (PrintInfo      *pi,
 
        text_node = gl_label_barcode_get_data (object);
        gl_label_barcode_get_props (object,
-                                   &style, &text_flag, &checksum_flag);
+                                   &id, &text_flag, &checksum_flag);
        color = gl_label_object_get_line_color (GL_LABEL_OBJECT(object));
        gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h);
 
        text = gl_text_node_expand (text_node, record);
-       gbc = gl_barcode_new (style, text_flag, checksum_flag, w, h, text);
+       gbc = gl_barcode_new (id, text_flag, checksum_flag, w, h, text);
        g_free (text);
        gl_text_node_free (&text_node);
+       g_free (id);
 
        if (gbc == NULL) {
 
index 6b5dc852593b2c7c5a14b713faf59afd922c31ae..22d4054975e68e996c82180243368463f1da8b1f 100644 (file)
@@ -258,7 +258,7 @@ update_object_from_editor_cb (glObjectEditor *editor,
 {
        gdouble            x, y, w, h;
        glTextNode        *text_node;
-       glBarcodeStyle     style;
+       gchar             *id;
        gboolean           text_flag, cs_flag;
        guint              color;
 
@@ -282,11 +282,12 @@ 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, &style, &text_flag, &cs_flag);
+       gl_object_editor_get_bc_style (editor, &id, &text_flag, &cs_flag);
        color = gl_object_editor_get_bc_color (editor);
        gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
-                                   style, text_flag, cs_flag);
+                                   id, text_flag, cs_flag);
        gl_label_object_set_line_color (object, color);
+       g_free (id);
 
        g_signal_handlers_unblock_by_func (G_OBJECT(object),
                                           update_editor_from_object_cb,
@@ -307,7 +308,7 @@ update_editor_from_object_cb (glLabelObject  *object,
 {
        gdouble            w, h;
        glTextNode        *text_node;
-       glBarcodeStyle     style;
+       gchar             *id;
        gboolean           text_flag, cs_flag;
        guint              color;
        glMerge           *merge;
@@ -318,10 +319,11 @@ update_editor_from_object_cb (glLabelObject  *object,
        gl_object_editor_set_size (editor, w, h);
 
        gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
-                                   &style, &text_flag, &cs_flag);
+                                   &id, &text_flag, &cs_flag);
        color = gl_label_object_get_line_color (object);
-       gl_object_editor_set_bc_style (editor, style, text_flag, cs_flag);
+       gl_object_editor_set_bc_style (editor, id, text_flag, cs_flag);
        gl_object_editor_set_bc_color (editor, color);
+       g_free (id);
 
        text_node = gl_label_barcode_get_data (GL_LABEL_BARCODE(object));
        merge = gl_label_get_merge (GL_LABEL(object->parent));
@@ -447,7 +449,7 @@ gl_view_barcode_create_event_handler (GnomeCanvas *canvas,
                        gl_label_barcode_set_data (GL_LABEL_BARCODE(object),
                                                   text_node);
                        gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
-                                                   GL_BARCODE_STYLE_POSTNET,
+                                                   "POSTNET",
                                                    FALSE,
                                                    TRUE);
                        gl_label_object_set_line_color (GL_LABEL_OBJECT(object),
@@ -476,7 +478,7 @@ gl_view_barcode_create_event_handler (GnomeCanvas *canvas,
                        gl_label_object_set_position (GL_LABEL_OBJECT(object),
                                                      x, y);
                        gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
-                                                   GL_BARCODE_STYLE_POSTNET,
+                                                   "POSTNET",
                                                    FALSE,
                                                    TRUE);
                        gl_label_object_set_line_color (GL_LABEL_OBJECT(object),
@@ -518,7 +520,7 @@ draw_barcode (glViewBarcode *view_barcode)
        glLabelObject    *object;
        GnomeCanvasItem  *item;
        glTextNode *text_node;
-       glBarcodeStyle style;
+       gchar *id;
        gboolean text_flag;
        gboolean checksum_flag;
        guint color;
@@ -539,12 +541,12 @@ draw_barcode (glViewBarcode *view_barcode)
        /* 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),
-                                   &style, &text_flag, &checksum_flag);
+                                   &id, &text_flag, &checksum_flag);
        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 (style);
+               digits = gl_barcode_default_digits (id);
        } else {
                digits = gl_text_node_expand (text_node, NULL);
        }
@@ -565,7 +567,7 @@ draw_barcode (glViewBarcode *view_barcode)
                                                          FALSE,
                                                          10.0);
 
-       gbc = gl_barcode_new (style, text_flag, checksum_flag, w, h, digits);
+       gbc = gl_barcode_new (id, text_flag, checksum_flag, w, h, digits);
        if (gbc == NULL) {
 
                cstring = _("Invalid barcode data");
@@ -641,6 +643,7 @@ draw_barcode (glViewBarcode *view_barcode)
        /* clean up */
        gl_barcode_free (&gbc);
        g_free (digits);
+       g_free (id);
 
        gl_debug (DEBUG_VIEW, "END");
 }
index 26f9835b9baf1e5bb23d8c36d69e934ec78168a4..152457dc6375a6c2a536047ff10c548d8d602a8a 100644 (file)
@@ -412,7 +412,7 @@ static void
 xml04_parse_barcode_props (xmlNodePtr    node,
                           glLabelBarcode *object)
 {
-       glBarcodeStyle style;
+       gchar         *id;
        gboolean       text_flag;
        guint          color;
        gdouble        scale;
@@ -424,16 +424,14 @@ xml04_parse_barcode_props (xmlNodePtr    node,
 
        color = gl_xml_get_prop_uint (node, "color", 0);
 
-       string = xmlGetProp (node, "style");
-       style = gl_barcode_text_to_style (string);
-       g_free (string);
+       id = xmlGetProp (node, "style");
 
        text_flag = gl_xml_get_prop_boolean (node, "text", FALSE);
        scale = gl_xml_get_prop_double (node, "scale", 1.0);
        if (scale == 0.0) {
                scale = 0.5; /* Set to a valid value */
        }
-       gl_label_barcode_set_props (object, style, text_flag, TRUE);
+       gl_label_barcode_set_props (object, id, text_flag, TRUE);
        gl_label_object_set_line_color (GL_LABEL_OBJECT(object), color);
 
        child = node->xmlChildrenNode;
@@ -450,6 +448,7 @@ xml04_parse_barcode_props (xmlNodePtr    node,
        gl_label_barcode_set_data (object, text_node);
 
        gl_text_node_free (&text_node);
+       g_free (id);
 
        gl_debug (DEBUG_XML, "END");
 }
index 731c866f1c763040a5c94b6074b39205780be9a9..87d0c50b29b45cdc306b95fb47a8aba42b115515 100644 (file)
@@ -510,7 +510,7 @@ xml191_parse_barcode_props (xmlNodePtr  node,
        gdouble             w, h;
        gchar              *string;
        glTextNode         *text_node;
-       glBarcodeStyle      style;
+       gchar              *id;
        gboolean            text_flag;
        gboolean            checksum_flag;
        guint               color;
@@ -524,9 +524,7 @@ xml191_parse_barcode_props (xmlNodePtr  node,
 
        color = gl_xml_get_prop_uint (node, "color", 0);
 
-       string = xmlGetProp (node, "style");
-       style = gl_barcode_text_to_style (string);
-       g_free (string);
+       id = xmlGetProp (node, "style");
 
        text_flag = gl_xml_get_prop_boolean (node, "text", FALSE);
        checksum_flag = gl_xml_get_prop_boolean (node, "checksum", TRUE);
@@ -548,10 +546,11 @@ 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),
-                                   style, text_flag, checksum_flag);
+                                   id, text_flag, checksum_flag);
        gl_label_object_set_line_color (GL_LABEL_OBJECT(object), color);
 
        gl_text_node_free (&text_node);
+       g_free (id);
 
        gl_debug (DEBUG_XML, "END");
 
index 452678837bda7b4136f9742c887337b845fc6475..c08394ae6a54dab32e2ddfb611a04ec45d60f8ea 100644 (file)
@@ -676,7 +676,7 @@ xml_parse_object_barcode (xmlNodePtr  node,
        gdouble             w, h;
        gchar              *string;
        glTextNode         *text_node;
-       glBarcodeStyle      style;
+       gchar              *id;
        gboolean            text_flag;
        gboolean            checksum_flag;
        guint               color;
@@ -697,15 +697,14 @@ xml_parse_object_barcode (xmlNodePtr  node,
        gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h);
 
        /* prop attrs */
-       string = xmlGetProp (node, "style");
-       style = gl_barcode_text_to_style (string);
-       g_free (string);
+       id = xmlGetProp (node, "style");
        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);
        gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
-                                   style, text_flag, checksum_flag);
+                                   id, text_flag, checksum_flag);
        gl_label_object_set_line_color (GL_LABEL_OBJECT(object), color);
+       g_free (id);
 
        /* data or field attr */
        string = xmlGetProp (node, "data");
@@ -1343,7 +1342,7 @@ xml_create_object_barcode (xmlNodePtr     root,
        gdouble           x, y;
        gdouble           w, h;
        glTextNode       *text_node;
-       glBarcodeStyle    style;
+       gchar            *id;
        gboolean          text_flag;
        gboolean          checksum_flag;
        guint             color;
@@ -1365,12 +1364,13 @@ xml_create_object_barcode (xmlNodePtr     root,
 
        /* Barcode properties attrs */
        gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
-                                   &style, &text_flag, &checksum_flag);
+                                   &id, &text_flag, &checksum_flag);
        color = gl_label_object_get_line_color (GL_LABEL_OBJECT(object));
-       xmlSetProp (node, "style", gl_barcode_style_to_text (style));
+       xmlSetProp (node, "style", id);
        gl_xml_set_prop_boolean (node, "text", text_flag);
        gl_xml_set_prop_boolean (node, "checksum", checksum_flag);
        gl_xml_set_prop_uint_hex (node, "color", color);
+       g_free (id);
 
        /* data OR field attr */
        text_node = gl_label_barcode_get_data (GL_LABEL_BARCODE(object));