Working receive

This commit is contained in:
Luke Murphy 2020-07-23 13:06:56 +02:00
parent 5f95a06046
commit fb2e82c282
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -48,6 +48,7 @@ class DropShip:
self.init_glade() self.init_glade()
self.init_css() self.init_css()
self.init_drop_box() self.init_drop_box()
self.init_recv_box()
self.init_window() self.init_window()
def init_glade(self): def init_glade(self):
@ -90,7 +91,14 @@ class DropShip:
self.drop_box.connect("drag-data-received", self.on_drop) self.drop_box.connect("drag-data-received", self.on_drop)
self.drop_label = self.builder.get_object(self.drop_box_label) self.drop_label = self.builder.get_object(self.drop_box_label)
def init_recv_box(self):
"""Initialise the receive code box."""
self.recv_box_id = "receiveBoxCodeEntry"
self.recv_box = self.builder.get_object(self.recv_box_id)
self.recv_box.connect("activate", self.on_recv)
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."""
files = data.get_text().split() files = data.get_text().split()
self.files_to_send = files self.files_to_send = files
if len(files) == 1: if len(files) == 1:
@ -100,6 +108,11 @@ class DropShip:
else: else:
log.info("Multiple file sending coming soon ™") log.info("Multiple file sending coming soon ™")
def on_recv(self, entry):
"""Handler for receiving transfers."""
code = entry.get_text()
self.schedule(self.wormhole_recv(self, code))
def on_quit(self, *args, **kwargs): def on_quit(self, *args, **kwargs):
"""Quit the program.""" """Quit the program."""
self.window.close() self.window.close()
@ -123,6 +136,7 @@ class DropShip:
process = await asyncio.create_subprocess_exec( process = await asyncio.create_subprocess_exec(
"wormhole", "wormhole",
"send", "send",
"--hide-progress",
fpath, fpath,
stdout=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
@ -136,7 +150,6 @@ class DropShip:
await process.wait() await process.wait()
async def wormhole_recv(self, widget, code): async def wormhole_recv(self, widget, code):
"""Run `wormhole receive` with a pending transfer code.""" """Run `wormhole receive` with a pending transfer code."""
process = await asyncio.create_subprocess_exec( process = await asyncio.create_subprocess_exec(