From f6085a187e67833a61b0132583ba8c54f5652611 Mon Sep 17 00:00:00 2001 From: Chrys Date: Mon, 21 Oct 2024 23:17:13 +0200 Subject: [PATCH] make ClassicPreferences plugin work --- configure.ac | 2 +- src/cthulhu/cthulhu.py | 49 --------------------------------- src/cthulhu/plugins/Makefile.am | 2 +- src/cthulhu/scripts/default.py | 14 ++-------- 4 files changed, 5 insertions(+), 62 deletions(-) diff --git a/configure.ac b/configure.ac index ec1e69b..35799b9 100644 --- a/configure.ac +++ b/configure.ac @@ -128,7 +128,7 @@ src/cthulhu/plugins/CapsLockHack/Makefile src/cthulhu/plugins/SelfVoice/Makefile src/cthulhu/plugins/Date/Makefile src/cthulhu/plugins/Time/Makefile -src/cthulhu/plugins/MouseReview/Makefile +src/cthulhu/plugins/ClassicPreferences/Makefile src/cthulhu/backends/Makefile src/cthulhu/cthulhu_bin.py src/cthulhu/cthulhu_i18n.py diff --git a/src/cthulhu/cthulhu.py b/src/cthulhu/cthulhu.py index bdd026e..4afb62e 100644 --- a/src/cthulhu/cthulhu.py +++ b/src/cthulhu/cthulhu.py @@ -530,55 +530,6 @@ def loadUserSettings(script=None, inputEvent=None, skipReloadMessage=False): return True -def _showPreferencesUI(script, prefs): - if cthulhu_state.cthulhuOS: - cthulhu_state.cthulhuOS.showGUI() - return - - try: - module = importlib.import_module('.cthulhu_gui_prefs', 'cthulhu') - except Exception: - debug.printException(debug.LEVEL_SEVERE) - return - - uiFile = os.path.join(cthulhu_platform.datadir, - cthulhu_platform.package, - "ui", - "cthulhu-setup.ui") - - cthulhu_state.cthulhuOS = module.CthulhuSetupGUI(uiFile, "cthulhuSetupWindow", prefs) - cthulhu_state.cthulhuOS.init(script) - cthulhu_state.cthulhuOS.showGUI() - -def showAppPreferencesGUI(script=None, inputEvent=None): - """Displays the user interface to configure the settings for a - specific applications within Cthulhu and set up those app-specific - user preferences using a GUI. - - Returns True to indicate the input event has been consumed. - """ - - prefs = {} - for key in settings.userCustomizableSettings: - prefs[key] = _settingsManager.getSetting(key) - - script = script or cthulhu_state.activeScript - _showPreferencesUI(script, prefs) - - return True - -def showPreferencesGUI(script=None, inputEvent=None): - """Displays the user interface to configure Cthulhu and set up - user preferences using a GUI. - - Returns True to indicate the input event has been consumed. - """ - - prefs = _settingsManager.getGeneralSettings(_settingsManager.profile) - script = _scriptManager.getDefaultScript() - _showPreferencesUI(script, prefs) - - return True def addKeyGrab(binding): """ Add a key grab for the given key binding.""" diff --git a/src/cthulhu/plugins/Makefile.am b/src/cthulhu/plugins/Makefile.am index 581341d..a2ac9a2 100644 --- a/src/cthulhu/plugins/Makefile.am +++ b/src/cthulhu/plugins/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = Clipboard HelloWorld SelfVoice Time MouseReview Date ByeCthulhu HelloCthulhu PluginManager CapsLockHack +SUBDIRS = Clipboard HelloWorld SelfVoice Time MouseReview Date ByeCthulhu HelloCthulhu PluginManager CapsLockHack ClassicPreferences cthulhu_pythondir=$(pkgpythondir)/plugins diff --git a/src/cthulhu/scripts/default.py b/src/cthulhu/scripts/default.py index 31c0adf..b1c990e 100644 --- a/src/cthulhu/scripts/default.py +++ b/src/cthulhu/scripts/default.py @@ -204,16 +204,6 @@ class Script(script.Script): cthulhu.quitCthulhu, cmdnames.QUIT_CTHULHU) - self.inputEventHandlers["preferencesSettingsHandler"] = \ - input_event.InputEventHandler( - cthulhu.showPreferencesGUI, - cmdnames.SHOW_PREFERENCES_GUI) - - self.inputEventHandlers["appPreferencesSettingsHandler"] = \ - input_event.InputEventHandler( - cthulhu.showAppPreferencesGUI, - cmdnames.SHOW_APP_PREFERENCES_GUI) - self.inputEventHandlers["cycleSettingsProfileHandler"] = \ input_event.InputEventHandler( Script.cycleSettingsProfile, @@ -239,7 +229,9 @@ class Script(script.Script): self.inputEventHandlers.update(self.learnModePresenter.get_handlers()) self.inputEventHandlers.update(self.mouseReviewer.get_handlers()) self.inputEventHandlers.update(self.actionPresenter.get_handlers()) - + cthulhu.getManager().getDynamicApiManager().registerAPI('inputEventHandlers',self.inputEventHandlers, overwrite=True) + cthulhu.getManager().getSignalManager().emitSignal('setup-inputeventhandlers-completed') + def getInputEventHandlerKey(self, inputEventHandler): """Returns the name of the key that contains an inputEventHadler passed as argument