Add auto clipboard

This commit is contained in:
Luke Murphy 2020-07-23 14:44:14 +02:00
parent 0c40acabe9
commit 3d655490b8
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -23,6 +23,8 @@ logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
log = logging.getLogger("dropship") log = logging.getLogger("dropship")
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
AUTO_CLIP_COPY_SIZE = -1
class PendingTransfer: class PendingTransfer:
"""A wormhole send waiting for a wormhole receive.""" """A wormhole send waiting for a wormhole receive."""
@ -39,9 +41,10 @@ class DropShip:
"""Object initialisation.""" """Object initialisation."""
self.GLADE_FILE = "dropship.glade" self.GLADE_FILE = "dropship.glade"
self.CSS_FILE = "dropship.css" self.CSS_FILE = "dropship.css"
self.DOWNLOAD_DIR = os.path.expanduser("~") self.DOWNLOAD_DIR = os.path.expanduser("~")
self.clipboard = gtk.Clipboard.get(gdk.SELECTION_CLIPBOARD)
self._running = loop.create_future() self._running = loop.create_future()
self._pending = [] self._pending = []
@ -144,9 +147,12 @@ class DropShip:
line = await self.read_lines(process.stderr, "wormhole receive") line = await self.read_lines(process.stderr, "wormhole receive")
code = line.split()[-1] code = line.split()[-1]
self.drop_label.set_selectable(True) self.drop_label.set_selectable(True)
self.drop_label.set_text(code) self.drop_label.set_text(code)
self.clipboard.set_text(code, AUTO_CLIP_COPY_SIZE)
self._pending.append(PendingTransfer(code)) self._pending.append(PendingTransfer(code))
await process.wait() await process.wait()