Added ClassicPreferences plugin but it needs more work before it is functioning.
This commit is contained in:
parent
41cf7ad88d
commit
814e210a7f
@ -0,0 +1,14 @@
|
|||||||
|
[Plugin]
|
||||||
|
Module=ClassicPreferences
|
||||||
|
Loader=python3
|
||||||
|
Name=Classic Preferences UI
|
||||||
|
Description=The classic preferences dialog
|
||||||
|
Authors=Chrys chrys@linux-a11y.org
|
||||||
|
Website=
|
||||||
|
Version=1.0
|
||||||
|
Copyright=
|
||||||
|
Builtin=true
|
||||||
|
Hidden=true
|
||||||
|
Depends=
|
||||||
|
Icon=
|
||||||
|
Help=
|
84
src/cthulhu/plugins/ClassicPreferences/ClassicPreferences.py
Normal file
84
src/cthulhu/plugins/ClassicPreferences/ClassicPreferences.py
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
from cthulhu import plugin
|
||||||
|
|
||||||
|
import gi, time
|
||||||
|
gi.require_version('Peas', '1.0')
|
||||||
|
from gi.repository import GObject
|
||||||
|
from gi.repository import Peas
|
||||||
|
import importlib, os
|
||||||
|
import cthulhu_gui_prefs
|
||||||
|
|
||||||
|
class ClassicPreferences(GObject.Object, Peas.Activatable, plugin.Plugin):
|
||||||
|
#__gtype_name__ = 'ClassicPreferences'
|
||||||
|
|
||||||
|
object = GObject.Property(type=GObject.Object)
|
||||||
|
def __init__(self):
|
||||||
|
plugin.Plugin.__init__(self)
|
||||||
|
def do_activate(self):
|
||||||
|
API = self.object
|
||||||
|
self.connectSignal("setup-inputeventhandlers-completed", self.setupCompatBinding)
|
||||||
|
#self.setupCompatBinding(API.app)
|
||||||
|
def setupCompatBinding(self, app):
|
||||||
|
cmdnames = app.getDynamicApiManager().getAPI('Cmdnames')
|
||||||
|
inputEventHandlers = app.getDynamicApiManager().getAPI('inputEventHandlers')
|
||||||
|
inputEventHandlers['preferencesSettingsHandler'] = app.getAPIHelper().createInputEventHandler(self.showPreferencesGUI, cmdnames.SHOW_PREFERENCES_GUI)
|
||||||
|
inputEventHandlers['appPreferencesSettingsHandler'] = app.getAPIHelper().createInputEventHandler(self.showAppPreferencesGUI, cmdnames.SHOW_APP_PREFERENCES_GUI)
|
||||||
|
def do_deactivate(self):
|
||||||
|
API = self.object
|
||||||
|
inputEventHandlers = API.app.getDynamicApiManager().getAPI('inputEventHandlers')
|
||||||
|
del inputEventHandlers['preferencesSettingsHandler']
|
||||||
|
del inputEventHandlers['appPreferencesSettingsHandler']
|
||||||
|
def do_update_state(self):
|
||||||
|
API = self.object
|
||||||
|
def showAppPreferencesGUI(self, 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.
|
||||||
|
"""
|
||||||
|
API = self.object
|
||||||
|
cthulhu_state = API.app.getDynamicApiManager().getAPI('CthulhuState')
|
||||||
|
settings = API.app.getDynamicApiManager().getAPI('Settings')
|
||||||
|
_settingsManager = API.app.getDynamicApiManager().getAPI('SettingsManager').getManager()
|
||||||
|
_scriptManager = API.app.getDynamicApiManager().getAPI('ScriptManager').getManager()
|
||||||
|
|
||||||
|
prefs = {}
|
||||||
|
for key in settings.userCustomizableSettings:
|
||||||
|
prefs[key] = _settingsManager.getSetting(key)
|
||||||
|
|
||||||
|
script = script or cthulhu_state.activeScript
|
||||||
|
self._showPreferencesUI(script, prefs)
|
||||||
|
return True
|
||||||
|
def showPreferencesGUI(self, 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.
|
||||||
|
"""
|
||||||
|
API = self.object
|
||||||
|
cthulhu_state = API.app.getDynamicApiManager().getAPI('CthulhuState')
|
||||||
|
settings = API.app.getDynamicApiManager().getAPI('Settings')
|
||||||
|
_settingsManager = API.app.getDynamicApiManager().getAPI('SettingsManager').getManager()
|
||||||
|
_scriptManager = API.app.getDynamicApiManager().getAPI('ScriptManager').getManager()
|
||||||
|
debug = API.app.getDynamicApiManager().getAPI('Debug')
|
||||||
|
prefs = _settingsManager.getGeneralSettings(_settingsManager.profile)
|
||||||
|
script = _scriptManager.getDefaultScript()
|
||||||
|
self._showPreferencesUI(script, prefs)
|
||||||
|
return True
|
||||||
|
def _showPreferencesUI(self, script, prefs):
|
||||||
|
API = self.object
|
||||||
|
cthulhu_state = API.app.getDynamicApiManager().getAPI('CthulhuState')
|
||||||
|
debug = API.app.getDynamicApiManager().getAPI('Debug')
|
||||||
|
cthulhu_platform = API.app.getDynamicApiManager().getAPI('CthulhuPlatform')
|
||||||
|
|
||||||
|
if cthulhu_state.cthulhuOS:
|
||||||
|
cthulhu_state.cthulhuOS.showGUI()
|
||||||
|
return
|
||||||
|
|
||||||
|
uiFile = os.path.join(self.getModuleDir(),
|
||||||
|
"cthulhu-setup.ui")
|
||||||
|
|
||||||
|
cthulhu_state.cthulhuOS = cthulhu_gui_prefs.CthulhuSetupGUI(uiFile, "cthulhuSetupWindow", prefs, API.app)
|
||||||
|
cthulhu_state.cthulhuOS.init(script)
|
||||||
|
cthulhu_state.cthulhuOS.setTranslationContext(self.getTranslationContext())
|
||||||
|
cthulhu_state.cthulhuOS.showGUI()
|
10
src/cthulhu/plugins/ClassicPreferences/Makefile.am
Normal file
10
src/cthulhu/plugins/ClassicPreferences/Makefile.am
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
cthulhu_python_PYTHON = \
|
||||||
|
__init__.py \
|
||||||
|
ClassicPreferences.plugin \
|
||||||
|
ClassicPreferences.py \
|
||||||
|
cthulhu_gui_prefs.py \
|
||||||
|
cthulhu_gui_profile.py \
|
||||||
|
cthulhu-setup.ui
|
||||||
|
|
||||||
|
cthulhu_pythondir=$(pkgpythondir)/plugins/ClassicPreferences
|
||||||
|
|
0
src/cthulhu/plugins/ClassicPreferences/__init__.py
Normal file
0
src/cthulhu/plugins/ClassicPreferences/__init__.py
Normal file
3432
src/cthulhu/plugins/ClassicPreferences/cthulhu-setup.ui
Normal file
3432
src/cthulhu/plugins/ClassicPreferences/cthulhu-setup.ui
Normal file
File diff suppressed because it is too large
Load Diff
3636
src/cthulhu/plugins/ClassicPreferences/cthulhu_gui_prefs.py
Normal file
3636
src/cthulhu/plugins/ClassicPreferences/cthulhu_gui_prefs.py
Normal file
File diff suppressed because it is too large
Load Diff
163
src/cthulhu/plugins/ClassicPreferences/cthulhu_gui_profile.py
Normal file
163
src/cthulhu/plugins/ClassicPreferences/cthulhu_gui_profile.py
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
# Cthulhu
|
||||||
|
#
|
||||||
|
# Copyright 2010 Consorcio Fernando de los Rios.
|
||||||
|
# Author: Javier Hernandez Antunez <jhernandez@emergya.es>
|
||||||
|
# Author: Alejandro Leiva <aleiva@emergya.es>
|
||||||
|
#
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the
|
||||||
|
# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
|
||||||
|
# Boston MA 02110-1301 USA.
|
||||||
|
|
||||||
|
"""Displays the Save Profile As dialog."""
|
||||||
|
|
||||||
|
__id__ = "$Id$"
|
||||||
|
__version__ = "$Revision$"
|
||||||
|
__date__ = "$Date$"
|
||||||
|
__copyright__ = "Copyright (c) 2010 Consorcio Fernando de los Rios."
|
||||||
|
__license__ = "LGPL"
|
||||||
|
|
||||||
|
import locale
|
||||||
|
import sys
|
||||||
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
cthulhu_state = None
|
||||||
|
guilabels = None
|
||||||
|
|
||||||
|
OS = None
|
||||||
|
newProfile = None
|
||||||
|
|
||||||
|
app = None
|
||||||
|
|
||||||
|
class CthulhuProfileGUI(Gtk.Dialog):
|
||||||
|
|
||||||
|
def __init__(self, app):
|
||||||
|
"""Initialize the Cthulhu profile configuration GUI."""
|
||||||
|
self.app = app
|
||||||
|
global guilabels
|
||||||
|
global cthulhu_state
|
||||||
|
|
||||||
|
guilabels = self.app.getDynamicApiManager().getAPI('GuiLabels')
|
||||||
|
cthulhu_state = self.app.getDynamicApiManager().getAPI('CthulhuState')
|
||||||
|
|
||||||
|
Gtk.Dialog.__init__(self)
|
||||||
|
self.set_title(guilabels.PROFILE_SAVE_AS_TITLE)
|
||||||
|
self.set_has_resize_grip(False)
|
||||||
|
|
||||||
|
self.add_button('gtk-cancel', Gtk.ResponseType.CANCEL)
|
||||||
|
self.add_button('gtk-save', Gtk.ResponseType.ACCEPT)
|
||||||
|
|
||||||
|
grid = Gtk.Grid()
|
||||||
|
grid.set_property('margin', 12)
|
||||||
|
grid.set_row_spacing(10)
|
||||||
|
grid.set_column_spacing(10)
|
||||||
|
|
||||||
|
# Right now the content area is a GtkBox. We'll need to update
|
||||||
|
# this once GtkBox is fully deprecated.
|
||||||
|
contentArea = self.get_content_area()
|
||||||
|
contentArea.pack_start(grid, True, True, 0)
|
||||||
|
|
||||||
|
self.profileEntry = Gtk.Entry()
|
||||||
|
self.profileEntry.set_property('hexpand', True)
|
||||||
|
self.profileEntry.set_activates_default(True)
|
||||||
|
grid.attach(self.profileEntry, 1, 0, 1, 1)
|
||||||
|
|
||||||
|
label = Gtk.Label(guilabels.PROFILE_NAME_LABEL)
|
||||||
|
label.set_use_underline(True)
|
||||||
|
label.set_mnemonic_widget(self.profileEntry)
|
||||||
|
grid.attach(label, 0, 0, 1, 1)
|
||||||
|
|
||||||
|
defaultButton = self.get_widget_for_response(Gtk.ResponseType.ACCEPT)
|
||||||
|
defaultButton.set_property('can-default', True)
|
||||||
|
defaultButton.set_property('has-default', True)
|
||||||
|
|
||||||
|
self.connect('response', self.onResponse)
|
||||||
|
self.connect('destroy', self.onDestroy)
|
||||||
|
|
||||||
|
self.searchString = None
|
||||||
|
self.profileString = None
|
||||||
|
self.prefsDialog = None
|
||||||
|
self.translationContext = None
|
||||||
|
|
||||||
|
def init(self):
|
||||||
|
self.profileString = ''
|
||||||
|
|
||||||
|
def showGUI(self, prefsDialog):
|
||||||
|
"""Show the Save Profile As dialog."""
|
||||||
|
|
||||||
|
self.show_all()
|
||||||
|
self.prefsDialog = prefsDialog
|
||||||
|
self.profileEntry.set_text(self.profileString)
|
||||||
|
ts = 0
|
||||||
|
try:
|
||||||
|
ts = cthulhu_state.lastInputEvent.timestamp
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
if ts == 0:
|
||||||
|
ts = Gtk.get_current_event_time()
|
||||||
|
self.present_with_time(ts)
|
||||||
|
|
||||||
|
def onResponse(self, widget, response):
|
||||||
|
"""Signal handler for the responses emitted by the dialog."""
|
||||||
|
|
||||||
|
if response in [Gtk.ResponseType.CANCEL, Gtk.ResponseType.DELETE_EVENT]:
|
||||||
|
self.hide()
|
||||||
|
return
|
||||||
|
|
||||||
|
if response == Gtk.ResponseType.ACCEPT:
|
||||||
|
global newProfile
|
||||||
|
|
||||||
|
newProfile = self.profileEntry.get_text()
|
||||||
|
if newProfile:
|
||||||
|
self.destroy()
|
||||||
|
if self.prefsDialog:
|
||||||
|
self.prefsDialog.saveProfile(newProfile)
|
||||||
|
|
||||||
|
def onDestroy(self, widget):
|
||||||
|
"""Signal handler for the 'destroy' signal of the dialog."""
|
||||||
|
|
||||||
|
global OS
|
||||||
|
|
||||||
|
OS = None
|
||||||
|
|
||||||
|
def setTranslationContext(newTranslationContext):
|
||||||
|
global _, translationContext
|
||||||
|
translationContext = newTranslationContext
|
||||||
|
_ = newTranslationContext.gettext
|
||||||
|
|
||||||
|
def setApp(newApp):
|
||||||
|
global app
|
||||||
|
app = newApp
|
||||||
|
|
||||||
|
def showProfileUI(prefsDialog=None):
|
||||||
|
global OS
|
||||||
|
global newProfile
|
||||||
|
|
||||||
|
newProfile = None
|
||||||
|
|
||||||
|
if not OS:
|
||||||
|
OS = CthulhuProfileGUI(app)
|
||||||
|
OS.init()
|
||||||
|
|
||||||
|
OS.showGUI(prefsDialog)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
|
|
||||||
|
showProfileUI()
|
||||||
|
|
||||||
|
Gtk.main()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user