Submit to the way of the threads

This commit is contained in:
Luke Murphy 2020-07-27 15:08:07 +02:00
parent 71cd34a99b
commit cac2ccebb3
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -4,6 +4,7 @@ import logging
import os import os
from signal import SIGINT, SIGTERM from signal import SIGINT, SIGTERM
from subprocess import PIPE, Popen, TimeoutExpired from subprocess import PIPE, Popen, TimeoutExpired
from threading import Thread
import gi import gi
@ -109,7 +110,7 @@ class DropShip:
self.files_to_send = files self.files_to_send = files
if len(files) == 1: if len(files) == 1:
fpath = files[0].replace("file://", "") fpath = files[0].replace("file://", "")
self.wormhole_send(self, fpath) Thread(target=self.wormhole_send, args=(self, fpath,)).start()
self.drop_label.set_text("Sending..") self.drop_label.set_text("Sending..")
self.drop_spinner.start() self.drop_spinner.start()
@ -120,7 +121,8 @@ class DropShip:
"""Handler for adding files with system interface""" """Handler for adding files with system interface"""
response = self.file_chooser.run() response = self.file_chooser.run()
if response == gtk.ResponseType.OK: if response == gtk.ResponseType.OK:
self.wormhole_send(self, self.file_chooser.get_filenames()[0]) fpath = self.file_chooser.get_filenames()[0]
Thread(target=self.wormhole_send, args=(self, fpath,)).start()
elif response == gtk.ResponseType.CANCEL: elif response == gtk.ResponseType.CANCEL:
# TODO(roel) something isn't right here.. maybe we need to initialize it every time we run it. # TODO(roel) something isn't right here.. maybe we need to initialize it every time we run it.
print("Cancel clicked") print("Cancel clicked")
@ -135,7 +137,7 @@ class DropShip:
def on_recv(self, entry): def on_recv(self, entry):
"""Handler for receiving transfers.""" """Handler for receiving transfers."""
code = entry.get_text() code = entry.get_text()
self.wormhole_recv(self, code) Thread(target=self.wormhole_recv, args=(self, code,)).start()
def wormhole_send(self, widget, fpath): def wormhole_send(self, widget, fpath):
"""Run `wormhole send` on a local file path.""" """Run `wormhole send` on a local file path."""