import gtk
class Visual:
- def __init__(self, config):
- self.builder = gtk.Builder()
+ def __init__(self, config, device, xively):
+ self.config = config
+ self.device = device
+ self.xively = xively
+ self.builder = gtk.Builder()
+
self.builder.add_from_file('visual.ui')
self.builder.connect_signals(self)
self.window = self.builder.get_object("window")
self.settings = self.builder.get_object("settings")
- self.config = config
# Signal handlers
def on_hide(self, win, *args):
self.settings.show()
return True
- def on_connect(self, win):
- print "Unimplemented: on_connect"
+ def on_serial(self, win):
+ self.device.connect()
+ return True
+
+ def on_xively(self, win):
+ self.xively.connect()
return True
def on_enable(self, _):
# Methods
def load_config(self):
# Serial settings
- baud = self.builder.get_object("baudrate")
- stopb = self.builder.get_object("stopbits")
- datab = self.builder.get_object("databits")
+ baud = self.builder.get_object("baudrate")
+ parity = self.builder.get_object("parity")
+ datab = self.builder.get_object("databits")
+ stopb = self.builder.get_object("stopbits")
baud.set_value(self.config.baudrate)
- stopb.set_value(self.config.stopbits)
+ parity.set_text(self.config.parity)
datab.set_value(self.config.databits)
+ stopb.set_value(self.config.stopbits)
# Xively settings
user = self.builder.get_object("username")
<interface>
<requires lib="gtk+" version="2.24"/>
<!-- interface-naming-policy project-wide -->
+ <object class="GtkAction" id="serial_con">
+ <property name="label" translatable="yes">Serial</property>
+ <property name="stock_id">gtk-connect</property>
+ <signal name="activate" handler="on_serial" swapped="no"/>
+ </object>
+ <object class="GtkAction" id="setting_act">
+ <property name="label" translatable="yes">Settings</property>
+ <property name="stock_id">gtk-preferences</property>
+ <signal name="activate" handler="on_show" swapped="no"/>
+ </object>
<object class="GtkAction" id="xively_con">
<property name="label" translatable="yes">Xively</property>
<property name="stock_id">gtk-connect</property>
- <signal name="activate" handler="on_connect" swapped="no"/>
+ <signal name="activate" handler="on_xively" swapped="no"/>
</object>
<object class="GtkAdjustment" id="a2d_adj">
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
- <object class="GtkAction" id="setting_act">
- <property name="label" translatable="yes">Settings</property>
- <property name="stock_id">gtk-preferences</property>
- <signal name="activate" handler="on_show" swapped="no"/>
- </object>
<object class="GtkTextBuffer" id="serial_buf"/>
- <object class="GtkAction" id="serial_con">
- <property name="label" translatable="yes">Serial</property>
- <property name="stock_id">gtk-connect</property>
- <signal name="activate" handler="on_connect" swapped="no"/>
- </object>
- <object class="GtkAdjustment" id="stopb_adj">
- <property name="lower">1</property>
- <property name="upper">2</property>
- <property name="step_increment">1</property>
- <property name="page_increment">10</property>
- </object>
<object class="GtkDialog" id="settings">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="n_rows">3</property>
+ <property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="column_spacing">20</property>
<child>
<property name="label" translatable="yes">Stop bits</property>
</object>
<packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
<property name="label" translatable="yes">Data bits</property>
</object>
<packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
<packing>
<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="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="parity_lbl">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Parity</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="parity">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="invisible_char_set">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ </object>
+ <packing>
+ <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">GTK_FILL</property>
</packing>
</child>
<action-widget response="0">close</action-widget>
</action-widgets>
</object>
+ <object class="GtkAdjustment" id="stopb_adj">
+ <property name="lower">1</property>
+ <property name="upper">2</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
<object class="GtkAdjustment" id="touch_adj">
<property name="upper">100</property>
<property name="value">1</property>