
    Vh                         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     J/home/dcms/DCMS/lib/python3.12/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                  | _        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    HHJGGDMr   )_gapplicationRuntimeError_startedr   hasattr_runr   _crash)r   r   r   s    ` r   registerGApplicationzGIReactor.registerGApplication2   su     )STT=='G  sF#7  !	 	hh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    tF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 U96G+G%H & +r   