509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
‰å<_Â:  ã               @   sì   d dl Z 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mZmZmZ ejZejZejZej Z ej!Z!ej"Z"ej#Z#ej$Z$e j%d
krÈe&Z'e(Z)ne*Z'e+Z)G dd„ de,ƒZ-dd	„ Z.dS )é    Né   )Ú_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_VARIANTé   c               @   sN  e Zd ZdZeeeeee	e
eeeeeiZedededee ee eeeeed/iZeeeeed1ed3eeeeeeeeiZedededededededededi	Z G d	d
„ d
e!ƒZ"dddddde#j$ddf	dd„Z%dd„ Z&dd„ Z'dd„ Z(dd„ Z)dd„ Z*dd„ Z+dd„ Z,dd„ Z-dd„ Z.d d!„ Z/d"d#„ Z0d$d%„ Z1d&d'„ Z2d(d)„ Z3d*d+„ Z4d,d-„ Z5dS )4ÚPropertyaÄ  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
    r   é   é?   r   é@   Ú g        c               @   s   e Zd Zdd„ ZdS )zProperty.__metaclass__c             C   s   dS )Nz<class 'GObject.Property'>© )Úselfr"   r"   ú'/usr/lib64/python3.6/_propertyhelper.pyÚ__repr__—   s    zProperty.__metaclass__.__repr__N)Ú__name__Ú
__module__Ú__qualname__r%   r"   r"   r"   r$   Ú__metaclass__–   s   r)   Nc
       
      C   s<  d | _ |d krt}| j|ƒ| _| j|ƒ| _| jƒ  t|tƒsDt	dƒ‚|| _
t|tƒs\t	dƒ‚|| _|| _|| _|r€| r€| j}n*|r’| r’| j}n| rª| rª| j}| j}| j|ƒ || _|d k	ræ|| jƒ k rît	d| j| jƒ f ƒ‚n| jƒ }|| _|	d k	�r$|	| jƒ k�r,t	d| j| jƒ f ƒ‚n| jƒ }	|	| _d | _d S )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Ú_basestringÚ	TypeErrorÚnickÚblurbÚ__doc__ÚflagsÚ_readonly_setterÚ_writeonly_getterÚ_default_getterÚ_default_setterÚgetterÚfsetÚ_get_minimumÚminimumÚ_get_maximumÚmaximumÚ_exc)
r#   r<   Úsetterr-   r/   r4   r5   r7   r?   rA   r"   r"   r$   Ú__init__š   sL    





zProperty.__init__c             C   s   d| j p
dtj| jƒf S )Nz<GObject Property %s (%s)>z(uninitialized))r*   r   Z	type_namer-   )r#   r"   r"   r$   r%   Ò   s    zProperty.__repr__c             C   s\   |d kr| S d | _ y| j|ƒ}W n  tk
r@   tjƒ  d }Y nX | j rX| j }d | _ |‚|S )N)rB   ÚfgetÚ	ExceptionÚ	tracebackÚ	print_exc)r#   ÚinstanceÚklassÚvalueÚexcr"   r"   r$   Ú__get__×   s    
zProperty.__get__c             C   s:   |d krt ‚d | _|j| j|ƒ | jr6| j}d | _|‚d S )N)r3   rB   Zset_propertyr*   )r#   rI   rK   rL   r"   r"   r$   Ú__set__ð   s    zProperty.__set__c             C   s
   | j |ƒS )z;Allows application of the getter along with init arguments.)r<   )r#   rE   r"   r"   r$   Ú__call__û   s    zProperty.__call__c             C   s    |j r|j | _|j | _ || _| S )z8Set the getter function to fget. For use as a decorator.)r6   r5   rE   )r#   rE   r"   r"   r$   r<   ÿ   s
    zProperty.getterc             C   s   || _ | js| jj| _| S )z8Set the setter function to fset. For use as a decorator.)r=   r*   rE   r&   )r#   r=   r"   r"   r$   rC     s    
zProperty.setterc             C   sŒ   || j kr| j | S t|tƒrBt|tjtjtjtjtj	fƒrB|j
S |tttttttttttttttttttttt fkrz|S t!d|f ƒ‚d S )NzUnsupported type: %r)"Ú_type_from_pytype_lookupr1   r-   Ú
issubclassr   ZGObjectZGEnumZGFlagsZGBoxedZ
GInterfaceÚ	__gtype__r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r3   )r#   Ztype_r"   r"   r$   r,     s"    




