o b @sdZddlZddlmZddlmZddlmZddl m Z dZ ej eedddur1eGd d d ejZGd d d ejZdddZdgZdS)a This module provides support for Twisted to interact with the glib mainloop via GObject Introspection. In order to use this support, simply do the following:: from twisted.internet import gireactor gireactor.install() If you wish to use a GApplication, register it with the reactor:: from twisted.internet import reactor reactor.registerGApplication(app) Then use twisted.internet APIs as usual. On Python 3, pygobject v3.4 or later is required. N)GLib) _glibbase)ReactorAlreadyRunning)runtimeT threads_initc@s^eZdZdZejjejjBejjBZ ejj Z ejj Z e e BZe e BZdZdddZddZdS) GIReactorz GObject-introspection event loop reactor. @ivar _gapplication: A C{Gio.Application} instance that was registered with C{registerGApplication}. NFcC0d}|dur ddlm}tjj|t||ddSNTr)GtkuseGtk) gi.repositoryr rGlibReactorBase__init__rselfr _gtkr.run) _gapplication RuntimeError_startedrhasattr_runr_crash)rrrrrrregisterGApplicationLs    zGIReactor.registerGApplicationF)__name__ __module__ __qualname____doc__r IOConditionHUPERRNVAL_POLL_DISCONNECTEDIN_POLL_INOUT _POLL_OUTINFLAGSOUTFLAGSrrr!rrrrr.s  rc@s"eZdZdZdddZddZdS) PortableGIReactorz< Portable GObject Introspection event loop reactor. FcCrr )r r rPortableGlibReactorBaserrrrrrrqrzPortableGIReactor.__init__cCstd)z Register a C{Gio.Application} or C{Gtk.Application}, whose main loop will be used instead of the default one. z3GApplication is not currently supported on Windows.)NotImplementedError)rrrrrr!xsz&PortableGIReactor.registerGApplicationNr")r#r$r%r&rr!rrrrr2ls  r2FcCs<tjdkr t|d}nt|d}ddlm}|||S)z Configure the twisted mainloop to be run inside the glib mainloop. @param useGtk: should GTK+ rather than glib event loop be used (this will be slightly slower but does support GUI). posixr r)installReactor)rplatformgetTyperr2twisted.internet.mainr6)r reactorr6rrrinstalls    r;r")r&gi.pygtkcompatgir rtwisted.internetrtwisted.internet.errorrtwisted.pythonr_pygtkcompatPresent pygtkcompatenablegetattrrrrr3r2r;__all__rrrrs     >