[gnome-keysign: 31/65] app: add missing reactor



commit c16fb25a40eb7ba3648a84fda461cb125d8dc801
Author: RyuzakiKK <aasonykk gmail com>
Date:   Sun Aug 20 17:48:21 2017 +0200

    app: add missing reactor

 keysign/app.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/keysign/app.py b/keysign/app.py
index 2de6f1e..22341b1 100755
--- a/keysign/app.py
+++ b/keysign/app.py
@@ -28,7 +28,10 @@ from gi.repository import Gtk, GLib
 gi.require_version('Gst', '1.0')
 from gi.repository import Gst
 from gi.repository import Gdk
+from twisted.internet import gtk3reactor
+gtk3reactor.install()
 
+from twisted.internet import reactor
 
 if  __name__ == "__main__" and __package__ is None:
     logging.getLogger().error("You seem to be trying to execute " +
@@ -110,6 +113,7 @@ class KeysignApp(Gtk.Application):
         window = builder.get_object(appwindow)
         window.set_wmclass ("GNOME Keysign", "GNOME Keysign")
         window.set_title("GNOME Keysign")
+        window.connect("delete-event", self.on_delete_window)
         self.headerbar = window.get_titlebar()
         self.header_button = builder.get_object("back_refresh_button")
         self.header_button.connect('clicked', self.on_header_button_clicked)
@@ -174,10 +178,13 @@ class KeysignApp(Gtk.Application):
         window.show_all()
         self.add_window(window)
 
-
     def run(self, args=[]):
         super(KeysignApp, self).run()
 
+    @staticmethod
+    def on_delete_window(*args):
+        reactor.callFromThread(reactor.stop)
+
     def on_key_activated(self, widget, key):
         log.info("Activated key %r", key)
         # Ouf, we rely on the the SendApp to have reacted to
@@ -303,10 +310,12 @@ def main(args = []):
 
     app = KeysignApp()
     try:
-        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : app.quit(), None)
+        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT,
+                                  lambda *args: reactor.callFromThread(reactor.stop), None)
     except AttributeError:
         pass
-    app.run(args)
+    reactor.registerGApplication(app)
+    reactor.run()
 
 if __name__ == '__main__':
     logging.basicConfig(stream=sys.stderr, level=logging.DEBUG,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]