Streamline the setup dialog

Just the minimal bits that are needed.
This commit is contained in:
Peter Hutterer 2019-07-16 15:21:47 +10:00
parent 79e3e02b66
commit 7be996e43a
3 changed files with 23 additions and 206 deletions

View File

@ -6,7 +6,7 @@
<property name="can_focus">False</property>
<property name="title" translatable="yes">Initial Device Setup</property>
<property name="modal">True</property>
<property name="window_position">center</property>
<property name="window_position">center-on-parent</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
<property name="gravity">center</property>
@ -62,23 +62,11 @@
<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="halign">center</property>
<property name="valign">center</property>
<property name="label" translatable="yes">Hold the button on the device until the blue light is flashing.</property>
<property name="justify">center</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>
@ -91,6 +79,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<child>
<object class="GtkSpinner">
<property name="visible">True</property>
@ -133,14 +122,16 @@
<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">
<object class="GtkLabel" id="label_devicename_p1">
<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="halign">center</property>
<property name="label" translatable="yes">Connecting to LE Paper</property>
<property name="wrap">True</property>
<property name="max_width_chars">55</property>
</object>
@ -155,6 +146,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<child>
<object class="GtkSpinner">
<property name="visible">True</property>
@ -198,6 +190,7 @@
<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>
@ -205,28 +198,15 @@
<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="halign">center</property>
<property name="valign">center</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="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
@ -236,6 +216,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<child>
<object class="GtkSpinner">
<property name="visible">True</property>
@ -276,166 +257,11 @@
</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>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>

View File

@ -26,10 +26,7 @@ class SetupDialog(Gtk.Dialog):
}
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()
label_devicename_p1 = Gtk.Template.Child()
btn_quit = Gtk.Template.Child()
def __init__(self, tuhi, *args, **kwargs):
@ -42,6 +39,7 @@ class SetupDialog(Gtk.Dialog):
def _on_unregistered_device(self, tuhi, device):
tuhi.disconnect(self._sig)
self.label_devicename_p1.set_text(f'Connecting to {device.name}')
self.stack.set_visible_child_name('page1')
self._sig = device.connect('button-press-required', self._on_button_press_required)
device.register()
@ -54,16 +52,8 @@ class SetupDialog(Gtk.Dialog):
def _on_registered(self, tuhi, device):
tuhi.disconnect(self._sig)
self.device_name_p3.set_text(device.name)
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")
self.response(Gtk.ResponseType.OK)
@GObject.Property
def name(self):

View File

@ -113,8 +113,9 @@ class MainWindow(Gtk.ApplicationWindow):
device = dialog.device
dialog.destroy()
if device is None:
if response != Gtk.ResponseType.OK or device is None:
self.destroy()
return
logger.debug('device was registered')
self.headerbar.set_title(f'Tuhi - {device.name}')