Ë
    oj®  ã                   óð   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
  eedd«      � ej                  «         G d	„ d
ej                  «      Z G d„ dej                  «      Zddedeeef   fd„ZdgZy)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.
é    )ÚUnion)ÚGLib)Ú	_glibbase)ÚReactorAlreadyRunning)ÚruntimeÚthreads_initNc                   ó"   — e Zd ZdZdZdd„Zd„ Zy)Ú	GIReactorz¥
    GObject-introspection event loop reactor.

    @ivar _gapplication: A C{Gio.Application} instance that was registered
        with C{registerGApplication}.
    Nc                 óN   — t         j                  j                  | t        d «       y ©N)r   ÚGlibReactorBaseÚ__init__r   )ÚselfÚuseGtks     ú</usr/lib/python3/dist-packages/twisted/internet/gireactor.pyr   zGIReactor.__init__/   s   € Ü×!Ñ!×*Ñ*¨4´°tÕ<ó    c                 óØ   ‡— | j                   �t        d«      ‚| j                  rt        d«      ‚t	        ‰d«      st        d«      ‚‰| _         ˆfd„}|| _        ‰j                  | _        y)aƒ  
        Register a C{Gio.Application} or C{Gtk.Application}, whose main loop
        will be used instead of the default one.

        We will C{hold} the application so it doesn't exit on its own. In
        versions of C{python-gi} 3.2 and later, we exit the event loop using
        the C{app.quit} method which overrides any holds. Older versions are
        not supported.
        Nz2Can't register more than one application instance.z5Can't register application after reactor was started.ÚquitzPApplication registration is not supported in versions of PyGObject prior to 3.2.c                  óH   •— ‰ j                  «        ‰ j                  d «       y r   )ÚholdÚrun)Úapps   €r   r   z+GIReactor.registerGApplication.<locals>.runI   s   ø€ Ø�H‰HŒJØ�G‰G�D�Mr   )Ú_gapplicationÚRuntimeErrorÚ_startedr   ÚhasattrÚ_runr   Ú_crash)r   r   r   s    ` r   ÚregisterGApplicationzGIReactor.registerGApplication2   su   ø€ ð ×ÑÐ)ÜÐSÓTÐTØ�=Š=Ü'ØGóð ô �s˜FÔ#Üð7óð ð !ˆÔô	ð ˆŒ	à—h‘hˆ�r   ©F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   © r   r   r
   r
   $   s   „ ñð €Mó=ór   r
   c                   ó2   ‡ — e Zd ZdZdˆ fd„	Zd„ Zdd„Zˆ xZS )ÚPortableGIReactorz<
    Portable GObject Introspection event loop reactor.
    c                 ó2   •— t         ‰| �  t        d |¬«       y )N©r   )Úsuperr   r   )r   r   Ú	__class__s     €r   r   zPortableGIReactor.__init__W   s   ø€ Ü‰Ñœ˜t¨FÐÕ3r   c                 ó   — t        d«      ‚)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)r   r   s     r   r   z&PortableGIReactor.registerGApplicationZ   s   € ô
 "Ð"WÓXÐXr   c                  ó   — y)z5
        For compatibility only. Do nothing.
        Nr%   )r   s    r   ÚsimulatezPortableGIReactor.simulatea   s   � r   r    )ÚreturnN)r!   r"   r#   r$   r   r   r/   Ú__classcell__)r+   s   @r   r'   r'   R   s   ø„ ñõ4òY÷r   r'   r   r0   c                 ó–   — t         j                  j                  «       dk(  rt        | ¬«      }nt	        | ¬«      }ddlm}  ||«       |S )zÃ
    Configure the twisted mainloop to be run inside the glib mainloop.

    @param useGtk: A hint that the Gtk GUI will or will not be used.  Currently
        does not modify any behavior.
    Úposixr)   r   )ÚinstallReactor)r   ÚplatformÚgetTyper
   r'   Útwisted.internet.mainr4   )r   Úreactorr4   s      r   Úinstallr9   g   s?   € ô ×Ñ×ÑÓ! WÒ,Ü 6Ô*‰ä#¨6Ô2ˆå4á�7ÔØ€Nr   r9   r    )r$   Útypingr   Úgi.repositoryr   Útwisted.internetr   Útwisted.internet.errorr   Útwisted.pythonr   Úgetattrr   r   r
   r'   Úboolr9   Ú__all__r%   r   r   ú<module>rB      s„   ðñõ( å å &Ý 8Ý "á
ˆ4� Ó&Ð2Ø€D×ÑÔô+�	×)Ñ)ô +ô\˜	×1Ñ1ô ñ*�Dð  U¨9Ð6GÐ+GÑ%Hó ð& ˆ+�r   