[tor-commits] [arm/release] Prepopulate linelist confs.

atagar at torproject.org atagar at torproject.org
Sun Sep 25 21:38:23 UTC 2011


commit 610420ea46ad2c03052c3656f0616b5224330e74
Author: Kamran Riaz Khan <krkhan at inspirated.com>
Date:   Sat Jul 30 16:11:21 2011 +0500

    Prepopulate linelist confs.
---
 src/gui/configPanel.py |    6 +++---
 src/util/gtkTools.py   |   10 +++++++++-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/gui/configPanel.py b/src/gui/configPanel.py
index 110c67f..efa9b71 100644
--- a/src/gui/configPanel.py
+++ b/src/gui/configPanel.py
@@ -21,9 +21,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):
+def input_conf_value_list(option, oldValue):
   prompt = "Enter value for %s" % option
-  return gtkTools.input_list(prompt)
+  return gtkTools.input_list(prompt, oldValue)
 
 def input_conf_value_string(option, oldValue):
   prompt = "Enter value for %s" % option
@@ -113,7 +113,7 @@ class ConfigPanel(object, CliConfigPanel):
     elif configType == 'String':
       newValue = input_conf_value_string(configOption, oldValue)
     elif configType == 'LineList':
-      newValue = input_conf_value_list(configOption)
+      newValue = input_conf_value_list(configOption, oldValue)
     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 44296f5..435f694 100644
--- a/src/util/gtkTools.py
+++ b/src/util/gtkTools.py
@@ -213,7 +213,7 @@ def input_string(prompt, default=None):
 
   return text if response == gtk.RESPONSE_OK else None
 
-def input_list(prompt):
+def input_list(prompt, default):
   def on_add_button_clicked(widget, listStore):
     newValue = input_string("Enter new value:")
 
@@ -266,11 +266,19 @@ def input_list(prompt):
   addButton.connect('clicked', on_add_button_clicked, listStore)
   deleteButton.connect('clicked', on_delete_button_clicked, treeView)
 
+  if default:
+    for value in default.split():
+      row = (value,)
+      listStore.append(row)
+
   dialog.show_all()
   response = dialog.run()
 
   dialog.destroy()
 
+  if not response == gtk.RESPONSE_OK:
+    return
+
   return None if len(listStore) == 0 else " ".join([row[0] for row in listStore])
 
 def input_bool(prompt, default=None):





More information about the tor-commits mailing list