
    fS7                     T   S SK Jr  S SKJrJrJrJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJr  \R6                  r\R8                  r\R:                  r\R<                  r\R>                  r\R@                  r \RB                  r!\RD                  r" " S S\#5      r$S r%g)   )_gi)	TYPE_NONETYPE_INTERFACE	TYPE_CHAR
TYPE_UCHARTYPE_BOOLEANTYPE_INT	TYPE_UINT	TYPE_LONG
TYPE_ULONG
TYPE_INT64TYPE_UINT64	TYPE_ENUM
TYPE_FLAGS
TYPE_FLOATTYPE_DOUBLETYPE_STRINGTYPE_POINTER
TYPE_BOXED
TYPE_PARAMTYPE_OBJECTTYPE_PYOBJECT
TYPE_GTYPE	TYPE_STRVTYPE_VARIANTc                   J   \ rS rSrSr\\\\\	\
\\\\0r\S\S\S\\* \
\* \\\\\S0r\\\\\S\S\\\
\\\\\0r\S\S\S\S\S\S\S\S\
S0	r  " S	 S
\!5      r"SSSSSS\#RH                  SS4	S jr%S r&S r'S r(S r)S r*S r+S r,S r-S r.S r/S r0S r1S r2S r3S r4S r5Sr6g)Property'   a  Creates a new Property which when used in conjunction with
GObject subclass will create a Python property accessor for the
GObject ParamSpec.

:param callable getter:
    getter to get the value of the property
:param callable setter:
    setter to set the value of the property
:param type type:
    type of property
:param default:
    default value, must match the property type.
:param str nick:
    short description
:param str blurb:
    long description
:param GObject.ParamFlags flags:
    parameter flags
:keyword minimum:
    minimum allowed value (int, float, long only)
:keyword maximum:
    maximum allowed value (int, float, long only)

.. code-block:: python

     class MyObject(GObject.Object):
         prop = GObject.Property(type=str)

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

     obj.prop  # now is 'value'

The API is similar to the builtin :py:func:`property`:

.. code-block:: python

    class AnotherObject(GObject.Object):
        value = 0

        @GObject.Property
        def prop(self):
            'Read only property.'
            return 1

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

        @propInt.setter
        def propInt(self, value):
            self.value = value
    l         l    l     g        c                       \ rS rSrS rSrg)Property.__metaclass__   c                     g)Nz<class 'GObject.Property'> selfs    4/usr/lib/python3/dist-packages/gi/_propertyhelper.py__repr__Property.__metaclass__.__repr__   s    /    r%   N)__name__
