
    Yf                         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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.
    )Union)GLib)	_glibbase)ReactorAlreadyRunning)runtimethreads_initNc                   $    e Zd Zd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                 R    t           j                            | t          d            d S N)r   GlibReactorBase__init__r   )selfuseGtks     L/var/www/html/env/lib/python3.11/site-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        | _        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 r   )holdrun)apps   r   r   z+GIReactor.registerGApplication.<locals>.runI   s#    HHJJJGGDMMMMMr   )_gapplicationRuntimeError_startedr   hasattr_runr   _crash)r   r   r   s    ` r   registerGApplicationzGIReactor.registerGApplication2   s     )STTT= 	'G   sF## 	7   !	 	 	 	 	 	hr   F)__name__
__module____qualname____doc__r   r   r    r   r   r
   r
   $   sH          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.
    Fc                 Z    t                                          t          d |           d S )Nr   )superr   r   )r   r   	__class__s     r   r   zPortableGIReactor.__init__W   s(    tF3333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XXr   returnNc                     dS )z5
        For compatibility only. Do nothing.
        Nr%   )r   s    r   simulatezPortableGIReactor.simulatea   s      r   r    )r.   N)r!   r"   r#   r$   r   r   r0   __classcell__)r+   s   @r   r'   r'   R   sm         4 4 4 4 4 4Y Y Y       r   r'   Fr   r.   c                     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: 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   sg     !!W,,6***#6222444444N7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 8 8 8 8 8 " " " " " "
74&&2D+ + + + +	) + + +\    	1   * D U96G+G%H    & +r   