Move the setup dialog to the main window
No need for a separate file just for those few lines of code
This commit is contained in:
parent
037d05babf
commit
efabaf3aaa
|
@ -12,7 +12,6 @@ tuhigui/application.py
|
||||||
tuhigui/config.py
|
tuhigui/config.py
|
||||||
tuhigui/drawing.py
|
tuhigui/drawing.py
|
||||||
tuhigui/drawingperspective.py
|
tuhigui/drawingperspective.py
|
||||||
tuhigui/setupdialog.py
|
|
||||||
tuhigui/svg.py
|
tuhigui/svg.py
|
||||||
tuhigui/tuhi.py
|
tuhigui/tuhi.py
|
||||||
tuhigui/window.py
|
tuhigui/window.py
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
|
|
||||||
from gettext import gettext as _
|
|
||||||
from gi.repository import GObject, Gtk
|
|
||||||
|
|
||||||
import gi
|
|
||||||
gi.require_version("Gtk", "3.0")
|
|
||||||
|
|
||||||
|
|
||||||
@Gtk.Template(resource_path="/org/freedesktop/TuhiGui/ui/SetupPerspective.ui")
|
|
||||||
class SetupDialog(Gtk.Dialog):
|
|
||||||
__gtype_name__ = "SetupDialog"
|
|
||||||
__gsignals__ = {
|
|
||||||
'new-device':
|
|
||||||
(GObject.SignalFlags.RUN_FIRST, None, (GObject.TYPE_PYOBJECT,)),
|
|
||||||
}
|
|
||||||
|
|
||||||
stack = Gtk.Template.Child()
|
|
||||||
label_devicename_p1 = 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.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()
|
|
||||||
|
|
||||||
def _on_button_press_required(self, tuhi, device):
|
|
||||||
tuhi.disconnect(self._sig)
|
|
||||||
|
|
||||||
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 = device
|
|
||||||
self.response(Gtk.ResponseType.OK)
|
|
||||||
|
|
||||||
@GObject.Property
|
|
||||||
def name(self):
|
|
||||||
return "setup_dialog"
|
|
|
@ -11,9 +11,9 @@
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from gettext import gettext as _
|
||||||
from gi.repository import Gtk, Gio, GLib, GObject
|
from gi.repository import Gtk, Gio, GLib, GObject
|
||||||
|
|
||||||
from .setupdialog import SetupDialog
|
|
||||||
from .drawingperspective import DrawingPerspective
|
from .drawingperspective import DrawingPerspective
|
||||||
from .tuhi import TuhiKeteManager
|
from .tuhi import TuhiKeteManager
|
||||||
from .config import Config
|
from .config import Config
|
||||||
|
@ -71,6 +71,52 @@ class ErrorPerspective(Gtk.Box):
|
||||||
return "error_perspective"
|
return "error_perspective"
|
||||||
|
|
||||||
|
|
||||||
|
@Gtk.Template(resource_path="/org/freedesktop/TuhiGui/ui/SetupPerspective.ui")
|
||||||
|
class SetupDialog(Gtk.Dialog):
|
||||||
|
'''
|
||||||
|
The setup dialog when we don't yet have a registered device with Tuhi.
|
||||||
|
'''
|
||||||
|
__gtype_name__ = "SetupDialog"
|
||||||
|
__gsignals__ = {
|
||||||
|
'new-device':
|
||||||
|
(GObject.SignalFlags.RUN_FIRST, None, (GObject.TYPE_PYOBJECT,)),
|
||||||
|
}
|
||||||
|
|
||||||
|
stack = Gtk.Template.Child()
|
||||||
|
label_devicename_p1 = 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.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()
|
||||||
|
|
||||||
|
def _on_button_press_required(self, tuhi, device):
|
||||||
|
tuhi.disconnect(self._sig)
|
||||||
|
|
||||||
|
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 = device
|
||||||
|
self.response(Gtk.ResponseType.OK)
|
||||||
|
|
||||||
|
@GObject.Property
|
||||||
|
def name(self):
|
||||||
|
return "setup_dialog"
|
||||||
|
|
||||||
|
|
||||||
@Gtk.Template(resource_path='/org/freedesktop/TuhiGui/ui/MainWindow.ui')
|
@Gtk.Template(resource_path='/org/freedesktop/TuhiGui/ui/MainWindow.ui')
|
||||||
class MainWindow(Gtk.ApplicationWindow):
|
class MainWindow(Gtk.ApplicationWindow):
|
||||||
__gtype_name__ = 'MainWindow'
|
__gtype_name__ = 'MainWindow'
|
||||||
|
|
Loading…
Reference in New Issue