
    h                         S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  \" \SS5      b  \R                  " 5          " S	 S
\R                  5      r " S S\R                  5      rSS\S\\\4   4S jjrS/rg)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                   ,    \ rS rSrSrSrSS jrS rSrg)	GIReactor$   z
GObject-introspection event loop reactor.

@ivar _gapplication: A C{Gio.Application} instance that was registered
    with C{registerGApplication}.
Nc                 N    [         R                  R                  U [        S 5        g N)r   GlibReactorBase__init__r   )selfuseGtks     a/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/internet/gireactor.pyr   GIReactor.__init__/   s    !!**4t<    c                    ^ U R                   b  [        S5      eU R                  (       a  [        S5      e[	        TS5      (       d  [        S5      eTU l         U4S jnX l        TR                  U l        g)aK  
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   > T R                  5         T R                  S 5        g r   )holdrun)apps   r   r   +GIReactor.registerGApplication.<locals>.runI   s    HHJGGDMr   )_gapplicationRuntimeError_startedr   hasattr_runr   _crash)r   r   r   s    ` r   registerGApplicationGIReactor.registerGApplication2   sv     )STT=='G  sF##7  !	 	hhr   )r!   r   r    F)	__name__
__module____qualname____firstlineno____doc__r   r   r"   __static_attributes__ r   r   r
   r
   $   s     M=r   r
   c                   @   ^  \ rS rSrSrSU 4S jjrS rSS jrSrU =r	$ )	PortableGIReactorR   z4
Portable GObject Introspection event loop reactor.
c                 ,   > [         TU ]  [        S US9  g )Nr   )superr   r   )r   r   	__class__s     r   r   PortableGIReactor.__init__W   s    tF3r   c                     [        S5      e)zo
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"   &PortableGIReactor.registerGApplicationZ   s    
 ""WXXr   c                     g)z%
For compatibility only. Do nothing.
Nr+   )r   s    r   simulatePortableGIReactor.simulatea   s    r   r+   r$   )returnN)
r%   r&   r'   r(   r)   r   r"   r8   r*   __classcell__)r2   s   @r   r-   r-   R   s    4Y r   r-   r   r:   c                     [         R                  R                  5       S:X  a
  [        U S9nO	[	        U S9nSSKJn  U" U5        U$ )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.
posixr0   r   )installReactor)r   platformgetTyper
   r-   twisted.internet.mainr>   )r   reactorr>   s      r   installrC   g   s?     !W,6*#6247Nr   rC   r$   )r)   typingr   gi.repositoryr   twisted.internetr   twisted.internet.errorr   twisted.pythonr   getattrr   r   r
   r-   boolrC   __all__r+   r   r   <module>rL      s   (   & 8 "
4&2+	)) +\	11 *D U96G+G%H & +r   