[moserial] move more combo box item definitions out of glade and into the code



commit ded8242efa19c1893d3d5e0e5ccf7ab64592fc94
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date:   Fri Aug 19 11:40:28 2011 -0400

    move more combo box item definitions out of glade and into the code

 data/glade/moserial.glade     |   10 ------
 data/glade/moserial.ui        |   72 -----------------------------------------
 src/ReceiveChooserDialog.vala |    5 ++-
 src/RecordDialog.vala         |    6 +++-
 src/Rzwrapper.vala            |    4 ++
 src/SendChooserDialog.vala    |    5 ++-
 src/SerialStreamRecorder.vala |    7 +++-
 src/Szwrapper.vala            |    5 +++
 8 files changed, 28 insertions(+), 86 deletions(-)
---
diff --git a/data/glade/moserial.glade b/data/glade/moserial.glade
index 31cb9ec..a2ab93e 100644
--- a/data/glade/moserial.glade
+++ b/data/glade/moserial.glade
@@ -1114,9 +1114,6 @@
             <child>
               <widget class="GtkComboBox" id="record_stream">
                 <property name="visible">True</property>
-                <property name="items" translatable="yes">Incoming
-Outgoing
-Incoming and Outgoing</property>
               </widget>
               <packing>
                 <property name="expand">False</property>
@@ -1180,9 +1177,6 @@ Incoming and Outgoing</property>
             <child>
               <widget class="GtkComboBox" id="receive_chooser_protocol">
                 <property name="visible">True</property>
-                <property name="items" translatable="yes">Xmodem
-Ymodem
-Zmodem</property>
               </widget>
               <packing>
                 <property name="expand">False</property>
@@ -1316,10 +1310,6 @@ Zmodem</property>
             <child>
               <widget class="GtkComboBox" id="send_chooser_protocol">
                 <property name="visible">True</property>
-                <property name="items" translatable="yes">Xmodem
-Ymodem
-Zmodem
-None (straight binary)</property>
               </widget>
               <packing>
                 <property name="expand">False</property>
diff --git a/data/glade/moserial.ui b/data/glade/moserial.ui
index cc5f2c1..3248e59 100644
--- a/data/glade/moserial.ui
+++ b/data/glade/moserial.ui
@@ -8,57 +8,6 @@
     <property name="page_size">0</property>
     <property name="value">60</property>
   </object>
-  <object class="GtkListStore" id="model1">
-    <columns>
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">Incoming</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Outgoing</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Incoming and Outgoing</col>
-      </row>
-    </data>
-  </object>
-  <object class="GtkListStore" id="model2">
-    <columns>
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">Xmodem</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Ymodem</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Zmodem</col>
-      </row>
-    </data>
-  </object>
-  <object class="GtkListStore" id="model3">
-    <columns>
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">Xmodem</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Ymodem</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Zmodem</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">None (straight binary)</col>
-      </row>
-    </data>
-  </object>
   <object class="GtkUIManager" id="uimanager1">
     <child>
       <object class="GtkActionGroup" id="actiongroup1">
@@ -1117,13 +1066,6 @@
             <child>
               <object class="GtkComboBox" id="record_stream">
                 <property name="visible">True</property>
-                <property name="model">model1</property>
-                <child>
-                  <object class="GtkCellRendererText" id="renderer1"/>
-                  <attributes>
-                    <attribute name="text">0</attribute>
-                  </attributes>
-                </child>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -1187,13 +1129,6 @@
             <child>
               <object class="GtkComboBox" id="receive_chooser_protocol">
                 <property name="visible">True</property>
-                <property name="model">model2</property>
-                <child>
-                  <object class="GtkCellRendererText" id="renderer2"/>
-                  <attributes>
-                    <attribute name="text">0</attribute>
-                  </attributes>
-                </child>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -1329,13 +1264,6 @@
             <child>
               <object class="GtkComboBox" id="send_chooser_protocol">
                 <property name="visible">True</property>
-                <property name="model">model3</property>
-                <child>
-                  <object class="GtkCellRendererText" id="renderer3"/>
-                  <attributes>
-                    <attribute name="text">0</attribute>
-                  </attributes>
-                </child>
               </object>
               <packing>
                 <property name="expand">False</property>
diff --git a/src/ReceiveChooserDialog.vala b/src/ReceiveChooserDialog.vala
index 1de305c..3c6f872 100644
--- a/src/ReceiveChooserDialog.vala
+++ b/src/ReceiveChooserDialog.vala
@@ -31,10 +31,13 @@ public class moserial.ReceiveChooserDialog : GLib.Object
 
         construct {
                 dialog = (FileChooserDialog)builder.get_object("receive_chooser_dialog");
+
                 protocolCombo = (ComboBox)builder.get_object("receive_chooser_protocol");
+		MoUtils.populateComboBox (protocolCombo, Rzwrapper.ProtocolStrings);
+
                 dialog.delete_event.connect(hide);
                 dialog.add_buttons(Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL, Gtk.Stock.OK, Gtk.ResponseType.ACCEPT, null);
-                protocolCombo.set_active(2);
+                protocolCombo.set_active(Rzwrapper.Protocol.ZMODEM);
                 dialog.response.connect(response);
         }
 
