make ClassicPreferences plugin work

This commit is contained in:
Chrys 2024-10-21 23:17:13 +02:00
parent 814e210a7f
commit f6085a187e
4 changed files with 5 additions and 62 deletions

View File

@ -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

View File

@ -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."""

View File

@ -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

View File

@ -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