From 98bb6c387a0fb6780a1068424c97da9b34c22e00 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sat, 21 Jun 2014 15:20:10 -0400 Subject: [PATCH 1/3] made logs display reverse chronological, so no need to autoscroll the log window --- onionshare_gui/static/onionshare.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onionshare_gui/static/onionshare.js b/onionshare_gui/static/onionshare.js index c470268d..6c7b7fa0 100644 --- a/onionshare_gui/static/onionshare.js +++ b/onionshare_gui/static/onionshare.js @@ -3,7 +3,7 @@ $(function(){ function update($msg) { var $line = $('
  • ').append($msg); - $('#log').append($line); + $('#log').prepend($line); } function copy_to_clipboard() { From d8dbbcc42aae67dbe7102b715926ef3a6e09d5f7 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sat, 21 Jun 2014 20:29:26 -0400 Subject: [PATCH 2/3] made copy to clipboard work in windows. fixes #46 --- onionshare_gui/webapp.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/onionshare_gui/webapp.py b/onionshare_gui/webapp.py index d2c951cf..80f2c3f8 100644 --- a/onionshare_gui/webapp.py +++ b/onionshare_gui/webapp.py @@ -65,8 +65,22 @@ def start_onionshare(): @app.route("/copy_url") def copy_url(): - global clipboard - clipboard.setText(url) + if platform.system() == 'Windows': + # Qt's QClipboard isn't working in Windows + # https://github.com/micahflee/onionshare/issues/46 + import ctypes + GMEM_DDESHARE = 0x2000 + ctypes.windll.user32.OpenClipboard(None) + ctypes.windll.user32.EmptyClipboard() + hcd = ctypes.windll.kernel32.GlobalAlloc(GMEM_DDESHARE, len(bytes(url))+1) + pch_data = ctypes.windll.kernel32.GlobalLock(hcd) + ctypes.cdll.msvcrt.strcpy(ctypes.c_char_p(pch_data), bytes(url)) + ctypes.windll.kernel32.GlobalUnlock(hcd) + ctypes.windll.user32.SetClipboardData(1, hcd) + ctypes.windll.user32.CloseClipboard() + else: + global clipboard + clipboard.setText(url) return '' @app.route("/heartbeat") From 272092f877ade0ada63fc1b7b43f7837e73adede Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sun, 22 Jun 2014 00:54:44 -0400 Subject: [PATCH 3/3] can now run onionshare_gui.py without building (fixes #51) --- onionshare_gui/onionshare_gui.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 2369d0dc..81ffdbd9 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -1,10 +1,18 @@ -import onionshare, webapp import os, sys, subprocess, inspect - from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * +onionshare_gui_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + +try: + import onionshare +except ImportError: + sys.path.append(os.path.abspath(onionshare_gui_dir+"/..")) + import onionshare + +import webapp + window_icon = None class Application(QApplication): @@ -79,8 +87,7 @@ def main(): return # create the onionshare icon - global window_icon - onionshare_gui_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + global window_icon, onionshare_gui_dir window_icon = QIcon("{0}/onionshare-icon.png".format(onionshare_gui_dir)) # try starting hidden service