
    \d                     
   d Z ddlZddlmZ ddlmZ ddlmZ ddl	m
Z
 dZej                                          eedd           ej                      G d	 d
ej                  Z G d dej                  ZddZdgZdS )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                       e Zd ZdZej        j        ej        j        z  ej        j        z  Z	ej        j
        Zej        j        Zee	z  Zee	z  ZdZddZd ZdS )	GIReactorz
    GObject-introspection event loop reactor.

    @ivar _gapplication: A C{Gio.Application} instance that was registered
        with C{registerGApplication}.
    NFc                 n    d }|du rddl m} t          j                            | t
          ||           d S NTr   )GtkuseGtk)gi.repositoryr   r   GlibReactorBase__init__r   selfr   _gtks      :lib/python3.11/site-packages/twisted/internet/gireactor.pyr   zGIReactor.__init__E   sH    T>>111111!**4tF*KKKKK    c                     | j         t          d          | j        rt          d          t	          d          st          d          | _         fd}|| _        j        | _        dS )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                  Z                                                            d            d S )N)holdrun)apps   r   r   z+GIReactor.registerGApplication.<locals>.runc   s#    HHJJJGGDMMMMMr   )_gapplicationRuntimeError_startedr   hasattr_runr   _crash)r   r   r   s    ` r   registerGApplicationzGIReactor.registerGApplicationL   s     )STTT= 	'G   sF## 	7   !	 	 	 	 	 	hr   F)__name__
__module____qualname____doc__r   IOConditionHUPERRNVAL_POLL_DISCONNECTEDIN_POLL_INOUT	_POLL_OUTINFLAGSOUTFLAGSr   r   r#    r   r   r	   r	   .   s          	t/33d6F6KK  "H $I
 ++G--H ML L L L    r   r	   c                        e Zd ZdZddZd ZdS )PortableGIReactorz<
    Portable GObject Introspection event loop reactor.
    Fc                 n    d }|du rddl m} t          j                            | t
          ||           d S r   )r   r   r   PortableGlibReactorBaser   r   r   s      r   r   zPortableGIReactor.__init__q   sH    T>>111111)224tF2SSSSSr   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.registerGApplicationx   s    
 ""WXXXr   Nr$   )r%   r&   r'   r(   r   r#   r4   r   r   r6   r6   l   sJ         T T T TY Y Y Y Yr   r6   Fc                     t           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: should GTK+ rather than glib event loop be
        used (this will be slightly slower but does support GUI).
    posixr   r   )installReactor)r   platformgetTyper	   r6   twisted.internet.mainr=   )r   reactorr=   s      r   installrB      sg     !!W,,6***#6222444444N7Nr   rB   r$   )r(   gi.pygtkcompatgir   r   twisted.internetr   twisted.internet.errorr   twisted.pythonr   _pygtkcompatPresentpygtkcompatenablegetattrr   r   r	   r8   r6   rB   __all__r4   r   r   <module>rM      s.   (           & & & & & & 8 8 8 8 8 8 " " " " " "  
      
 74&&2D; ; ; ; ;	) ; ; ;|Y Y Y Y Y	9 Y Y Y(   $ +r   