zProperty._type_from_pythonc             C   s   |d k	r|S | j j| jd ƒS )N)Ú_default_lookupÚgetr-   )r#   r/   r"   r"   r$   r.   &  s    zProperty._get_defaultc             C   s|  | j }| j}|tkr.|dkr.td|f ƒ‚�nJ|tkrJ|d k	rFtdƒ‚�n.|tkrf|d k	rbtdƒ‚�ntj|tƒr¢|d kr„tdƒ‚ntj||ƒs td||f ƒ‚nÖtj|t	ƒrÌtj||ƒsÊtd||f ƒ‚n¬tj|t
ƒoÞ|d k	�r2t|tƒ� sþtd	t|ƒ ƒ‚xx|D ](}t |ƒttfk�rtd
t|ƒ ƒ‚�qW nFtj|tƒ�rx|d k	�rxt|dƒ �shtj|tƒ �rxtd||f ƒ‚d S )NTFz%default must be True or False, not %rz)object types does not have default valuesz(GType types does not have default valuesz%enum properties needs a default valuez'enum value %s must be an instance of %rz(flags value %s must be an instance of %rzStrv value %s must be a listz'Strv value %s must contain only stringsrR   z*variant value %s must be an instance of %r)TF)r-   r/   r   r3   r   r   r   Z	type_is_ar   r   r   r1   ÚlistÚreprÚstrÚbytesr   Úhasattr)r#   Úptyper/   Úvalr"   r"   r$   r0   +  s>    

zProperty._check_defaultc             C   s   | j j| jd ƒS )N)Ú_min_value_lookuprT   r-   )r#   r"   r"   r$   r>   L  s    zProperty._get_minimumc             C   s   | j j| jd ƒS )N)Ú_max_value_lookuprT   r-   )r#   r"   r"   r$   r@   O  s    zProperty._get_maximumc             C   s   t |d| j |ƒ d S )NÚ_property_helper_)Úsetattrr*   )r#   rI   rK   r"   r"   r$   r;   V  s    zProperty._default_setterc             C   s   t |d| j | jƒS )Nr^   )Úgetattrr*   r/   )r#   rI   r"   r"   r$   r:   Y  s    zProperty._default_getterc             C   s   t d| jt|ƒjf ƒ| _d S )Nz%s property of %s is read-only)r3   r*   r-   r&   rB   )r#   rI   rK   r"   r"   r$   r8   \  s    zProperty._readonly_setterc             C   s   t d| jt|ƒjf ƒ| _d S )Nz%s property of %s is write-only)r3   r*   r-   r&   rB   )r#   rI   r"   r"   r$   r9   `  s    zProperty._writeonly_getterc          	   C   s¸   | j }|ttttttttfkr0| j	| j
| jf}nl|tks^|tks^|jtƒs^|jtƒs^|jtƒrh| jf}n4|ttfkrzf }n"|jtƒsŽ|jtƒr”f }nt|ƒ‚| j | j| jf| | jf S )N)r-   r	   r
   r   r   r   r   r   r   r?   rA   r/   r   r   Zis_ar   r   r   r   r   r   r   ÚNotImplementedErrorr4   r5   r7   )r#   rZ   Úargsr"   r"   r$   Úget_pspec_argsh  s    


zProperty.get_pspec_argsl            lûÿÿÿ         l            l   ÿÿÿÿ l            l   ÿÿÿÿ )6r&   r'   r(   r6   Ú_longr   Úintr	   Úboolr   Úfloatr   rW   r   r+   r   rP   r
   r   r   r   Ú
G_MAXFLOATÚG_MAXDOUBLEÚG_MININTÚ	G_MINLONGr   r\   Ú	G_MAXUINTÚ
G_MAXULONGÚG_MAXINTÚ	G_MAXLONGr]   rS   r-   r)   r   ZPARAM_READWRITErD   r%   rM   rN   rO   r<   rC   r,   r.   r0   r>   r@   r;   r:   r8   r9   rc   r"   r"   r"   r$   r   2   sh   66	
!r   c                s   ˆ j jdi ƒ}g }xpˆ j jƒ D ]b\}}t|tƒr|js<||_|j|krh||j |jƒ krZqtd|j ƒ‚|jƒ ||j< |j|ƒ qW |sŒdS |ˆ _	dˆ j ks¦dˆ j krÜx4|D ],}|j
|jksÈ|j|jkr¬tdˆ jf ƒ‚q¬W dd„ }|ˆ _‡ fd	d
„}|ˆ _dS )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 %r defines do_get/set_property and it also uses a property with a custom setter or getter. This is not allowedc             S   s   |j jddƒ}t| |d ƒS )Nú-Ú_)r*   Úreplacer`   )r#   Úpspecr*   r"   r"   r$   Úobj_get_property¡  s    z,install_properties.<locals>.obj_get_propertyc                s.   |j jddƒ}tˆ |d ƒ}|r*|j| |ƒ d S )Nrs   rt   )r*   ru   r`   r=   )r#   rv   rK   r*   Úprop)Úclsr"   r$   Úobj_set_property¦  s    z,install_properties.<locals>.obj_set_property)Ú__dict__rT   Úitemsr1   r   r*   rc   Ú
ValueErrorÚappendrp   rE   r:   r=   r;   r3   r&   rq   rr   )ry   ZgpropertiesZpropsr*   rx   rw   rz   r"   )ry   r$   Úinstall_properties{  s2    


r   )r   r   )/ÚsysrG   r!   r   Z
_constantsr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rh   ri   rj   rn   rl   rk   ro   rm   Úversion_inforW   r2   re   rd   Z
basestringZlongr+   r   r   r"   r"   r"   r$   Ú<module>   s(   h
  K