ó
§Zc           @   s‰   d  d l  Z  d d l m Z d e  j k o6 d k  n rG d „  Z n  d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d „  Z d „  Z	 d S(   iÿÿÿÿNi   (   t   _gobjecti   i    i   c         C   s   t  |  d ƒ S(   Nt   __call__(   t   hasattr(   t   fn(    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyt   callable   s    t   Signalc        	   B   s~   e  Z d  Z d e f d „  ƒ  YZ d d „ Z d d
 e j d
 d
 d d
 d
 d „ Z	 d
 d „ Z
 d „  Z d
 d „ Z d	 „  Z RS(   s¸  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()
    t   BoundSignalc           B   sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   s‘   
        Temporary binding object which can be used for connecting signals
        without specifying the signal name string to connect.
        c         O   s   t  j |  | ƒ S(   N(   t   strt   __new__(   t   clst   namet   argst   kargs(    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyR   X   s    c         C   s#   t  j |  ƒ | |  _ | |  _ d  S(   N(   R   t   __init__t   signalt   gobj(   t   selfR   R   (    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyR   [   s    	c         C   s   d |  S(   Ns   BoundSignal("%s")(    (   R   (    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyt   __repr__`   s    c         O   s   |  j  j |  j | | Ž S(   s   Call the signals closure.(   R   t   funcR   (   R   R   R   (    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyR   c   s    c         O   s   |  j  j |  | | | Ž S(   s^   Same as GObject.Object.connect except there is no need to specify
            the signal name.(   R   t   connect(   R   t   callbackR   R   (    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyR   g   s    c         O   s!   |  j  j |  d | | | | Ž S(   s
  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.
            s   ::(   R   R   (   R   R   t   detailR   R   (    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyt   connect_detailedl   s    c         C   s   |  j  j | ƒ d S(   s"   Same as GObject.Object.disconnect.N(   t   instancet
   disconnect(   R   t
   handler_id(    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyR   t   s    c         O   s   |  j  j t |  ƒ | | Ž S(   s[   Same as GObject.Object.emit except there is no need to specify
            the signal name.(   R   t   emitR   (   R   R   R   (    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyR   x   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R   R   (    (    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyR   S   s   							t    c         O   s(   t  | ƒ r | j } n  t j |  | ƒ S(   N(   R   R   R   R   (   R	   R
   R   R   (    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyR   }   s    c	   	      C   sà   | r | r | j  } n t | ƒ r7 | } | j  } n  | rP | rP | j } n  t j |  ƒ | r… | pl | r… t | ƒ \ } } n  | d  k r t ƒ  } n  | |  _ | |  _	 | |  _
 | |  _ | |  _ | |  _ | |  _ d  S(   N(   R   R   R   R   R   t   get_signal_annotationst   Nonet   tupleR   t   flagst   return_typet	   arg_typest   accumulatort	   accu_data(	   R   R
   R   R"   R#   R$   t   docR%   R&   (    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyR   ‚   s&    						c         C   s    | d k r |  S|  j |  | ƒ S(   s:   Returns a BoundSignal when accessed on an object instance.N(   R    R   (   R   R   t   owner(    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyt   __get__›   s    c         O   sŸ   t  | t j ƒ r( |  j | | | Ž ns t |  ƒ rC t |  ƒ } n	 | j } t |  ƒ d | d | d |  j d |  j d |  j	 d |  j
 d |  j d |  j ƒ Sd	 S(
   sm   Allows for instantiated Signals to be used as a decorator or calling
        of the underlying signal method.R
   R   R"   R#   R$   R'   R%   R&   N(   t
   isinstanceR    t   GObjectR   R   R   t   typeR"   R#   R$   R   R%   R&   (   R   t   objR   R   R
   (    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyR   ¡   s    	!c         C   sj   | d	 k r |  j } n  t |  ƒ d | d |  j d |  j d |  j d |  j d |  j d |  j d |  j	 ƒ S(
   s%   Returns a renamed copy of the Signal.R
   R   R"   R#   R$   R'   R%   R&   N(
   R    R
   R,   R   R"   R#   R$   R   R%   R&   (   R   t   newName(    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyt   copyµ   s
    $c         C   s"   |  j  |  j |  j |  j |  j f S(   sK   Returns a tuple of: (flags, return_type, arg_types, accumulator, accu_data)(   R"   R#   R$   R%   R&   (   R   (    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyt   get_signal_args½   s    N(   R   R   R   R   R   R   R    R    t   SIGNAL_RUN_FIRSTR   R)   R   R/   R0   (    (    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyR   !   s   1*	t   SignalOverridec           B   s   e  Z d  Z d „  Z RS(   s&  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
    c         C   s   d S(   s   Returns the string 'override'.t   override(    (   R   (    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyR0   Ï   s    (   R   R   R   R0   (    (    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyR2   Â   s   c            s„   t  ƒ  } d } t |  d ƒ rz d d l } | j |  ƒ ‰  t  ‡  f d †  ˆ  j Dƒ ƒ } d ˆ  j k rz ˆ  j d } qz n  | | f S(   s  Attempt 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.
    t   __annotations__iÿÿÿÿNc         3   s+   |  ]! } | ˆ  j  k r ˆ  j  | Vq d  S(   N(   t   annotations(   t   .0t   arg(   t   spec(    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pys	   <genexpr>á   s    t   return(   R!   R    R   t   inspectt   getfullargspecR   R5   (   R   R$   R#   R:   (    (   R8   s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyR   Ô   s    	c         C   s7  |  j  j d i  ƒ } i  } x¢ |  j  j ƒ  D]‘ \ } } t | t ƒ r+ t | ƒ } | s€ | } | j | ƒ } t |  | | ƒ n  | | k rŸ t d | ƒ ‚ n  | | | <| j	 ƒ  | | <q+ q+ W| |  _
 xg | j ƒ  D]Y \ } } | j d k	 rÖ d | j d d ƒ } t |  | ƒ s/t |  | | j ƒ q/qÖ qÖ Wd S(   s”   Adds Signal instances on a GObject derived class into the '__gsignals__'
    dictionary to be picked up and registered as real GObject signals.
    t   __gsignals__s(   Signal "%s" has already been registered.t   do_t   -t   _N(   t   __dict__t   gett   itemsR*   R   R   R/   t   setattrt
   ValueErrorR0   R<   R   R    t   replaceR   (   R	   t   gsignalst
   newsignalsR
   R   t
   signalNamet   funcName(    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyt   install_signalsé   s&    
	(   i   i    (   i   i   (
   t   syst   _giR    t   version_infoR   R   R   R2   R   RJ   (    (    (    s6   /usr/lib64/python2.7/site-packages/gi/_signalhelper.pyt   <module>   s   ¡	