mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-12 07:49:39 -05:00
ported select_file to Qt
This commit is contained in:
parent
1c59072a2b
commit
ff7791939b
@ -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.",
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user