[glabels/vala] Added new BarcodeMenuButton widget for selecting barcode styles.
- From: Jim Evins <jimevins src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glabels/vala] Added new BarcodeMenuButton widget for selecting barcode styles.
- Date: Tue, 25 Sep 2012 02:49:20 +0000 (UTC)
commit c045dc6404b037dab7960734f46c2b935339548d
Author: Jim Evins <evins snaught com>
Date: Mon Sep 24 22:48:35 2012 -0400
Added new BarcodeMenuButton widget for selecting barcode styles.
data/ui/object_editor.ui | 19 +-
glabels/Makefile.am | 3 +
glabels/barcode_backends.vala | 489 ++++++++++++++++++++-----------------
glabels/barcode_menu.vala | 97 ++++++++
glabels/barcode_menu_button.vala | 160 ++++++++++++
glabels/barcode_menu_item.vala | 41 +++
glabels/barcode_style.vala | 3 +
glabels/label_object.vala | 3 +-
glabels/label_object_barcode.vala | 33 +--
glabels/object_editor.vala | 70 +++---
glabels/xml_label.vala | 10 +-
11 files changed, 634 insertions(+), 294 deletions(-)
---
diff --git a/data/ui/object_editor.ui b/data/ui/object_editor.ui
index c0077a9..9fee43d 100644
--- a/data/ui/object_editor.ui
+++ b/data/ui/object_editor.ui
@@ -842,18 +842,15 @@
<property name="can_focus">False</property>
<property name="spacing">3</property>
<child>
- <object class="GtkComboBoxText" id="bc_type_combo">
+ <object class="GtkBox" id="bc_menu_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="entry_text_column">0</property>
- <property name="id_column">1</property>
- <items>
- <item translatable="yes">Code 39</item>
- </items>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
@@ -1053,9 +1050,6 @@
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
<object class="GtkGrid" id="bc_key_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -1125,6 +1119,9 @@
<property name="height">1</property>
</packing>
</child>
+ <child>
+ <placeholder/>
+ </child>
</object>
</child>
</object>
diff --git a/glabels/Makefile.am b/glabels/Makefile.am
index a139668..10d8340 100644
--- a/glabels/Makefile.am
+++ b/glabels/Makefile.am
@@ -12,6 +12,9 @@ glabels_4_SOURCES = \
barcode_backends.vala \
barcode_backends/gnu_barcode.vala \
barcode_backends/libbarcode.vapi \
+ barcode_menu.vala \
+ barcode_menu_button.vala \
+ barcode_menu_item.vala \
barcode_style.vala \
color.vala \
color_button.vala \
diff --git a/glabels/barcode_backends.vala b/glabels/barcode_backends.vala
index 8e768a7..28f49dd 100644
--- a/glabels/barcode_backends.vala
+++ b/glabels/barcode_backends.vala
@@ -30,48 +30,56 @@ namespace glabels
private const string DEFAULT_ID = "Code39";
private const string DEFAULT_NAME = _("Code 39");
- private static bool initialized = false;
+
+ private static HashTable<string,string> backend_map;
+
private static HashTable<string,BarcodeStyle> id_map;
private static HashTable<string,BarcodeStyle> name_map;
+ private static bool initialized = false;
+
static construct
{
+ backend_map = new HashTable<string,string>( str_hash, str_equal );
+
id_map = new HashTable<string,BarcodeStyle>( str_hash, str_equal );
name_map = new HashTable<string,BarcodeStyle>( str_hash, str_equal );
- register( "POSTNET", _("POSTNET (any)"),
- false, false, true, false, "12345-6789-12", false, 11 );
+ register_style( "POSTNET", "", _("POSTNET (any)"),
+ false, false, true, false, "12345-6789-12", false, 11 );
- register( "POSTNET-5", _("POSTNET-5 (ZIP only)"),
- false, false, true, false, "12345", false, 5 );
+ register_style( "POSTNET-5", "", _("POSTNET-5 (ZIP only)"),
+ false, false, true, false, "12345", false, 5 );
- register( "POSTNET-9", _("POSTNET-9 (ZIP+4)"),
- false, false, true, false, "12345-6789", false, 9 );
+ register_style( "POSTNET-9", "", _("POSTNET-9 (ZIP+4)"),
+ false, false, true, false, "12345-6789", false, 9 );
- register( "POSTNET-11", _("POSTNET-11 (DPBC)"),
- false, false, true, false, "12345-6789-12", false, 11 );
+ register_style( "POSTNET-11", "", _("POSTNET-11 (DPBC)"),
+ false, false, true, false, "12345-6789-12", false, 11 );
- register( "CEPNET", _("CEPNET"),
- false, false, true, false, "12345-678", false, 8 );
+ register_style( "CEPNET", "", _("CEPNET"),
+ false, false, true, false, "12345-678", false, 8 );
- register( "ONECODE", _("One Code"),
- false, false, true, false, "12345678901234567890", false, 20 );
+ register_style( "ONECODE", "", _("USPS Intelligent Mail"),
+ false, false, true, false, "12345678901234567890", false, 20 );
- register( "Code39", _("Code 39"),
- true, true, true, true, "1234567890", true, 10 );
+ register_style( "Code39", "", _("Code 39"),
+ true, true, true, true, "1234567890", true, 10 );
- register( "Code39Ext", _("Code 39 Extended"),
- true, true, true, true, "1234567890", true, 10 );
+ register_style( "Code39Ext", "", _("Code 39 Extended"),
+ true, true, true, true, "1234567890", true, 10 );
- register( "UPC-A", _("UPC - A"),
- true, false, true, false, "12345678901", false, 11 );
+ register_style( "UPC-A", "", _("UPC-A"),
+ true, false, true, false, "12345678901", false, 11 );
- register( "EAN-13", _("EAN - 13"),
- true, false, true, false, "123456789012", false, 12 );
+ register_style( "EAN-13", "", _("EAN-13"),
+ true, false, true, false, "123456789012", false, 12 );
#if HAVE_LIBBARCODE
+ register_backend( "gnu-barcode", _("GNU Barcode") );
+
glbarcode.Factory.register_type( "gnu-barcode:EAN", typeof(BackendGnuBarcode.Ean) );
glbarcode.Factory.register_type( "gnu-barcode:EAN-8", typeof(BackendGnuBarcode.Ean8) );
glbarcode.Factory.register_type( "gnu-barcode:EAN-8+2", typeof(BackendGnuBarcode.Ean8_2) );
@@ -98,303 +106,310 @@ namespace glabels
glbarcode.Factory.register_type( "gnu-barcode:PLS", typeof(BackendGnuBarcode.Pls) );
glbarcode.Factory.register_type( "gnu-barcode:Code93", typeof(BackendGnuBarcode.Code93) );
- register( "gnu-barcode:EAN", _("GNU-Barcode : EAN (any)"),
- true, true, true, false, "000000000000 00000", false, 17 );
+ register_style( "gnu-barcode:EAN", "gnu-barcode", _("EAN (any)"),
+ true, true, true, false, "000000000000 00000", false, 17 );
- register( "gnu-barcode:EAN-8", _("GNU-Barcode : EAN-8"),
- true, true, true, false, "0000000", false, 7 );
+ register_style( "gnu-barcode:EAN-8", "gnu-barcode", _("EAN-8"),
+ true, true, true, false, "0000000", false, 7 );
- register( "gnu-barcode:EAN-8+2", _("GNU-Barcode : EAN-8 +2"),
- true, true, true, false, "0000000 00", false, 9 );
+ register_style( "gnu-barcode:EAN-8+2", "gnu-barcode", _("EAN-8 +2"),
+ true, true, true, false, "0000000 00", false, 9 );
- register( "gnu-barcode:EAN-8+5", _("GNU-Barcode : EAN-8 +5"),
- true, true, true, false, "0000000 00000", false, 12 );
+ register_style( "gnu-barcode:EAN-8+5", "gnu-barcode", _("EAN-8 +5"),
+ true, true, true, false, "0000000 00000", false, 12 );
- register( "gnu-barcode:EAN-13", _("GNU-Barcode : EAN-13"),
- true, true, true, false, "000000000000", false, 12 );
+ register_style( "gnu-barcode:EAN-13", "gnu-barcode", _("EAN-13"),
+ true, true, true, false, "000000000000", false, 12 );
- register( "gnu-barcode:EAN-13+2", _("GNU-Barcode : EAN-13 +2"),
- true, true, true, false, "000000000000 00", false, 14 );
+ register_style( "gnu-barcode:EAN-13+2", "gnu-barcode", _("EAN-13 +2"),
+ true, true, true, false, "000000000000 00", false, 14 );
- register( "gnu-barcode:EAN-13+5", _("GNU-Barcode : EAN-13 +5"),
- true, true, true, false, "000000000000 00000", false, 17 );
+ register_style( "gnu-barcode:EAN-13+5", "gnu-barcode", _("EAN-13 +5"),
+ true, true, true, false, "000000000000 00000", false, 17 );
- register( "gnu-barcode:UPC", _("GNU-Barcode : UPC (UPC-A or UPC-E)"),
- true, true, true, false, "00000000000 00000", false, 16 );
+ register_style( "gnu-barcode:UPC", "gnu-barcode", _("UPC (UPC-A or UPC-E)"),
+ true, true, true, false, "00000000000 00000", false, 16 );
- register( "gnu-barcode:UPC-A", _("GNU-Barcode : UPC-A"),
- true, true, true, false, "00000000000", false, 11 );
+ register_style( "gnu-barcode:UPC-A", "gnu-barcode", _("UPC-A"),
+ true, true, true, false, "00000000000", false, 11 );
- register( "gnu-barcode:UPC-A+2", _("GNU-Barcode : UPC-A +2"),
- true, true, true, false, "00000000000 00", false, 13 );
+ register_style( "gnu-barcode:UPC-A+2", "gnu-barcode", _("UPC-A +2"),
+ true, true, true, false, "00000000000 00", false, 13 );
- register( "gnu-barcode:UPC-A+5", _("GNU-Barcode : UPC-A +5"),
- true, true, true, false, "00000000000 00000", false, 16 );
+ register_style( "gnu-barcode:UPC-A+5", "gnu-barcode", _("UPC-A +5"),
+ true, true, true, false, "00000000000 00000", false, 16 );
- register( "gnu-barcode:UPC-E", _("GNU-Barcode : UPC-E"),
- true, true, true, false, "000000", false, 6 );
+ register_style( "gnu-barcode:UPC-E", "gnu-barcode", _("UPC-E"),
+ true, true, true, false, "000000", false, 6 );
- register( "gnu-barcode:UPC-E+2", _("GNU-Barcode : UPC-E +2"),
- true, true, true, false, "000000 00", false, 8 );
+ register_style( "gnu-barcode:UPC-E+2", "gnu-barcode", _("UPC-E +2"),
+ true, true, true, false, "000000 00", false, 8 );
- register( "gnu-barcode:UPC-E+5", _("GNU-Barcode : UPC-E +5"),
- true, true, true, false, "000000 00000", false, 11 );
+ register_style( "gnu-barcode:UPC-E+5", "gnu-barcode", _("UPC-E +5"),
+ true, true, true, false, "000000 00000", false, 11 );
- register( "gnu-barcode:ISBN", _("GNU-Barcode : ISBN"),
- true, true, true, true, "0-00000-000-0", false, 10 );
+ register_style( "gnu-barcode:ISBN", "gnu-barcode", _("ISBN"),
+ true, true, true, true, "0-00000-000-0", false, 10 );
- register( "gnu-barcode:ISBN+5", _("GNU-Barcode : ISBN +5"),
- true, true, true, true, "0-00000-000-0 00000", false, 15 );
+ register_style( "gnu-barcode:ISBN+5", "gnu-barcode", _("ISBN +5"),
+ true, true, true, true, "0-00000-000-0 00000", false, 15 );
- register( "gnu-barcode:Code39", _("GNU-Barcode : Code 39"),
- true, true, true, true, "0000000000", true, 10 );
+ register_style( "gnu-barcode:Code39", "gnu-barcode", _("Code 39"),
+ true, true, true, true, "0000000000", true, 10 );
- register( "gnu-barcode:Code128", _("GNU-Barcode : Code 128"),
- true, true, true, true, "0000000000", true, 10 );
+ register_style( "gnu-barcode:Code128", "gnu-barcode", _("Code 128"),
+ true, true, true, true, "0000000000", true, 10 );
- register( "gnu-barcode:Code128C", _("GNU-Barcode : Code 128C"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "gnu-barcode:Code128C", "gnu-barcode", _("Code 128C"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "gnu-barcode:Code128B", _("GNU-Barcode : Code 128B"),
- true, true, true, true, "0000000000", true, 10 );
+ register_style( "gnu-barcode:Code128B", "gnu-barcode", _("Code 128B"),
+ true, true, true, true, "0000000000", true, 10 );
- register( "gnu-barcode:I25", _("GNU-Barcode : Interleaved 2 of 5"),
- true, true, true, true, "0000000000", true, 10 );
+ register_style( "gnu-barcode:I25", "gnu-barcode", _("Interleaved 2 of 5"),
+ true, true, true, true, "0000000000", true, 10 );
- register( "gnu-barcode:CBR", _("GNU-Barcode : Codabar"),
- true, true, true, true, "0000000000", true, 10 );
+ register_style( "gnu-barcode:CBR", "gnu-barcode", _("Codabar"),
+ true, true, true, true, "0000000000", true, 10 );
- register( "gnu-barcode:MSI", _("GNU-Barcode : MSI"),
- true, true, true, true, "0000000000", true, 10 );
+ register_style( "gnu-barcode:MSI", "gnu-barcode", _("MSI"),
+ true, true, true, true, "0000000000", true, 10 );
- register( "gnu-barcode:PLS", _("GNU-Barcode : Plessey"),
- true, true, true, true, "0000000000", true, 10 );
+ register_style( "gnu-barcode:PLS", "gnu-barcode", _("Plessey"),
+ true, true, true, true, "0000000000", true, 10 );
- register( "gnu-barcode:Code93", _("GNU-Barcode : Code 93"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "gnu-barcode:Code93", "gnu-barcode", _("Code 93"),
+ true, true, true, false, "0000000000", true, 10 );
#endif
#if HAVE_LIBZINT
- register( "zint:AUSP", _("zint : Australia Post Standard"),
- false, false, true, false, "12345678901234567890123", true, 23 );
+ register_backend( "zint", _("Zint") );
- register( "zint:AUSRP", _("zint : Australia Post Reply Paid"),
- false, false, true, false, "12345678", true, 8 );
+ register_style( "zint:AUSP", "zint", _("Australia Post Standard"),
+ false, false, true, false, "12345678901234567890123", true, 23 );
- register( "zint:AUSRT", _("zint : Australia Post Route Code"),
- false, false, true, false, "12345678", true, 8 );
+ register_style( "zint:AUSRP", "zint", _("Australia Post Reply Paid"),
+ false, false, true, false, "12345678", true, 8 );
- register( "zint:AUSRD", _("zint : Australia Post Redirect"),
- false, false, true, false, "12345678", true, 8 );
+ register_style( "zint:AUSRT", "zint", _("Australia Post Route Code"),
+ false, false, true, false, "12345678", true, 8 );
- register( "zint:AZTEC", _("zint : Aztec Code"),
- false, false, true, false, "1234567890", true, 10 );
+ register_style( "zint:AUSRD", "zint", _("Australia Post Redirect"),
+ false, false, true, false, "12345678", true, 8 );
+
+ register_style( "zint:AZTEC", "zint", _("Aztec Code"),
+ false, false, true, false, "1234567890", true, 10 );
- register( "zint:AZRUN", _("zint : Aztec Rune"),
- false, false, true, false, "255", true, 3 );
+ register_style( "zint:AZRUN", "zint", _("Aztec Rune"),
+ false, false, true, false, "255", true, 3 );
- register( "zint:CBR", _("zint : Codabar"),
- true, true, true, false, "ABCDABCDAB", true, 10 );
+ register_style( "zint:CBR", "zint", _("Codabar"),
+ true, true, true, false, "ABCDABCDAB", true, 10 );
- register( "zint:Code1", _("zint : Code One"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:Code1", "zint", _("Code One"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:Code11", _("zint : Code 11"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:Code11", "zint", _("Code 11"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:C16K", _("zint : Code 16K"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:C16K", "zint", _("Code 16K"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:C25M", _("zint : Code 2 of 5 Matrix"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:C25M", "zint", _("Code 2 of 5 Matrix"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:C25I", _("zint : Code 2 of 5 IATA"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:C25I", "zint", _("Code 2 of 5 IATA"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:C25DL", _("zint : Code 2 of 5 Data Logic"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:C25DL", "zint", _("Code 2 of 5 Data Logic"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:Code32", _("zint : Code 32 (Italian Pharmacode)"),
- true, true, true, false, "12345678", true, 8 );
+ register_style( "zint:Code32", "zint", _("Code 32 (Italian Pharmacode)"),
+ true, true, true, false, "12345678", true, 8 );
- register( "zint:Code39", _("zint : Code 39"),
- true, true, false, false, "0000000000", true, 10 );
+ register_style( "zint:Code39", "zint", _("Code 39"),
+ true, true, false, false, "0000000000", true, 10 );
- register( "zint:Code39E", _("zint : Code 39 Extended"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:Code39E", "zint", _("Code 39 Extended"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:Code49", _("zint : Code 49"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:Code49", "zint", _("Code 49"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:Code93", _("zint : Code 93"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:Code93", "zint", _("Code 93"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:Code128", _("zint : Code 128"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:Code128", "zint", _("Code 128"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:Code128B", _("zint : Code 128 (Mode C supression)"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:Code128B", "zint", _("Code 128 (Mode C supression)"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:DAFT", _("zint : DAFT Code"),
- false, false, false, false, "DAFTDAFTDAFTDAFT", true, 16 );
+ register_style( "zint:DAFT", "zint", _("DAFT Code"),
+ false, false, false, false, "DAFTDAFTDAFTDAFT", true, 16 );
- register( "zint:DMTX", _("zint : Data Matrix"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:DMTX", "zint", _("Data Matrix"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:DPL", _("zint : Deutsche Post Leitcode"),
- true, true, true, false, "1234567890123", true, 13 );
+ register_style( "zint:DPL", "zint", _("Deutsche Post Leitcode"),
+ true, true, true, false, "1234567890123", true, 13 );
- register( "zint:DPI", _("zint : Deutsche Post Identcode"),
- true, true, true, false, "12345678901", true, 11 );
+ register_style( "zint:DPI", "zint", _("Deutsche Post Identcode"),
+ true, true, true, false, "12345678901", true, 11 );
- register( "zint:KIX", _("zint : Dutch Post KIX Code"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:KIX", "zint", _("Dutch Post KIX Code"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:EAN", _("zint : EAN"),
- true, true, true, false, "1234567890123", false, 13 );
+ register_style( "zint:EAN", "zint", _("EAN"),
+ true, true, true, false, "1234567890123", false, 13 );
- register( "zint:GMTX", _("zint : Grid Matrix"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:GMTX", "zint", _("Grid Matrix"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:GS1-128", _("zint : GS1-128"),
- true, true, true, false, "[01]12345678901234", false, 18 );
+ register_style( "zint:GS1-128", "zint", _("GS1-128"),
+ true, true, true, false, "[01]12345678901234", false, 18 );
- register( "zint:RSS14", _("zint : GS1 DataBar-14"),
- true, true, true, false, "1234567890123", true, 13 );
+ register_style( "zint:RSS14", "zint", _("GS1 DataBar-14"),
+ true, true, true, false, "1234567890123", true, 13 );
- register( "zint:RSSLTD", "GS1 DataBar-14 Limited",
- true, true, true, false, "1234567890123", true, 13 );
+ register_style( "zint:RSSLTD", "GS1 DataBar-14 Limited",
+ true, true, true, false, "1234567890123", true, 13 );
- register( "zint:RSSEXP", "GS1 DataBar Extended",
- true, true, true, false, "[01]12345678901234", false, 18 );
+ register_style( "zint:RSSEXP", "GS1 DataBar Extended",
+ true, true, true, false, "[01]12345678901234", false, 18 );
- register( "zint:RSSS", _("zint : GS1 DataBar-14 Stacked"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:RSSS", "zint", _("GS1 DataBar-14 Stacked"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:RSSSO", _("zint : GS1 DataBar-14 Stacked Omni."),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:RSSSO", "zint", _("GS1 DataBar-14 Stacked Omni."),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:RSSSE", _("zint : GS1 DataBar Extended Stacked"),
- false, false, true, false, "[01]12345678901234", false, 18 );
+ register_style( "zint:RSSSE", "zint", _("GS1 DataBar Extended Stacked"),
+ false, false, true, false, "[01]12345678901234", false, 18 );
- register( "zint:HIBC128", _("zint : HIBC Code 128"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:HIBC128", "zint", _("HIBC Code 128"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:HIBC39", _("zint : HIBC Code 39"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:HIBC39", "zint", _("HIBC Code 39"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:HIBCDM", _("zint : HIBC Data Matrix"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:HIBCDM", "zint", _("HIBC Data Matrix"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:HIBCQR", _("zint : HIBC QR Code"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:HIBCQR", "zint", _("HIBC QR Code"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:HIBCPDF", _("zint : HIBC PDF417"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:HIBCPDF", "zint", _("HIBC PDF417"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:HIBCMPDF", _("zint : HIBC Micro PDF417"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:HIBCMPDF", "zint", _("HIBC Micro PDF417"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:HIBCAZ", _("zint : HIBC Aztec Code"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:HIBCAZ", "zint", _("HIBC Aztec Code"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:I25", _("zint : Interleaved 2 of 5"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:I25", "zint", _("Interleaved 2 of 5"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:ISBN", _("zint : ISBN"),
- true, true, true, false, "123456789", false, 9 );
+ register_style( "zint:ISBN", "zint", _("ISBN"),
+ true, true, true, false, "123456789", false, 9 );
- register( "zint:ITF14", _("zint : ITF-14"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:ITF14", "zint", _("ITF-14"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:JAPAN", _("zint : Japanese Postal"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:JAPAN", "zint", _("Japanese Postal"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:KOREA", _("zint : Korean Postal"),
- true, true, true, false, "123456", false, 6 );
+ register_style( "zint:KOREA", "zint", _("Korean Postal"),
+ true, true, true, false, "123456", false, 6 );
- register( "zint:LOGM", _("zint : LOGMARS"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:LOGM", "zint", _("LOGMARS"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:MAXI", _("zint : Maxicode"),
- false, false, false, false, "0000000000", true, 10 );
+ register_style( "zint:MAXI", "zint", _("Maxicode"),
+ false, false, false, false, "0000000000", true, 10 );
- register( "zint:MPDF", _("zint : Micro PDF417"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:MPDF", "zint", _("Micro PDF417"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:MQR", _("zint : Micro QR Code"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:MQR", "zint", _("Micro QR Code"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:MSI", _("zint : MSI Plessey"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:MSI", "zint", _("MSI Plessey"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:NVE", _("zint : NVE-18"),
- true, true, true, false, "12345678901234567", false, 17 );
+ register_style( "zint:NVE", "zint", _("NVE-18"),
+ true, true, true, false, "12345678901234567", false, 17 );
- register( "zint:PDF", _("zint : PDF417"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:PDF", "zint", _("PDF417"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:PDFT", _("zint : PDF417 Truncated"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:PDFT", "zint", _("PDF417 Truncated"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:PLAN", _("zint : PLANET"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:PLAN", "zint", _("PLANET"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:POSTNET", _("zint : PostNet"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:POSTNET", "zint", _("PostNet"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:PHARMA", _("zint : Pharmacode"),
- false, false, true, false, "123456", false, 6 );
+ register_style( "zint:PHARMA", "zint", _("Pharmacode"),
+ false, false, true, false, "123456", false, 6 );
- register( "zint:PHARMA2", _("zint : Pharmacode 2-track"),
- false, false, true, false, "12345678", false, 8 );
+ register_style( "zint:PHARMA2", "zint", _("Pharmacode 2-track"),
+ false, false, true, false, "12345678", false, 8 );
- register( "zint:PZN", _("zint : Pharmazentral Nummer (PZN)"),
- true, true, true, false, "123456", false, 6 );
+ register_style( "zint:PZN", "zint", _("Pharmazentral Nummer (PZN)"),
+ true, true, true, false, "123456", false, 6 );
- register( "zint:QR", _("zint : QR Code"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:QR", "zint", _("QR Code"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:RM4", _("zint : Royal Mail 4-State"),
- false, false, true, false, "0000000000", true, 10 );
+ register_style( "zint:RM4", "zint", _("Royal Mail 4-State"),
+ false, false, true, false, "0000000000", true, 10 );
- register( "zint:TELE", _("zint : Telepen"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:TELE", "zint", _("Telepen"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:TELEX", _("zint : Telepen Numeric"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:TELEX", "zint", _("Telepen Numeric"),
+ true, true, true, false, "0000000000", true, 10 );
- register( "zint:UPC-A", _("zint : UPC-A"),
- true, true, true, false, "12345678901", false, 11 );
+ register_style( "zint:UPC-A", "zint", _("UPC-A"),
+ true, true, true, false, "12345678901", false, 11 );
- register( "zint:UPC-E", _("zint : UPC-E"),
- true, true, true, false, "1234567", false, 7 );
+ register_style( "zint:UPC-E", "zint", _("UPC-E"),
+ true, true, true, false, "1234567", false, 7 );
- register( "zint:USPS", _("zint : USPS One Code"),
- false, false, true, false, "12345678901234567890", true, 20 );
+ register_style( "zint:USPS", "zint", _("USPS One Code"),
+ false, false, true, false, "12345678901234567890", true, 20 );
- register( "zint:PLS", _("zint : UK Plessey"),
- true, true, true, false, "0000000000", true, 10 );
+ register_style( "zint:PLS", "zint", _("UK Plessey"),
+ true, true, true, false, "0000000000", true, 10 );
#endif
#if HAVE_LIBIEC16022
- register( "iec16022:IEC16022", _("IEC16022 : IEC16022 (DataMatrix)"),
- false, false, true, false, "12345678", true, 8 );
+ register_backend( "iec16022", _("IEC16022") );
+
+ register_style( "iec16022:IEC16022", "iec16022", _("DataMatrix"),
+ false, false, true, false, "12345678", true, 8 );
#endif
#if HAVE_LIBQRENCODE
- register( "qrencode:IEC18004", _("qrencode : IEC18004 (QRCode)"),
- false, false, true, false, "12345678", true, 8 );
+ register_backend( "qrencode", _("QREncode") );
+
+ register_style( "qrencode:IEC18004", "qrencode", _("IEC18004 (QRCode)"),
+ false, false, true, false, "12345678", true, 8 );
#endif
initialized = true;
+
}
@@ -411,17 +426,24 @@ namespace glabels
}
- private static void register ( string id,
- string name,
- bool can_text,
- bool text_optional,
- bool can_checksum,
- bool checksum_optional,
- string default_digits,
- bool can_freeform,
- int prefered_n )
+ private static void register_backend( string id, string name )
{
- BarcodeStyle style = new BarcodeStyle( id, name,
+ backend_map.insert( id, name );
+ }
+
+
+ private static void register_style ( string id,
+ string backend_id,
+ string name,
+ bool can_text,
+ bool text_optional,
+ bool can_checksum,
+ bool checksum_optional,
+ string default_digits,
+ bool can_freeform,
+ int prefered_n )
+ {
+ BarcodeStyle style = new BarcodeStyle( id, backend_id, name,
can_text, text_optional, can_checksum, checksum_optional,
default_digits, can_freeform, prefered_n );
@@ -430,6 +452,19 @@ namespace glabels
}
+ public static string backend_id_to_name( string id )
+ {
+ if ( backend_map.contains( id ) )
+ {
+ return backend_map.lookup( id );
+ }
+ else
+ {
+ return ""; /* Built-in backend. */
+ }
+ }
+
+
public static BarcodeStyle? lookup_style_from_name( string name )
{
if ( name_map.contains( name ) )
@@ -493,6 +528,22 @@ namespace glabels
return list;
}
+
+ public static List<weak string> get_id_list()
+ {
+ List<weak string> list = id_map.get_keys();
+ list.sort( strcmp );
+ return list;
+ }
+
+
+ public static List<weak string> get_backend_id_list()
+ {
+ List<weak string> list = backend_map.get_keys();
+ list.sort( strcmp );
+ return list;
+ }
+
}
}
diff --git a/glabels/barcode_menu.vala b/glabels/barcode_menu.vala
new file mode 100644
index 0000000..fe04251
--- /dev/null
+++ b/glabels/barcode_menu.vala
@@ -0,0 +1,97 @@
+/* barcode_menu.vala
+ *
+ * Copyright (C) 2012 Jim Evins <evins snaught com>
+ *
+ * This file is part of gLabels.
+ *
+ * gLabels is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * gLabels is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+using GLib;
+
+namespace glabels
+{
+
+ public class BarcodeMenu : Gtk.Menu
+ {
+
+ public signal void style_changed();
+
+
+ public BarcodeStyle bc_style;
+
+
+ public BarcodeMenu()
+ {
+ List<weak string> id_list = BarcodeBackends.get_id_list();
+
+ foreach ( string id in id_list )
+ {
+ BarcodeStyle bc_style = BarcodeBackends.lookup_style_from_id( id );
+ if ( bc_style.backend_id == "" )
+ {
+ BarcodeMenuItem bc_menu_item = new BarcodeMenuItem( bc_style );
+ bc_menu_item.show();
+ bc_menu_item.activate.connect( on_menu_item_activated );
+
+ append( bc_menu_item );
+ }
+ }
+
+ Gtk.MenuItem separator_item = new Gtk.SeparatorMenuItem();
+ separator_item.show();
+ append( separator_item );
+
+ foreach ( string backend_id in BarcodeBackends.get_backend_id_list() )
+ {
+ string backend_name = BarcodeBackends.backend_id_to_name( backend_id );
+ Gtk.MenuItem menu_item = new Gtk.MenuItem.with_label( backend_name );
+ menu_item.show();
+ append( menu_item );
+
+ Gtk.Menu sub_menu = new Gtk.Menu();
+ menu_item.set_submenu( sub_menu );
+
+ foreach ( string id in id_list )
+ {
+ BarcodeStyle bc_style = BarcodeBackends.lookup_style_from_id( id );
+ if ( bc_style.backend_id == backend_id )
+ {
+ BarcodeMenuItem bc_menu_item = new BarcodeMenuItem( bc_style );
+ bc_menu_item.show();
+ bc_menu_item.activate.connect( on_menu_item_activated );
+
+ sub_menu.append( bc_menu_item );
+ }
+ }
+
+ }
+
+ }
+
+
+ private void on_menu_item_activated( Gtk.MenuItem menu_item )
+ {
+ BarcodeMenuItem bc_menu_item = (BarcodeMenuItem)menu_item;
+ bc_style = bc_menu_item.bc_style;
+ style_changed();
+ }
+
+
+ }
+
+}
+
+
diff --git a/glabels/barcode_menu_button.vala b/glabels/barcode_menu_button.vala
new file mode 100644
index 0000000..bc5d3d9
--- /dev/null
+++ b/glabels/barcode_menu_button.vala
@@ -0,0 +1,160 @@
+/* barcode_menu_button.vala
+ *
+ * Copyright (C) 2012 Jim Evins <evins snaught com>
+ *
+ * This file is part of gLabels.
+ *
+ * gLabels is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * gLabels is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+using GLib;
+
+namespace glabels
+{
+
+ public class BarcodeMenuButton : Gtk.ToggleButton
+ {
+
+ public BarcodeStyle bc_style
+ {
+ get { return _bc_style; }
+
+ set
+ {
+ _bc_style = value;
+ if ( bc_style.backend_id == "" )
+ {
+ bc_label.set_text( bc_style.name );
+ }
+ else
+ {
+ bc_label.set_text( "%s : %s".printf( BarcodeBackends.backend_id_to_name( bc_style.backend_id ),
+ bc_style.name ) );
+ }
+
+ style_changed();
+ }
+ }
+ BarcodeStyle _bc_style;
+
+
+ private Gtk.Label bc_label;
+ private BarcodeMenu menu;
+
+ public signal void style_changed();
+
+
+ public BarcodeMenuButton()
+ {
+ Gtk.Box hbox = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 3 );
+ this.add( hbox );
+
+ bc_label = new Gtk.Label( "" );
+ bc_label.set_alignment( 0, 0.5f );
+ hbox.pack_start( bc_label, true, true, 0 );
+
+ Gtk.Arrow arrow = new Gtk.Arrow( Gtk.ArrowType.DOWN, Gtk.ShadowType.IN );
+ hbox.pack_end( arrow, false, false, 0 );
+
+ bc_style = BarcodeBackends.lookup_style_from_id( "" ); /* Default style */
+
+ menu = new BarcodeMenu();
+
+ button_press_event.connect( on_button_press_event );
+ menu.style_changed.connect( on_menu_style_changed );
+ menu.selection_done.connect( on_menu_selection_done );
+ }
+
+
+ private void menu_position_function( Gtk.Menu menu,
+ out int x,
+ out int y,
+ out bool push_in )
+ {
+ Gdk.Screen screen = this.get_screen();
+ int w_screen = screen.get_width();
+ int h_screen = screen.get_height();
+
+ Gdk.Window window = this.get_window();
+ int x_window, y_window;
+ window.get_origin( out x_window, out y_window );
+
+ Gtk.Allocation allocation;
+ this.get_allocation( out allocation );
+ int x_this = allocation.x;
+ int y_this = allocation.y;
+ int h_this = allocation.height;
+
+ int w_menu, h_menu;
+ menu.get_size_request( out w_menu, out h_menu );
+
+ x = x_window + x_this;
+ y = y_window + y_this + h_this;
+
+ if ( (y + h_menu) > h_screen )
+ {
+ y = y_window + y_this - h_menu;
+
+ if ( y < 0 )
+ {
+ y = h_screen - h_menu;
+ }
+ }
+
+ if ( (x + w_menu) > w_screen )
+ {
+ x = w_screen - w_menu;
+ }
+
+ push_in = true;
+ }
+
+
+ private bool on_button_press_event( Gdk.EventButton event )
+ {
+ switch (event.button)
+ {
+
+ case 1:
+ set_active( true );
+ menu.popup( null, null, menu_position_function, event.button, event.time );
+ break;
+
+ default:
+ break;
+
+ }
+
+ return false;
+ }
+
+
+ private void on_menu_style_changed()
+ {
+ bc_style = menu.bc_style;
+ }
+
+
+ private void on_menu_selection_done()
+ {
+ this.set_active( false );
+ }
+
+
+ }
+
+}
+
+
diff --git a/glabels/barcode_menu_item.vala b/glabels/barcode_menu_item.vala
new file mode 100644
index 0000000..1060a04
--- /dev/null
+++ b/glabels/barcode_menu_item.vala
@@ -0,0 +1,41 @@
+/* barcode_menu_item.vala
+ *
+ * Copyright (C) 2012 Jim Evins <evins snaught com>
+ *
+ * This file is part of gLabels.
+ *
+ * gLabels is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * gLabels is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+using GLib;
+
+namespace glabels
+{
+
+ public class BarcodeMenuItem : Gtk.MenuItem
+ {
+ public BarcodeStyle bc_style { get; private set; }
+
+ public BarcodeMenuItem( BarcodeStyle bc_style )
+ {
+ this.bc_style = bc_style;
+
+ set_label( bc_style.name );
+ }
+
+ }
+
+}
+
diff --git a/glabels/barcode_style.vala b/glabels/barcode_style.vala
index f69e681..05c4933 100644
--- a/glabels/barcode_style.vala
+++ b/glabels/barcode_style.vala
@@ -28,6 +28,7 @@ namespace glabels
{
public string id { get; private set; }
+ public string backend_id { get; private set; }
public string name { get; private set; }
public bool can_text { get; private set; }
public bool text_optional { get; private set; }
@@ -39,6 +40,7 @@ namespace glabels
public BarcodeStyle ( string id,
+ string backend_id,
string name,
bool can_text,
bool text_optional,
@@ -49,6 +51,7 @@ namespace glabels
int prefered_n )
{
this.id = id;
+ this.backend_id = backend_id;
this.name = name;
this.can_text = can_text;
this.text_optional = text_optional;
diff --git a/glabels/label_object.vala b/glabels/label_object.vala
index 0ca8ffa..8b7eec4 100644
--- a/glabels/label_object.vala
+++ b/glabels/label_object.vala
@@ -173,12 +173,11 @@ namespace glabels
* Barcode parameters interface
*/
public virtual TextNode bc_data_node { get; set; }
- public virtual string bc_type { get; set; }
+ public virtual BarcodeStyle bc_style { get; set; }
public virtual bool bc_text_flag { get; set; }
public virtual bool bc_checksum_flag { get; set; }
public virtual int bc_format_digits { get; set; }
public virtual ColorNode bc_color_node { get; set; }
- public virtual BarcodeStyle bc_style { get; set; }
/**
diff --git a/glabels/label_object_barcode.vala b/glabels/label_object_barcode.vala
index 2be1716..df8ff1a 100644
--- a/glabels/label_object_barcode.vala
+++ b/glabels/label_object_barcode.vala
@@ -123,24 +123,20 @@ namespace glabels
/**
- * Barcode type
+ * Style information
*/
- public override string bc_type
+ public override BarcodeStyle bc_style
{
- get { return _bc_type; }
+ get { return _bc_style; }
set
{
- if ( _bc_type != value )
- {
- _bc_type = value;
- update_cached_barcode();
- changed();
- }
+ _bc_style = value;
+ update_cached_barcode();
+ changed();
}
-
}
- private string _bc_type;
+ private BarcodeStyle _bc_style;
/**
@@ -223,12 +219,6 @@ namespace glabels
private ColorNode _bc_color_node;
- /**
- * Style information
- */
- public override BarcodeStyle bc_style { get; private set; }
-
-
public LabelObjectBarcode()
{
handles.append( new HandleSouthEast( this ) );
@@ -245,7 +235,6 @@ namespace glabels
Prefs prefs = new Prefs();
_bc_style = BarcodeBackends.lookup_style_from_id( "Code39" );
- _bc_type = _bc_style.id;
_bc_text_flag = _bc_style.can_text;
_bc_checksum_flag = _bc_style.can_checksum;
_bc_format_digits = _bc_style.prefered_n;
@@ -283,7 +272,7 @@ namespace glabels
{
string text = bc_data_node.expand( record );
- glbarcode.Barcode bc = glbarcode.Factory.create_barcode( bc_type, bc_text_flag, bc_checksum_flag, w, h, text );
+ glbarcode.Barcode bc = glbarcode.Factory.create_barcode( bc_style.id, bc_text_flag, bc_checksum_flag, w, h, text );
if ( bc != null )
{
@@ -406,8 +395,6 @@ namespace glabels
{
string data;
- _bc_style = BarcodeBackends.lookup_style_from_id( bc_type );
-
if ( bc_data_node.field_flag )
{
data = _bc_style.get_example_digits( bc_format_digits );
@@ -417,14 +404,14 @@ namespace glabels
data = bc_data_node.expand( null );
}
- cached_bc = glbarcode.Factory.create_barcode( bc_type, bc_text_flag, bc_checksum_flag, _w_raw, _h_raw, data );
+ cached_bc = glbarcode.Factory.create_barcode( bc_style.id, bc_text_flag, bc_checksum_flag, _w_raw, _h_raw, data );
if ( (cached_bc == null) || !cached_bc.is_data_valid )
{
/* Try again with default digits, but don't save -- just extract size. */
data = _bc_style.get_example_digits( bc_format_digits );
- glbarcode.Barcode bc = glbarcode.Factory.create_barcode( bc_type, bc_text_flag, bc_checksum_flag, _w_raw, _h_raw, data );
+ glbarcode.Barcode bc = glbarcode.Factory.create_barcode( bc_style.id, bc_text_flag, bc_checksum_flag, _w_raw, _h_raw, data );
if ( bc != null )
{
diff --git a/glabels/object_editor.vala b/glabels/object_editor.vala
index f96f181..cdb9187 100644
--- a/glabels/object_editor.vala
+++ b/glabels/object_editor.vala
@@ -65,26 +65,27 @@ namespace glabels
private Gtk.Box text_insert_field_box;
private FieldButton text_insert_field_button;
- private Gtk.RadioButton image_file_radio;
- private Gtk.RadioButton image_key_radio;
- private Gtk.FileChooserButton image_filebutton;
- private Gtk.Box image_key_box;
- private FieldButton image_key_button;
-
- private Gtk.ComboBoxText bc_type_combo;
- private Gtk.CheckButton bc_show_text_check;
- private Gtk.CheckButton bc_checksum_check;
- private Gtk.Box bc_color_box;
- private ColorButton bc_color_button;
- private Gtk.RadioButton bc_literal_radio;
- private Gtk.RadioButton bc_key_radio;
- private Gtk.TextView bc_data_textview;
- private Gtk.TextBuffer bc_data_textbuffer;
- private Gtk.Box bc_key_box;
- private FieldButton bc_key_button;
- private Gtk.Grid bc_key_grid;
- private Gtk.Label bc_format_label;
- private Gtk.SpinButton bc_digits_spin;
+ private Gtk.RadioButton image_file_radio;
+ private Gtk.RadioButton image_key_radio;
+ private Gtk.FileChooserButton image_filebutton;
+ private Gtk.Box image_key_box;
+ private FieldButton image_key_button;
+
+ private Gtk.Box bc_menu_box;
+ private BarcodeMenuButton bc_menu_button;
+ private Gtk.CheckButton bc_show_text_check;
+ private Gtk.CheckButton bc_checksum_check;
+ private Gtk.Box bc_color_box;
+ private ColorButton bc_color_button;
+ private Gtk.RadioButton bc_literal_radio;
+ private Gtk.RadioButton bc_key_radio;
+ private Gtk.TextView bc_data_textview;
+ private Gtk.TextBuffer bc_data_textbuffer;
+ private Gtk.Box bc_key_box;
+ private FieldButton bc_key_button;
+ private Gtk.Grid bc_key_grid;
+ private Gtk.Label bc_format_label;
+ private Gtk.SpinButton bc_digits_spin;
private Gtk.SpinButton line_width_spin;
private Gtk.Box line_color_box;
@@ -142,7 +143,7 @@ namespace glabels
private ulong sigid_image_filebutton_selection_changed;
private ulong sigid_image_key_button_changed;
- private ulong sigid_bc_type_combo_changed;
+ private ulong sigid_bc_menu_button_style_changed;
private ulong sigid_bc_show_text_check_toggled;
private ulong sigid_bc_checksum_check_toggled;
private ulong sigid_bc_color_button_changed;
@@ -290,7 +291,7 @@ namespace glabels
/* Barcode widgets. */
- bc_type_combo = builder.get_object( "bc_type_combo" ) as Gtk.ComboBoxText;
+ bc_menu_box = builder.get_object( "bc_menu_box" ) as Gtk.Box;
bc_show_text_check = builder.get_object( "bc_show_text_check" ) as Gtk.CheckButton;
bc_checksum_check = builder.get_object( "bc_checksum_check" ) as Gtk.CheckButton;
bc_color_box = builder.get_object( "bc_color_box" ) as Gtk.Box;
@@ -302,6 +303,9 @@ namespace glabels
bc_format_label = builder.get_object( "bc_format_label" ) as Gtk.Label;
bc_digits_spin = builder.get_object( "bc_digits_spin" ) as Gtk.SpinButton;
+ bc_menu_button = new BarcodeMenuButton();
+ bc_menu_box.pack_start( bc_menu_button, true, true, 0 );
+
bc_color_button = new ColorButton( _("Default"), Color.black(), Color.black() );
bc_color_box.pack_start( bc_color_button, true, true, 0 );
@@ -311,9 +315,8 @@ namespace glabels
bc_key_button = new FieldButton( null );
bc_key_box.pack_start( bc_key_button, true, true, 0 );
- ComboUtil.load_strings( bc_type_combo, BarcodeBackends.get_name_list() );
-
- sigid_bc_type_combo_changed = bc_type_combo.changed.connect( on_bc_type_combo_changed );
+ sigid_bc_menu_button_style_changed =
+ bc_menu_button.style_changed.connect( on_bc_menu_button_style_changed );
sigid_bc_show_text_check_toggled =
bc_show_text_check.toggled.connect( on_bc_show_text_check_toggled );
sigid_bc_checksum_check_toggled =
@@ -592,7 +595,7 @@ namespace glabels
load_text_textview();
load_image_filebutton();
load_image_key_button();
- load_bc_type_combo();
+ load_bc_menu_button();
load_bc_show_text_check();
load_bc_checksum_check();
load_bc_color_button();
@@ -1172,26 +1175,25 @@ namespace glabels
/******************************
- * bc_type_combo
+ * bc_menu_button
******************************/
- private void on_bc_type_combo_changed()
+ private void on_bc_menu_button_style_changed()
{
if ( object != null )
{
- object.bc_type = BarcodeBackends.name_to_id( bc_type_combo.get_active_text() );
+ object.bc_style = bc_menu_button.bc_style;
}
}
- private void load_bc_type_combo()
+ private void load_bc_menu_button()
{
if ( (object != null) && object is LabelObjectBarcode )
{
- GLib.SignalHandler.block( (void*)bc_type_combo, sigid_bc_type_combo_changed );
+ GLib.SignalHandler.block( (void*)bc_menu_button, sigid_bc_menu_button_style_changed );
- ComboUtil.set_active_text( bc_type_combo,
- BarcodeBackends.id_to_name( object.bc_type ) );
+ bc_menu_button.bc_style = object.bc_style;
- GLib.SignalHandler.unblock( (void*)bc_type_combo, sigid_bc_type_combo_changed );
+ GLib.SignalHandler.unblock( (void*)bc_menu_button, sigid_bc_menu_button_style_changed );
}
}
diff --git a/glabels/xml_label.vala b/glabels/xml_label.vala
index 51635b0..d645536 100644
--- a/glabels/xml_label.vala
+++ b/glabels/xml_label.vala
@@ -393,11 +393,11 @@ namespace glabels
string style_id = XmlUtil.get_prop_string( node, "style", "Code39" );
if ( (backend_id != null) && (backend_id != "built-in") )
{
- object.bc_type = "%s:%s".printf( backend_id, style_id );
+ object.bc_style = BarcodeBackends.lookup_style_from_id( "%s:%s".printf( backend_id, style_id ) );
}
else
{
- object.bc_type = style_id;
+ object.bc_style = BarcodeBackends.lookup_style_from_id( style_id );
}
object.bc_text_flag = XmlUtil.get_prop_bool( node, "text", false );
object.bc_checksum_flag = XmlUtil.get_prop_bool( node, "checksum", true );
@@ -940,16 +940,16 @@ namespace glabels
XmlUtil.set_prop_length( node, "h", object.h_raw );
/* style attrs */
- if ( object.bc_type.contains( ":" ) )
+ if ( object.bc_style.backend_id != "" )
{
- string[] token = object.bc_type.split( ":", 2 );
+ string[] token = object.bc_style.id.split( ":", 2 );
XmlUtil.set_prop_string( node, "backend", token[0] );
XmlUtil.set_prop_string( node, "style", token[1] );
}
else
{
XmlUtil.set_prop_string( node, "backend", "built-in" );
- XmlUtil.set_prop_string( node, "style", object.bc_type );
+ XmlUtil.set_prop_string( node, "style", object.bc_style.id );
}
XmlUtil.set_prop_bool( node, "text", object.bc_text_flag );
XmlUtil.set_prop_bool( node, "checksum", object.bc_text_flag );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]