[tor-commits] [arm/master] Support integer confs.
atagar at torproject.org
atagar at torproject.org
Thu Aug 11 15:27:57 UTC 2011
commit e72dad26709f7260af4567a53c4b334681eb3072
Author: Kamran Riaz Khan <krkhan at inspirated.com>
Date: Sat Jul 30 14:25:07 2011 +0500
Support integer confs.
---
src/gui/configPanel.py | 8 ++++++++
src/util/gtkTools.py | 26 ++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/src/gui/configPanel.py b/src/gui/configPanel.py
index b87c1b3..582034a 100644
--- a/src/gui/configPanel.py
+++ b/src/gui/configPanel.py
@@ -17,6 +17,10 @@ def input_conf_value_size(option):
prompt = "Enter value for %s" % option
return gtkTools.input_size(prompt)
+def input_conf_value_int(option):
+ prompt = "Enter value for %s" % option
+ return gtkTools.input_int(prompt)
+
def input_conf_value_list(option):
prompt = "Enter value for %s" % option
return gtkTools.input_list(prompt)
@@ -31,6 +35,8 @@ def input_conf_value_boolean(option):
class ConfContents(gtkTools.ListWrapper):
def _create_row_from_value(self, entry):
+ print entry.get(Field.OPTION), ":", entry.get(Field.TYPE)
+
option = entry.get(Field.OPTION)
value = entry.get(Field.VALUE)
summary = entry.get(Field.SUMMARY)
@@ -89,6 +95,8 @@ class ConfigPanel(object, CliConfigPanel):
if configType == 'DataSize':
newValue = input_conf_value_size(configOption)
+ elif configType == 'Integer':
+ newValue = input_conf_value_int(configOption)
elif configType == 'LineList':
newValue = input_conf_value_list(configOption)
elif configType == 'Boolean':
diff --git a/src/util/gtkTools.py b/src/util/gtkTools.py
index 37e818e..afd4fef 100644
--- a/src/util/gtkTools.py
+++ b/src/util/gtkTools.py
@@ -149,6 +149,32 @@ def input_size(prompt):
return "%d %s" % (value, units) if response == gtk.RESPONSE_OK else None
+def input_int(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)
+
+ spinButton = gtk.SpinButton(None)
+ spinButton.connect("activate", response_to_dialog, dialog, gtk.RESPONSE_OK)
+
+ spinButton.set_increments(1, 10)
+ spinButton.set_range(0, 65535)
+
+ dialog.vbox.pack_end(spinButton, True, True, 0)
+
+ dialog.show_all()
+ response = dialog.run()
+
+ value = spinButton.get_value_as_int()
+
+ dialog.destroy()
+
+ return "%d" % (value) if response == gtk.RESPONSE_OK else None
+
def input_text(prompt):
dialog = gtk.MessageDialog(None,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
More information about the tor-commits
mailing list