From ad6aa96000df79c62b943929f23c3d20a74f5f8e Mon Sep 17 00:00:00 2001 From: wheaney <42350981+wheaney@users.noreply.github.com> Date: Fri, 24 May 2024 13:30:53 -0700 Subject: [PATCH] Add check for granted productivity features, messaging and disable inputs if not granted --- ui/modules/PyXRLinuxDriverIPC | 2 +- ui/src/connecteddevice.py | 10 ++++++++++ ui/src/gtk/window.ui | 7 +++++++ ui/src/license.py | 1 + ui/src/meson.build | 1 + ui/src/statemanager.py | 12 ++++++++++-- ui/src/window.py | 12 +++++++++--- 7 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 ui/src/license.py diff --git a/ui/modules/PyXRLinuxDriverIPC b/ui/modules/PyXRLinuxDriverIPC index b98e0ec..1d0519b 160000 --- a/ui/modules/PyXRLinuxDriverIPC +++ b/ui/modules/PyXRLinuxDriverIPC @@ -1 +1 @@ -Subproject commit b98e0ec9a12f2ec37ebbb06e6b2226246da11107 +Subproject commit 1d0519bb4dfdc35ccb5c4ceb880cceab0edd0d68 diff --git a/ui/src/connecteddevice.py b/ui/src/connecteddevice.py index 7eb0d91..16f9ad4 100644 --- a/ui/src/connecteddevice.py +++ b/ui/src/connecteddevice.py @@ -1,5 +1,6 @@ from gi.repository import Gio, Gtk, GObject from .extensionsmanager import ExtensionsManager +from .license import BREEZY_GNOME_FEATURES from .settingsmanager import SettingsManager from .shortcutdialog import bind_shortcut_settings from .statemanager import StateManager @@ -59,6 +60,7 @@ class ConnectedDevice(Gtk.Box): self.state_manager = StateManager.get_instance() self.state_manager.bind_property('follow-mode', self.follow_mode_switch, 'active', GObject.BindingFlags.DEFAULT) + self.state_manager.connect('notify::enabled-features-list', self._handle_enabled_features) self.follow_mode_switch.set_active(self.state_manager.follow_mode) self.follow_mode_switch.connect('notify::active', self._refresh_follow_mode) @@ -66,11 +68,19 @@ class ConnectedDevice(Gtk.Box): self.effect_enable_switch.set_active(self._is_config_enabled(self.ipc.retrieve_config()) and self.extensions_manager.is_enabled()) self.effect_enable_switch.connect('notify::active', self._refresh_inputs_for_enabled_state) + self._handle_enabled_features(self.state_manager, None) self._refresh_inputs_for_enabled_state(self.effect_enable_switch, None) self.extensions_manager.bind_property('breezy-enabled', self.effect_enable_switch, 'active', GObject.BindingFlags.BIDIRECTIONAL) self.connect("destroy", self._on_widget_destroy) + def _handle_enabled_features(self, state_manager, val): + enabled_breezy_features = [feature for feature in state_manager.get_property('enabled-features-list') if feature in BREEZY_GNOME_FEATURES] + breezy_features_granted = len(enabled_breezy_features) > 0 + if not breezy_features_granted: + self.effect_enable_switch.set_active(False) + self.effect_enable_switch.set_sensitive(breezy_features_granted) + def _is_config_enabled(self, config): return config.get('disabled') == False and 'breezy_desktop' in config.get('external_mode', []) diff --git a/ui/src/gtk/window.ui b/ui/src/gtk/window.ui index e1a5fbd..d06e8c7 100644 --- a/ui/src/gtk/window.ui +++ b/ui/src/gtk/window.ui @@ -36,6 +36,13 @@ View details + + + 0 + Productivity features are disabled + View details + + diff --git a/ui/src/license.py b/ui/src/license.py new file mode 100644 index 0000000..c4c0997 --- /dev/null +++ b/ui/src/license.py @@ -0,0 +1 @@ +BREEZY_GNOME_FEATURES = ['productivity_basic', 'productivity_pro'] \ No newline at end of file diff --git a/ui/src/meson.build b/ui/src/meson.build index 63d4fae..6eb9b49 100644 --- a/ui/src/meson.build +++ b/ui/src/meson.build @@ -32,6 +32,7 @@ breezydesktop_sources = [ 'connecteddevice.py', 'extensionsmanager.py', 'failedverification.py', + 'license.py', 'licensedialog.py', 'licensefeaturerow.py', 'licensetierrow.py', diff --git a/ui/src/statemanager.py b/ui/src/statemanager.py index deada77..a8aa977 100644 --- a/ui/src/statemanager.py +++ b/ui/src/statemanager.py @@ -24,6 +24,7 @@ class StateManager(GObject.GObject): 'follow-threshold': (float, 'Follow Threshold', 'The follow threshold', 1.0, 45.0, 15.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), + 'enabled-features-list': (object, 'Enabled Features List', 'A list of the enabled features', GObject.ParamFlags.READWRITE), } _instance = None @@ -56,6 +57,7 @@ class StateManager(GObject.GObject): self.license_action_needed_seconds = 0 self.confirmed_token = False self.license_present = False + self.enabled_features = [] self.start() @@ -83,9 +85,11 @@ class StateManager(GObject.GObject): action_needed = action_needed_seconds is not None and action_needed_seconds < LICENSE_WARN_SECONDS if (action_needed != self.license_action_needed): - self.license_action_needed = action_needed self.license_action_needed_seconds = action_needed_seconds self.set_property('license-action-needed', action_needed) + enabled_features = license_view.get('enabled_features', []) + if self.enabled_features != enabled_features: + self.set_property('enabled-features-list', enabled_features) elif self.license_present: self.set_property('license-present', False) @@ -100,6 +104,8 @@ class StateManager(GObject.GObject): self.license_action_needed = value if prop.name == 'license-present': self.license_present = value + if prop.name == 'enabled-features-list': + self.enabled_features = value def do_get_property(self, prop): if prop.name == 'follow-mode': @@ -107,4 +113,6 @@ class StateManager(GObject.GObject): 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 + return self.license_present + if prop.name == 'enabled-features-list': + return self.enabled_features \ No newline at end of file diff --git a/ui/src/window.py b/ui/src/window.py index fdf2404..2c4f45e 100644 --- a/ui/src/window.py +++ b/ui/src/window.py @@ -19,6 +19,7 @@ from gi.repository import Gtk, GLib from .extensionsmanager import ExtensionsManager +from .license import BREEZY_GNOME_FEATURES from .licensedialog import LicenseDialog from .statemanager import StateManager from .connecteddevice import ConnectedDevice @@ -27,7 +28,6 @@ from .nodevice import NoDevice from .noextension import NoExtension from .nolicense import NoLicense from .verify import verify_installation -from .time import LICENSE_WARN_SECONDS @Gtk.Template(resource_path='/com/xronlinux/BreezyDesktop/gtk/window.ui') class BreezydesktopWindow(Gtk.ApplicationWindow): @@ -35,6 +35,7 @@ class BreezydesktopWindow(Gtk.ApplicationWindow): main_content = Gtk.Template.Child() license_action_needed_banner = Gtk.Template.Child() + missing_breezy_features_banner = Gtk.Template.Child() def __init__(self, **kwargs): super().__init__(**kwargs) @@ -43,6 +44,7 @@ class BreezydesktopWindow(Gtk.ApplicationWindow): 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.state_manager.connect('notify::enabled-features-list', self._handle_state_update) self.connected_device = ConnectedDevice() self.failed_verification = FailedVerification() @@ -50,7 +52,8 @@ class BreezydesktopWindow(Gtk.ApplicationWindow): self.no_extension = NoExtension() self.no_license = NoLicense() - self.license_action_needed_banner.connect('button-clicked', self._on_license_action_needed_button_clicked) + self.license_action_needed_banner.connect('button-clicked', self._on_license_button_clicked) + self.missing_breezy_features_banner.connect('button-clicked', self._on_license_button_clicked) self._handle_state_update(self.state_manager, None) @@ -60,6 +63,9 @@ class BreezydesktopWindow(Gtk.ApplicationWindow): GLib.idle_add(self._handle_state_update_gui, state_manager) def _handle_state_update_gui(self, state_manager): + enabled_breezy_features = [feature for feature in state_manager.get_property('enabled-features-list') if feature in BREEZY_GNOME_FEATURES] + breezy_features_granted = len(enabled_breezy_features) > 0 + self.missing_breezy_features_banner.set_revealed(not breezy_features_granted) self.license_action_needed_banner.set_revealed(state_manager.get_property('license-action-needed') == True) for child in self.main_content: @@ -77,7 +83,7 @@ class BreezydesktopWindow(Gtk.ApplicationWindow): else: self.main_content.append(self.no_device) - def _on_license_action_needed_button_clicked(self, widget): + def _on_license_button_clicked(self, widget): dialog = LicenseDialog() dialog.set_transient_for(widget.get_ancestor(Gtk.Window)) dialog.present()