Your IP : 18.226.34.148


Current Path : /lib64/python3.6/site-packages/gi/__pycache__/
Upload File :
Current File : //lib64/python3.6/site-packages/gi/__pycache__/_signalhelper.cpython-36.pyc

3

��<_r&�@sjddlZddlmZdejko(dknr6dd�ZGdd	�d	e�ZGd
d�de�Zdd
�Zdd�Z	dS)�N�)�_gi��cCs
t|d�S)N�__call__)�hasattr)�fn�r	�%/usr/lib64/python3.6/_signalhelper.py�callablesrc@sjeZdZdZGdd�de�Zddd�Zddejdddddfdd	�Z	dd
d�Z
dd
�Zddd�Zdd�Z
dS)�Signala�Object which gives a nice API for creating and binding signals.

    :param name:
        Name of signal or callable closure when used as a decorator.
    :type name: str or callable
    :param callable func:
        Callable closure method.
    :param GObject.SignalFlags flags:
        Flags specifying when to run closure.
    :param type return_type:
        Return type of the Signal.
    :param list arg_types:
        List of argument types specifying the signals function signature
    :param str doc:
        Documentation of signal object.
    :param callable accumulator:
        Accumulator method with the signature:
        func(ihint, return_accu, handler_return, accu_data) -> boolean
    :param object accu_data:
        User data passed to the accumulator.

    :Example:

    .. code-block:: python

        class Spam(GObject.Object):
            velocity = 0

            @GObject.Signal
            def pushed(self):
                self.velocity += 1

            @GObject.Signal(flags=GObject.SignalFlags.RUN_LAST)
            def pulled(self):
                self.velocity -= 1

            stomped = GObject.Signal('stomped', arg_types=(int,))

            @GObject.Signal
            def annotated_signal(self, a:int, b:str):
                "Python3 annotation support for parameter types.

        def on_pushed(obj):
            print(obj)

        spam = Spam()
        spam.pushed.connect(on_pushed)
        spam.pushed.emit()
    c@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)zSignal.BoundSignalz�
        Temporary binding object which can be used for connecting signals
        without specifying the signal name string to connect.
        cOstj||�S)N)�str�__new__)�cls�name�args�kargsr	r	r
rXszSignal.BoundSignal.__new__cCstj|�||_||_dS)N)r
�__init__�signal�gobj)�selfrrr	r	r
r[s
zSignal.BoundSignal.__init__cCsd|S)NzBoundSignal("%s")r	)rr	r	r
�__repr__`szSignal.BoundSignal.__repr__cOs|jj|jf|�|�S)zCall the signals closure.)r�funcr)rrrr	r	r
rcszSignal.BoundSignal.__call__cOs|jj||f|�|�S)z^Same as GObject.Object.connect except there is no need to specify
            the signal name.)r�connect)r�callbackrrr	r	r
rgszSignal.BoundSignal.connectcOs|jj|d||f|�|�S)a
Same as GObject.Object.connect except there is no need to specify
            the signal name. In addition concats "::<detail>" to the signal name
            when connecting; for use with notifications like "notify" when a property
            changes.
            z::)rr)rrZdetailrrr	r	r
�connect_detailedlsz#Signal.BoundSignal.connect_detailedcCs|jj|�dS)z"Same as GObject.Object.disconnect.N)�instance�
disconnect)rZ
handler_idr	r	r
rtszSignal.BoundSignal.disconnectcOs|jjt|�f|�|�S)z[Same as GObject.Object.emit except there is no need to specify
            the signal name.)r�emitr
)rrrr	r	r
rxszSignal.BoundSignal.emitN)�__name__�
__module__�__qualname__�__doc__rrrrrrrrr	r	r	r
�BoundSignalSsr#�cOst|�r|j}tj||�S)N)rrr
r)rrrrr	r	r
r}szSignal.__new__Nc		Cs�|r|r|j}nt|�r$|}|j}|r4|r4|j}tj|�|rX|pH|rXt|�\}}|dkrft�}||_||_||_	||_
||_||_||_dS)N)
rrr"r
r�get_signal_annotations�tupler�flags�return_type�	arg_types�accumulator�	accu_data)	rrrr'r(r)�docr*r+r	r	r
r�s&


zSignal.__init__cCs|dkr|S|j||�S)z:Returns a BoundSignal when accessed on an object instance.N)r#)rr�ownerr	r	r
�__get__�szSignal.__get__c
Osdt|tj�r |j|f|�|�n@t|�r2t|�}n|j}t|�|||j|j|j	|j
|j|jd�SdS)zmAllows for instantiated Signals to be used as a decorator or calling
        of the underlying signal method.)rrr'r(r)r,r*r+N)
�
isinstancerZGObjectrr
r�typer'r(r)r"r*r+)r�objrrrr	r	r
r�s
zSignal.__call__c
Cs8|dkr|j}t|�||j|j|j|j|j|j|jd�S)z%Returns a renamed copy of the Signal.N)rrr'r(r)r,r*r+)	rr0rr'r(r)r"r*r+)rZnewNamer	r	r
�copy�s
zSignal.copycCs|j|j|j|j|jfS)zKReturns a tuple of: (flags, return_type, arg_types, accumulator, accu_data))r'r(r)r*r+)rr	r	r
�get_signal_args�szSignal.get_signal_args)r$)N)N)rr r!r"r
r#rrZSIGNAL_RUN_FIRSTrr.rr2r3r	r	r	r
r!s1*


rc@seZdZdZdd�ZdS)�SignalOverridea&Specialized sub-class of Signal which can be used as a decorator for overriding
    existing signals on GObjects.

    :Example:

    .. code-block:: python

        class MyWidget(Gtk.Widget):
            @GObject.SignalOverride
            def configure_event(self):
                pass
    cCsdS)zReturns the string 'override'.�overrider	)rr	r	r
r3�szSignalOverride.get_signal_argsN)rr r!r"r3r	r	r	r
r4�sr4csZt�}d}t|d�rRddl}|j|��t�fdd��jD��}d�jkrR�jd}||fS)aAttempt pulling python 3 function annotations off of 'func' for
    use as a signals type information. Returns an ordered nested tuple
    of (return_type, (arg_type1, arg_type2, ...)). If the given function
    does not have annotations then (None, tuple()) is returned.
    N�__annotations__rc3s"|]}|�jkr�j|VqdS)N)�annotations)�.0�arg)�specr	r
�	<genexpr>�sz)get_signal_annotations.<locals>.<genexpr>�return)r&r�inspectZgetfullargspecrr7)rr)r(r=r	)r:r
r%�s



r%cCs�|jjdi�}i}xn|jj�D]`\}}t|t�rt|�}|sV|}|j|�}t|||�||krjtd|��|||<|j	�||<qW||_
xF|j�D]:\}}|jdk	r�d|jdd�}t
||�s�t|||j�q�WdS)z�Adds Signal instances on a GObject derived class into the '__gsignals__'
    dictionary to be picked up and registered as real GObject signals.
    �__gsignals__z(Signal "%s" has already been registered.NZdo_�-�_)�__dict__�get�itemsr/rr
r2�setattr�
ValueErrorr3r>r�replacer)rZgsignalsZ
newsignalsrrZ
signalNameZfuncNamer	r	r
�install_signals�s&



rG)rr)rr)
�sysr$r�version_inforr
rr4r%rGr	r	r	r
�<module>s"

?>