[node-patches] Change in ovirt-node[master]: keyboard: Display available keybpoard layouts

fabiand at fedoraproject.org fabiand at fedoraproject.org
Tue Dec 11 20:09:40 UTC 2012


Fabian Deutsch has uploaded a new change for review.

Change subject: keyboard: Display available keybpoard layouts
......................................................................

keyboard: Display available keybpoard layouts

Change-Id: Icf60d595b25ca1cbfedb5debca7f8d9fdc9a1d12
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/setup/keyboard_page.py
M scripts/tui/src/ovirt/node/utils/__init__.py
2 files changed, 18 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/38/9938/1

diff --git a/scripts/tui/src/ovirt/node/setup/keyboard_page.py b/scripts/tui/src/ovirt/node/setup/keyboard_page.py
index 006f428..df6ffcf 100644
--- a/scripts/tui/src/ovirt/node/setup/keyboard_page.py
+++ b/scripts/tui/src/ovirt/node/setup/keyboard_page.py
@@ -23,11 +23,9 @@
 Configure Keyboard Layout
 """
 
-import ovirt.node.plugins
-import ovirt.node.ui
+from ovirt.node import plugins, ui, utils
 
-
-class Plugin(ovirt.node.plugins.NodePlugin):
+class Plugin(plugins.NodePlugin):
     _model = None
     _widgets = None
 
@@ -52,25 +50,19 @@
         """Describes the UI this plugin requires
         This is an ordered list of (path, widget) tuples.
         """
+        kbd = utils.Keyboard()
         widgets = [
             ("layout._header",
-                ovirt.node.ui.Header("Keyboard Layout Selection")),
-            ("layout", ovirt.node.ui.Table("Available Keyboard Layouts",
-                                           "", self._get_layouts())),
+                ui.Header("Keyboard Layout Selection")),
+            ("layout", ui.Table("Available Keyboard Layouts",
+                                "", kbd.available_layouts())),
 
         ]
         # Save it "locally" as a dict, for better accessability
         self._widgets = dict(widgets)
 
-        page = ovirt.node.ui.Page(widgets)
+        page = ui.Page(widgets)
         return page
-
-    def _get_layouts(self):
-        # FIXME load from somewhere
-        return [
-                ("en_US", "U.S. English"),
-                ("de_DE", "German"),
-                ]
 
     def on_change(self, changes):
         pass
diff --git a/scripts/tui/src/ovirt/node/utils/__init__.py b/scripts/tui/src/ovirt/node/utils/__init__.py
index 4faabb6..5c7304f 100644
--- a/scripts/tui/src/ovirt/node/utils/__init__.py
+++ b/scripts/tui/src/ovirt/node/utils/__init__.py
@@ -29,6 +29,7 @@
 
 import hashlib
 import augeas as _augeas
+import system_config_keyboard.keyboard
 
 from ovirt.node import base
 
@@ -156,3 +157,13 @@
         if len(utxt) > 0 and utxt[0] in ["y", "t", "Y", "T", "1"]:
             return True
     return False
+
+
+class Keyboard(base.Base):
+    def available_layouts(self):
+        kbd = system_config_keyboard.keyboard.Keyboard()
+        kbd.read()
+        layoutgen = ((details[0], kid)
+                     for kid, details in kbd.modelDict.items())
+        layouts = [(kid, name) for name, kid in sorted(layoutgen)]
+        return layouts
\ No newline at end of file


--
To view, visit http://gerrit.ovirt.org/9938
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icf60d595b25ca1cbfedb5debca7f8d9fdc9a1d12
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list