[tor-commits] [arm/master] Use file selection dialogs for filename confs.

atagar at torproject.org atagar at torproject.org
Thu Aug 11 15:27:57 UTC 2011


commit 8f793419458866575f08d69dc1d8e15d0107f2b3
Author: Kamran Riaz Khan <krkhan at inspirated.com>
Date:   Sat Jul 30 14:34:09 2011 +0500

    Use file selection dialogs for filename confs.
---
 src/gui/configPanel.py |   10 ++++++++--
 src/util/gtkTools.py   |   12 ++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/gui/configPanel.py b/src/gui/configPanel.py
index 582034a..a6f5c07 100644
--- a/src/gui/configPanel.py
+++ b/src/gui/configPanel.py
@@ -33,10 +33,12 @@ def input_conf_value_boolean(option):
   prompt = "Select value for %s" % option
   return "1" if gtkTools.input_boolean(prompt) else "0"
 
+def input_conf_value_filename(option):
+  prompt = "Select value for %s" % option
+  return gtkTools.input_filename(prompt)
+
 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)
@@ -97,10 +99,14 @@ class ConfigPanel(object, CliConfigPanel):
       newValue = input_conf_value_size(configOption)
     elif configType == 'Integer':
       newValue = input_conf_value_int(configOption)
+    elif configType == 'String':
+      newValue = input_conf_value_text(configOption)
     elif configType == 'LineList':
       newValue = input_conf_value_list(configOption)
     elif configType == 'Boolean':
       newValue = input_conf_value_boolean(configOption)
+    elif configType == 'Filename':
+      newValue = input_conf_value_filename(configOption)
     else:
       newValue = input_conf_value_text(configOption)
 
diff --git a/src/util/gtkTools.py b/src/util/gtkTools.py
index afd4fef..1d3468f 100644
--- a/src/util/gtkTools.py
+++ b/src/util/gtkTools.py
@@ -288,6 +288,18 @@ def input_boolean(prompt):
 
   return choice if response == gtk.RESPONSE_OK else None
 
+def input_filename(prompt):
+  dialog = gtk.FileSelection(prompt)
+
+  dialog.show_all()
+  response = dialog.run()
+
+  choice = dialog.get_filename()
+
+  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,





More information about the tor-commits mailing list