ó
-£´Oc           @   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 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):
            '''Read only property.'''
            return ...

        @GObject.Property(type=int)
        def propInt(self):
            '''Read-write integer property.'''
            return ...

        @propInt.setter
        def propInt(self, value):
            ...
    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__N   s    (   t   __name__t
   __module__R#   (    (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR!   M   s   t    c
   
      C   sý  | d k r t } n  |  j | ƒ |  _ |  j | ƒ |  _ |  j ƒ  t | t ƒ sa t	 d ƒ ‚ n  | |  _
 t | t ƒ sˆ t	 d ƒ ‚ n  | |  _ | d k  s© | d k r¿ t	 d | f ƒ ‚ n  | |  _ | rá | rá |  j } n< | rú | rú |  j } n# | r| r|  j } |  j } n  |  j | ƒ |  j | ƒ | d k	 rz| |  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   Nonet   objectt   _type_from_pythont   typet   _get_defaultt   defaultt   _check_defaultt
   isinstancet   _basestringt	   TypeErrort   nickt   blurbt   flagst   _readonly_settert   _writeonly_gettert   _default_gettert   _default_settert   gettert   settert   _get_minimumt   minimumt   _get_maximumt   maximumt   namet   _exc(
   R"   R8   R9   R*   R,   R1   R2   R3   R;   R=   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyt   __init__Q   sN    	
							c         C   s#   d |  j  p d t j |  j ƒ f S(   Ns   <GObject Property %s (%s)>s   (uninitialized)(   R>   R    t	   type_nameR*   (   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'   R0   R?   t   set_propertyR>   (   R"   RC   RE   RF   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyt   __set__¯   s    					c         C   s   |  j  | ƒ S(   s;   Allows application of the getter along with init arguments.(   R8   (   R"   t   fget(    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyt   __call__º   s    c         C   sM   |  j  d k r | j  |  _  n  |  j r@ | j  r@ | j  |  _ n  | |  _ |  S(   s8   Set the getter function to fget. For use as a decorator.N(   t   __doc__R'   R2   RJ   (   R"   RJ   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR8   ¾   s    	c         C   s   | |  _  |  S(   s8   Set the setter function to fset. For use as a decorator.(   t   fset(   R"   RM   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR9   Ç   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 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   R.   R*   t
   issubclassR    t   GObjectt   GEnumt   GBoxedt	   __gtype__R   R   R   R   R   R	   R
   R   R   R   R   R   R   R0   (   R"   t   type_(    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR)   Ì   s2    		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        (   R*   R'   R   R   R   R	   R
   R   R   R   R   (   R"   R,   t   ptype(    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR+   è   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(   R*   R,   R   t   Truet   FalseR0   R   R'   R    t	   type_is_aR   (   R"   RY   R,   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR-   ÷   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   I       @I       ÀIÿÿÿÿÿÿÿ¿(   R*   R   R	   R   R   R   R   R   R   R   R   R   R
   R'   (   R"   RY   (    (    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?   I       @Iÿÿÿÿÿÿÿ?l            l   ÿÿÿÿ (   R*   R   R   R	   R   R
   R   R   R   R   R   R   R   R   R   R'   (   R"   RY   (    (    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.pyR7   2  s    c         C   s   t  | d |  j |  j ƒ S(   NR]   (   t   getattrR>   R,   (   R"   RC   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR6   5  s    c         C   s)   t  d |  j t | ƒ j f ƒ |  _ d  S(   Ns   %s property of %s is read-only(   R0   R>   R*   R$   R?   (   R"   RC   RE   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR4   8  s    c         C   s)   t  d |  j t | ƒ j f ƒ |  _ d  S(   Ns   %s property of %s is write-only(   R0   R>   R*   R$   R?   (   R"   RC   (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR5   <  s    c      	   C   sê   |  j  } | t t t t t t t t g k rH |  j	 |  j
 |  j f } n~ | t k so | t k so | j t ƒ r~ |  j f } nH | t k r“ d } n3 | j t ƒ s± | j t ƒ rº d } n t | ƒ ‚ |  j  |  j |  j f | |  j f S(   N(    (    (   R*   R   R   R   R	   R
   R   R   R   R;   R=   R,   R   R   t   is_aR   R   R   R   t   NotImplementedErrorR1   R2   R3   (   R"   RY   t   args(    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyt   get_pspec_argsD  s    			N(   R$   R%   RL   R*   R!   R'   R    t   PARAM_READWRITER@   R#   RG   RI   RK   R8   R9   R)   R+   R-   R:   R<   R7   R6   R4   R5   Rc   (    (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyR    -   s*   J																(   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_infoRR   R/   RO   RN   t
   basestringt   longR(   R    (    (    (    s>   /usr/lib/python2.7/dist-packages/gi/_gobject/propertyhelper.pyt   <module>   s   ˆF	