Add a pending transfer to the transfer list

This doesn't work yet...
This commit is contained in:
Luke Murphy 2020-10-11 14:06:58 +02:00
parent 6be4865e54
commit 91e6e0a127
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 7 additions and 12 deletions

View File

@ -96,18 +96,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://", "")
fname = basename(fpath)
# TODO Luke can u make a callback that spawns pendingTransmissions after we got a code?
self.nursery.start_soon(self.wormhole_send, fpath) self.nursery.start_soon(self.wormhole_send, fpath)
# TODO Roel/Luke, move this somewhere logical in its own function?
status = PendingTransferRow(self, fname, self.transfer_code)
# TODO Roel, find out how to add to a listbox
self.pending_transfers_list.insert(
status, -1
) # -1 is add at bottom
else: else:
log.info("Multiple file sending coming soon ™") log.info("Multiple file sending coming soon ™")
@ -140,12 +129,18 @@ class DropShip:
self.drop_spinner.set_vexpand(False) self.drop_spinner.set_vexpand(False)
self.drop_spinner.set_visible(False) self.drop_spinner.set_visible(False)
def _create_pending_transfer(self, fpath):
"""Create a new pending transfer."""
pending = PendingTransferRow(basename(fpath), self.transfer_code)
self.pending_transfers_list.insert(pending, -1)
async def wormhole_send(self, fpath): async def wormhole_send(self, fpath):
"""Run `wormhole send` on a local file path.""" """Run `wormhole send` on a local file path."""
self._send_spinner_on() self._send_spinner_on()
process = await open_process(["wormhole", "send", fpath], stderr=PIPE) process = await open_process(["wormhole", "send", fpath], stderr=PIPE)
output = await process.stderr.receive_some() output = await process.stderr.receive_some()
self.transfer_code = output.decode().split()[-1] self.transfer_code = output.decode().split()[-1]
self._create_pending_transfer(fpath)
self.clipboard.set_text(self.transfer_code, -1) self.clipboard.set_text(self.transfer_code, -1)
self._send_spinner_off() self._send_spinner_off()
await process.wait() await process.wait()

View File

@ -18,7 +18,7 @@ class PendingTransferRow(Gtk.ListBoxRow):
transferCodeButton = Gtk.Template.Child() transferCodeButton = Gtk.Template.Child()
cancelTransfer = Gtk.Template.Child() cancelTransfer = Gtk.Template.Child()
def __init__(self, parent, fileName, transferCode): def __init__(self, fileName, transferCode):
super(PendingTransferRow, self).__init__() super(PendingTransferRow, self).__init__()
self.fileNameLabel.set_text(fileName) self.fileNameLabel.set_text(fileName)
self.transferCodeButton.set_label(transferCode) self.transferCodeButton.set_label(transferCode)