allow turning off UDP output
Stefan Schuermans

Stefan Schuermans commited on 2014-05-21 20:59:46
Showing 2 changed files, with 31 additions and 4 deletions.

... ...
@@ -7,7 +7,7 @@
7 7
     <property name="title" translatable="yes">About BlinkenArea Stage Director</property>
8 8
     <property name="type_hint">dialog</property>
9 9
     <property name="program_name">BlinkenArea Stage Director</property>
10
-    <property name="version">0.1.2</property>
10
+    <property name="version">0.1.3</property>
11 11
     <property name="copyright" translatable="yes">Copyright 2013-2014 Stefan Schuermans &lt;stefan@schuermans.info&gt;
12 12
 Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
13 13
 a blinkenarea.org project - https://www.blinkenarea.org/</property>
... ...
@@ -614,7 +614,6 @@ a blinkenarea.org project - https://www.blinkenarea.org/</property>
614 614
             <property name="visible">True</property>
615 615
             <property name="can_focus">False</property>
616 616
             <property name="border_width">3</property>
617
-            <property name="orientation">vertical</property>
618 617
             <child>
619 618
               <object class="GtkCheckButton" id="SingleStep">
620 619
                 <property name="label" translatable="yes">single-step mode</property>
... ...
@@ -627,11 +626,30 @@ a blinkenarea.org project - https://www.blinkenarea.org/</property>
627 626
                 <property name="draw_indicator">True</property>
628 627
               </object>
629 628
               <packing>
630
-                <property name="expand">False</property>
629
+                <property name="expand">True</property>
631 630
                 <property name="fill">True</property>
632 631
                 <property name="position">0</property>
633 632
               </packing>
634 633
             </child>
634
+            <child>
635
+              <object class="GtkCheckButton" id="UdpOutput">
636
+                <property name="label" translatable="yes">UDP output</property>
637
+                <property name="use_action_appearance">False</property>
638
+                <property name="visible">True</property>
639
+                <property name="can_focus">True</property>
640
+                <property name="receives_default">False</property>
641
+                <property name="use_action_appearance">False</property>
642
+                <property name="xalign">0</property>
643
+                <property name="active">True</property>
644
+                <property name="draw_indicator">True</property>
645
+                <signal name="toggled" handler="onUdpOutput" swapped="no"/>
646
+              </object>
647
+              <packing>
648
+                <property name="expand">True</property>
649
+                <property name="fill">True</property>
650
+                <property name="position">1</property>
651
+              </packing>
652
+            </child>
635 653
           </object>
636 654
           <packing>
637 655
             <property name="expand">False</property>
... ...
@@ -38,6 +38,7 @@ class StageDirector:
38 38
     self.widLogoUdpErr = self.builder.get_object("LogoUdpErr")
39 39
     self.widLogoUdpOk = self.builder.get_object("LogoUdpOk")
40 40
     self.widSingleStep = self.builder.get_object("SingleStep")
41
+    self.widUdpOutput = self.builder.get_object("UdpOutput")
41 42
     self.widStatus = self.builder.get_object("Status")
42 43
     handlers = {
43 44
       "onDestroy":           self.onDestroy,
... ...
@@ -52,6 +53,7 @@ class StageDirector:
52 53
       "onPause":             self.onPause,
53 54
       "onStop":              self.onStop,
54 55
       "onNext":              self.onNext,
56
+      "onUdpOutput":         self.onUdpOutput,
55 57
     }
56 58
     self.builder.connect_signals(handlers)
57 59
     self.playlist = playlist.Playlist()
... ...
@@ -158,7 +160,7 @@ class StageDirector:
158 160
     self.widLogoUdpErr.set_visible(True)
159 161
     self.widLogoUdpOk.set_visible(False)
160 162
     self.widStatus.remove_all(0)
161
-    self.widStatus.push(0, "UDP output ERROR")
163
+    self.widStatus.push(0, "UDP output turned off")
162 164
     if self.sock is not None:
163 165
       self.sock.close()
164 166
     self.sock = None
... ...
@@ -166,6 +168,7 @@ class StageDirector:
166 168
   def setupSock(self):
167 169
     """create a new UDP socket and "connect" it to the destination address"""
168 170
     self.closeSock()
171
+    if self.widUdpOutput.get_active():
169 172
       try:
170 173
         self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
171 174
         self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
... ...
@@ -177,6 +180,7 @@ class StageDirector:
177 180
         self.widLogoUdpOk.set_visible(True)
178 181
       except:
179 182
         self.closeSock()
183
+        self.widStatus.push(0, "UDP output ERROR")
180 184
 
181 185
   def onDestroy(self, widget):
182 186
     """window will be destroyed"""
... ...
@@ -311,6 +315,11 @@ class StageDirector:
311 315
       self.stEntryIdx = 0
312 316
     self.updateEntry()
313 317
 
318
+  def onUdpOutput(self, widget):
319
+    """UDP Output check box toggled"""
320
+    # re-create UDP socket
321
+    self.setupSock()
322
+
314 323
   def onTimer10ms(self):
315 324
     """timer callback, every 10ms"""
316 325
     # update position if playing
317 326