mirror of
https://github.com/onionshare/onionshare.git
synced 2025-06-06 22:09:15 -04:00
onionshare-gui automatically copies URL to clipboard
This commit is contained in:
parent
898cbfce31
commit
6ad85f3e64
1 changed files with 23 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import onionshare, webgui
|
import onionshare, webgui
|
||||||
import os, sys, time, json, gtk, thread
|
import os, sys, time, json, gtk, gobject, thread
|
||||||
|
|
||||||
class Global(object):
|
class Global(object):
|
||||||
quit = False
|
quit = False
|
||||||
|
@ -69,9 +69,15 @@ def main():
|
||||||
browser, web_recv, web_send = webgui.sync_gtk_msg(webgui.launch_window)(
|
browser, web_recv, web_send = webgui.sync_gtk_msg(webgui.launch_window)(
|
||||||
title="OnionShare | {0}".format(basename),
|
title="OnionShare | {0}".format(basename),
|
||||||
quit_function=Global.set_quit)
|
quit_function=Global.set_quit)
|
||||||
time.sleep(0.1)
|
|
||||||
|
# clipboard
|
||||||
|
clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
|
||||||
|
def set_clipboard(url):
|
||||||
|
clipboard.set_text(url)
|
||||||
|
web_send("update('{0}')".format('Copied secret URL to clipboard'))
|
||||||
|
|
||||||
# startup
|
# startup
|
||||||
|
def startup():
|
||||||
web_send("init('{0}', {1});".format(basename, json.dumps(strings)))
|
web_send("init('{0}', {1});".format(basename, json.dumps(strings)))
|
||||||
web_send("update('{0}')".format(strings['calculating_sha1']))
|
web_send("update('{0}')".format(strings['calculating_sha1']))
|
||||||
filehash, filesize = onionshare.file_crunching(filename)
|
filehash, filesize = onionshare.file_crunching(filename)
|
||||||
|
@ -79,11 +85,16 @@ def main():
|
||||||
onionshare.tails_open_port(port)
|
onionshare.tails_open_port(port)
|
||||||
url = 'http://{0}/{1}'.format(onion_host, onionshare.slug)
|
url = 'http://{0}/{1}'.format(onion_host, onionshare.slug)
|
||||||
web_send("update('{0}')".format('Secret URL is {0}'.format(url)))
|
web_send("update('{0}')".format('Secret URL is {0}'.format(url)))
|
||||||
web_send("set_url('{0}')".format(url));
|
|
||||||
|
# clipboard needs a bit of time before copying url
|
||||||
|
gobject.timeout_add(1500, set_clipboard, url)
|
||||||
|
|
||||||
# start the web server
|
# start the web server
|
||||||
web_thread = thread.start_new_thread(onionshare.app.run, (), {"port": port})
|
web_thread = thread.start_new_thread(onionshare.app.run, (), {"port": port})
|
||||||
|
|
||||||
|
# webview needs a bit of time before receiving data
|
||||||
|
gobject.timeout_add(100, startup)
|
||||||
|
|
||||||
# main loop
|
# main loop
|
||||||
last_second = time.time()
|
last_second = time.time()
|
||||||
uptime_seconds = 1
|
uptime_seconds = 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue