Make the setup parts a dialog

A more traditional interface.
This commit is contained in:
Peter Hutterer 2019-07-15 15:05:30 +10:00
parent 64dca90f54
commit 517a7e6882
4 changed files with 445 additions and 441 deletions

View File

@ -2,414 +2,35 @@
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="SetupPerspective" parent="GtkStack">
<property name="visible">True</property>
<template class="SetupDialog" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="margin_bottom">100</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<property name="baseline_position">bottom</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Device Setup</property>
<property name="justify">center</property>
<property name="track_visited_links">False</property>
<attributes>
<attribute name="weight" value="medium"/>
<attribute name="size" value="50000"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<child>
<object class="GtkSpinner">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_right">20</property>
<property name="active">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Searching for device</property>
<attributes>
<attribute name="size" value="20000"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Hold the button on the device until the blue light is flashing.</property>
<property name="wrap">True</property>
<property name="max_width_chars">65</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="size" value="20000"/>
</attributes>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="name">page0</property>
<property name="title" translatable="yes">page0</property>
</packing>
<property name="title" translatable="yes">Initial Device Setup</property>
<property name="modal">True</property>
<property name="window_position">center</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
<property name="gravity">center</property>
<child type="titlebar">
<placeholder/>
</child>
<child>
<child internal-child="vbox">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<property name="baseline_position">bottom</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="label" translatable="yes">Device Setup</property>
<property name="justify">center</property>
<property name="track_visited_links">False</property>
<attributes>
<attribute name="weight" value="medium"/>
<attribute name="size" value="50000"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<child>
<object class="GtkSpinner">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_right">20</property>
<property name="active">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Connecting to device...</property>
<attributes>
<attribute name="size" value="20000"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="device_name_p1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Device found</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="size" value="20000"/>
</attributes>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="name">page1</property>
<property name="title" translatable="yes">page1</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<property name="baseline_position">bottom</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Device Setup</property>
<property name="justify">center</property>
<property name="track_visited_links">False</property>
<attributes>
<attribute name="weight" value="medium"/>
<attribute name="size" value="50000"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<child>
<object class="GtkSpinner">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_right">20</property>
<property name="active">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">waiting for reply</property>
<attributes>
<attribute name="size" value="20000"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Press the button on the device now!</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="size" value="20000"/>
</attributes>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="name">page2</property>
<property name="title" translatable="yes">page2</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<property name="baseline_position">bottom</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Setup Complete</property>
<attributes>
<attribute name="weight" value="medium"/>
<attribute name="size" value="50000"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkFrame">
<object class="GtkButton" id="btn_quit">
<property name="label" translatable="yes">Quit</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_homogeneous">True</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Size</property>
<property name="width_chars">25</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_size">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">100x100mm</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Bluetooth Address</property>
<property name="width_chars">25</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_btaddr">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">12:34:AB:CD:67:78</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Battery</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_battery">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">55%</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="device_name_p3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Device name</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">True</property>
@ -417,8 +38,400 @@
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkStack" id="stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">100</property>
<child>
<placeholder/>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<property name="baseline_position">bottom</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">No device found by Tuhi. Let's setup your device for the first time. This needs to be done only once for this device.</property>
<property name="wrap">True</property>
<property name="max_width_chars">55</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Hold the button on the device until the blue light is flashing. Once the device is found, we will process to the next stage.</property>
<property name="wrap">True</property>
<property name="max_width_chars">55</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<child>
<object class="GtkSpinner">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_right">20</property>
<property name="active">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Searching for device</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="name">page0</property>
<property name="title" translatable="yes">page0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<property name="baseline_position">bottom</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Compatible device found. Attempting to connect.</property>
<property name="wrap">True</property>
<property name="max_width_chars">55</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<child>
<object class="GtkSpinner">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_right">20</property>
<property name="active">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Connecting to device...</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="name">page1</property>
<property name="title" translatable="yes">page1</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<property name="baseline_position">bottom</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Connected to device and finalizing setup.</property>
<property name="justify">center</property>
<property name="track_visited_links">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Press the button on the device now!</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="size" value="20000"/>
</attributes>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<child>
<object class="GtkSpinner">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_right">20</property>
<property name="active">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">waiting for reply</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="name">page2</property>
<property name="title" translatable="yes">page2</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<property name="baseline_position">bottom</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_homogeneous">True</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Size</property>
<property name="width_chars">25</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_size">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">100x100mm</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Bluetooth Address</property>
<property name="width_chars">25</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_btaddr">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">12:34:AB:CD:67:78</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Battery</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_battery">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">55%</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="device_name_p3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Device name</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Setup Complete</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="name">page3</property>
<property name="title" translatable="yes">page3</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
@ -427,28 +440,10 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Let's go!</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">end</property>
<signal name="clicked" handler="_on_go_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="name">page3</property>
<property name="title" translatable="yes">page3</property>
<property name="position">3</property>
</packing>
</child>
<action-widgets>
<action-widget response="-6">btn_quit</action-widget>
</action-widgets>
</template>
</interface>

