]> git.sur5r.net Git - glabels/commitdiff
Allow user selection of barcode backend.
authorJim Evins <evins@snaught.com>
Mon, 30 Aug 2010 01:56:45 +0000 (21:56 -0400)
committerJim Evins <evins@snaught.com>
Mon, 30 Aug 2010 01:56:45 +0000 (21:56 -0400)
- User can now select which backend to use for a particular barcode.
- This prevents one implementation from eclipsing another.
- For backwards compatability, do best guess at backend.

data/ui/object-editor.ui
src/bc-backends.c
src/bc-backends.h
src/label-barcode.c
src/label-barcode.h
src/object-editor-bc-page.c
src/object-editor-private.h
src/object-editor.c
src/xml-label-04.c
src/xml-label.c
templates/glabels-2.3.dtd

index 9f6adb35c26b09f1bd23576527909c7038b6168c..59a2fc40bbf344722e8df464f4de94b5f90255a8 100644 (file)
                     <property name="orientation">vertical</property>
                     <property name="spacing">12</property>
                     <child>
-                      <object class="GtkHBox" id="hbox79">
+                      <object class="GtkTable" id="table1">
                         <property name="visible">True</property>
-                        <property name="spacing">12</property>
+                        <property name="n_rows">2</property>
+                        <property name="n_columns">2</property>
+                        <property name="column_spacing">6</property>
+                        <property name="row_spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="bc_be_label">
+                            <property name="visible">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Backend engine:</property>
+                          </object>
+                          <packing>
+                            <property name="x_options">GTK_FILL</property>
+                            <property name="y_options"></property>
+                          </packing>
+                        </child>
                         <child>
                           <object class="GtkLabel" id="bc_style_label">
                             <property name="visible">True</property>
                             <property name="label" translatable="yes">Style:</property>
                           </object>
                           <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
+                            <property name="x_options">GTK_FILL</property>
+                            <property name="y_options"></property>
                           </packing>
                         </child>
                         <child>
                           <object class="GtkComboBox" id="bc_style_combo">
                             <property name="visible">True</property>
+                            <property name="button_sensitivity">on</property>
                           </object>
                           <packing>
-                            <property name="position">1</property>
+                            <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="y_options"></property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkComboBox" id="bc_backend_combo">
+                            <property name="visible">True</property>
+                            <property name="button_sensitivity">on</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                            <property name="y_options"></property>
                           </packing>
                         </child>
                       </object>
                                     <property name="receives_default">False</property>
                                     <property name="use_underline">True</property>
                                     <property name="focus_on_click">False</property>
+                                    <property name="active">True</property>
                                     <property name="draw_indicator">True</property>
                                   </object>
                                   <packing>
   <object class="GtkSizeGroup" id="page_sizegroup">
     <property name="mode">both</property>
     <widgets>
-      <widget name="edit_page_vbox"/>
-      <widget name="text_page_vbox"/>
-      <widget name="line_page_vbox"/>
-      <widget name="fill_page_vbox"/>
-      <widget name="img_page_vbox"/>
-      <widget name="data_page_vbox"/>
-      <widget name="bc_page_vbox"/>
-      <widget name="size_page_vbox"/>
-      <widget name="lsize_page_vbox"/>
       <widget name="shadow_page_vbox"/>
+      <widget name="lsize_page_vbox"/>
+      <widget name="size_page_vbox"/>
+      <widget name="bc_page_vbox"/>
+      <widget name="data_page_vbox"/>
+      <widget name="img_page_vbox"/>
+      <widget name="fill_page_vbox"/>
+      <widget name="line_page_vbox"/>
+      <widget name="text_page_vbox"/>
+      <widget name="edit_page_vbox"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup" id="width_sizegroup">
     <widgets>
-      <widget name="title_hbox"/>
       <widget name="notebook"/>
+      <widget name="title_hbox"/>
     </widgets>
   </object>
 </interface>
