[node-patches] Change in ovirt-node[master]: builder: Fix Table selection

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


Fabian Deutsch has uploaded a new change for review.

Change subject: builder: Fix Table selection
......................................................................

builder: Fix Table selection

Previously it wasn't possible to hit ENTER on an entry in a Table
without doing an up-down-cycle.

Change-Id: Ie5c7ea82b293c364ce8d787b612029c30568af4b
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/ui/__init__.py
M scripts/tui/src/ovirt/node/ui/builder.py
M scripts/tui/src/ovirt/node/ui/widgets.py
3 files changed, 19 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/16/9916/1

diff --git a/scripts/tui/src/ovirt/node/ui/__init__.py b/scripts/tui/src/ovirt/node/ui/__init__.py
index aac852c..84fa56e 100644
--- a/scripts/tui/src/ovirt/node/ui/__init__.py
+++ b/scripts/tui/src/ovirt/node/ui/__init__.py
@@ -294,3 +294,9 @@
         self.header = header
         self.items = items
         self.height = height
+
+    @Element.signal_change
+    def select(self, selected=None):
+        if selected in dict(self.items).keys():
+            self._selected = selected
+        return self._selected
diff --git a/scripts/tui/src/ovirt/node/ui/builder.py b/scripts/tui/src/ovirt/node/ui/builder.py
index 38f74e1..41d9b27 100644
--- a/scripts/tui/src/ovirt/node/ui/builder.py
+++ b/scripts/tui/src/ovirt/node/ui/builder.py
@@ -247,8 +247,10 @@
         children.append(c)
     widget = ovirt.node.ui.widgets.TableWidget(item.header, children,
                                                item.height)
-    urwid.connect_signal(widget, "changed",
-                         lambda w: plugin._on_ui_change({path: w._key}))
+    def on_change_cb(w, d=None):
+        plugin._on_ui_change({path: w._key})
+        item.select(w._key)
+    urwid.connect_signal(widget, "changed", on_change_cb)
 
     return widget
 
@@ -257,9 +259,10 @@
     c = ovirt.node.ui.widgets.TableEntryWidget(label)
     c._key = key
 
-    def on_click_cb(widget, data):
+    def on_activate_cb(w, data):
+        plugin._on_ui_change({path: w._key})
         parse_plugin_result(tui, plugin, plugin._on_ui_save())
-    urwid.connect_signal(c, "click", on_click_cb)
+    urwid.connect_signal(c, "activate", on_activate_cb)
     return c
 
 
diff --git a/scripts/tui/src/ovirt/node/ui/widgets.py b/scripts/tui/src/ovirt/node/ui/widgets.py
index 2affe1e..5a7dced 100644
--- a/scripts/tui/src/ovirt/node/ui/widgets.py
+++ b/scripts/tui/src/ovirt/node/ui/widgets.py
@@ -42,7 +42,7 @@
     """
     _text = None
 
-    signals = ["click"]
+    signals = ["activate"]
 
     def __init__(self, title):
         self._text = SelectableText(title)
@@ -53,15 +53,15 @@
                                                            'table.entry:focus')
 
     def keypress(self, size, key):
-        if self._command_map[key] != 'activate':
-            return key
-        self._emit('click', None)
+        if urwid.Button._command_map[key] == 'activate':
+            self._emit('activate', None)
+        return key
 
     def mouse_event(self, size, event, button, x, y, focus):
         if button != 1 or not urwid.util.is_mouse_press(event):
             return False
 
-        self._emit('click', self)
+        self._emit('activate', self)
         return True
 
 
@@ -238,7 +238,7 @@
 
 
 class Entry(urwid.WidgetWrap):
-    signals = ['change']
+    signals = ['change', 'click']
 
     notice = property(lambda self: self._notice.get_text(), \
                       lambda self, v: self._notice.set_text(v))


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie5c7ea82b293c364ce8d787b612029c30568af4b
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