commit eb9f21e88de70774ec990e8256ffa2b4e35c9c4b Author: Kamran Riaz Khan krkhan@inspirated.com Date: Sat Jul 30 15:57:26 2011 +0500
Prepopulate string confs. --- src/gui/configPanel.py | 6 +++--- src/util/gtkTools.py | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/gui/configPanel.py b/src/gui/configPanel.py index cf36e23..d3b3a9c 100644 --- a/src/gui/configPanel.py +++ b/src/gui/configPanel.py @@ -25,9 +25,9 @@ def input_conf_value_list(option): prompt = "Enter value for %s" % option return gtkTools.input_list(prompt)
-def input_conf_value_text(option): +def input_conf_value_string(option, oldValue): prompt = "Enter value for %s" % option - return gtkTools.input_text(prompt) + return gtkTools.input_string(prompt, oldValue)
def input_conf_value_boolean(option): prompt = "Select value for %s" % option @@ -105,7 +105,7 @@ class ConfigPanel(object, CliConfigPanel): elif configType == 'Integer': newValue = input_conf_value_int(configOption, oldValue) elif configType == 'String': - newValue = input_conf_value_text(configOption) + newValue = input_conf_value_string(configOption, oldValue) 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 6526701..68946de 100644 --- a/src/util/gtkTools.py +++ b/src/util/gtkTools.py @@ -188,7 +188,7 @@ def input_int(prompt, default=None):
return "%d" % (value) if response == gtk.RESPONSE_OK else None
-def input_text(prompt): +def input_string(prompt, default=None): dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, @@ -202,6 +202,9 @@ def input_text(prompt):
dialog.vbox.pack_end(entry, True, True, 0)
+ if default: + entry.set_text(default) + dialog.show_all() response = dialog.run()
@@ -212,7 +215,7 @@ def input_text(prompt):
def input_list(prompt): def on_add_button_clicked(widget, listStore): - newValue = input_text("Enter new value:") + newValue = input_string("Enter new value:")
if newValue: row = (newValue,)