[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [arm/release] Use separate file choosers for dir selection and file selection.



commit f6178103cceb94e65c911f17e014e5691228e95c
Author: Kamran Riaz Khan <krkhan@xxxxxxxxxxxxxx>
Date:   Sat Jul 30 14:57:50 2011 +0500

    Use separate file choosers for dir selection and file selection.
---
 src/gui/configPanel.py |    9 ++++++++-
 src/util/gtkTools.py   |   28 +++++++++++++++++++++++++---
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/src/gui/configPanel.py b/src/gui/configPanel.py
index a6f5c07..8c3a5e0 100644
--- a/src/gui/configPanel.py
+++ b/src/gui/configPanel.py
@@ -33,6 +33,10 @@ 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_dir(option):
+  prompt = "Select value for %s" % option
+  return gtkTools.input_dir(prompt)
+
 def input_conf_value_filename(option):
   prompt = "Select value for %s" % option
   return gtkTools.input_filename(prompt)
@@ -106,7 +110,10 @@ class ConfigPanel(object, CliConfigPanel):
     elif configType == 'Boolean':
       newValue = input_conf_value_boolean(configOption)
     elif configType == 'Filename':
-      newValue = input_conf_value_filename(configOption)
+      if 'Directory' in configOption:
+        newValue = input_conf_value_dir(configOption)
+      else:
+        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 1d3468f..87b3981 100644
--- a/src/util/gtkTools.py
+++ b/src/util/gtkTools.py
@@ -288,17 +288,39 @@ def input_boolean(prompt):
 
   return choice if response == gtk.RESPONSE_OK else None
 
+def input_dir(prompt):
+  dialog = gtk.FileChooserDialog(prompt,
+                               None,
+                               gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
+                               (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+                                gtk.STOCK_OPEN, gtk.RESPONSE_OK))
+  dialog.set_default_response(gtk.RESPONSE_OK)
+
+  dialog.show_all()
+  response = dialog.run()
+
+  filename = dialog.get_filename()
+
+  dialog.destroy()
+
+  return filename if response == gtk.RESPONSE_OK else None
+
 def input_filename(prompt):
-  dialog = gtk.FileSelection(prompt)
+  dialog = gtk.FileChooserDialog(prompt,
+                               None,
+                               gtk.FILE_CHOOSER_ACTION_SAVE,
+                               (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+                                gtk.STOCK_OPEN, gtk.RESPONSE_OK))
+  dialog.set_default_response(gtk.RESPONSE_OK)
 
   dialog.show_all()
   response = dialog.run()
 
-  choice = dialog.get_filename()
+  filename = dialog.get_filename()
 
   dialog.destroy()
 
-  return choice if response == gtk.RESPONSE_OK else None
+  return filename if response == gtk.RESPONSE_OK else None
 
 def showError(msg):
   dialog = gtk.MessageDialog(None,



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits