Pass transfer code around since there are multiple

This commit is contained in:
Luke Murphy 2020-10-11 14:11:54 +02:00
parent 91e6e0a127
commit 536d1c36f2
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -88,7 +88,6 @@ class DropShip:
self.pending_transfers_list = self.builder.get_object( self.pending_transfers_list = self.builder.get_object(
"pendingTransfersList" "pendingTransfersList"
) )
self.transfer_code = ""
def on_drop(self, widget, drag_context, x, y, data, info, time): def on_drop(self, widget, drag_context, x, y, data, info, time):
"""Handler for file dropping.""" """Handler for file dropping."""
@ -120,18 +119,18 @@ class DropShip:
self.drop_spinner.set_visible(True) self.drop_spinner.set_visible(True)
self.drop_spinner.start() self.drop_spinner.start()
def _send_spinner_off(self): def _send_spinner_off(self, code):
"""Turn spinner off for sending interaction.""" """Turn spinner off for sending interaction."""
self.drop_label.set_text(self.transfer_code) self.drop_label.set_text(code)
self.drop_label.set_visible(True) self.drop_label.set_visible(True)
self.drop_label.set_selectable(True) self.drop_label.set_selectable(True)
self.drop_spinner.stop() self.drop_spinner.stop()
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): def _create_pending_transfer(self, fpath, code):
"""Create a new pending transfer.""" """Create a new pending transfer."""
pending = PendingTransferRow(basename(fpath), self.transfer_code) pending = PendingTransferRow(basename(fpath), code)
self.pending_transfers_list.insert(pending, -1) self.pending_transfers_list.insert(pending, -1)
async def wormhole_send(self, fpath): async def wormhole_send(self, fpath):
@ -139,10 +138,10 @@ class DropShip:
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] code = output.decode().split()[-1]
self._create_pending_transfer(fpath) self._create_pending_transfer(fpath, code)
self.clipboard.set_text(self.transfer_code, -1) self.clipboard.set_text(code, -1)
self._send_spinner_off() self._send_spinner_off(code)
await process.wait() await process.wait()
async def wormhole_recv(self, code): async def wormhole_recv(self, code):