diff --git a/src/RecordDialog.vala b/src/RecordDialog.vala
index 6dc9cb4..2085d20 100644
--- a/src/RecordDialog.vala
+++ b/src/RecordDialog.vala
@@ -34,13 +34,17 @@ public class moserial.RecordDialog : GLib.Object
         construct {
                 dialog = (FileChooserDialog)builder.get_object("record_dialog");
                 cancelButton = (Button)builder.get_object("record_cancel");
+
                 streamCombo = (ComboBox)builder.get_object("record_stream");
+		MoUtils.populateComboBox (streamCombo, SerialStreamRecorder.DirectionStrings);
+                streamCombo.set_active(SerialStreamRecorder.Direction.INCOMING);
+
                 dialog.delete_event.connect(hide);
                 dialog.response.connect(response);
                 dialog.add_buttons(Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL, Gtk.Stock.SAVE, Gtk.ResponseType.ACCEPT, null);
                 dialog.set_do_overwrite_confirmation(true);
 		dialog.set_local_only(false);
-                streamCombo.set_active(0);
+
                 fileName=null;
         }
 
diff --git a/src/Rzwrapper.vala b/src/Rzwrapper.vala
index f38f025..60809a3 100644
--- a/src/Rzwrapper.vala
+++ b/src/Rzwrapper.vala
@@ -21,6 +21,10 @@
 public class moserial.Rzwrapper: GLib.Object
 {
 	public enum Protocol {XMODEM, YMODEM, ZMODEM, NULL}
+	public const string[] ProtocolStrings = { GLib.N_("Xmodem"),
+						  GLib.N_("Ymodem"),
+                                                  GLib.N_("Zmodem") };
+
 	public Protocol protocol {get; construct;}
 	public SerialConnection? sc {get; construct;}
         private IOChannel IOChannelInput;
diff --git a/src/SendChooserDialog.vala b/src/SendChooserDialog.vala
index eab9eed..19fb6df 100644
--- a/src/SendChooserDialog.vala
+++ b/src/SendChooserDialog.vala
@@ -30,10 +30,13 @@ public class moserial.SendChooserDialog : GLib.Object
         }
         construct {
                 dialog = (FileChooserDialog)builder.get_object("send_chooser_dialog");
+
                 protocolCombo = (ComboBox)builder.get_object("send_chooser_protocol");
+		MoUtils.populateComboBox (protocolCombo, Szwrapper.ProtocolStrings);
+
                 dialog.delete_event.connect(hide);
                 dialog.add_buttons(Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL, Gtk.Stock.OK, Gtk.ResponseType.ACCEPT, null);
-                protocolCombo.set_active(2);
+                protocolCombo.set_active(Szwrapper.Protocol.ZMODEM);
                 dialog.response.connect(response);
         }
 
diff --git a/src/SerialStreamRecorder.vala b/src/SerialStreamRecorder.vala
index 6625d8d..efdfd54 100644
--- a/src/SerialStreamRecorder.vala
+++ b/src/SerialStreamRecorder.vala
@@ -24,7 +24,12 @@ public class moserial.SerialStreamRecorder {
 	private string uri;
 	private bool isOpen=false;
 	private FileOutputStream? fos;
-	public static enum Direction { INCOMING, OUTGOING, BOTH, NULL }
+
+	public static enum Direction { INCOMING, OUTGOING, BOTH }
+	public const string[] DirectionStrings = { GLib.N_("Incoming"),
+                                                   GLib.N_("Outgoing"),
+                                                   GLib.N_("Incoming and Outgoing") };
+
 	private Direction direction;
 	public void open (string filename, Direction direction) throws GLib.Error {
 		try {
diff --git a/src/Szwrapper.vala b/src/Szwrapper.vala
index ddd34d5..b71a200 100644
--- a/src/Szwrapper.vala
+++ b/src/Szwrapper.vala
@@ -21,6 +21,11 @@
 public class moserial.Szwrapper: GLib.Object
 {
 	public enum Protocol {XMODEM, YMODEM, ZMODEM, RAW, NULL}
+        public const string[] ProtocolStrings = { GLib.N_("Xmodem"),
+                                                  GLib.N_("Ymodem"),
+                                                  GLib.N_("Zmodem"),
+						  GLib.N_("None (straight binary)") };
+
 	public Protocol protocol {get; construct;}
 	public SerialConnection? sc {get; construct;}
         private IOChannel IOChannelInput;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]