[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [arm/release] Support boolean conf options.



commit ac0278521e4d71348ec68776112a9fb55497d02d
Author: Kamran Riaz Khan <krkhan@xxxxxxxxxxxxxx>
Date:   Wed Jul 27 07:15:23 2011 +0500

    Support boolean conf options.
---
 src/gui/configPanel.py |    6 ++++++
 src/util/gtkTools.py   |   31 +++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/src/gui/configPanel.py b/src/gui/configPanel.py
index a1d1daa..7b1ea42 100644
--- a/src/gui/configPanel.py
+++ b/src/gui/configPanel.py
@@ -17,6 +17,10 @@ def inputConfValueText(option):
   prompt = "Enter value for %s" % option
   return gtkTools.inputText(prompt)
 
+def inputConfValueBoolean(option):
+  prompt = "Select value for %s" % option
+  return "1" if gtkTools.inputBoolean(prompt) else "0"
+
 class ConfContents(gtkTools.ListWrapper):
   def _create_row_from_value(self, entry):
     option = entry.get(Field.OPTION)
@@ -77,6 +81,8 @@ class ConfigPanel(object, CliConfigPanel):
 
     if configType == 'DataSize':
       newValue = inputConfValueText(configOption)
+    elif configType == 'Boolean':
+      newValue = inputConfValueBoolean(configOption)
 
     if newValue:
       try:
diff --git a/src/util/gtkTools.py b/src/util/gtkTools.py
index 5180e82..cc2d361 100644
--- a/src/util/gtkTools.py
+++ b/src/util/gtkTools.py
@@ -125,6 +125,37 @@ def inputText(prompt):
 
   return text if response == gtk.RESPONSE_OK else None
 
+def inputBoolean(prompt):
+  dialog = gtk.MessageDialog(None,
+      gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+      gtk.MESSAGE_QUESTION,
+      gtk.BUTTONS_OK_CANCEL,
+      None)
+
+  dialog.set_markup(prompt)
+
+  hbox = gtk.HBox()
+  buttonTrue = gtk.RadioButton(None, "True")
+  buttonFalse = gtk.RadioButton(buttonTrue, "False")
+  hbox.pack_start(buttonTrue, True, True, 0)
+  hbox.pack_start(buttonFalse, True, True, 0)
+
+  dialog.vbox.pack_end(hbox, True, True, 0)
+
+  dialog.show_all()
+  response = dialog.run()
+
+  choice = None
+
+  if buttonTrue.get_active():
+    choice = True
+  elif buttonFalse.get_active():
+    choice = False
+
+  dialog.destroy()
+
+  return choice if response == gtk.RESPONSE_OK else None
+
 def showError(msg):
   dialog = gtk.MessageDialog(None,
       gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits