commit eccb84e2494dc2b31aeea8ee33053368d0763d71
Author: Kamran Riaz Khan <krkhan(a)inspirated.com>
Date: Sun Jul 31 15:47:30 2011 +0500
Use CSVs for RouterList values.
---
src/gui/configPanel.py | 8 +++++---
src/util/gtkTools.py | 9 +++++----
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/gui/configPanel.py b/src/gui/configPanel.py
index 1b57341..adcdcec 100644
--- a/src/gui/configPanel.py
+++ b/src/gui/configPanel.py
@@ -34,9 +34,9 @@ def input_conf_value_int(option, oldValue):
prompt = "Enter value for %s" % option
return gtkTools.input_int(prompt, oldValue)
-def input_conf_value_list(option, oldValue):
+def input_conf_value_list(option, oldValue, csv=False):
prompt = "Enter value for %s" % option
- return gtkTools.input_list(prompt, oldValue)
+ return gtkTools.input_list(prompt, oldValue, csv)
def input_conf_value_string(option, oldValue):
prompt = "Enter value for %s" % option
@@ -138,7 +138,9 @@ class ConfigPanel(object, CliConfigPanel):
elif configType == 'String':
newValue = input_conf_value_string(configOption, oldValue)
elif configType == 'LineList':
- newValue = input_conf_value_list(configOption, oldValue)
+ newValue = input_conf_value_list(configOption, oldValue, csv=False)
+ elif configType == 'RouterList':
+ newValue = input_conf_value_list(configOption, oldValue, csv=True)
elif configType == 'Boolean':
newValue = input_conf_value_bool(configOption, oldValue)
elif configType == 'Filename':
diff --git a/src/util/gtkTools.py b/src/util/gtkTools.py
index 8e8b985..2960188 100644
--- a/src/util/gtkTools.py
+++ b/src/util/gtkTools.py
@@ -214,7 +214,7 @@ def input_time(prompt, default=None):
return "%d %s" % (value, units) if response == gtk.RESPONSE_OK else None
-def input_int(prompt, default=None):
+def input_int(prompt, default=None, csvResponse=False):
dialog = gtk.MessageDialog(None,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_QUESTION,
@@ -268,7 +268,7 @@ def input_string(prompt, default=None):
return text if response == gtk.RESPONSE_OK else None
-def input_list(prompt, default):
+def input_list(prompt, default, csv=False):
def on_add_button_clicked(widget, listStore):
newValue = input_string("Enter new value:")
@@ -321,8 +321,9 @@ def input_list(prompt, default):
addButton.connect('clicked', on_add_button_clicked, listStore)
deleteButton.connect('clicked', on_delete_button_clicked, treeView)
+ separator = "," if csv else " "
if default:
- for value in default.split():
+ for value in default.split(separator):
row = (value,)
listStore.append(row)
@@ -334,7 +335,7 @@ def input_list(prompt, default):
if not response == gtk.RESPONSE_OK:
return
- return None if len(listStore) == 0 else " ".join([row[0] for row in listStore])
+ return None if len(listStore) == 0 else separator.join([row[0] for row in listStore])
def input_bool(prompt, default=None):
dialog = gtk.MessageDialog(None,