Browse Source

Working receive

unifiedWindowUI
Luke Murphy 4 years ago
parent
commit
fb2e82c282
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 15
      dropship.py

15
dropship.py

@ -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(

Loading…
Cancel
Save