From ff7791939b7fe4e8903f2c6592906377719363e3 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Thu, 19 Jun 2014 16:36:49 -0400 Subject: [PATCH] ported select_file to Qt --- onionshare/strings.json | 3 ++- onionshare_gui/onionshare_gui.py | 19 ++++++------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/onionshare/strings.json b/onionshare/strings.json index 741ee04e..1dcf1f45 100644 --- a/onionshare/strings.json +++ b/onionshare/strings.json @@ -16,7 +16,8 @@ "other_page_loaded": "Other page has been loaded", "tails_requires_root": "You must run OnionShare as root in Tails", "close_on_finish": "Close automatically", - "close_countdown": "Closing in {0} seconds..." + "close_countdown": "Closing in {0} seconds...", + "choose_file": "Choose a file to share" }, "no": { "punching_a_hole": "Ã…pner port i brannmuren.", "closing_hole": "Lukker port i brannmuren.", diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 8e42ef9e..15fb45e1 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -24,23 +24,16 @@ def select_file(strings): if len(sys.argv) == 2: filename = sys.argv[1] else: - canceled = False - chooser = gtk.FileChooserDialog( - title="Choose a file to share", - action=gtk.FILE_CHOOSER_ACTION_OPEN, - buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) + args = {} if onionshare.get_platform() == 'Tails': - chooser.set_current_folder('/home/amnesia/') - response = chooser.run() - if response == gtk.RESPONSE_OK: - filename = chooser.get_filename() - elif response == gtk.RESPONSE_CANCEL: - canceled = True - chooser.destroy() + args['directory'] = '/home/amnesia' - if canceled: + filename = QFileDialog.getOpenFileName(caption=strings['choose_file'], options=QFileDialog.ReadOnly, **args) + if not filename: return False, False + filename = str(filename) + # validate filename if not os.path.isfile(filename): alert(strings["not_a_file"].format(filename), gtk.MESSAGE_ERROR)