mirror of
https://github.com/onionshare/onionshare.git
synced 2025-03-20 04:46:09 -04:00
onionshare closes automatically (if box is checked) when download finishes. fixes #36
This commit is contained in:
parent
de0e8f9eb0
commit
86d835f291
@ -73,10 +73,11 @@ def download():
|
||||
chunk = fp.read(102400)
|
||||
if chunk == '':
|
||||
done = True
|
||||
yield chunk
|
||||
|
||||
# tell GUI the progress
|
||||
add_request(REQUEST_PROGRESS, path, { 'id':download_id, 'bytes':fp.tell() })
|
||||
else:
|
||||
yield chunk
|
||||
|
||||
# tell GUI the progress
|
||||
add_request(REQUEST_PROGRESS, path, { 'id':download_id, 'bytes':fp.tell() })
|
||||
fp.close()
|
||||
|
||||
r = Response(generate())
|
||||
|
@ -14,7 +14,9 @@
|
||||
"download_started": "Download started",
|
||||
"download_finished": "Download finished",
|
||||
"other_page_loaded": "Other page has been loaded",
|
||||
"tails_requires_root": "You must run OnionShare as root in Tails"
|
||||
"tails_requires_root": "You must run OnionShare as root in Tails",
|
||||
"close_on_finish": "Close automatically",
|
||||
"close_countdown": "Closing in {0} seconds..."
|
||||
}, "no": {
|
||||
"punching_a_hole": "Åpner port i brannmuren.",
|
||||
"closing_hole": "Lukker port i brannmuren.",
|
||||
|
@ -1,6 +1,8 @@
|
||||
import onionshare, webapp
|
||||
import threading, gtk, gobject, webkit, os, sys, subprocess
|
||||
|
||||
window = gtk.Window()
|
||||
|
||||
def alert(msg, type=gtk.MESSAGE_INFO):
|
||||
dialog = gtk.MessageDialog(
|
||||
parent=None,
|
||||
@ -43,10 +45,12 @@ def select_file(strings):
|
||||
return filename, basename
|
||||
|
||||
def start_webapp(webapp_port, onionshare_port, filename, onion_host):
|
||||
global window
|
||||
webapp.onionshare = onionshare
|
||||
webapp.onionshare_port = onionshare_port
|
||||
webapp.filename = filename
|
||||
webapp.onion_host = onion_host
|
||||
webapp.window = window
|
||||
webapp.app.run(port=webapp_port)
|
||||
|
||||
def launch_window(webapp_port, onionshare_port):
|
||||
@ -55,7 +59,7 @@ def launch_window(webapp_port, onionshare_port):
|
||||
onionshare.tails_close_port(webapp_port)
|
||||
gtk.main_quit()
|
||||
|
||||
window = gtk.Window()
|
||||
global window
|
||||
window.set_title('OnionShare')
|
||||
window.resize(520, 400)
|
||||
window.set_resizable(False)
|
||||
|
@ -44,6 +44,22 @@ $(function(){
|
||||
// is the download complete?
|
||||
if(r.data.bytes == onionshare.filesize) {
|
||||
$('#download-'+r.data.id).html(onionshare.strings['download_finished']);
|
||||
|
||||
// close on finish?
|
||||
if($('#close-on-finish').is(':checked')) {
|
||||
function close_countdown(i) {
|
||||
$('#close-countdown').html(onionshare.strings['close_countdown'].replace('{0}', i));
|
||||
if(i == 0) {
|
||||
// close program
|
||||
$.ajax({ url: '/close' });
|
||||
} else {
|
||||
// continue countdown
|
||||
setTimeout(function(){ close_countdown(i-1) }, 1000);
|
||||
}
|
||||
}
|
||||
update($('<span>').attr('id', 'close-countdown'));
|
||||
close_countdown(3);
|
||||
}
|
||||
}
|
||||
// still in progress
|
||||
else {
|
||||
@ -71,6 +87,7 @@ $(function(){
|
||||
$('#basename').html(onionshare.basename);
|
||||
$('#filesize .label').html(onionshare.strings['filesize']+':');
|
||||
$('#filehash .label').html(onionshare.strings['sha1_checksum']+':');
|
||||
$('#close-on-finish-wrapper label').html(onionshare.strings['close_on_finish']);
|
||||
$('#loading .calculating').html(onionshare.strings['calculating_sha1']);
|
||||
|
||||
// after getting the initial info, start the onionshare server
|
||||
|
@ -46,6 +46,16 @@ body {
|
||||
font-weight: bold;
|
||||
font-size: 12px;
|
||||
}
|
||||
#metadata #close-on-finish-wrapper {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
#metadata #close-on-finish-wrapper input {
|
||||
cursor: pointer;
|
||||
}
|
||||
#metadata #close-on-finish-wrapper label {
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
ul#log {
|
||||
float: left;
|
||||
@ -88,6 +98,10 @@ ul#log li#loading .calculating {
|
||||
font-style: italic;
|
||||
font-size: 12px;
|
||||
}
|
||||
ul#log #close-countdown {
|
||||
font-weight: bold;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.button {
|
||||
-moz-box-shadow:inset 0px 1px 0px 0px #d197fe;
|
||||
|
@ -16,6 +16,10 @@
|
||||
<span class="label"></span>
|
||||
<span class="value"></span>
|
||||
</div>
|
||||
<div id="close-on-finish-wrapper">
|
||||
<input type="checkbox" id="close-on-finish" name="close-on-finish" checked />
|
||||
<label for="close-on-finish"></span>
|
||||
</div>
|
||||
<div id="button-wrapper">
|
||||
<button class="button" id="copy-button">Copy URL</button>
|
||||
</div>
|
||||
|
@ -1,10 +1,11 @@
|
||||
from flask import Flask, render_template
|
||||
import threading, json, os, gtk
|
||||
import threading, json, os, gtk, gobject
|
||||
|
||||
onionshare = None
|
||||
onionshare_port = None
|
||||
filename = None
|
||||
onion_host = None
|
||||
window = None
|
||||
|
||||
clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
|
||||
url = None
|
||||
@ -66,3 +67,9 @@ def check_for_requests():
|
||||
|
||||
return json.dumps(events)
|
||||
|
||||
@app.route("/close")
|
||||
def close():
|
||||
global window
|
||||
gobject.timeout_add(1000, window.destroy)
|
||||
return ''
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user