[node-patches] Change in ovirt-node[master]: Introduce ui_config for plugins

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


Fabian Deutsch has uploaded a new change for review.

Change subject: Introduce ui_config for plugins
......................................................................

Introduce ui_config for plugins

Change-Id: I7f214e62886aa12dd6499915b1377602749ae2e5
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/plugins/__init__.py
M scripts/tui/src/ovirt/node/plugins/example.py
M scripts/tui/src/ovirt/node/plugins/features.py
M scripts/tui/src/ovirt/node/plugins/ping.py
M scripts/tui/src/ovirt/node/plugins/usage.py
M scripts/tui/src/ovirt/node/tui.py
6 files changed, 44 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/72/9872/1

diff --git a/scripts/tui/src/ovirt/node/plugins/__init__.py b/scripts/tui/src/ovirt/node/plugins/__init__.py
index 337d38d..bf2f087 100644
--- a/scripts/tui/src/ovirt/node/plugins/__init__.py
+++ b/scripts/tui/src/ovirt/node/plugins/__init__.py
@@ -114,10 +114,26 @@
 
     def ui_content(self):
         """Describes the UI this plugin requires
-        This is an ordered list of (path, widget) tuples.
+        This is an ordered list of (path, widget) tuples or a tuple with the
+        previous specified list of items and a second element with a dict
+        serving additional ui configs.
+
+        Returns:
+            List of (path, widget)
         """
         raise Exception("Not yet implemented.")
 
+    def ui_config(self):
+        """Specifies additional details for the UI
+        E.g. if some defaults should be omitted (default save button).
+
+        save_button: If the save button shall be displayed (True)
+
+        Returns:
+            A dict of config items and their values.
+        """
+        return {}
+
     def on_change(self, changes):
         """Applies the changes to the plugins model, will do all required logic
         return True if succeeds, otherwie false or throw an error
diff --git a/scripts/tui/src/ovirt/node/plugins/example.py b/scripts/tui/src/ovirt/node/plugins/example.py
index f2cac40..36bb83a 100644
--- a/scripts/tui/src/ovirt/node/plugins/example.py
+++ b/scripts/tui/src/ovirt/node/plugins/example.py
@@ -48,8 +48,6 @@
             ("foo.hostname", ovirt.node.plugins.Entry(label="Hostname")),
             ("foo.port", ovirt.node.plugins.Entry(label="Port")),
             ("foo.password", ovirt.node.plugins.PasswordEntry(label="Password")),
-            # This SaveButton will automatuically trigger the do_merge at the end
-            ("foo.do_save", ovirt.node.plugins.SaveButton()),
         ]
         self._widgets = dict(widgets)
         return widgets
diff --git a/scripts/tui/src/ovirt/node/plugins/features.py b/scripts/tui/src/ovirt/node/plugins/features.py
index b34d12d..2fc766d 100644
--- a/scripts/tui/src/ovirt/node/plugins/features.py
+++ b/scripts/tui/src/ovirt/node/plugins/features.py
@@ -26,3 +26,8 @@
             ("features.info", ovirt.node.plugins.Label(features))
         ]
         return widgets
+
+    def ui_config(self):
+        return {
+            "save_button": False
+        }
diff --git a/scripts/tui/src/ovirt/node/plugins/ping.py b/scripts/tui/src/ovirt/node/plugins/ping.py
index 4f2e004..1dd94d6 100644
--- a/scripts/tui/src/ovirt/node/plugins/ping.py
+++ b/scripts/tui/src/ovirt/node/plugins/ping.py
@@ -56,9 +56,15 @@
             ("ping.result-divider", ovirt.node.plugins.Divider("-")),
             ("ping.result", ovirt.node.plugins.Label("Result:")),
         ]
+        # Save it "locally" as a dict, for better accessability
         self._widgets = dict(widgets)
         return widgets
 
+    def ui_config(self):
+        return {
+            "save_button": False
+        }
+
     def on_change(self, changes):
         """Applies the changes to the plugins model, will do all required logic
         """
diff --git a/scripts/tui/src/ovirt/node/plugins/usage.py b/scripts/tui/src/ovirt/node/plugins/usage.py
index a7137a3..b79799e 100644
--- a/scripts/tui/src/ovirt/node/plugins/usage.py
+++ b/scripts/tui/src/ovirt/node/plugins/usage.py
@@ -28,3 +28,8 @@
             ("usage.info", ovirt.node.plugins.Label(usage))
         ]
         return widgets
+
+    def ui_config(self):
+        return {
+            "save_button": False
+        }
diff --git a/scripts/tui/src/ovirt/node/tui.py b/scripts/tui/src/ovirt/node/tui.py
index 1765160..0b22473 100644
--- a/scripts/tui/src/ovirt/node/tui.py
+++ b/scripts/tui/src/ovirt/node/tui.py
@@ -142,14 +142,24 @@
         """This method is building the widget for a plugin
         """
         widgets = []
+        config = {
+            "save_button": True
+        }
 
-        for path, item in plugin.ui_content():
+        ui_content = plugin.ui_content()
+        config.update(plugin.ui_config())
+
+        for path, item in ui_content:
             widget = self.__build_widget_for_item(plugin, path, item)
             widgets.append(("flow", widget))
 
+        if config["save_button"]:
 #            save = urwid.Button("Save", lambda x: plugin._on_ui_save())
 #            save = urwid.Padding(save, "left", width=8)
 #            save = urwid.Filler(save, ("fixed top", 1))
+            save = ovirt.node.widgets.Button("Save")
+            urwid.connect_signal(save, 'click', lambda x: plugin._on_ui_save())
+            widgets.append(urwid.Filler(save))
 
         widgets.append(urwid.Filler(urwid.Text("")))
 


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

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