File: //lib/python3/dist-packages/twisted/internet/__pycache__/gireactor.cpython-38.pyc
U
W[� � @ s d Z ddlmZmZ ddlmZ ddlmZ ddlm Z ddl
mZ erNdZn6ddl
mZ dZzed W n ek
r� d
ZY nX ddd
dgZdd� Zes�e� n6ddlZej�� ddlma etdd�dk r�t�� G dd� de j�ZG dd� de j�Zddd�ZdgZdS )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.
� )�division�absolute_import)�_PY3)�ReactorAlreadyRunning)� _glibbase)�runtimeT)�
theSystemPathzgi.pygtkcompatFZgobjectZglibZgioZgtkc C sD t �td� ddlma ttdd�dk r0t�� t jg dtd� dS )za
Make sure pygtk and gi aren't loaded at the same time, and import Glib if
possible.
z|Introspected and static glib/gtk bindings must not be mixed; can't import gireactor since pygtk2 module is already imported.r ��GLib�threads_initN� )ZpreventImports)r ZensureNotImported�_PYGTK_MODULES�
gi.repositoryr
�getattrr � r r �</usr/lib/python3/dist-packages/twisted/internet/gireactor.py�
_oldGiInit1 s ��r Nr r c @ s^ e Zd ZdZejjejjB ejjB Z ejj
ZejjZ
ee B Ze
e B ZdZddd�Zdd� ZdS ) � GIReactorz�
GObject-introspection event loop reactor.
@ivar _gapplication: A C{Gio.Application} instance that was registered
with C{registerGApplication}.
NFc C s0 d }|dkrddl m} tjj| t||d� d S �NTr )�Gtk��useGtk)r r r �GlibReactorBase�__init__r
��selfr Z_gtkr r r r p s zGIReactor.__init__c sV | j dk rtd��| jr td��t� d�s2td��� | _ � fdd�}|| _� j| _dS )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 s � � � � �d � d S )N)Zhold�runr ��appr r r � s z+GIReactor.registerGApplication.<locals>.run)�
_gapplication�RuntimeErrorZ_startedr �hasattrZ_runr Z_crash)r r r r r r �registerGApplicationx s
��
zGIReactor.registerGApplication)F)�__name__�
__module__�__qualname__�__doc__r
ZIOConditionZHUPZERRZNVALZ_POLL_DISCONNECTED�INZ_POLL_INZOUTZ _POLL_OUTZINFLAGSZOUTFLAGSr r r# r r r r r Z s �
r c @ s"