[tor-commits] [arm/master] Prepopulate bool confs.

atagar at torproject.org atagar at torproject.org
Thu Aug 11 15:27:57 UTC 2011


commit e088d225dc023c5d7c81002de0bc30cb674e6aab
Author: Kamran Riaz Khan <krkhan at inspirated.com>
Date:   Sat Jul 30 16:06:31 2011 +0500

    Prepopulate bool confs.
---
 src/gui/configPanel.py |   12 +++++++++---
 src/util/gtkTools.py   |    8 +++++++-
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/gui/configPanel.py b/src/gui/configPanel.py
index d3b3a9c..110c67f 100644
--- a/src/gui/configPanel.py
+++ b/src/gui/configPanel.py
@@ -29,9 +29,15 @@ def input_conf_value_string(option, oldValue):
   prompt = "Enter value for %s" % option
   return gtkTools.input_string(prompt, oldValue)
 
-def input_conf_value_boolean(option):
+def input_conf_value_bool(option, oldValue):
   prompt = "Select value for %s" % option
-  return "1" if gtkTools.input_boolean(prompt) else "0"
+
+  newValue = gtkTools.input_bool(prompt, oldValue)
+
+  if newValue == None:
+    return
+
+  return "1" if newValue else "0"
 
 def input_conf_value_dir(option):
   prompt = "Select value for %s" % option
@@ -109,7 +115,7 @@ class ConfigPanel(object, CliConfigPanel):
     elif configType == 'LineList':
       newValue = input_conf_value_list(configOption)
     elif configType == 'Boolean':
-      newValue = input_conf_value_boolean(configOption)
+      newValue = input_conf_value_bool(configOption, oldValue)
     elif configType == 'Filename':
       if 'Directory' in configOption:
         newValue = input_conf_value_dir(configOption)
diff --git a/src/util/gtkTools.py b/src/util/gtkTools.py
index 68946de..44296f5 100644
--- a/src/util/gtkTools.py
+++ b/src/util/gtkTools.py
@@ -273,7 +273,7 @@ def input_list(prompt):
 
   return None if len(listStore) == 0 else " ".join([row[0] for row in listStore])
 
-def input_boolean(prompt):
+def input_bool(prompt, default=None):
   dialog = gtk.MessageDialog(None,
       gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
       gtk.MESSAGE_QUESTION,
@@ -290,6 +290,12 @@ def input_boolean(prompt):
 
   dialog.vbox.pack_end(hbox, True, True, 0)
 
+  if not default == None:
+    if default == 'True':
+      buttonTrue.set_active(True)
+    elif default == 'False':
+      buttonFalse.set_active(True)
+
   dialog.show_all()
   response = dialog.run()
 





More information about the tor-commits mailing list