diff --git a/ui/src/breezydesktop.gresource.xml b/ui/src/breezydesktop.gresource.xml index b20a15c..4e96ef5 100644 --- a/ui/src/breezydesktop.gresource.xml +++ b/ui/src/breezydesktop.gresource.xml @@ -6,6 +6,7 @@ gtk/license-dialog.ui gtk/no-device.ui gtk/no-extension.ui + gtk/no-license.ui gtk/shortcut-dialog.ui gtk/window.ui diff --git a/ui/src/failedverification.py b/ui/src/failedverification.py index 15e44f5..7ee4875 100644 --- a/ui/src/failedverification.py +++ b/ui/src/failedverification.py @@ -1,4 +1,4 @@ -from gi.repository import Adw, Gtk +from gi.repository import Gtk @Gtk.Template(resource_path='/com/xronlinux/BreezyDesktop/gtk/failed-verification.ui') class FailedVerification(Gtk.Box): diff --git a/ui/src/gtk/no-license.ui b/ui/src/gtk/no-license.ui new file mode 100644 index 0000000..4671b2a --- /dev/null +++ b/ui/src/gtk/no-license.ui @@ -0,0 +1,31 @@ + + + + + diff --git a/ui/src/licensedialog.py b/ui/src/licensedialog.py index 2a85f65..c21af54 100644 --- a/ui/src/licensedialog.py +++ b/ui/src/licensedialog.py @@ -19,7 +19,7 @@ class LicenseDialog(Gtk.Dialog): self.init_template() self.ipc = XRDriverIPC.get_instance() - StateManager.get_instance().connect('license-action-needed', self._handle_license) + StateManager.get_instance().connect('notify::license-action-needed', self._handle_license) self._handle_license(StateManager.get_instance()) self.request_token.connect('apply', self._on_request_token) diff --git a/ui/src/licensefeaturerow.py b/ui/src/licensefeaturerow.py index 0e733ca..5f4904a 100644 --- a/ui/src/licensefeaturerow.py +++ b/ui/src/licensefeaturerow.py @@ -1,4 +1,4 @@ -from gi.repository import Adw, Gtk +from gi.repository import Adw from .time import time_remaining_text diff --git a/ui/src/meson.build b/ui/src/meson.build index 55b0c5f..63d4fae 100644 --- a/ui/src/meson.build +++ b/ui/src/meson.build @@ -38,6 +38,7 @@ breezydesktop_sources = [ 'main.py', 'nodevice.py', 'noextension.py', + 'nolicense.py', 'settingsmanager.py', 'shortcutdialog.py', 'statemanager.py', diff --git a/ui/src/nodevice.py b/ui/src/nodevice.py index 7006584..ed71c40 100644 --- a/ui/src/nodevice.py +++ b/ui/src/nodevice.py @@ -1,4 +1,4 @@ -from gi.repository import Adw, Gtk +from gi.repository import Gtk @Gtk.Template(resource_path='/com/xronlinux/BreezyDesktop/gtk/no-device.ui') class NoDevice(Gtk.Box): diff --git a/ui/src/noextension.py b/ui/src/noextension.py index 2c8e444..ab73c71 100644 --- a/ui/src/noextension.py +++ b/ui/src/noextension.py @@ -1,4 +1,4 @@ -from gi.repository import Adw, Gtk +from gi.repository import Gtk @Gtk.Template(resource_path='/com/xronlinux/BreezyDesktop/gtk/no-extension.ui') class NoExtension(Gtk.Box): diff --git a/ui/src/nolicense.py b/ui/src/nolicense.py new file mode 100644 index 0000000..afe059b --- /dev/null +++ b/ui/src/nolicense.py @@ -0,0 +1,20 @@ +from gi.repository import Gtk, GLib, GObject + +from .xrdriveripc import XRDriverIPC + +@Gtk.Template(resource_path='/com/xronlinux/BreezyDesktop/gtk/no-license.ui') +class NoLicense(Gtk.Box): + __gtype_name__ = "NoLicense" + + refresh_license_button = Gtk.Template.Child() + + def __init__(self, **kwargs): + super(Gtk.Box, self).__init__() + self.init_template() + + self.ipc = XRDriverIPC.get_instance() + + self.refresh_license_button.connect("clicked", self.on_refresh_license_button_clicked) + + def on_refresh_license_button_clicked(self, button): + self.ipc.write_control_flags({'refresh_device_license': True}) \ No newline at end of file diff --git a/ui/src/statemanager.py b/ui/src/statemanager.py index c352734..deada77 100644 --- a/ui/src/statemanager.py +++ b/ui/src/statemanager.py @@ -16,14 +16,14 @@ class Logger: class StateManager(GObject.GObject): __gsignals__ = { - 'device-update': (GObject.SIGNAL_RUN_FIRST, None, (str,)), - 'license-action-needed': (GObject.SIGNAL_RUN_FIRST, None, (bool,)), + 'device-update': (GObject.SIGNAL_RUN_FIRST, None, (str,)) } __gproperties__ = { 'follow-mode': (bool, 'Follow Mode', 'Whether the follow mode is enabled', False, GObject.ParamFlags.READWRITE), 'follow-threshold': (float, 'Follow Threshold', 'The follow threshold', 1.0, 45.0, 15.0, GObject.ParamFlags.READWRITE), - 'license-action-needed-seconds': (int, 'License Action Needed Seconds', 'The remaining time until the license action is needed', 0, LICENSE_ACTION_NEEDED_MAX, 0, GObject.ParamFlags.READWRITE), + 'license-action-needed': (bool, 'License Action Needed', 'Whether the license needs attention', False, GObject.ParamFlags.READWRITE), + 'license-present': (bool, 'License Present', 'Whether a license is present', False, GObject.ParamFlags.READWRITE), } _instance = None @@ -55,6 +55,7 @@ class StateManager(GObject.GObject): self.license_action_needed = False self.license_action_needed_seconds = 0 self.confirmed_token = False + self.license_present = False self.start() @@ -74,30 +75,36 @@ class StateManager(GObject.GObject): license_view = self.state['ui_view'].get('license') if license_view: - confirmed_token = license_view.get('confirmed_token') == True + if not self.license_present: + self.set_property('license-present', True) + self.confirmed_token = license_view.get('confirmed_token') == True action_needed_details = license_view.get('action_needed') action_needed_seconds = action_needed_details.get('seconds') if action_needed_details else None action_needed = action_needed_seconds is not None and action_needed_seconds < LICENSE_WARN_SECONDS - if (action_needed != self.license_action_needed or self.confirmed_token != confirmed_token): + if (action_needed != self.license_action_needed): self.license_action_needed = action_needed self.license_action_needed_seconds = action_needed_seconds - self.confirmed_token = confirmed_token - self.emit('license-action-needed', action_needed or not confirmed_token) + self.set_property('license-action-needed', action_needed) + elif self.license_present: + self.set_property('license-present', False) self.set_property('follow-mode', self.state.get('breezy_desktop_smooth_follow_enabled')) - self.set_property('license-action-needed-seconds', self.license_action_needed_seconds) if self.running: threading.Timer(1.0, self._refresh_state).start() def do_set_property(self, prop, value): if prop.name == 'follow-mode': self.follow_mode = value - if prop.name == 'license-action-needed-seconds': - self.license_action_needed_seconds = value + if prop.name == 'license-action-needed': + self.license_action_needed = value + if prop.name == 'license-present': + self.license_present = value def do_get_property(self, prop): if prop.name == 'follow-mode': return self.follow_mode - if prop.name == 'license-action-needed-seconds': - return self.license_action_needed_seconds \ No newline at end of file + if prop.name == 'license-action-needed': + return self.license_action_needed + if prop.name == 'license-present': + return self.license_present \ No newline at end of file diff --git a/ui/src/window.py b/ui/src/window.py index 59f5fda..fdf2404 100644 --- a/ui/src/window.py +++ b/ui/src/window.py @@ -25,6 +25,7 @@ from .connecteddevice import ConnectedDevice from .failedverification import FailedVerification from .nodevice import NoDevice from .noextension import NoExtension +from .nolicense import NoLicense from .verify import verify_installation from .time import LICENSE_WARN_SECONDS @@ -39,33 +40,35 @@ class BreezydesktopWindow(Gtk.ApplicationWindow): super().__init__(**kwargs) self.state_manager = StateManager.get_instance() - self.state_manager.connect('device-update', self._handle_device_update) - self.state_manager.connect('license-action-needed', self._handle_device_update) + self.state_manager.connect('device-update', self._handle_state_update) + self.state_manager.connect('notify::license-action-needed', self._handle_state_update) + self.state_manager.connect('notify::license-present', self._handle_state_update) self.connected_device = ConnectedDevice() + self.failed_verification = FailedVerification() self.no_device = NoDevice() self.no_extension = NoExtension() - self.failed_verification = FailedVerification() + self.no_license = NoLicense() self.license_action_needed_banner.connect('button-clicked', self._on_license_action_needed_button_clicked) - self._handle_device_update(self.state_manager, None) + self._handle_state_update(self.state_manager, None) self.connect("destroy", self._on_window_destroy) - def _handle_device_update(self, state_manager, val): - GLib.idle_add(self._handle_device_update_gui, state_manager) + def _handle_state_update(self, state_manager, val): + GLib.idle_add(self._handle_state_update_gui, state_manager) - def _handle_device_update_gui(self, state_manager): - license_action_needed_seconds = state_manager.get_property('license-action-needed-seconds') - show_banner = license_action_needed_seconds is not None and license_action_needed_seconds < LICENSE_WARN_SECONDS - self.license_action_needed_banner.set_revealed(show_banner) + def _handle_state_update_gui(self, state_manager): + self.license_action_needed_banner.set_revealed(state_manager.get_property('license-action-needed') == True) for child in self.main_content: self.main_content.remove(child) if not verify_installation(): self.main_content.append(self.failed_verification) + elif not self.state_manager.get_property('license-present'): + self.main_content.append(self.no_license) elif not ExtensionsManager.get_instance().is_installed(): self.main_content.append(self.no_extension) elif state_manager.connected_device_name: @@ -80,4 +83,4 @@ class BreezydesktopWindow(Gtk.ApplicationWindow): dialog.present() def _on_window_destroy(self, widget): - self.state_manager.disconnect_by_func(self._handle_device_update) \ No newline at end of file + self.state_manager.disconnect_by_func(self._handle_state_update) \ No newline at end of file