def destroy(self): cron.cancel(self.disable_poller_job) cron.cancel(self.update_environment_debouncer) self.event_dispatch.unregister("persist_preferences", self.debounce_widget_preferences) self.event_dispatch.unregister("hide_context_menu", self.hide_context_menu) self.event_dispatch.unregister("deactivate_poller", self.deactivate_poller) self.event_dispatch.unregister("show_context_menu", self.move_context_menu) self.event_dispatch.unregister("synchronize_poller", self.synchronize_widget_poller) self.event_dispatch = None ui.unregister('screen_change', self.reload_preferences) settings.unregister("user.talon_hud_environment", self.hud_environment_change) if self.display_state: self.display_state.unregister('broadcast_update', self.broadcast_update) self.display_state = None if self.enabled: for widget in self.widget_manager.widgets: show_animations = widget.show_animations widget.show_animations = False widget.disable() widget.show_animations = show_animations self.widget_manager.widgets = [] self.widget_manager = None
def register_events(register: bool): global events_registered if register: if not events_registered and live_update: events_registered = True ui.register('', ui_event) else: events_registered = False ui.unregister('', ui_event)
def disable(self, persisted=False): if self.enabled: self.set_current_flow("disabled" if persisted else "auto_disabled") self.enabled = False for widget in self.widget_manager.widgets: if widget.enabled: widget.disable() self.synchronize_pollers() # Disconnect the events relating to non-content communication self.event_dispatch.unregister("persist_preferences", self.debounce_widget_preferences) self.event_dispatch.unregister("hide_context_menu", self.hide_context_menu) self.event_dispatch.unregister("deactivate_poller", self.deactivate_poller) self.event_dispatch.unregister("show_context_menu", self.move_context_menu) self.event_dispatch.unregister("synchronize_poller", self.synchronize_widget_poller) self.disable_poller_job = cron.interval("30ms", self.disable_poller_check) self.display_state.unregister("broadcast_update", self.broadcast_update) ui.unregister("screen_change", self.reload_preferences) settings.unregister("user.talon_hud_environment", self.hud_environment_change) self.determine_active_setup_mouse() # Only change the tags upon a user action - No automatic flow should set tags to prevent cascades if persisted: ctx.tags = ["user.talon_hud_available"] self.preferences.persist_preferences({"enabled": False}) # Make sure context isn't updated in this thread because of automatic reloads cron.cancel(self.update_context_debouncer) self.update_context_debouncer = cron.after("50ms", self.update_context)
def disable(self): if self.enabled: self.enabled = False self.content.publish_event("status_icons", "focus_toggle", "remove") self.content.publish_event("screen_regions", "focus", "remove") ui.unregister("win_focus", self.update_focus_indicator) ui.unregister("win_resize", self.update_focus_indicator) ui.unregister("win_move", self.move_focus_indicator) cron.cancel(self.move_indicator_job)
def unload(): ctx.unload() ui.unregister('', update_lists)