commit 2f8b1f7cf961de27cbdf4b8f851a50591e63682a Author: Kamran Riaz Khan krkhan@inspirated.com Date: Sat Jul 30 15:55:30 2011 +0500
Prepopulate integer confs. --- src/gui/configPanel.py | 6 +++--- src/util/gtkTools.py | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/gui/configPanel.py b/src/gui/configPanel.py index 8be7020..cf36e23 100644 --- a/src/gui/configPanel.py +++ b/src/gui/configPanel.py @@ -17,9 +17,9 @@ def input_conf_value_size(option, oldValue): prompt = "Enter value for %s" % option return gtkTools.input_size(prompt, oldValue)
-def input_conf_value_int(option): +def input_conf_value_int(option, oldValue): prompt = "Enter value for %s" % option - return gtkTools.input_int(prompt) + return gtkTools.input_int(prompt, oldValue)
def input_conf_value_list(option): prompt = "Enter value for %s" % option @@ -103,7 +103,7 @@ class ConfigPanel(object, CliConfigPanel): if configType == 'DataSize': newValue = input_conf_value_size(configOption, oldValue) elif configType == 'Integer': - newValue = input_conf_value_int(configOption) + newValue = input_conf_value_int(configOption, oldValue) elif configType == 'String': newValue = input_conf_value_text(configOption) elif configType == 'LineList': diff --git a/src/util/gtkTools.py b/src/util/gtkTools.py index 8a628e2..6526701 100644 --- a/src/util/gtkTools.py +++ b/src/util/gtkTools.py @@ -159,7 +159,7 @@ def input_size(prompt, default=None):
return "%d %s" % (value, units) if response == gtk.RESPONSE_OK else None
-def input_int(prompt): +def input_int(prompt, default=None): dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, @@ -176,6 +176,9 @@ def input_int(prompt):
dialog.vbox.pack_end(spinButton, True, True, 0)
+ if default: + spinButton.set_value(float(default)) + dialog.show_all() response = dialog.run()