From 7be996e43a2c24b51f4343585a9d66ffba417d5f Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 16 Jul 2019 15:21:47 +1000 Subject: [PATCH] Streamline the setup dialog Just the minimal bits that are needed. --- data/ui/SetupPerspective.ui | 210 ++++-------------------------------- tuhigui/setupdialog.py | 16 +-- tuhigui/window.py | 3 +- 3 files changed, 23 insertions(+), 206 deletions(-) diff --git a/data/ui/SetupPerspective.ui b/data/ui/SetupPerspective.ui index 7e4c724..a40e95a 100644 --- a/data/ui/SetupPerspective.ui +++ b/data/ui/SetupPerspective.ui @@ -6,7 +6,7 @@ False Initial Device Setup True - center + center-on-parent True dialog center @@ -62,23 +62,11 @@ True False - No device found by Tuhi. Let's setup your device for the first time. This needs to be done only once for this device. + center + center + Hold the button on the device until the blue light is flashing. + center True - 55 - - - False - True - 0 - - - - - True - False - Hold the button on the device until the blue light is flashing. Once the device is found, we will process to the next stage. - True - 55 False @@ -91,6 +79,7 @@ True False center + center True @@ -133,14 +122,16 @@ True False + center vertical True bottom - + True False - Compatible device found. Attempting to connect. + center + Connecting to LE Paper True 55 @@ -155,6 +146,7 @@ True False center + center True @@ -198,6 +190,7 @@ True False + center vertical True bottom @@ -205,28 +198,15 @@ True False - Connected to device and finalizing setup. - center - False - - - False - True - 0 - - - - - True - False + center + center Press the button on the device now! - - True + False True 1 @@ -236,6 +216,7 @@ True False center + center True @@ -276,166 +257,11 @@ - - True - False - vertical - True - bottom - - - True - False - center - - - - - - True - False - 0 - none - - - True - False - 12 - - - True - False - True - - - True - False - 5 - 5 - Size - 25 - - - 0 - 0 - - - - - True - False - 100x100mm - - - 1 - 0 - - - - - True - False - 5 - 5 - Bluetooth Address - 25 - - - 0 - 1 - - - - - True - False - 12:34:AB:CD:67:78 - - - 1 - 1 - - - - - True - False - 5 - 5 - Battery - - - 0 - 2 - - - - - True - False - 55% - - - 1 - 2 - - - - - - - - - - True - False - Device name - - - - - - - - True - True - 1 - - - - - - - - False - True - 0 - - - - - True - False - Setup Complete - - - False - True - 1 - - - - - page3 - page3 - 3 - + - False + True True 1 diff --git a/tuhigui/setupdialog.py b/tuhigui/setupdialog.py index 1c60473..4a87357 100644 --- a/tuhigui/setupdialog.py +++ b/tuhigui/setupdialog.py @@ -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): diff --git a/tuhigui/window.py b/tuhigui/window.py index 8cb0d1c..2fb2cb0 100644 --- a/tuhigui/window.py +++ b/tuhigui/window.py @@ -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}')