[tor-commits] [arm/release] Prepopulate data size configs.
atagar at torproject.org
atagar at torproject.org
Sun Sep 25 21:38:23 UTC 2011
commit 93acdc1831cecb23760cbc1b8a195058c7a23739
Author: Kamran Riaz Khan <krkhan at inspirated.com>
Date: Sat Jul 30 15:53:41 2011 +0500
Prepopulate data size configs.
---
src/gui/configPanel.py | 11 ++++++-----
src/util/gtkTools.py | 18 ++++++++++++++----
2 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/src/gui/configPanel.py b/src/gui/configPanel.py
index 8c3a5e0..8be7020 100644
--- a/src/gui/configPanel.py
+++ b/src/gui/configPanel.py
@@ -13,9 +13,9 @@ from cli.configPanel import (ConfigPanel as CliConfigPanel, Field, State)
from util import connections, gtkTools, sysTools, torTools, uiTools
from TorCtl import TorCtl
-def input_conf_value_size(option):
+def input_conf_value_size(option, oldValue):
prompt = "Enter value for %s" % option
- return gtkTools.input_size(prompt)
+ return gtkTools.input_size(prompt, oldValue)
def input_conf_value_int(option):
prompt = "Enter value for %s" % option
@@ -95,12 +95,13 @@ class ConfigPanel(object, CliConfigPanel):
(index,) = path
entry = self._wrappedConfImportantContents[index]
- configOption = entry.fields[Field.OPTION]
- configType = entry.fields[Field.TYPE]
+ configOption = entry.get(Field.OPTION)
+ configType = entry.get(Field.TYPE)
+ oldValue = entry.get(Field.VALUE)
newValue = None
if configType == 'DataSize':
- newValue = input_conf_value_size(configOption)
+ newValue = input_conf_value_size(configOption, oldValue)
elif configType == 'Integer':
newValue = input_conf_value_int(configOption)
elif configType == 'String':
diff --git a/src/util/gtkTools.py b/src/util/gtkTools.py
index 87b3981..8a628e2 100644
--- a/src/util/gtkTools.py
+++ b/src/util/gtkTools.py
@@ -103,7 +103,7 @@ class TreeWrapper(ListWrapper):
def response_to_dialog(entry, dialog, response):
dialog.response(response)
-def input_size(prompt):
+def input_size(prompt, default=None):
dialog = gtk.MessageDialog(None,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_QUESTION,
@@ -117,7 +117,7 @@ def input_size(prompt):
dialog.vbox.pack_end(hBox, True, True, 0)
spinButton = gtk.SpinButton(None)
- spinButton.connect("activate", response_to_dialog, dialog, gtk.RESPONSE_OK)
+ spinButton.connect('activate', response_to_dialog, dialog, gtk.RESPONSE_OK)
spinButton.set_increments(1, 10)
spinButton.set_range(0, 1024)
@@ -136,6 +136,16 @@ def input_size(prompt):
hBox.pack_end(comboBox, False, False, 0)
+ if default:
+ value, units = default.split()
+
+ spinButton.set_value(float(value))
+
+ model = comboBox.get_model()
+ modelUnits = [row[0] for row in model]
+ index = modelUnits.index(units)
+ comboBox.set_active(index)
+
dialog.show_all()
response = dialog.run()
@@ -159,7 +169,7 @@ def input_int(prompt):
dialog.set_markup(prompt)
spinButton = gtk.SpinButton(None)
- spinButton.connect("activate", response_to_dialog, dialog, gtk.RESPONSE_OK)
+ spinButton.connect('activate', response_to_dialog, dialog, gtk.RESPONSE_OK)
spinButton.set_increments(1, 10)
spinButton.set_range(0, 65535)
@@ -185,7 +195,7 @@ def input_text(prompt):
dialog.set_markup(prompt)
entry = gtk.Entry()
- entry.connect("activate", response_to_dialog, dialog, gtk.RESPONSE_OK)
+ entry.connect('activate', response_to_dialog, dialog, gtk.RESPONSE_OK)
dialog.vbox.pack_end(entry, True, True, 0)
More information about the tor-commits
mailing list