__module____qualname____firstlineno__r)   __static_attributes__r%   r+   r(   __metaclass__r"      s    	0r+   r1   Nc
                    S U l         Uc  [        nU R                  U5      U l        U R	                  U5      U l        U R                  5         [        U[        5      (       d  [        S5      eXPl
        [        U[        5      (       d  [        S5      eX`l        X`l        Xpl        U(       a  U(       d  U R                  nOAU(       a  U(       d  U R                  nO&U(       d  U(       d  U R                   nU R"                  nU R%                  U5        X l        Ub<  XR)                  5       :  a(  [        SU R                  U R)                  5       4-  5      eOU R)                  5       nXl        U	b<  XR-                  5       :  a(  [        SU R                  U R-                  5       4-  5      eOU R-                  5       n	Xl        S U l        g )Nznick must be a stringzblurb must be a stringz+Minimum for type %s cannot be lower than %dz,Maximum for type %s cannot be higher than %d)nameobject_type_from_pythontype_get_defaultdefault_check_default
isinstancestr	TypeErrornickblurb__doc__flags_readonly_setter_writeonly_getter_default_getter_default_settergetterfset_get_minimumminimum_get_maximummaximum_exc)
r'   rE   setterr6   r8   r=   r>   r@   rH   rJ   s
             r(   __init__Property.__init__   s    	<D**40	((1$$$344	%%%455
 
 &**FF++F))F))FF 	**,,AYY 1 1 3456 6 -
 '')G**,,BYY 1 1 3456 6 -
 '')G	r+   c                 f    SU R                   =(       d    S< SU R                  R                   < S3$ )Nz<GObject Property z(uninitialized)z (z)>)r3   r6   r&   s    r(   r)   Property.__repr__   s'    II***IINN 	r+   c                     Uc  U $ S U l         U R                  U5      nU R                   (       a  U R                   nS U l         UeU$ N)rK   fget)r'   instanceklassvalueexcs        r(   __get__Property.__get__   sC    K			(#99))CDIIr+   c                     Uc  [         eS U l        UR                  U R                  U5        U R                  (       a  U R                  nS U l        Ueg rR   )r<   rK   set_propertyr3   )r'   rT   rV   rW   s       r(   __set__Property.__set__   sI    O	dii/99))CDII r+   c                 $    U R                  U5      $ )z;Allows application of the getter along with init arguments.)rE   r'   rS   s     r(   __call__Property.__call__   s    {{4  r+   c                 x    UR                   (       a"  UR                   U l        UR                   U l         Xl        U $ )z8Set the getter function to fget. For use as a decorator.)r?   r>   rS   r_   s     r(   rE   Property.getter   s)    <<DJ<<DL	r+   c                 j    Xl         U R                  (       d  U R                  R                  U l        U $ )z8Set the setter function to fset. For use as a decorator.)rF   r3   rS   r,   )r'   rF   s     r(   rL   Property.setter   s&    	 yy		**DIr+   c                 B   XR                   ;   a  U R                   U   $ [        U[        5      (       ah  [        U[        R
                  [        R                  [        R                  [        R                  [        R                  45      (       a  UR                  $ U[        [        [        [        [        [         ["        [$        [&        [(        [*        [,        [.        [0        [2        [4        [6        [8        [:        [<        [>        [@        4;   a  U$ [C        SU< 35      e)NzUnsupported type: )"_type_from_pytype_lookupr:   r6   
issubclassr   GObjectGEnumGFlagsGBoxed
GInterface	__gtype__r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r<   )r'   type_s     r(   r5   Property._type_from_python   s    1110077%%!$!$!$!$	!1 2 2
 ??"y.)ZL)!:{!;!:{K$j)\K K Le=>>r+   c                 X    Ub  U$ U R                   R                  U R                  S 5      $ rR   )_default_lookupgetr6   )r'   r8   s     r(   r7   Property._get_default  s*    N##''		488r+   c                 :   U R                   nU R                  nU[        :X  a  US;  a  [        SU< 35      eU[        :X  a  Ub  [        S5      eg U[
        :X  a  Ub  [        S5      eg UR                  [        5      (       aL  Uc  [        S5      e[        R                  " U5      R                  U5      (       d  [        SU< SU< 35      eg UR                  [        5      (       a>  [        R                  " U5      R                  U5      (       d  [        SU< SU< 35      eg UR                  [        5      (       ai  Ubf  [        U[        5      (       d  [        S	[        U5      -  5      eU H3  n[        U5      [        [         4;  d  M  [        S
[        U5      -  5      e   g UR                  ["        5      (       aW  UbS  [%        US5      (       a.  [        R                  " U5      R                  ["        5      (       d  [        SU< SU< 35      eg g g )N)TFz#default must be True or False, not z)object types does not have default valuesz(GType types does not have default valuesz%enum properties needs a default valuezenum value z must be an instance of zflags value zStrv value %s must be a listz'Strv value %s must contain only stringsrn   zvariant value )r6   r8   r   r<   r   r   is_ar   r   GTyper   r   r:   listreprr;   bytesr   hasattr)r'   ptyper8   vals       r(   r9   Property._check_default  s   		,,\!wm'C;BDF Fm#" KLL #j " JKK #ZZ	"" GHHYYw',,U33!(%!1 2 2 4 ZZ
##99W%**511!(%!1 2 2 2 ZZ	""w':gt,, >g NOO9S%L0#$MPST[P\$\]]  ZZ%%'*=7K00		'8J8O8OP\8]8]!(%!1 2 2 9^ +>%r+   c                 N    U R                   R                  U R                  S 5      $ rR   )_min_value_lookuprs   r6   r&   s    r(   rG   Property._get_minimum3      %%))$))T::r+   c                 N    U R                   R                  U R                  S 5      $ rR   )_max_value_lookuprs   r6   r&   s    r(   rI   Property._get_maximum6  r   r+   c                 8    [        USU R                  -   U5        g N_property_helper_)setattrr3   r'   rT   rV   s      r(   rD   Property._default_setter=  s    -		95Ar+   c                 J    [        USU R                  -   U R                  5      $ r   )getattrr3   r8   r'   rT   s     r(   rC   Property._default_getter@  s    x!4tyy!@$,,OOr+   c                 n    [        U R                  < S[        U5      R                  < S35      U l        g )N property of z is read-onlyr<   r3   r6   r,   rK   r   s      r(   rA   Property._readonly_setterC  &    IItH~..0 1	r+   c                 n    [        U R                  < S[        U5      R                  < S35      U l        g )Nr   z is write-onlyr   r   s     r(   rB   Property._writeonly_getterG  r   r+   c           	         U R                   nU[        [        [        [        [
        [        [        [        4;   a$  U R                  U R                  U R                  4nOU[        :X  dX  U[        :X  dN  UR                  [        5      (       d4  UR                  [         5      (       d  UR                  ["        5      (       a  U R                  4nOUU[$        [&        4;   a  SnOBUR                  [(        5      (       d  UR                  [*        5      (       a  SnO[-        U5      eU R                   U R.                  U R0                  4U-   U R2                  4-   $ )Nr%   )r6   r	   r
   r   r   r   r   r   r   rH   rJ   r8   r   r   rv   r   r   r   r   r   r   r   NotImplementedErrorr=   r>   r@   )r'   r|   argss      r(   get_pspec_argsProperty.get_pspec_argsO  s    		Xy)Zj+G G<<t||;D{"e|&;jj##uzz*'='=jj&&LL?D}j11DZZ$$

:(>(>D%e,,		499djj1D8DJJ=HHr+   )r?   rK   r>   r8   rS   r@   rF   rJ   rH   r3   r=   r6   )7r,   r-   r.   r/   r?   intr	   boolr   floatr   r;   r   r4   r   rg   r
   r   r   r   
G_MAXFLOATG_MAXDOUBLEG_MININTr   	G_MINLONGr   r   	G_MAXUINT
G_MAXULONGG_MAXINT	G_MAXLONGr   rr   r6   r1   r   PARAM_READWRITErM   r)   rX   r\   r`   rE   rL   r5   r7   r9   rG   rI   rD   rC   rA   rB   r   r0   r%   r+   r(   r   r   '   sL   5n 	Xl{[  	1AQZKk\(9H
 	9JK[J[(9	 	!11AAQRCS
O0 0 #4dD#*=*=t6p
	!?(9
2B;;BP11Ir+   r   c                   ^  T R                   R                  S0 5      n/ nT R                   R                  5        H  u  p4[        U[        5      (       d  M  UR
                  (       d  X4l        UR
                  U;   a:  XR
                     UR                  5       :X  a  Me  [        SUR
                  -  5      eUR                  5       XR
                  '   UR                  U5        M     U(       d  gUT l	        ST R                   ;   d  ST R                   ;   aW  U HQ  nUR                  UR                  :w  d  UR                  UR                  :w  d  M9  [        ST R                  < S35      e   S nUT l        U 4S	 jnUT l        g)
z
Scans the given class for instances of Property and merges them
into the classes __gproperties__ dict if it exists or adds it if not.
__gproperties__z0Property %s was already found in __gproperties__Ndo_get_propertydo_set_propertyzGObject subclass zl defines do_get/set_property and it also uses a property with a custom setter or getter. This is not allowedc                 R    UR                   R                  SS5      n[        XS 5      $ N-_)r3   replacer   )r'   pspecr3   s      r(   obj_get_property,install_properties.<locals>.obj_get_property  s%    zz!!#s+t4((r+   c                    > UR                   R                  SS5      n[        TUS 5      nU(       a  UR                  X5        g g r   )r3   r   r   rF   )r'   r   rV   r3   propclss        r(   obj_set_property,install_properties.<locals>.obj_set_property  s;    zz!!#s+sD$'IId" r+   )__dict__rs   itemsr:   r   r3   r   
ValueErrorappendr   rS   rC   rF   rD   r<   r,   r   r   )r   gpropertiespropsr3   r   r   r   s   `      r(   install_propertiesr   b  sE   
 ,,""#4b9KEll((*
dH%% 99 	 yyK'yy)T-@-@-BB !SVZV_V_!_``%)%8%8%:K		"LL +  %CCLL(,=,MDyyD000DIIAUAU4U \\$% % ) +C#
 +Cr+   N)&r    r   
_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   r   r4   r   r   r%   r+   r(   <module>r      s   ( 7 7 7 7 7 7 7 ^^
oo<<<<MM	MM	MM	^^
xIv xIv	0+r+   