index 89c202a27f33bcf3d6e045eefe9ff224b4be55ac..3d966034d8f2f99720788f858ff405a3bc8d9ff1 100644 (file)
@@ -54,6 +54,13 @@ typedef glBarcode *(*glBarcodeNewFunc) (const gchar    *id,
 typedef struct {
         gchar            *id;
         gchar            *name;
+} Backend;
+
+
+typedef struct {
+        gchar            *backend_id;
+        gchar            *id;
+        gchar            *name;
         glBarcodeNewFunc  new_barcode;
         gboolean          can_text;
         gboolean          text_optional;
@@ -62,7 +69,7 @@ typedef struct {
         gchar            *default_digits;
         gboolean          can_freeform;
         guint             prefered_n;
-} Backend;
+} Style;
 
 
 /*========================================================*/
@@ -71,320 +78,340 @@ typedef struct {
 
 static const Backend backends[] = {
 
-        { "POSTNET", N_("POSTNET (any)"), gl_barcode_postnet_new,
+        { "built-in",    N_("Built-in") },
+#ifdef HAVE_LIBBARCODE
+        { "gnu-barcode", "GNU Barcode" },
+#endif
+#ifdef HAVE_LIBZINT
+        { "zint",        "Zint" },
+#endif
+#ifdef HAVE_LIBIEC16022
+        { "libiec16022", "IEC16022" },
+#endif
+#ifdef HAVE_LIBQRENCODE
+        { "libqrencode", "QREncode" },
+#endif
+
+        { NULL, NULL }
+};
+
+
+static const Style styles[] = {
+
+        { "built-in", "POSTNET", N_("POSTNET (any)"), gl_barcode_postnet_new,
           FALSE, FALSE, TRUE, FALSE, "12345-6789-12", FALSE, 11},
 
-        { "POSTNET-5", N_("POSTNET-5 (ZIP only)"), gl_barcode_postnet_new,
+        { "built-in", "POSTNET-5", N_("POSTNET-5 (ZIP only)"), gl_barcode_postnet_new,
           FALSE, FALSE, TRUE, FALSE, "12345", FALSE, 5},
 
-        { "POSTNET-9", N_("POSTNET-9 (ZIP+4)"), gl_barcode_postnet_new,
+        { "built-in", "POSTNET-9", N_("POSTNET-9 (ZIP+4)"), gl_barcode_postnet_new,
           FALSE, FALSE, TRUE, FALSE, "12345-6789", FALSE, 9},
 
-        { "POSTNET-11", N_("POSTNET-11 (DPBC)"), gl_barcode_postnet_new,
+        { "built-in", "POSTNET-11", N_("POSTNET-11 (DPBC)"), gl_barcode_postnet_new,
           FALSE, FALSE, TRUE, FALSE, "12345-6789-12", FALSE, 11},
 
-        { "CEPNET", N_("CEPNET"), gl_barcode_postnet_new,
+        { "built-in", "CEPNET", N_("CEPNET"), gl_barcode_postnet_new,
           FALSE, FALSE, TRUE, FALSE, "12345-678", FALSE, 8},
 
 #ifdef HAVE_LIBBARCODE
 
-        { "EAN", N_("EAN (any)"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "EAN", N_("EAN (any)"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "000000000000 00000", FALSE, 17},
 
-        { "EAN-8", N_("EAN-8"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "EAN-8", N_("EAN-8"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "0000000", FALSE, 7},
 
-        { "EAN-8+2", N_("EAN-8 +2"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "EAN-8+2", N_("EAN-8 +2"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "0000000 00", FALSE, 9},
 
-        { "EAN-8+5", N_("EAN-8 +5"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "EAN-8+5", N_("EAN-8 +5"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "0000000 00000", FALSE, 12},
 
-        { "EAN-13", N_("EAN-13"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "EAN-13", N_("EAN-13"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "000000000000", FALSE, 12},
 
-        { "EAN-13+2", N_("EAN-13 +2"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "EAN-13+2", N_("EAN-13 +2"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "000000000000 00", FALSE, 14},
 
-        { "EAN-13+5", N_("EAN-13 +5"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "EAN-13+5", N_("EAN-13 +5"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "000000000000 00000", FALSE, 17},
 
-        { "UPC", N_("UPC (UPC-A or UPC-E)"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "UPC", N_("UPC (UPC-A or UPC-E)"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "00000000000 00000", FALSE, 16},
 
-        { "UPC-A", N_("UPC-A"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "UPC-A", N_("UPC-A"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "00000000000", FALSE, 11},
 
-        { "UPC-A+2", N_("UPC-A +2"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "UPC-A+2", N_("UPC-A +2"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "00000000000 00", FALSE, 13},
 
-        { "UPC-A+5", N_("UPC-A +5"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "UPC-A+5", N_("UPC-A +5"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "00000000000 00000", FALSE, 16},
 
-        { "UPC-E", N_("UPC-E"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "UPC-E", N_("UPC-E"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "000000", FALSE, 6},
 
-        { "UPC-E+2", N_("UPC-E +2"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "UPC-E+2", N_("UPC-E +2"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "000000 00", FALSE, 8},
 
-        { "UPC-E+5", N_("UPC-E +5"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "UPC-E+5", N_("UPC-E +5"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "000000 00000", FALSE, 11},
 
-        { "ISBN", N_("ISBN"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "ISBN", N_("ISBN"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, TRUE, "0-00000-000-0", FALSE, 10},
 
-        { "ISBN+5", N_("ISBN +5"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "ISBN+5", N_("ISBN +5"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, TRUE, "0-00000-000-0 00000", FALSE, 15},
 
-        { "Code39", N_("Code 39"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "Code39", N_("Code 39"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10},
 
-        { "Code128", N_("Code 128"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "Code128", N_("Code 128"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10},
 
-        { "Code128C", N_("Code 128C"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "Code128C", N_("Code 128C"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "Code128B", N_("Code 128B"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "Code128B", N_("Code 128B"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10},
 
-        { "I25", N_("Interleaved 2 of 5"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "I25", N_("Interleaved 2 of 5"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10},
 
-        { "CBR", N_("Codabar"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "CBR", N_("Codabar"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10},
 
-        { "MSI", N_("MSI"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "MSI", N_("MSI"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10},
 
-        { "PLS", N_("Plessey"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "PLS", N_("Plessey"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, TRUE, "0000000000", TRUE, 10},
 
-        { "Code93", N_("Code 93"), gl_barcode_gnubarcode_new,
+        { "gnu-barcode", "Code93", N_("Code 93"), gl_barcode_gnubarcode_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
 #endif /* HAVE_LIBBARCODE */
 
 #ifdef HAVE_LIBZINT
 
-        { "AUSP", N_("Australia Post Standard"), gl_barcode_zint_new,
+        { "zint", "AUSP", N_("Australia Post Standard"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "12345678901234567890123", TRUE, 23},
 
-        { "AUSRP", N_("Australia Post Reply Paid"), gl_barcode_zint_new,
+        { "zint", "AUSRP", N_("Australia Post Reply Paid"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "12345678", TRUE, 8},
 
-        { "AUSRT", N_("Australia Post Route Code"), gl_barcode_zint_new,
+        { "zint", "AUSRT", N_("Australia Post Route Code"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "12345678", TRUE, 8},
 
-        { "AUSRD", N_("Australia Post Redirect"), gl_barcode_zint_new,
+        { "zint", "AUSRD", N_("Australia Post Redirect"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "12345678", TRUE, 8},
 
-        { "AZTEC", N_("Aztec Code"), gl_barcode_zint_new,
+        { "zint", "AZTEC", N_("Aztec Code"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "1234567890", TRUE, 10},
           
-        { "AZRUN", N_("Aztec Rune"), gl_barcode_zint_new,
+        { "zint", "AZRUN", N_("Aztec Rune"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "255", TRUE, 3},
 
-        { "CBR", N_("Codabar"), gl_barcode_zint_new,
+        { "zint", "CBR", N_("Codabar"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "ABCDABCDAB", TRUE, 10},
 
-        { "Code1", N_("Code One"),  gl_barcode_zint_new,
+        { "zint", "Code1", N_("Code One"),  gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "Code11", N_("Code 11"), gl_barcode_zint_new,
+        { "zint", "Code11", N_("Code 11"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
           
-        { "C16K", N_("Code 16K"), gl_barcode_zint_new,
+        { "zint", "C16K", N_("Code 16K"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
           
-        { "C25M", N_("Code 2 of 5 Matrix"),  gl_barcode_zint_new,
+        { "zint", "C25M", N_("Code 2 of 5 Matrix"),  gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
           
-        { "C25I", N_("Code 2 of 5 IATA"),  gl_barcode_zint_new,
+        { "zint", "C25I", N_("Code 2 of 5 IATA"),  gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
           
-        { "C25DL", N_("Code 2 of 5 Data Logic"),  gl_barcode_zint_new,
+        { "zint", "C25DL", N_("Code 2 of 5 Data Logic"),  gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "Code32", N_("Code 32 (Italian Pharmacode)"),  gl_barcode_zint_new,
+        { "zint", "Code32", N_("Code 32 (Italian Pharmacode)"),  gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "12345678", TRUE, 8},
 
-        { "Code39", N_("Code 39"), gl_barcode_zint_new,
+        { "zint", "Code39", N_("Code 39"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
           
-        { "Code39E", N_("Code 39 Extended"),  gl_barcode_zint_new,
+        { "zint", "Code39E", N_("Code 39 Extended"),  gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "Code49", N_("Code 49"), gl_barcode_zint_new,
+        { "zint", "Code49", N_("Code 49"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "Code93", N_("Code 93"), gl_barcode_zint_new,
+        { "zint", "Code93", N_("Code 93"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "Code128", N_("Code 128"), gl_barcode_zint_new,
+        { "zint", "Code128", N_("Code 128"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
           
-        { "Code128B", N_("Code 128 (Mode C supression)"), gl_barcode_zint_new,
+        { "zint", "Code128B", N_("Code 128 (Mode C supression)"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
           
-        { "DAFT", N_("DAFT Code"), gl_barcode_zint_new,
+        { "zint", "DAFT", N_("DAFT Code"), gl_barcode_zint_new,
           FALSE, FALSE, FALSE, FALSE, "DAFTDAFTDAFTDAFT", TRUE, 16},
 
-        { "DMTX", N_("Data Matrix"), gl_barcode_zint_new,
+        { "zint", "DMTX", N_("Data Matrix"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "DPL", N_("Deutsche Post Leitcode"), gl_barcode_zint_new,
+        { "zint", "DPL", N_("Deutsche Post Leitcode"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "1234567890123", TRUE, 13},
           
-        { "DPI", N_("Deutsche Post Identcode"), gl_barcode_zint_new,
+        { "zint", "DPI", N_("Deutsche Post Identcode"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "12345678901", TRUE, 11},
           
-        { "KIX", N_("Dutch Post KIX Code"), gl_barcode_zint_new,
+        { "zint", "KIX", N_("Dutch Post KIX Code"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "EAN", N_("EAN"), gl_barcode_zint_new,
+        { "zint", "EAN", N_("EAN"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "1234567890123", FALSE, 13},
 
-        { "GMTX", N_("Grid Matrix"),  gl_barcode_zint_new,
+        { "zint", "GMTX", N_("Grid Matrix"),  gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "GS1-128", N_("GS1-128"), gl_barcode_zint_new,
+        { "zint", "GS1-128", N_("GS1-128"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "[01]12345678901234", FALSE, 18},
 
-        { "RSS14", N_("GS1 DataBar-14"), gl_barcode_zint_new,
+        { "zint", "RSS14", N_("GS1 DataBar-14"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "1234567890123", TRUE, 13},
           
-        { "RSSLTD", "GS1 DataBar-14 Limited",  gl_barcode_zint_new,
+        { "zint", "RSSLTD", "GS1 DataBar-14 Limited",  gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "1234567890123", TRUE, 13},
           
-        { "RSSEXP", "GS1 DataBar Extended",  gl_barcode_zint_new,
+        { "zint", "RSSEXP", "GS1 DataBar Extended",  gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "[01]12345678901234", FALSE, 18},
           
-        { "RSSS", N_("GS1 DataBar-14 Stacked"), gl_barcode_zint_new,
+        { "zint", "RSSS", N_("GS1 DataBar-14 Stacked"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "RSSSO", N_("GS1 DataBar-14 Stacked Omni."), gl_barcode_zint_new,
+        { "zint", "RSSSO", N_("GS1 DataBar-14 Stacked Omni."), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "RSSSE", N_("GS1 DataBar Extended Stacked"), gl_barcode_zint_new,
+        { "zint", "RSSSE", N_("GS1 DataBar Extended Stacked"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "[01]12345678901234", FALSE, 18},
 
-        { "HIBC128", N_("HIBC Code 128"), gl_barcode_zint_new,
+        { "zint", "HIBC128", N_("HIBC Code 128"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "HIBC39", N_("HIBC Code 39"), gl_barcode_zint_new,
+        { "zint", "HIBC39", N_("HIBC Code 39"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "HIBCDM", N_("HIBC Data Matrix"), gl_barcode_zint_new,
+        { "zint", "HIBCDM", N_("HIBC Data Matrix"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "HIBCQR", N_("HIBC QR Code"), gl_barcode_zint_new,
+        { "zint", "HIBCQR", N_("HIBC QR Code"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "HIBCPDF", N_("HIBC PDF417"), gl_barcode_zint_new,
+        { "zint", "HIBCPDF", N_("HIBC PDF417"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "HIBCMPDF", N_("HIBC Micro PDF417"), gl_barcode_zint_new,
+        { "zint", "HIBCMPDF", N_("HIBC Micro PDF417"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "HIBCAZ", N_("HIBC Aztec Code"), gl_barcode_zint_new,
+        { "zint", "HIBCAZ", N_("HIBC Aztec Code"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "I25", N_("Interleaved 2 of 5"), gl_barcode_zint_new,
+        { "zint", "I25", N_("Interleaved 2 of 5"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "ISBN", N_("ISBN"), gl_barcode_zint_new,
+        { "zint", "ISBN", N_("ISBN"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "123456789", FALSE, 9},
 
-        { "ITF14", N_("ITF-14"), gl_barcode_zint_new,
+        { "zint", "ITF14", N_("ITF-14"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "JAPAN", N_("Japanese Postal"), gl_barcode_zint_new,
+        { "zint", "JAPAN", N_("Japanese Postal"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "KOREA", N_("Korean Postal"), gl_barcode_zint_new,
+        { "zint", "KOREA", N_("Korean Postal"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "123456", FALSE, 6},
 
-        { "LOGM", N_("LOGMARS"), gl_barcode_zint_new,
+        { "zint", "LOGM", N_("LOGMARS"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "MAXI", N_("Maxicode"), gl_barcode_zint_new,
+        { "zint", "MAXI", N_("Maxicode"), gl_barcode_zint_new,
           FALSE, FALSE, FALSE, FALSE, "0000000000", TRUE, 10},
 
-        { "MPDF", N_("Micro PDF417"), gl_barcode_zint_new,
+        { "zint", "MPDF", N_("Micro PDF417"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "MQR", N_("Micro QR Code"), gl_barcode_zint_new,
+        { "zint", "MQR", N_("Micro QR Code"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "MSI", N_("MSI Plessey"), gl_barcode_zint_new,
+        { "zint", "MSI", N_("MSI Plessey"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "NVE", N_("NVE-18"), gl_barcode_zint_new,
+        { "zint", "NVE", N_("NVE-18"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "12345678901234567", FALSE, 17},
 
-        { "PDF", N_("PDF417"), gl_barcode_zint_new,
+        { "zint", "PDF", N_("PDF417"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "PDFT", N_("PDF417 Truncated"), gl_barcode_zint_new,
+        { "zint", "PDFT", N_("PDF417 Truncated"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "PLAN", N_("PLANET"), gl_barcode_zint_new,
+        { "zint", "PLAN", N_("PLANET"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "POSTNET", N_("PostNet"), gl_barcode_zint_new,
+        { "zint", "POSTNET", N_("PostNet"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "PHARMA", N_("Pharmacode"), gl_barcode_zint_new,
+        { "zint", "PHARMA", N_("Pharmacode"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "123456", FALSE, 6},
 
-        { "PHARMA2", N_("Pharmacode 2-track"), gl_barcode_zint_new,
+        { "zint", "PHARMA2", N_("Pharmacode 2-track"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "12345678", FALSE, 8},
 
-        { "PZN", N_("Pharmazentral Nummer (PZN)"), gl_barcode_zint_new,
+        { "zint", "PZN", N_("Pharmazentral Nummer (PZN)"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "123456", FALSE, 6},
 
-        { "QR", N_("QR Code"), gl_barcode_zint_new,
+        { "zint", "QR", N_("QR Code"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "RM4", N_("Royal Mail 4-State"), gl_barcode_zint_new,
+        { "zint", "RM4", N_("Royal Mail 4-State"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "TELE", N_("Telepen"), gl_barcode_zint_new,
+        { "zint", "TELE", N_("Telepen"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "TELEX", N_("Telepen Numeric"), gl_barcode_zint_new,
+        { "zint", "TELEX", N_("Telepen Numeric"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
-        { "UPC-A", N_("UPC-A"),  gl_barcode_zint_new,
+        { "zint", "UPC-A", N_("UPC-A"),  gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "12345678901", FALSE, 11},
           
-        { "UPC-E", N_("UPC-E"),  gl_barcode_zint_new,
+        { "zint", "UPC-E", N_("UPC-E"),  gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "1234567", FALSE, 7},
           
-        { "USPS", N_("USPS One Code"), gl_barcode_zint_new,
+        { "zint", "USPS", N_("USPS One Code"), gl_barcode_zint_new,
           FALSE, FALSE, TRUE, FALSE, "12345678901234567890", TRUE, 20},
 
-        { "PLS", N_("UK Plessey"), gl_barcode_zint_new,
+        { "zint", "PLS", N_("UK Plessey"), gl_barcode_zint_new,
           TRUE, TRUE, TRUE, FALSE, "0000000000", TRUE, 10},
 
 #endif /* HAVE_LIBZINT */
 
 #ifdef HAVE_LIBIEC16022
 
-        { "IEC16022", N_("IEC16022 (DataMatrix)"), gl_barcode_iec16022_new,
+        { "libiec16022", "IEC16022", N_("IEC16022 (DataMatrix)"), gl_barcode_iec16022_new,
           FALSE, FALSE, TRUE, FALSE, "12345678", TRUE, 8},
 
 #endif /* HAVE_LIBIEC16022 */
 
 #ifdef HAVE_LIBQRENCODE
 
-        { "IEC18004", N_("IEC18004 (QRCode)"), gl_barcode_iec18004_new,
+        { "libqrencode", "IEC18004", N_("IEC18004 (QRCode)"), gl_barcode_iec18004_new,
           FALSE, FALSE, TRUE, FALSE, "12345678", TRUE, 8},
 
 #endif /* HAVE_LIBQRENCODE */
 
-        { NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, NULL, FALSE, 0}
+        { NULL, NULL, NULL, NULL, FALSE, FALSE, FALSE, FALSE, NULL, FALSE, 0}
 
 };
 
@@ -393,23 +420,30 @@ static const Backend backends[] = {
 /* Private function prototypes.                           */
 /*========================================================*/
 
-static gint id_to_index   (const gchar *id);
-static gint name_to_index (const gchar *name);
+static gint backend_id_to_index   (const gchar *id);
+static gint backend_name_to_index (const gchar *name);
+static gint style_id_to_index     (const gchar *backend_id,
+                                   const gchar *id);
+static gint style_name_to_index   (const gchar *backend_id,
+                                   const gchar *name);
 
 /*---------------------------------------------------------------------------*/
-/* Convert id to index into above table.                                     */
+/* Convert backend id to index into backends table.                          */
 /*---------------------------------------------------------------------------*/
 static gint
-id_to_index (const gchar *id)
+backend_id_to_index (const gchar *id)
 {
         gint i;
 
-        if (id == 0) {
+        if (id == NULL)
+        {
                 return 0; /* NULL request default. I.e., the first element. */
         }
 
-        for (i=0; backends[i].id != NULL; i++) {
-                if (g_ascii_strcasecmp (id, backends[i].id) == 0) {
+        for (i=0; styles[i].id != NULL; i++)
+        {
+                if (g_ascii_strcasecmp (id, backends[i].id) == 0)
+                {
                         return i;
                 }
         }
@@ -420,17 +454,106 @@ id_to_index (const gchar *id)
 
 
 /*---------------------------------------------------------------------------*/
-/* Convert name to index into above table.                                   */
+/* Convert backend name to index into backends table.                        */
 /*---------------------------------------------------------------------------*/
 static gint
-name_to_index (const gchar *name)
+backend_name_to_index (const gchar *name)
 {
         gint i;
 
-        g_return_val_if_fail (name!=NULL, 0);
+        if (name == NULL)
+        {
+                return 0; /* NULL request default. I.e., the first element. */
+        }
 
-        for (i=0; backends[i].id != NULL; i++) {
-                if (strcmp (name, gettext (backends[i].name)) == 0) {
+        for (i=0; styles[i].id != NULL; i++)
+        {
+                if (strcmp (name, gettext (backends[i].name)) == 0)
+                {
+                        return i;
+                }
+        }
+
+        g_message( "Unknown barcode name \"%s\"", name );
+        return 0;
+}
+
+
+/*---------------------------------------------------------------------------*/
+/* Convert style id to index into styles table.                              */
+/*---------------------------------------------------------------------------*/
+static gint
+style_id_to_index (const gchar *backend_id,
+                   const gchar *id)
+{
+        gint i;
+
+        if (backend_id == NULL)
+        {
+                return 0; /* NULL request default. I.e., the first element. */
+        }
+
+        if (id == NULL)
+        {
+                /* Search for first element with given backend_id. */
+                for (i=0; styles[i].id != NULL; i++)
+                {
+                        if (g_ascii_strcasecmp (backend_id, styles[i].backend_id) == 0)
+                        {
+                                return i;
+                        }
+                }
+                g_message( "Unknown barcode backend id \"%s\"", backend_id );
+                return 0;
+        }
+
+        for (i=0; styles[i].id != NULL; i++)
+        {
+                if ((g_ascii_strcasecmp (backend_id, styles[i].backend_id) == 0) &&
+                    (g_ascii_strcasecmp (id, styles[i].id) == 0))
+                {
+                        return i;
+                }
+        }
+
+        g_message( "Unknown barcode id \"%s\"", id );
+        return 0;
+}
+
+
+/*---------------------------------------------------------------------------*/
+/* Convert style name to index into styles table.                            */
+/*---------------------------------------------------------------------------*/
+static gint
+style_name_to_index (const gchar *backend_id,
+                     const gchar *name)
+{
+        gint i;
+
+        if (backend_id == NULL)
+        {
+                return 0; /* NULL request default. I.e., the first element. */
+        }
+
+        if (name == NULL)
+        {
+                /* Search for first element with given backend_id. */
+                for (i=0; styles[i].id != NULL; i++)
+                {
+                        if (g_ascii_strcasecmp (backend_id, styles[i].backend_id) == 0)
+                        {
+                                return i;
+                        }
+                }
+                g_message( "Unknown barcode backend id \"%s\"", backend_id );
+                return 0;
+        }
+
+        for (i=0; styles[i].id != NULL; i++)
+        {
+                if ((g_ascii_strcasecmp (backend_id, styles[i].backend_id) == 0) &&
+                    (strcmp (name, gettext (styles[i].name)) == 0))
+                {
                         return i;
                 }
         }
@@ -441,15 +564,16 @@ name_to_index (const gchar *name)
 
 
 /*****************************************************************************/
-/* Get a list of names for valid barcode styles.                             */
+/* Get a list of names for configured backends.                              */
 /*****************************************************************************/
 GList *
-gl_barcode_backends_get_styles_list  (void)
+gl_barcode_backends_get_backend_list (void)
 {
         gint   i;
         GList *list = NULL;
 
-        for (i=0; backends[i].id != NULL; i++) {
+        for (i=0; backends[i].id != NULL; i++)
+        {
                 list = g_list_prepend (list, g_strdup (gettext (backends[i].name)));
         }
 
@@ -458,118 +582,210 @@ gl_barcode_backends_get_styles_list  (void)
 
 
 /*****************************************************************************/
-/* Free up a previously allocated list of style names.                       */
+/* Free up a previously allocated list of backend names.                     */
 /*****************************************************************************/
 void
-gl_barcode_backends_free_styles_list (GList *styles_list)
+gl_barcode_backends_free_backend_list (GList *backend_list)
 {
         GList *p;
 
-        for (p=styles_list; p != NULL; p=p->next) {
+        for (p=backend_list; p != NULL; p=p->next)
+        {
                 g_free (p->data);
                 p->data = NULL;
         }
 
-        g_list_free (styles_list);
+        g_list_free (backend_list);
 }
 
 
 /*****************************************************************************/
-/* Return an appropriate set of digits for the given barcode style.          */
+/* Convert backend id to name.                                               */
 /*****************************************************************************/
-gchar *
-gl_barcode_backends_default_digits (const gchar *id,
-                           guint        n)
+const gchar *
+gl_barcode_backends_backend_id_to_name (const gchar *backend_id)
 {
-        int i;
+        return gettext (backends[backend_id_to_index (backend_id)].name);
+}
 
-        i = id_to_index (id);
 
-        if (backends[i].can_freeform) {
+/*****************************************************************************/
+/* Convert backend name to id.                                               */
+/*****************************************************************************/
+const gchar *
+gl_barcode_backends_backend_name_to_id (const gchar *backend_name)
+{
+        return backends[backend_name_to_index (backend_name)].id;
+}
 
-                return g_strnfill (MAX (n,1), '0');
 
-        } else {
+/*****************************************************************************/
+/* Guess backend id from style id (for backwards compatability).             */
+/*****************************************************************************/
+const gchar *
+gl_barcode_backends_guess_backend_id (const gchar *id)
+{
+        gint i;
 
-                return g_strdup (backends[i].default_digits);
+        if (id == NULL)
+        {
+                return styles[0].backend_id;
+        }
 
+        for (i=0; styles[i].id != NULL; i++)
+        {
+                if (g_ascii_strcasecmp (id, styles[i].id) == 0)
+                {
+                        return styles[i].backend_id;
+                }
         }
+
+        g_message( "Unknown barcode id \"%s\"", id );
+        return styles[0].backend_id;
 }
 
 
 /*****************************************************************************/
-/* Query text capabilities.                                                  */
+/* Get a list of names for valid barcode styles.                             */
 /*****************************************************************************/
-gboolean
-gl_barcode_backends_can_text (const gchar *id)
+GList *
+gl_barcode_backends_get_styles_list  (const gchar *backend_id)
 {
-        return backends[id_to_index (id)].can_text;
+        gint   i;
+        GList *list = NULL;
+
+        for (i=0; styles[i].id != NULL; i++)
+        {
+                if ( g_ascii_strcasecmp (styles[i].backend_id, backend_id) == 0 )
+                {
+                        list = g_list_prepend (list, g_strdup (gettext (styles[i].name)));
+                }
+        }
+
+        return g_list_reverse (list);
 }
 
 
-gboolean
-gl_barcode_backends_text_optional (const gchar *id)
+/*****************************************************************************/
+/* Free up a previously allocated list of style names.                       */
+/*****************************************************************************/
+void
+gl_barcode_backends_free_styles_list (GList *styles_list)
 {
-        return backends[id_to_index (id)].text_optional;
+        GList *p;
+
+        for (p=styles_list; p != NULL; p=p->next)
+        {
+                g_free (p->data);
+                p->data = NULL;
+        }
+
+        g_list_free (styles_list);
 }
 
 
 /*****************************************************************************/
-/* Query checksum capabilities.                                              */
+/* Convert style to text.                                                    */
 /*****************************************************************************/
-gboolean
-gl_barcode_backends_can_csum (const gchar *id)
+const gchar *
+gl_barcode_backends_style_id_to_name (const gchar *backend_id,
+                                      const gchar *id)
 {
-        return backends[id_to_index (id)].can_checksum;
+        return gettext (styles[style_id_to_index (backend_id, id)].name);
 }
 
 
-gboolean
-gl_barcode_backends_csum_optional (const gchar *id)
+/*****************************************************************************/
+/* Convert name to style.                                                    */
+/*****************************************************************************/
+const gchar *
+gl_barcode_backends_style_name_to_id (const gchar *backend_id,
+                                      const gchar *name)
 {
-        return backends[id_to_index (id)].checksum_optional;
+        return styles[style_name_to_index (backend_id, name)].id;
 }
 
 
 /*****************************************************************************/
-/* Query if freeform input is allowed.                                       */
+/* Return an appropriate set of digits for the given barcode style.          */
 /*****************************************************************************/
-gboolean
-gl_barcode_backends_can_freeform     (const gchar    *id)
+gchar *
+gl_barcode_backends_style_default_digits (const gchar *backend_id,
+                                          const gchar *id,
+                                          guint        n)
 {
-        return backends[id_to_index (id)].can_freeform;
+        int i;
+
+        i = style_id_to_index (backend_id, id);
+
+        if (styles[i].can_freeform)
+        {
+                return g_strnfill (MAX (n,1), '0');
+        }
+        else
+        {
+                return g_strdup (styles[i].default_digits);
+        }
 }
 
 
 /*****************************************************************************/
-/* Query prefered number of digits of input.                                 */
+/* Query text capabilities.                                                  */
 /*****************************************************************************/
-guint
-gl_barcode_backends_get_prefered_n (const gchar    *id)
+gboolean
+gl_barcode_backends_style_can_text (const gchar *backend_id,
+                                    const gchar *id)
+{
+        return styles[style_id_to_index (backend_id, id)].can_text;
+}
+
+
+gboolean
+gl_barcode_backends_style_text_optional (const gchar *backend_id,
+                                         const gchar *id)
 {
-        return backends[id_to_index (id)].prefered_n;
+        return styles[style_id_to_index (backend_id, id)].text_optional;
 }
 
 
 /*****************************************************************************/
-/* Convert style to text.                                                    */
+/* Query checksum capabilities.                                              */
 /*****************************************************************************/
-const gchar *
-gl_barcode_backends_id_to_name (const gchar *id)
+gboolean
+gl_barcode_backends_style_can_csum (const gchar *backend_id,
+                                    const gchar *id)
+{
+        return styles[style_id_to_index (backend_id, id)].can_checksum;
+}
+
+
+gboolean
+gl_barcode_backends_style_csum_optional (const gchar *backend_id,
+                                         const gchar *id)
 {
-        return gettext (backends[id_to_index (id)].name);
+        return styles[style_id_to_index (backend_id, id)].checksum_optional;
 }
 
 
 /*****************************************************************************/
-/* Convert name to style.                                                    */
+/* Query if freeform input is allowed.                                       */
 /*****************************************************************************/
-const gchar *
-gl_barcode_backends_name_to_id (const gchar *name)
+gboolean
+gl_barcode_backends_style_can_freeform (const gchar *backend_id,
+                                        const gchar    *id)
 {
-        g_return_val_if_fail (name!=NULL, backends[0].id);
+        return styles[style_id_to_index (backend_id, id)].can_freeform;
+}
+
 
-        return backends[name_to_index (name)].id;
+/*****************************************************************************/
+/* Query prefered number of digits of input.                                 */
+/*****************************************************************************/
+guint
+gl_barcode_backends_style_get_prefered_n (const gchar *backend_id,
+                                          const gchar *id)
+{
+        return styles[style_id_to_index (backend_id, id)].prefered_n;
 }
 
 
@@ -577,7 +793,8 @@ gl_barcode_backends_name_to_id (const gchar *name)
 /* Call appropriate barcode backend to create barcode in intermediate format.*/
 /*****************************************************************************/
 glBarcode *
-gl_barcode_backends_new_barcode (const gchar    *id,
+gl_barcode_backends_new_barcode (const gchar    *backend_id,
+                                 const gchar    *id,
                                  gboolean        text_flag,
                                  gboolean        checksum_flag,
                                  gdouble         w,
@@ -589,13 +806,14 @@ gl_barcode_backends_new_barcode (const gchar    *id,
 
         g_return_val_if_fail (digits!=NULL, NULL);
 
-        i = id_to_index (id);
-        gbc = backends[i].new_barcode (backends[i].id,
-                                       text_flag,
-                                       checksum_flag,
-                                       w,
-                                       h,
-                                       digits);
+        i = style_id_to_index (backend_id, id);
+
+        gbc = styles[i].new_barcode (styles[i].id,
+                                     text_flag,
+                                     checksum_flag,
+                                     w,
+                                     h,
+                                     digits);
 
         return gbc;
 }
index 6d9558076276d65aed0a8889bf51cae0d2d3f792..1cd2b1224874664ae95f013630e0acb6fa69cdce 100644 (file)
 G_BEGIN_DECLS
 
 
-GList           *gl_barcode_backends_get_styles_list  (void);
-void             gl_barcode_backends_free_styles_list (GList          *styles_list);
-
-gchar           *gl_barcode_backends_default_digits   (const gchar    *id,
-                                                       guint           n);
-
-gboolean         gl_barcode_backends_can_text         (const gchar    *id);
-gboolean         gl_barcode_backends_text_optional    (const gchar    *id);
-
-gboolean         gl_barcode_backends_can_csum         (const gchar    *id);
-gboolean         gl_barcode_backends_csum_optional    (const gchar    *id);
-
-gboolean         gl_barcode_backends_can_freeform     (const gchar    *id);
-guint            gl_barcode_backends_get_prefered_n   (const gchar    *id);
-
-const gchar     *gl_barcode_backends_id_to_name       (const gchar    *id);
-const gchar     *gl_barcode_backends_name_to_id       (const gchar    *name);
-
-glBarcode       *gl_barcode_backends_new_barcode      (const gchar    *id,
-                                                       gboolean        text_flag,
-                                                       gboolean        checksum_flag,
-                                                       gdouble         w,
-                                                       gdouble         h,
-                                                       const gchar    *digits);
+GList           *gl_barcode_backends_get_backend_list     (void);
+void             gl_barcode_backends_free_backend_list    (GList          *backend_list);
+
+const gchar     *gl_barcode_backends_backend_id_to_name   (const gchar    *backend_id);
+const gchar     *gl_barcode_backends_backend_name_to_id   (const gchar    *backend_name);
+
+const gchar     *gl_barcode_backends_guess_backend_id     (const gchar    *id);
+
+GList           *gl_barcode_backends_get_styles_list      (const gchar    *backend_id);
+void             gl_barcode_backends_free_styles_list     (GList          *styles_list);
+
+const gchar     *gl_barcode_backends_style_id_to_name     (const gchar    *backend_id,
+                                                           const gchar    *id);
+const gchar     *gl_barcode_backends_style_name_to_id     (const gchar    *backend_id,
+                                                           const gchar    *name);
+
+gchar           *gl_barcode_backends_style_default_digits (const gchar    *backend_id,
+                                                           const gchar    *id,
+                                                           guint           n);
+
+gboolean         gl_barcode_backends_style_can_text       (const gchar    *backend_id,
+                                                           const gchar    *id);
+gboolean         gl_barcode_backends_style_text_optional  (const gchar    *backend_id,
+                                                           const gchar    *id);
+
+gboolean         gl_barcode_backends_style_can_csum       (const gchar    *backend_id,
+                                                           const gchar    *id);
+gboolean         gl_barcode_backends_style_csum_optional  (const gchar    *backend_id,
+                                                           const gchar    *id);
+
+gboolean         gl_barcode_backends_style_can_freeform   (const gchar    *backend_id,
+                                                           const gchar    *id);
+guint            gl_barcode_backends_style_get_prefered_n (const gchar    *backend_id,
+                                                           const gchar    *id);
+
+glBarcode       *gl_barcode_backends_new_barcode          (const gchar    *backend_id,
+                                                           const gchar    *id,
+                                                           gboolean        text_flag,
+                                                           gboolean        checksum_flag,
+                                                           gdouble         w,
+                                                           gdouble         h,
+                                                           const gchar    *digits);
 
 
 
index a57721f1bd486e1082a424c99ed984e57c08f53d..c458552a7cdc9f2e2a65de5a012c7fcd0ee28173 100644 (file)
@@ -43,6 +43,7 @@
 
 struct _glLabelBarcodePrivate {
         glTextNode     *text_node;
+        gchar          *backend_id;
         gchar          *id;
         glColorNode    *color_node;
         gboolean        text_flag;
@@ -155,8 +156,18 @@ gl_label_barcode_new (glLabel *label,
                         gl_label_checkpoint (label, _("Create barcode object"));
                 }
 
-                line_color_node = gl_color_node_new_default ();
+                /* Default barcode style and properties. */
+                lbc->priv->backend_id = g_strdup (gl_barcode_backends_backend_name_to_id (NULL));
+                lbc->priv->id         = g_strdup (gl_barcode_backends_style_name_to_id (lbc->priv->backend_id,
+                                                                                        NULL));
+                lbc->priv->text_flag     = gl_barcode_backends_style_can_text (lbc->priv->backend_id,
+                                                                               lbc->priv->id);
+                lbc->priv->checksum_flag = gl_barcode_backends_style_can_csum (lbc->priv->backend_id,
+                                                                               lbc->priv->id);
+                lbc->priv->format_digits = gl_barcode_backends_style_get_prefered_n (lbc->priv->backend_id,
+                                                                                     lbc->priv->id);
 
+                line_color_node = gl_color_node_new_default ();
                 line_color_node->color = gl_label_get_default_line_color(label);
 
                 lbc->priv->color_node = line_color_node;
@@ -179,6 +190,7 @@ copy (glLabelObject *dst_object,
         glLabelBarcode      *lbc     = (glLabelBarcode *)src_object;
         glLabelBarcode      *new_lbc = (glLabelBarcode *)dst_object;
         glTextNode          *text_node;
+        gchar               *backend_id;
         gchar               *id;
         gboolean             text_flag;
         gboolean             checksum_flag;
@@ -191,15 +203,16 @@ 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, &format_digits);
+        gl_label_barcode_get_props (lbc, &backend_id, &id, &text_flag, &checksum_flag, &format_digits);
         color_node = get_line_color (src_object);
 
         gl_label_barcode_set_data (new_lbc, text_node, FALSE);
-        gl_label_barcode_set_props (new_lbc, id, text_flag, checksum_flag, format_digits, FALSE);
+        gl_label_barcode_set_props (new_lbc, backend_id, id, text_flag, checksum_flag, format_digits, FALSE);
         set_line_color (dst_object, color_node, FALSE);
 
         gl_color_node_free (&color_node);
         gl_text_node_free (&text_node);
+        g_free (backend_id);
         g_free (id);
 
         gl_debug (DEBUG_LABEL, "END");
@@ -240,6 +253,7 @@ gl_label_barcode_set_data (glLabelBarcode *lbc,
 
 void
 gl_label_barcode_set_props (glLabelBarcode *lbc,
+                            gchar          *backend_id,
                             gchar          *id,
                             gboolean        text_flag,
                             gboolean        checksum_flag,
@@ -252,7 +266,9 @@ gl_label_barcode_set_props (glLabelBarcode *lbc,
 
         g_return_if_fail (lbc && GL_IS_LABEL_BARCODE (lbc));
 
-        if ( ((lbc->priv->id == NULL) && (id != NULL))
+        if ( ((lbc->priv->backend_id == NULL) && (backend_id != NULL))
+             || ((lbc->priv->id == NULL) && (id != NULL))
+             || ((lbc->priv->backend_id != NULL) && (backend_id != NULL) && (g_ascii_strcasecmp (lbc->priv->backend_id, backend_id) != 0))
              || ((lbc->priv->id != NULL) && (id != NULL) && (g_ascii_strcasecmp (lbc->priv->id, id) != 0))
              || (lbc->priv->text_flag != text_flag)
              || (lbc->priv->checksum_flag != checksum_flag)
@@ -264,6 +280,7 @@ gl_label_barcode_set_props (glLabelBarcode *lbc,
                         gl_label_checkpoint (label, _("Barcode property"));
                 }
 
+                lbc->priv->backend_id       = g_strdup (backend_id);
                 lbc->priv->id               = g_strdup (id);
                 lbc->priv->text_flag        = text_flag;
                 lbc->priv->checksum_flag    = checksum_flag;
@@ -290,6 +307,7 @@ gl_label_barcode_get_data (glLabelBarcode *lbc)
 
 void
 gl_label_barcode_get_props (glLabelBarcode *lbc,
+                            gchar          **backend_id,
                             gchar          **id,
                             gboolean       *text_flag,
                             gboolean       *checksum_flag,
@@ -297,6 +315,7 @@ gl_label_barcode_get_props (glLabelBarcode *lbc,
 {
         g_return_if_fail (lbc && GL_IS_LABEL_BARCODE (lbc));
 
+        *backend_id       = g_strdup (lbc->priv->backend_id);
         *id               = g_strdup (lbc->priv->id);
         *text_flag        = lbc->priv->text_flag;
         *checksum_flag    = lbc->priv->checksum_flag;
@@ -324,13 +343,15 @@ get_size (glLabelObject *object,
         gl_label_object_get_raw_size (object, &w_parent, &h_parent);
 
         if (lbc->priv->text_node->field_flag) {
-                data = gl_barcode_backends_default_digits (lbc->priv->id,
-                                                           lbc->priv->format_digits);
+                data = gl_barcode_backends_style_default_digits (lbc->priv->backend_id,
+                                                                 lbc->priv->id,
+                                                                 lbc->priv->format_digits);
         } else {
                 data = gl_text_node_expand (lbc->priv->text_node, NULL);
         }
 
-        gbc = gl_barcode_backends_new_barcode (lbc->priv->id,
+        gbc = gl_barcode_backends_new_barcode (lbc->priv->backend_id,
+                                               lbc->priv->id,
                                                lbc->priv->text_flag,
                                                lbc->priv->checksum_flag,
                                                w_parent,
@@ -340,9 +361,11 @@ get_size (glLabelObject *object,
 
         if ( gbc == NULL ) {
                 /* Try again with default digits. */
-                data = gl_barcode_backends_default_digits (lbc->priv->id,
-                                                  lbc->priv->format_digits);
-                gbc = gl_barcode_backends_new_barcode (lbc->priv->id,
+                data = gl_barcode_backends_style_default_digits (lbc->priv->backend_id,
+                                                                 lbc->priv->id,
+                                                                 lbc->priv->format_digits);
+                gbc = gl_barcode_backends_new_barcode (lbc->priv->backend_id,
+                                                       lbc->priv->id,
                                                        lbc->priv->text_flag,
                                                        lbc->priv->checksum_flag,
                                                        w_parent,
@@ -436,6 +459,7 @@ draw_object (glLabelObject *object,
         PangoFontDescription *desc;
         gchar                *text, *cstring;
         glTextNode           *text_node;
+        gchar                *backend_id;
         gchar                *id;
         gboolean              text_flag;
         gboolean              checksum_flag;
@@ -453,7 +477,7 @@ draw_object (glLabelObject *object,
 
         text_node = gl_label_barcode_get_data (GL_LABEL_BARCODE (object));
         gl_label_barcode_get_props (GL_LABEL_BARCODE (object),
-                                    &id, &text_flag, &checksum_flag, &format_digits);
+                                    &backend_id, &id, &text_flag, &checksum_flag, &format_digits);
 
         color_node = gl_label_object_get_line_color (object);
         color = gl_color_node_expand (color_node, record);
@@ -468,10 +492,10 @@ draw_object (glLabelObject *object,
         text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
         text = gl_text_node_expand (text_node, record);
         if (text_node->field_flag && screen_flag) {
-                text = gl_barcode_backends_default_digits (id, format_digits);
+                text = gl_barcode_backends_style_default_digits (backend_id, id, format_digits);
         }
 
-        gbc = gl_barcode_backends_new_barcode (id, text_flag, checksum_flag, w, h, text);
+        gbc = gl_barcode_backends_new_barcode (backend_id, id, text_flag, checksum_flag, w, h, text);
 
         cairo_set_source_rgba (cr, GL_COLOR_RGBA_ARGS (color));
 
@@ -611,6 +635,7 @@ draw_object (glLabelObject *object,
 
         g_free (text);
         gl_text_node_free (&text_node);
+        g_free (backend_id);
         g_free (id);
 
         gl_debug (DEBUG_LABEL, "END");
index 3ae672ba551f8cc184c12053342359ddc4407ce2..bba52f9cc89a8a244ac6392283720010f118f27a 100644 (file)
@@ -59,6 +59,7 @@ void            gl_label_barcode_set_data  (glLabelBarcode *lbc,
                                             gboolean        checkpoint);
 
 void            gl_label_barcode_set_props (glLabelBarcode *lbc,
+                                            gchar          *backend_id,
                                            gchar          *id,
                                            gboolean        text_flag,
                                            gboolean        checksum_flag,
@@ -68,6 +69,7 @@ void            gl_label_barcode_set_props (glLabelBarcode *lbc,
 glTextNode     *gl_label_barcode_get_data  (glLabelBarcode *lbc);
 
 void            gl_label_barcode_get_props (glLabelBarcode *lbc,
+                                           gchar         **backend_id,
                                            gchar         **id,
                                            gboolean       *text_flag,
                                            gboolean       *checksum_flag,
index 95c29159d96717e97f6e2926e19ea66204f3b8a5..0d9d5fb10700cd5c5ddf561124ff4b1c485ec97e 100644 (file)
@@ -58,6 +58,7 @@
 /* Local function prototypes                 */
 /*===========================================*/
 
+static void backend_changed_cb          (glObjectEditor       *editor);
 static void style_changed_cb            (glObjectEditor       *editor);
 static void bc_radio_toggled_cb         (glObjectEditor       *editor);
 static void data_digits_spin_changed_cb (glObjectEditor       *editor);
@@ -69,13 +70,14 @@ static void data_digits_spin_changed_cb (glObjectEditor       *editor);
 void
 gl_object_editor_prepare_bc_page (glObjectEditor       *editor)
 {
-       GList        *styles = NULL;
+       GList        *backends = NULL;
 
        gl_debug (DEBUG_EDITOR, "START");
 
        /* Extract widgets from XML tree. */
         gl_builder_util_get_widgets (editor->priv->builder,
                                      "bc_page_vbox",      &editor->priv->bc_page_vbox,
+                                     "bc_backend_combo",  &editor->priv->bc_backend_combo,
                                      "bc_style_combo",    &editor->priv->bc_style_combo,
                                      "bc_text_check",     &editor->priv->bc_text_check,
                                      "bc_cs_check",       &editor->priv->bc_cs_check,
@@ -103,13 +105,14 @@ gl_object_editor_prepare_bc_page (glObjectEditor       *editor)
                             editor->priv->bc_key_combo,
                             TRUE, TRUE, 0);
 
+       gl_combo_util_add_text_model ( GTK_COMBO_BOX(editor->priv->bc_backend_combo));
        gl_combo_util_add_text_model ( GTK_COMBO_BOX(editor->priv->bc_style_combo));
 
-       /* Load barcode styles */
-       styles = gl_barcode_backends_get_styles_list ();
-       gl_combo_util_set_strings (GTK_COMBO_BOX(editor->priv->bc_style_combo),
-                                   styles);
-       gl_barcode_backends_free_styles_list (styles);
+       /* Load barcode backends */
+       backends = gl_barcode_backends_get_backend_list ();
+       gl_combo_util_set_strings (GTK_COMBO_BOX(editor->priv->bc_backend_combo),
+                                   backends);
+       gl_barcode_backends_free_backend_list (backends);
 
        /* Modify widgets */
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->bc_color_radio), TRUE);
@@ -120,6 +123,10 @@ gl_object_editor_prepare_bc_page (glObjectEditor       *editor)
        gtk_widget_show_all (editor->priv->bc_page_vbox);
 
        /* Connect signals */
+       g_signal_connect_swapped (G_OBJECT (editor->priv->bc_backend_combo),
+                                 "changed",
+                                 G_CALLBACK (backend_changed_cb),
+                                 G_OBJECT (editor));
        g_signal_connect_swapped (G_OBJECT (editor->priv->bc_style_combo),
                                  "changed",
                                  G_CALLBACK (style_changed_cb),
@@ -157,12 +164,41 @@ gl_object_editor_prepare_bc_page (glObjectEditor       *editor)
 }
 
 
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Callback for when backend has changed.                         */
+/*--------------------------------------------------------------------------*/
+static void
+backend_changed_cb (glObjectEditor       *editor)
+{
+        gchar          *backend_name = NULL;
+       const gchar    *backend_id;
+        const gchar    *style_name;
+
+        if (editor->priv->stop_signals) return;
+
+        backend_name =
+               gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->bc_backend_combo));
+
+        backend_id = gl_barcode_backends_backend_name_to_id (backend_name);
+
+        gl_object_editor_load_bc_styles (editor, backend_id);
+
+        style_name = gl_barcode_backends_style_id_to_name (backend_id, NULL);
+        gl_combo_util_set_active_text (GTK_COMBO_BOX (editor->priv->bc_style_combo),
+                                       style_name);
+
+        g_free (backend_name);
+}
+
+
 /*--------------------------------------------------------------------------*/
 /* PRIVATE.  Callback for when style has changed.                           */
 /*--------------------------------------------------------------------------*/
 static void
 style_changed_cb (glObjectEditor       *editor)
 {
+        gchar          *backend_name = NULL;
+       const gchar    *backend_id;
         gchar          *style_string = NULL;
        const gchar    *id;
        gchar          *ex_string = NULL;
@@ -170,28 +206,33 @@ style_changed_cb (glObjectEditor       *editor)
 
         if (editor->priv->stop_signals) return;
 
+        backend_name =
+               gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->bc_backend_combo));
+
+        backend_id = gl_barcode_backends_backend_name_to_id (backend_name);
+
         style_string =
                gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->bc_style_combo));
-                                                                                
+
         /* Don't emit if entry is empty. */
-        if ( *style_string != 0 ) {
-                id = gl_barcode_backends_name_to_id (style_string);
+        if ( style_string && *style_string != 0 ) {
+                id = gl_barcode_backends_style_name_to_id (backend_id, style_string);
                                                                                 
                 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(editor->priv->bc_text_check),
-                                             gl_barcode_backends_can_text (id));
+                                             gl_barcode_backends_style_can_text (backend_id, id));
                 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(editor->priv->bc_cs_check),
-                                             gl_barcode_backends_can_csum (id));
+                                             gl_barcode_backends_style_can_csum (backend_id, id));
                                                                                 
                 gtk_widget_set_sensitive (editor->priv->bc_text_check,
-                                          gl_barcode_backends_text_optional (id));
+                                          gl_barcode_backends_style_text_optional (backend_id, id));
                 gtk_widget_set_sensitive (editor->priv->bc_cs_check,
-                                          gl_barcode_backends_csum_optional (id));
+                                          gl_barcode_backends_style_csum_optional (backend_id, id));
                                                                                 
-               editor->priv->data_format_fixed_flag = !gl_barcode_backends_can_freeform (id);
-                digits = gl_barcode_backends_get_prefered_n(id);
+               editor->priv->data_format_fixed_flag = !gl_barcode_backends_style_can_freeform (backend_id, id);
+                digits = gl_barcode_backends_style_get_prefered_n(backend_id, id);
                 gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->data_digits_spin), digits);
                                                                                 
-               ex_string = gl_barcode_backends_default_digits (id, digits);
+               ex_string = gl_barcode_backends_style_default_digits (backend_id, 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))) {
@@ -216,27 +257,57 @@ style_changed_cb (glObjectEditor       *editor)
 }
                                                                                 
 
+/*****************************************************************************/
+/* Load barcode styles based on backend_id.                                  */
+/*****************************************************************************/
+void
+gl_object_editor_load_bc_styles (glObjectEditor      *editor,
+                                 const gchar         *backend_id)
+{
+       const gchar *backend_name;
+        GList       *styles;
+       gl_debug (DEBUG_EDITOR, "START");
+
+        editor->priv->stop_signals = TRUE;
+
+       styles = gl_barcode_backends_get_styles_list (backend_id);
+       gl_combo_util_set_strings (GTK_COMBO_BOX(editor->priv->bc_style_combo),
+                                   styles);
+       gl_barcode_backends_free_styles_list (styles);
+
+        editor->priv->stop_signals = FALSE;
+
+       gl_debug (DEBUG_EDITOR, "END");
+}
+
+
 /*****************************************************************************/
 /* Set barcode style.                                                        */
 /*****************************************************************************/
 void
 gl_object_editor_set_bc_style (glObjectEditor      *editor,
-                              gchar               *id,
+                              const gchar         *backend_id,
+                              const gchar         *id,
                               gboolean             text_flag,
                               gboolean             checksum_flag,
                               guint                format_digits)
 {
-       const gchar *style_string;
+       const gchar *backend_name;
+       const gchar *style_name;
        gchar       *ex_string;
  
        gl_debug (DEBUG_EDITOR, "START");
 
         editor->priv->stop_signals = TRUE;
 
-        style_string = gl_barcode_backends_id_to_name (id);
-       gl_combo_util_set_active_text (GTK_COMBO_BOX (editor->priv->bc_style_combo),
-                                       style_string);
+        backend_name = gl_barcode_backends_backend_id_to_name (backend_id);
+        style_name   = gl_barcode_backends_style_id_to_name (backend_id, id);
+
+       gl_combo_util_set_active_text (GTK_COMBO_BOX (editor->priv->bc_backend_combo),
+                                       backend_name);
+       gl_combo_util_set_active_text (GTK_COMBO_BOX (editor->priv->bc_style_combo),
+                                       style_name);
  
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->bc_text_check),
                                       text_flag);
@@ -245,17 +316,17 @@ gl_object_editor_set_bc_style (glObjectEditor      *editor,
                                       checksum_flag);
 
        gtk_widget_set_sensitive (editor->priv->bc_text_check,
-                                 gl_barcode_backends_text_optional (id));
+                                 gl_barcode_backends_style_text_optional (backend_id, id));
        gtk_widget_set_sensitive (editor->priv->bc_cs_check,
-                                 gl_barcode_backends_csum_optional (id));
+                                 gl_barcode_backends_style_csum_optional (backend_id, id));
 
-       editor->priv->data_format_fixed_flag = !gl_barcode_backends_can_freeform (id);
+       editor->priv->data_format_fixed_flag = !gl_barcode_backends_style_can_freeform (backend_id, id);
 
        if (editor->priv->data_format_fixed_flag) {
-               format_digits = gl_barcode_backends_get_prefered_n (id);
+               format_digits = gl_barcode_backends_style_get_prefered_n (backend_id, id);
        }
 
-       ex_string = gl_barcode_backends_default_digits (id, format_digits);
+       ex_string = gl_barcode_backends_style_default_digits (backend_id, id, format_digits);
        gtk_label_set_text (GTK_LABEL(editor->priv->data_ex_label), ex_string);
        g_free (ex_string);
 
@@ -287,18 +358,24 @@ gl_object_editor_set_bc_style (glObjectEditor      *editor,
 /*****************************************************************************/
 void
 gl_object_editor_get_bc_style (glObjectEditor      *editor,
+                               gchar              **backend_id,
                               gchar              **id,
                               gboolean            *text_flag,
                               gboolean            *checksum_flag,
                               guint               *format_digits)
 {
-        gchar *style_string;
+        gchar *backend_name;
+        gchar *style_name;
 
        gl_debug (DEBUG_EDITOR, "START");
                                                                                 
-        style_string =
+        backend_name =
+               gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->bc_backend_combo));
+        *backend_id = g_strdup (gl_barcode_backends_backend_name_to_id (backend_name));
+
+        style_name =
                gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->bc_style_combo));
-        *id = g_strdup (gl_barcode_backends_name_to_id (style_string));
+        *id = g_strdup (gl_barcode_backends_style_name_to_id (*backend_id, style_name));
                                                                                 
         *text_flag =
             gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->bc_text_check));
@@ -310,7 +387,8 @@ gl_object_editor_get_bc_style (glObjectEditor      *editor,
        *format_digits =
                gtk_spin_button_get_value (GTK_SPIN_BUTTON(editor->priv->data_digits_spin));
 
-        g_free (style_string);
+        g_free (backend_name);
+        g_free (style_name);
 
        gl_debug (DEBUG_EDITOR, "END");
 }
@@ -429,23 +507,29 @@ bc_radio_toggled_cb (glObjectEditor *editor)
 static void
 data_digits_spin_changed_cb (glObjectEditor *editor)
 {
-        gchar          *style_string;
+        gchar          *backend_name;
+        const gchar    *backend_id;
+        gchar          *style_name;
         const gchar    *id;
         guint           digits;
         gchar          *ex_string;
 
         if (editor->priv->stop_signals) return;
 
-        style_string = gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->bc_style_combo));
-        if ( *style_string != 0 ) {
-                id = gl_barcode_backends_name_to_id (style_string);
+        backend_name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->bc_backend_combo));
+        backend_id = gl_barcode_backends_backend_name_to_id (backend_name);
+
+        style_name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->bc_style_combo));
+        if ( *style_name != 0 ) {
+                id = gl_barcode_backends_style_name_to_id (backend_id, style_name);
 
                 digits = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->data_digits_spin));
-                ex_string = gl_barcode_backends_default_digits (id, digits);
+                ex_string = gl_barcode_backends_style_default_digits (backend_id, id, digits);
                 gtk_label_set_text (GTK_LABEL(editor->priv->data_ex_label), ex_string);
         }
 
-        g_free (style_string);
+        g_free (backend_name);
+        g_free (style_name);
         g_free (ex_string);
 
         gl_object_editor_changed_cb (editor);
index c7ad1dad731c4c59a640af9ce69c418f3dd334ca..f60d15425ce72dded6ec56737d0eb5dde9528847 100644 (file)
@@ -122,6 +122,7 @@ struct _glObjectEditorPrivate {
        GtkWidget  *edit_insert_field_button;
 
        GtkWidget  *bc_page_vbox;
+       GtkWidget  *bc_backend_combo;
        GtkWidget  *bc_style_combo;
        GtkWidget  *bc_text_check;
        GtkWidget  *bc_cs_check;
@@ -349,13 +350,18 @@ void        gl_object_editor_set_text_buffer      (glObjectEditor      *editor,
 /*
  * Barcode Page
  */
+void        gl_object_editor_load_bc_styles       (glObjectEditor      *editor,
+                                                   const gchar         *backend_id);
+
 void        gl_object_editor_set_bc_style         (glObjectEditor      *editor,
-                                                  gchar               *id,
+                                                   const gchar         *backend_id,
+                                                  const gchar         *id,
                                                   gboolean             text_flag,
                                                   gboolean             checksum_flag,
                                                   guint                format_digits);
 
 void        gl_object_editor_get_bc_style         (glObjectEditor      *editor,
+                                                   gchar              **backend_id,
                                                   gchar              **id,
                                                   gboolean            *text_flag,
                                                   gboolean            *checksum_flag,
index 8640371225a728b2623f52611e918c835eb10bf2..ea5bd83d2797001c1189ed925e22d7e2bc2f22da 100644 (file)
@@ -285,6 +285,10 @@ set_object (glObjectEditor  *editor,
         gchar         *s;
         GtkTextBuffer *buffer;
         gint           old_page, new_page;
+        gchar         *backend_id;
+        gchar         *id;
+        gboolean       text_flag, cs_flag;
+        guint          format_digits;
 
        gl_debug (DEBUG_EDITOR, "START");
 
@@ -299,8 +303,6 @@ set_object (glObjectEditor  *editor,
         {
                 editor->priv->object = g_object_ref (object);
 
-                object_changed_cb (object, editor);
-
                 old_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (editor->priv->notebook));
 
                 if (GL_IS_LABEL_BOX (object))
@@ -415,6 +417,13 @@ set_object (glObjectEditor  *editor,
                         gtk_widget_hide     (editor->priv->shadow_page_vbox);
 
                         gtk_widget_hide     (editor->priv->size_reset_image_button);
+
+                        gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
+                                                    &backend_id, &id, &text_flag, &cs_flag, &format_digits);
+                        gl_object_editor_load_bc_styles (editor, backend_id);
+                        g_free (backend_id);
+                        g_free (id);
+
                 }
 
                 gtk_image_set_from_stock (GTK_IMAGE(editor->priv->title_image),
@@ -445,6 +454,8 @@ set_object (glObjectEditor  *editor,
                         gtk_notebook_set_current_page (GTK_NOTEBOOK (editor->priv->notebook), 0);
                 }
 
+                object_changed_cb (object, editor);
+
                 g_signal_connect (G_OBJECT (object), "changed",
                                   G_CALLBACK (object_changed_cb), editor);
         }
@@ -745,6 +756,7 @@ object_changed_cb (glLabelObject  *object,
         gdouble          image_w, image_h;
         glTextNode      *filename;
         glTextNode      *bc_data;
+        gchar           *backend_id;
         gchar           *id;
         gboolean         text_flag, cs_flag;
         guint            format_digits;
@@ -847,15 +859,17 @@ object_changed_cb (glLabelObject  *object,
                 gl_label_object_get_size (object, &w, &h);
                 bc_data = gl_label_barcode_get_data (GL_LABEL_BARCODE(object));
                 gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
-                                            &id, &text_flag, &cs_flag, &format_digits);
+                                            &backend_id, &id, &text_flag, &cs_flag, &format_digits);
                 line_color_node   = gl_label_object_get_line_color (GL_LABEL_OBJECT(object));
 
                 gl_object_editor_set_size (editor, w, h);
                 gl_object_editor_set_data (editor, (merge != NULL), bc_data);
-                gl_object_editor_set_bc_style (editor, id, text_flag, cs_flag, format_digits);
+                gl_object_editor_set_bc_style (editor, backend_id, id, text_flag, cs_flag, format_digits);
                 gl_object_editor_set_bc_color (editor, (merge != NULL), line_color_node);
 
                 gl_text_node_free (&bc_data);
+                g_free (backend_id);
+                g_free (id);
 
         }
 
@@ -903,6 +917,7 @@ gl_object_editor_changed_cb (glObjectEditor *editor)
         gdouble            image_w, image_h;
         gdouble            new_w, new_h;
         glTextNode        *bc_data;
+        gchar             *backend_id;
         gchar             *id;
         gboolean           text_flag, cs_flag;
         guint              format_digits;
@@ -1001,15 +1016,16 @@ gl_object_editor_changed_cb (glObjectEditor *editor)
                 line_color_node = gl_object_editor_get_bc_color (editor);
                 bc_data = gl_object_editor_get_data (editor);
                 gl_object_editor_get_bc_style (editor,
-                                               &id, &text_flag, &cs_flag, &format_digits);
+                                               &backend_id, &id, &text_flag, &cs_flag, &format_digits);
 
                 gl_label_object_set_line_color (object, line_color_node, TRUE);
                 gl_label_barcode_set_data (GL_LABEL_BARCODE(object), bc_data, TRUE);
                 gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
-                                            id, text_flag, cs_flag, format_digits, TRUE);
+                                            backend_id, id, text_flag, cs_flag, format_digits, TRUE);
 
                 gl_color_node_free (&line_color_node);
                 gl_text_node_free (&bc_data);
+                g_free (backend_id);
                 g_free (id);
 
         }
index 7c7e2976823feb2b77280ab69f88ad07a152d7a2..1abedf54bdc37b138f4ba41e749a590ce447d78c 100644 (file)
@@ -31,6 +31,7 @@
 #include "label-ellipse.h"
 #include "label-image.h"
 #include "label-barcode.h"
+#include "bc-backends.h"
 #include "str-util.h"
 
 #include "debug.h"
@@ -439,6 +440,7 @@ xml04_parse_barcode_props (xmlNodePtr    node,
                           glLabelBarcode *object)
 {
        xmlChar       *id;
+        const gchar   *backend_id;
        gboolean       text_flag;
        glColorNode   *color_node;
        gdouble        scale;
@@ -451,13 +453,14 @@ xml04_parse_barcode_props (xmlNodePtr    node,
        color_node->color = lgl_xml_get_prop_uint (node, "color", 0);
 
        id = xmlGetProp (node, (xmlChar *)"style");
+        backend_id = gl_barcode_backends_guess_backend_id (id);
 
        text_flag = lgl_xml_get_prop_boolean (node, "text", FALSE);
        scale = lgl_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, (gchar *)id, text_flag, TRUE, 0, FALSE);
+       gl_label_barcode_set_props (object, (gchar *)id, (gchar *)backend_id, text_flag, TRUE, 0, FALSE);
        gl_label_object_set_line_color (GL_LABEL_OBJECT(object), color_node, FALSE);
 
        child = node->xmlChildrenNode;
index a0d9c4fe58a8410d40aba2a59337b5ca861ba925..3483846dd656eae3627684c12ae56879e9c3e564 100644 (file)
@@ -38,6 +38,7 @@
 #include "label-ellipse.h"
 #include "label-image.h"
 #include "label-barcode.h"
+#include "bc-backends.h"
 #include "xml-label-04.h"
 #include "str-util.h"
 #include "prefs.h"
@@ -744,6 +745,7 @@ xml_parse_object_barcode (xmlNodePtr  node,
        gdouble             w, h;
        gchar              *string;
        glTextNode         *text_node;
+       gchar              *backend_id;
        gchar              *id;
        gboolean            text_flag;
        gboolean            checksum_flag;
@@ -765,12 +767,18 @@ xml_parse_object_barcode (xmlNodePtr  node,
        gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h, FALSE);
 
        /* prop attrs */
+       backend_id = lgl_xml_get_prop_string (node, "backend", NULL);
        id = lgl_xml_get_prop_string (node, "style", NULL);
+        if ( !backend_id )
+        {
+                backend_id = g_strdup (gl_barcode_backends_guess_backend_id (id));
+        }
        text_flag = lgl_xml_get_prop_boolean (node, "text", FALSE);
        checksum_flag = lgl_xml_get_prop_boolean (node, "checksum", TRUE);
        format_digits = lgl_xml_get_prop_uint (node, "format", 10);
        gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
-                                   (gchar *)id, text_flag, checksum_flag, format_digits, FALSE);
+                                   backend_id, id, text_flag, checksum_flag, format_digits, FALSE);
+       g_free (backend_id);
        g_free (id);
        
        color_node = gl_color_node_new_default ();
@@ -1586,6 +1594,7 @@ xml_create_object_barcode (xmlNodePtr     parent,
        gdouble           x, y;
        gdouble           w, h;
        glTextNode       *text_node;
+       gchar            *backend_id;
        gchar            *id;
        gboolean          text_flag;
        gboolean          checksum_flag;
@@ -1608,11 +1617,13 @@ xml_create_object_barcode (xmlNodePtr     parent,
 
        /* Barcode properties attrs */
        gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
-                                   &id, &text_flag, &checksum_flag, &format_digits);
+                                   &backend_id, &id, &text_flag, &checksum_flag, &format_digits);
+       lgl_xml_set_prop_string (node, "backend", backend_id);
        lgl_xml_set_prop_string (node, "style", id);
        lgl_xml_set_prop_boolean (node, "text", text_flag);
        lgl_xml_set_prop_boolean (node, "checksum", checksum_flag);
        
+       g_free (backend_id);
        g_free (id);
        
        color_node = gl_label_object_get_line_color (GL_LABEL_OBJECT(object));
index 1e276c363f2c72ef8be07895a7c9cca9bc6a6eea..31a973756cdf11d16a5369fbdbed90617979ff7c 100644 (file)
 <!ENTITY % FONT_WEIGHT_TYPE   "(Regular | Bold)">
 
 <!-- Barcode related enumerations/types -->
+<!ENTITY % BC_BACKEND_TYPE    "CDATA">
+                              <!-- one of:
+                              "(built-in    |
+                                gnu-barcode |
+                               zint        |
+                               libiec16022 |
+                               libqrencode")
+                               -->
 <!ENTITY % BC_STYLE_TYPE      "CDATA">
                               <!-- one of:
                               "(POSTNET    |
 <!ATTLIST Object-barcode
                  %position_attrs;
                  %size_attrs;
+                 backend          %BC_BACKEND_TYPE;       #REQUIRED
                  style            %BC_STYLE_TYPE;         #REQUIRED
                  text             %BOOLEAN_TYPE;          #REQUIRED
                  checksum         %BOOLEAN_TYPE;          #REQUIRED