Browse Source

Use upstream trio-gtk implementation

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

35
dropship.py

@ -2,11 +2,12 @@
import logging import logging
import os import os
from signal import SIGINT, SIGTERM from signal import SIGINT
from subprocess import PIPE from subprocess import PIPE
import gi import gi
import trio import trio
import trio_gtk
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
gi.require_version("Gdk", "3.0") gi.require_version("Gdk", "3.0")
@ -19,8 +20,6 @@ logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
log = logging.getLogger("dropship") log = logging.getLogger("dropship")
AUTO_CLIP_COPY_SIZE = -1
class DropShip: class DropShip:
"""Drag it, drop it, ship it.""" """Drag it, drop it, ship it."""
@ -146,31 +145,9 @@ class DropShip:
await trio.run_process(command, stderr=PIPE) await trio.run_process(command, stderr=PIPE)
def trio_run_with_gtk(): async def main(nursery):
"""Run Trio and Gtk together.""" """Trio main entrypoint."""
DropShip(nursery=nursery)
async def trio_main():
"""Trio main loop."""
async with trio.open_nursery() as nursery:
DropShip(nursery=nursery)
while True:
await trio.sleep(1) # Note(decentral1se): replace this hack
def done_callback(outcome):
glib.idle_add(gtk.main_quit)
def glib_schedule(function):
glib.idle_add(function)
trio.lowlevel.start_guest_run(
trio_main,
run_sync_soon_threadsafe=glib_schedule,
done_callback=done_callback,
host_uses_signal_set_wakeup_fd=True,
)
gtk.main()
if __name__ == "__main__": trio_gtk.run(main)
trio_run_with_gtk()

Loading…
Cancel
Save