mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-24 14:59:42 -05:00
running async startup work in a separate thread, and design tweaks
This commit is contained in:
parent
23f9a577fe
commit
906eeccb54
@ -4,7 +4,7 @@
|
||||
<link rel="stylesheet" type="text/css" media="all" href="style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1><span id="basename">...</span></h1>
|
||||
<h1><span id="basename"></span></h1>
|
||||
<div id="output"></div>
|
||||
<button class="button" id="copy-button">Copy URL</button>
|
||||
|
||||
|
BIN
onionshare_gui/html/loader.gif
Normal file
BIN
onionshare_gui/html/loader.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.3 KiB |
@ -1,23 +1,24 @@
|
||||
function send(msg) {
|
||||
document.title = "null";
|
||||
document.title = msg;
|
||||
document.title = "null";
|
||||
document.title = msg;
|
||||
}
|
||||
|
||||
function init(basename, strings) {
|
||||
$('#basename').html(basename);
|
||||
$('#basename').html(basename).show();
|
||||
}
|
||||
|
||||
function url_is_set() {
|
||||
$('#copy-button')
|
||||
.click(function(){
|
||||
send('copy_url');
|
||||
})
|
||||
.show();
|
||||
$('#copy-button')
|
||||
.click(function(){
|
||||
send('copy_url');
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
function update(msg) {
|
||||
$('#output').append($('<p></p>').html(msg))
|
||||
|
||||
// scroll to bottom
|
||||
$('#output').scrollTop($('#output').height());
|
||||
var $line = $('<p></p>').append(msg);
|
||||
$('#output').append($line);
|
||||
|
||||
// scroll to bottom
|
||||
$('#output').scrollTop($('#output').height());
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ body {
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
font-family: arial;
|
||||
width: 650px;
|
||||
width: 550px;
|
||||
height: 300px;
|
||||
margin: 0 auto;
|
||||
padding: 0;
|
||||
@ -28,6 +28,7 @@ p {
|
||||
word-wrap: break-word;
|
||||
height: 260px;
|
||||
overflow: auto;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.button {
|
||||
@ -75,3 +76,11 @@ p {
|
||||
right: 20px;
|
||||
bottom: 10px;
|
||||
}
|
||||
|
||||
.loader {
|
||||
width: 21px;
|
||||
height: 20px;
|
||||
background-image: url('loader.gif');
|
||||
background-position: top left;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ def main():
|
||||
except onionshare.NoTor as e:
|
||||
alert(e.args[0], gtk.MESSAGE_ERROR)
|
||||
return
|
||||
onionshare.tails_open_port(port)
|
||||
|
||||
# select file to share
|
||||
filename, basename = select_file(strings)
|
||||
@ -80,14 +81,11 @@ def main():
|
||||
clipboard.set_text(url)
|
||||
web_send("update('{0}')".format('Copied secret URL to clipboard.'))
|
||||
|
||||
# startup
|
||||
def startup():
|
||||
# the async nature of things requires startup to be split into multiple functions
|
||||
def startup_async():
|
||||
global url
|
||||
web_send("init('{0}', {1});".format(basename, json.dumps(strings)))
|
||||
web_send("update('{0}')".format(strings['calculating_sha1']))
|
||||
filehash, filesize = onionshare.file_crunching(filename)
|
||||
onionshare.set_file_info(filename, filehash, filesize)
|
||||
onionshare.tails_open_port(port)
|
||||
url = 'http://{0}/{1}'.format(onion_host, onionshare.slug)
|
||||
web_send("update('{0}')".format(strings['give_this_url'].replace('\'', '\\\'')))
|
||||
web_send("update('<strong>{0}</strong>')".format(url))
|
||||
@ -96,11 +94,17 @@ def main():
|
||||
# clipboard needs a bit of time before copying url
|
||||
gobject.timeout_add(500, set_clipboard)
|
||||
|
||||
# start the web server
|
||||
web_thread = thread.start_new_thread(onionshare.app.run, (), {"port": port})
|
||||
def startup_sync():
|
||||
web_send("init('{0}', {1});".format(basename, json.dumps(strings)))
|
||||
web_send("update('{0}')".format(strings['calculating_sha1']))
|
||||
|
||||
# webview needs a bit of time before receiving data
|
||||
gobject.timeout_add(100, startup)
|
||||
# run other startup in the background
|
||||
thread_crunch = thread.start_new_thread(startup_async, ())
|
||||
|
||||
# start the web server
|
||||
thread_web = thread.start_new_thread(onionshare.app.run, (), {"port": port})
|
||||
|
||||
gobject.timeout_add(100, startup_sync)
|
||||
|
||||
# main loop
|
||||
last_second = time.time()
|
||||
|
Loading…
Reference in New Issue
Block a user