ó
%ŠNc           @   s.  d  d l  Z  d d l m Z d d l m Z m Z m Z m Z m Z m	 Z	 m
 Z
 m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z d d l m Z m Z m Z m Z m Z m Z m Z m  Z  m! Z! m" Z" e  j# d
 k re$ Z% e& Z' n e( Z% e) Z' d e* f d	 „  ƒ  YZ+ d S(   iÿÿÿÿNi   (   t   _gobject(   t	   TYPE_NONEt   TYPE_INTERFACEt	   TYPE_CHARt
   TYPE_UCHARt   TYPE_BOOLEANt   TYPE_INTt	   TYPE_UINTt	   TYPE_LONGt
   TYPE_ULONGt
   TYPE_INT64t   TYPE_UINT64t	   TYPE_ENUMt
   TYPE_FLAGSt
   TYPE_FLOATt   TYPE_DOUBLEt   TYPE_STRINGt   TYPE_POINTERt
   TYPE_BOXEDt
   TYPE_PARAMt   TYPE_OBJECTt   TYPE_PYOBJECT(
   t
   G_MINFLOATt
   G_MAXFLOATt   G_MINDOUBLEt   G_MAXDOUBLEt   G_MININTt   G_MAXINTt	   G_MAXUINTt	   G_MINLONGt	   G_MAXLONGt
   G_MAXULONGi   i    t   propertyc        
   B   sÀ   e  Z d  Z d e f d „  ƒ  YZ d d d d d d e j d d d „	 Z d „  Z	 d „  Z
 d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sö  
    Creates a new property which in conjunction with GObject subclass will
    create a property proxy:

    >>> class MyObject(gobject.GObject):
    >>> ... prop = gobject.property(type=str)

    >>> obj = MyObject()
    >>> obj.prop = 'value'

    >>> obj.prop
    'value'

    The API is similar to the builtin property:

    class AnotherObject(gobject.GObject):
        @gobject.property
        def prop(self):
            return ...

    Which will create a read-only property called prop.
    t   __metaclass__c           B   s   e  Z d  „  Z RS(   c         C   s   d S(   Ns   <class 'gobject.property'>(    (   t   self(    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyt   __repr__F   s    (   t   __name__t
   __module__R#   (    (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR!   E   s   t    c
   
      C   sõ  | r | r |  j  } n< | r2 | r2 |  j } n# | rU | rU |  j } |  j } n  | |  _ | |  _ | d k r| t } n  |  j | ƒ |  _	 |  j
 | ƒ |  _ |  j ƒ  t | t ƒ sÈ t d ƒ ‚ n  | |  _ t | t ƒ sï t d ƒ ‚ n  | |  _ | d k  s| d k r&t d | f ƒ ‚ n  | |  _ | d k	 rr| |  j ƒ  k  r~t d |  j	 |  j ƒ  f ƒ ‚ q~n |  j ƒ  } | |  _ |	 d k	 rÊ|	 |  j ƒ  k rÖt d |  j	 |  j ƒ  f ƒ ‚ qÖn |  j ƒ  }	 |	 |  _ d |  _ d |  _ d S(	   s`  
        @param  getter: getter to get the value of the property
        @type   getter: callable
        @param  setter: setter to set the value of the property
        @type   setter: callable
        @param    type: type of property
        @type     type: type
        @param default: default value
        @param    nick: short description
        @type     nick: string
        @param   blurb: long description
        @type    blurb: string
        @param flags:    parameter flags, one of:
        - gobject.PARAM_READABLE
        - gobject.PARAM_READWRITE
        - gobject.PARAM_WRITABLE
        - gobject.PARAM_CONSTRUCT
        - gobject.PARAM_CONSTRUCT_ONLY
        - gobject.PARAM_LAX_VALIDATION
        @keyword minimum:  minimum allowed value (int, float, long only)
        @keyword maximum:  maximum allowed value (int, float, long only)
        s   nick must be a strings   blurb must be a stringi    i    s   invalid flag value: %rs+   Minimum for type %s cannot be lower than %ds,   Maximum for type %s cannot be higher than %dN(   t   _readonly_settert   _writeonly_gettert   _default_gettert   _default_settert   gettert   settert   Nonet   objectt   _type_from_pythont   typet   _get_defaultt   defaultt   _check_defaultt
   isinstancet   _basestringt	   TypeErrort   nickt   blurbt   flagst   _get_minimumt   minimumt   _get_maximumt   maximumt   namet   _exc(
   R"   R+   R,   R0   R2   R7   R8   R9   R;   R=   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyt   __init__I   sN    				
						c         C   s#   d |  j  p d t j |  j ƒ f S(   Ns   <gobject property %s (%s)>s   (uninitialized)(   R>   R    t	   type_nameR0   (   R"   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR#   ”   s    c         C   sS   | d  k r |  Sd  |  _ | j |  j ƒ } |  j rO |  j } d  |  _ | ‚ n  | S(   N(   R-   R?   t   get_propertyR>   (   R"   t   instancet   klasst   valuet   exc(    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyt   __get__™   s    					c         C   sY   | d  k r t ‚ n  d  |  _ | j |  j | ƒ |  j rU |  j } d  |  _ | ‚ n  d  S(   N(   R-   R6   R?   t   set_propertyR>   (   R"   RC   RE   RF   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyt   __set__¦   s    					c         C   sñ   | t  k r t S| t k r  t S| t k r0 t S| t k r@ t S| t k rP t	 S| t
 k r` t St | t ƒ r‘ t | t j t j f ƒ r‘ | j S| t t t t t t t t t t t t t t t t t t	 t g k rÚ | St  d | f ƒ ‚ d  S(   Ns   Unsupported type: %r(!   t   _longR   t   intR   t   boolR   t   floatR   t   strR   R.   R   R4   R0   t
   issubclassR    t   GObjectt   GEnumt	   __gtype__R   R   R   R   R   R	   R
   R   R   R   R   R   R   R6   (   R"   t   type_(    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR/   ±   s0    		c         C   so   |  j  } | d  k	 r | S| t t t t t t g k r; d S| t k rK d S| t	 k sc | t
 k rg d Sd  Sd  S(   Ni    R&   g        (   R0   R-   R   R   R   R	   R
   R   R   R   R   (   R"   R2   t   ptype(    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR1   Ì   s    	c         C   sÏ   |  j  } |  j } | t k rF | t t f k rF t d | f ƒ ‚ n… | t k rp | d  k	 rË t d ƒ ‚ qË n[ t j	 | t
 ƒ rË | d  k r t d ƒ ‚ qË t j	 | | ƒ sË t d | | f ƒ ‚ qË n  d  S(   Ns%   default must be True or False, not %rs)   object types does not have default valuess%   enum properties needs a default values'   enum value %s must be an instance of %r(   R0   R2   R   t   Truet   FalseR6   R   R-   R    t	   type_is_aR   (   R"   RT   R2   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR3   Û   s    		c         C   sx   |  j  } | t t t g k r" d S| t k r3 t S| t k rD t S| t k rT t	 S| t
 k rd t S| t k rt d Sd  S(   Ni    i   i>   i   l            lûÿÿÿ         lûÿÿÿ        (   R0   R   R	   R   R   R   R   R   R   R   R   R   R
   R-   (   R"   RT   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR:   ë   s    	c         C   s   |  j  } | t k r t S| t k r) t S| t k r9 d S| t k rI d S| t k rY t S| t	 k ri t
 S| t k ry t S| t k r‰ t Sd  S(	   Ni   i>   i   i?   l            l   ÿÿÿÿ l            l   ÿÿÿÿ (   R0   R   R   R	   R   R
   R   R   R   R   R   R   R   R   R   R-   (   R"   RT   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR<   ý   s$    	c         C   s   t  | d |  j | ƒ d  S(   Nt   _property_helper_(   t   setattrR>   (   R"   RC   RE   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR*     s    c         C   s   t  | d |  j |  j ƒ S(   NRX   (   t   getattrR>   R2   (   R"   RC   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR)     s    c         C   s)   t  d |  j t | ƒ j f ƒ |  _ d  S(   Ns   %s property of %s is read-only(   R6   R>   R0   R$   R?   (   R"   RC   RE   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR'     s    c         C   s)   t  d |  j t | ƒ j f ƒ |  _ d  S(   Ns   %s property of %s is write-only(   R6   R>   R0   R$   R?   (   R"   RC   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR(      s    c      	   C   sá   |  j  } | t t t t t t t t g k rN |  j	 ƒ  |  j
 ƒ  |  j f } no | t k su | t k su | j t ƒ r„ |  j f } n9 | t k r™ d } n$ | j t ƒ r± d } n t | ƒ ‚ |  j  |  j |  j f | |  j f S(   N(    (    (   R0   R   R   R   R	   R
   R   R   R   R:   R<   R2   R   R   t   is_aR   R   R   t   NotImplementedErrorR7   R8   R9   (   R"   RT   t   args(    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyt   get_pspec_args(  s    	!		N(   R$   R%   t   __doc__R0   R!   R-   R    t   PARAM_READWRITER@   R#   RG   RI   R/   R1   R3   R:   R<   R*   R)   R'   R(   R^   (    (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR    -   s$   I												(   i   i    (,   t   sysR&   R    t	   constantsR   R   R   R   R   R   R   R   R	   R
   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   version_infoRN   R5   RK   RJ   t
   basestringt   longR.   R    (    (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyt   <module>   s   ˆF	