diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2009-05-10 14:04:45 +0200 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2009-05-10 14:04:45 +0200 |
| commit | 946fb003e4be2e1485308d7fc5bb7274732751a3 (patch) | |
| tree | 8cc44adc5dc7a7885632c410925e4e6d6c7d332d /lib/python/Components | |
| parent | a012dfc95def3f4043f5b0bb319f1f4073592543 (diff) | |
| parent | d245191dd27ad9884c33ad3a76992dc6c4e8f33b (diff) | |
| download | enigma2-946fb003e4be2e1485308d7fc5bb7274732751a3.tar.gz enigma2-946fb003e4be2e1485308d7fc5bb7274732751a3.zip | |
Merge branch 'master' of /home/tmbinc/enigma2-git
Diffstat (limited to 'lib/python/Components')
| -rwxr-xr-x | lib/python/Components/Keyboard.py | 47 | ||||
| -rwxr-xr-x[-rw-r--r--] | lib/python/Components/Makefile.am | 3 | ||||
| -rwxr-xr-x[-rw-r--r--] | lib/python/Components/SetupDevices.py | 7 |
3 files changed, 55 insertions, 2 deletions
diff --git a/lib/python/Components/Keyboard.py b/lib/python/Components/Keyboard.py new file mode 100755 index 00000000..820d1036 --- /dev/null +++ b/lib/python/Components/Keyboard.py @@ -0,0 +1,47 @@ +from Components.Console import Console +from os import listdir as os_listdir, path as os_path +from re import compile as re_compile + +class Keyboard: + def __init__(self): + self.keyboardmaps = [] + self.readKeyboardMapFiles() + + def readKeyboardMapFiles(self): + for keymapfile in os_listdir('/usr/share/keymaps/'): + if (keymapfile.endswith(".info")): + f = open('/usr/share/keymaps/' + keymapfile) + mapfile = None + mapname = None + for line in f: + m = re_compile('^\s*(\w+)\s*=\s*(.*)\s*$').match(line) + if m: + key, val = m.groups() + if key == 'kmap': + mapfile = val + if key == 'name': + mapname = val + if (mapfile is not None) and (mapname is not None): + self.keyboardmaps.append(( mapfile,mapname)) + f.close() + + if len(self.keyboardmaps) == 0: + self.keyboardmaps = [('dream-de.kmap', 'Dreambox Keyboard Deutsch'), ('eng.kmap', 'Keyboard English')] + + def activateKeyboardMap(self, index): + try: + keymap = self.keyboardmaps[index] + print "Activating keymap:",keymap[1] + keymappath = '/usr/share/keymaps/' + keymap[0] + if os_path.exists(keymappath): + Console().ePopen(("loadkmap < " + str(keymappath))) + except: + print "Selected keymap does not exist!" + + def getKeyboardMaplist(self): + return self.keyboardmaps + + def getDefaultKeyboardMap(self): + return 'eng.kmap' + +keyboard = Keyboard() diff --git a/lib/python/Components/Makefile.am b/lib/python/Components/Makefile.am index 67cec18d..85e4d3ec 100644..100755 --- a/lib/python/Components/Makefile.am +++ b/lib/python/Components/Makefile.am @@ -18,4 +18,5 @@ install_PYTHON = \ MultiContent.py MediaPlayer.py TunerInfo.py VideoWindow.py ChoiceList.py \ Element.py Playlist.py ParentalControl.py ParentalControlList.py \ Ipkg.py SelectionList.py Scanner.py SystemInfo.py DreamInfoHandler.py \ - Task.py language_cache.py Console.py ResourceManager.py TuneTest.py + Task.py language_cache.py Console.py ResourceManager.py TuneTest.py \ + Keyboard.py diff --git a/lib/python/Components/SetupDevices.py b/lib/python/Components/SetupDevices.py index 71fb1e47..b037ea77 100644..100755 --- a/lib/python/Components/SetupDevices.py +++ b/lib/python/Components/SetupDevices.py @@ -1,6 +1,7 @@ from config import config, ConfigSelection, ConfigSubsection, ConfigOnOff, ConfigText from Components.Timezones import timezones from Components.Language import language +from Components.Keyboard import keyboard def InitSetupDevices(): @@ -11,8 +12,12 @@ def InitSetupDevices(): config.timezone.val = ConfigSelection(default = timezones.getDefaultTimezone(), choices = timezones.getTimezoneList()) config.timezone.val.addNotifier(timezoneNotifier) + def keyboardNotifier(configElement): + keyboard.activateKeyboardMap(configElement.index) + config.keyboard = ConfigSubsection(); - config.keyboard.keymap = ConfigSelection(choices = [("en", _("English")), ("de",_("German"))]) + config.keyboard.keymap = ConfigSelection(default = keyboard.getDefaultKeyboardMap(), choices = keyboard.getKeyboardMaplist()) + config.keyboard.keymap.addNotifier(keyboardNotifier) def languageNotifier(configElement): language.activateLanguage(configElement.value) |