View File

@ -18,53 +18,53 @@ gi.require_version("Gtk", "3.0")
@Gtk.Template(resource_path="/org/freedesktop/TuhiGui/ui/SetupPerspective.ui")
class SetupPerspective(Gtk.Stack):
__gtype_name__ = "SetupPerspective"
class SetupDialog(Gtk.Dialog):
__gtype_name__ = "SetupDialog"
__gsignals__ = {
'new-device':
(GObject.SignalFlags.RUN_FIRST, None, (GObject.TYPE_PYOBJECT,)),
}
device_name_p1 = Gtk.Template.Child()
stack = Gtk.Template.Child()
device_name_p3 = Gtk.Template.Child()
label_size = Gtk.Template.Child()
label_btaddr = Gtk.Template.Child()
label_battery = Gtk.Template.Child()
btn_quit = Gtk.Template.Child()
def __init__(self, tuhi, *args, **kwargs):
super().__init__(*args, **kwargs)
self._tuhi = tuhi
self._sig = tuhi.connect('unregistered-device', self._on_unregistered_device)
tuhi.start_search()
self.device = None
def _on_unregistered_device(self, tuhi, device):
tuhi.disconnect(self._sig)
self.device_name_p1.set_text(device.name)
self.set_visible_child_name('page1')
self.stack.set_visible_child_name('page1')
self._sig = device.connect('button-press-required', self._on_button_press_required)
device.register()
def _on_button_press_required(self, tuhi, device):
tuhi.disconnect(self._sig)
self.set_visible_child_name('page2')
self.stack.set_visible_child_name('page2')
self._sig = device.connect('registered', self._on_registered)
def _on_registered(self, tuhi, device):
tuhi.disconnect(self._sig)
self.device_name_p3.set_text(device.name)
self.set_visible_child_name('page3')
self.label_size.set_text(f'not implemented')
self.stack.set_visible_child_name('page3')
w, h = device.dimensions # in 100th of mm
self.label_size.set_text(f'{w/100}x{h/100}mm')
self.label_btaddr.set_text(device.address)
self.label_battery.set_text(f'{device.battery_percent}%')
self.device = device
self.btn_quit.set_label("Let's go")
@GObject.Property
def name(self):
return "setup_perspective"
@Gtk.Template.Callback("_on_go_button_clicked")
def _on_go_button_clicked(self, button):
self.emit('new-device', self.device)
return "setup_dialog"

View File

@ -184,6 +184,10 @@ class TuhiKeteDevice(_DBusObject):
def name(self):
return self._bluez_device.property('Name')
@GObject.Property
def dimensions(self):
return self.property('Dimensions')
@GObject.Property
def listening(self):
return self.property('Listening')

View File

@ -13,7 +13,7 @@
from gi.repository import Gtk, Gdk
from .setupperspective import SetupPerspective
from .setupdialog import SetupDialog
from .drawingperspective import DrawingPerspective
from .errorperspective import ErrorPerspective
from .tuhi import TuhiKeteManager
@ -70,23 +70,28 @@ class MainWindow(Gtk.ApplicationWindow):
dp = DrawingPerspective()
self._add_perspective(dp)
active = dp
self.headerbar.set_title(f'Tuhi')
self.stack_perspectives.set_visible_child_name(active.name)
if not self._tuhi.devices:
sp = SetupPerspective(self._tuhi)
sp.connect('new-device', self._on_new_device_registered)
self._add_perspective(sp)
active = sp
dialog = SetupDialog(self._tuhi)
dialog.set_transient_for(self)
dialog.connect('response', self._on_setup_dialog_closed)
dialog.show()
else:
dp.device = self._tuhi.devices[0]
active = dp
self.headerbar.set_title(f'Tuhi - {dp.device.name}')
self.stack_perspectives.set_visible_child_name(active.name)
def _on_setup_dialog_closed(self, dialog, response):
device = dialog.device
dialog.destroy()
if device is None:
self.destroy()
def _on_new_device_registered(self, setupperspective, device):
logger.debug('device was registered')
setupperspective.disconnect_by_func(self._on_new_device_registered)
self.headerbar.set_title(f'Tuhi - {device.name}')
dp = self._get_child('drawing_perspective')