ok

Mini Shell

Direktori : /usr/lib64/python3.6/site-packages/pygtkcompat/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/pygtkcompat/__pycache__/generictreemodel.cpython-36.pyc

3

��<_�6�@stddlZddlZddlZddlZddlmZddlmZGdd�dej�Zdd�Z	dd	�Z
Gd
d�dejej�ZdS)�N)�GObject)�Gtkc@s<eZdZdejfdejfdejfdejfgZedd��ZdS)�
_CTreeIter�stamp�	user_dataZ
user_data2Z
user_data3cCs$tjt��}tj|�jt|�|�S)N)�sys�	getsizeof�object�ctypesZPOINTERZfrom_address�id)�cls�iter�offset�r�(/usr/lib64/python3.6/generictreemodel.py�	from_iter&sz_CTreeIter.from_iterN)	�__name__�
__module__�__qualname__r
Zc_intZc_void_pZ_fields_�classmethodrrrrrr s
rcCstj|�}tj|jjtj�jS)N)rrr
�cast�contentsrZ	py_object�value)r
Zciterrrr�_get_user_data_as_pyobject,s
rcs�fdd�}|S)a]Returns a function which can act as a decorator for wrapping exceptions and
    returning "default_return" upon an exception being thrown.

    This is used to wrap Gtk.TreeModel "do_" method implementations so we can return
    a proper value from the override upon an exception occurring with client code
    implemented by the "on_" methods.
    cs��fdd�}|S)Nc	s*y
�||�Stjtj��YnX�S)N)r�
excepthook�exc_info)�argsZkargs)�default_return�funcrr�wrapped_func:s

z9handle_exception.<locals>.decorator.<locals>.wrapped_funcr)rr)r)rr�	decorator9sz#handle_exception.<locals>.decoratorr)rr r)rr�handle_exception1s
r!cs�eZdZdZejdedd�Z�fdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�Zdd�ZdT�fdd�	Zed�dd��Zed�dd��Zeej�dd ��ZedU�d"d#��Zed!�d$d%��Zed�d&d'��Zed�d(d)��ZedV�d*d+��Zed!�d,d-��Zed�d.d/��ZedW�d0d1��ZedX�d2d3��Zed�d4d5��Z ed�d6d7��Z!d8d9�Z"d:d;�Z#d<d=�Z$d>d?�Z%d@dA�Z&dBdC�Z'dDdE�Z(dFdG�Z)dHdI�Z*dJdK�Z+dLdM�Z,dNdO�Z-dPdQ�Z.dRdS�Z/�Z0S)Y�GenericTreeModelaA base implementation of a Gtk.TreeModel for python.

    The GenericTreeModel eases implementing the Gtk.TreeModel interface in Python.
    The class can be subclassed to provide a TreeModel implementation which works
    directly with Python objects instead of iterators.

    All of the on_* methods should be overridden by subclasses to provide the
    underlying implementation a way to access custom model data. For the purposes of
    this API, all custom model data supplied or handed back through the overridable
    API will use the argument names: node, parent, and child in regards to user data
    python objects.

    The create_tree_iter, set_user_data, invalidate_iters, iter_is_valid methods are
    available to help manage Gtk.TreeIter objects and their Python object references.

    GenericTreeModel manages a pool of user data nodes that have been used with iters.
    This pool stores a references to user data nodes as a dictionary value with the
    key being the integer id of the data. This id is what the Gtk.TreeIter objects
    use to reference data in the pool.
    References will be removed from the pool when the model is deleted or explicitly
    by using the optional "node" argument to the "row_deleted" method when notifying
    the model of row deletion.
    Tz�If True, strong references to user data attached to iters are stored in a dictionary pool (default). Otherwise the user data is stored as a raw pointer to a python object without a reference.)�default�typeZblurbcs(tt|�j�d|_t�|_|j�dS)zFInitialize. Make sure to call this from derived classes if overridden.rN)�superr"�__init__r�dict�
_held_refs�invalidate_iters)�self)�	__class__rrr&gszGenericTreeModel.__init__c#sbtjdg�}xP|r\|j���dk	r.�j��V��fdd�t�j���D�}|jt|��qWdS)zHDepth-first iteration of the entire TreeModel yielding the python nodes.Ncsg|]}�j�|��qSr)Ziter_nth_child)�.0�i)�itr*rr�
<listcomp>ysz5GenericTreeModel.iter_depth_first.<locals>.<listcomp>)�collections�deque�popleft�
get_user_data�rangeZiter_n_children�
extendleft�reversed)r*�stackZchildrenr)r.r*r�iter_depth_firstrsz!GenericTreeModel.iter_depth_firstcCs,d|_|jr(|j|jkr"|j|j=d|_dS)z?Clear user data and its reference from the iter and this model.rN)rrr()r*r
rrr�invalidate_iter|s

z GenericTreeModel.invalidate_itercCstjdd�|_|jj�dS)z�
        This method invalidates all TreeIter objects associated with this custom tree model
        and frees their locally pooled references.
        li���Ni�)�randomZrandintrr(�clear)r*rrrr)�sz!GenericTreeModel.invalidate_iterscCs|j|jkS)zv
        :Returns:
            True if the gtk.TreeIter specified by iter is valid for the custom tree model.
        )r)r*r
rrr�
iter_is_valid�szGenericTreeModel.iter_is_validcCs|jr|j|jSt|�SdS)z�Get the user_data associated with the given TreeIter.

        GenericTreeModel stores arbitrary Python objects mapped to instances of Gtk.TreeIter.
        This method allows to retrieve the Python object held by the given iterator.
        N)�leak_referencesr(rr)r*r
rrrr3�szGenericTreeModel.get_user_datacCs<t|�|_|dkr|j|�n|j|_|jr8||j|j<dS)z�Applies user_data and stamp to the given iter.

        If the models "leak_references" property is set, a reference to the
        user_data is stored with the model to ensure we don't run into bad
        memory problems with the TreeIter.
        N)rrr9rr=r()r*r
rrrr�
set_user_data�s
zGenericTreeModel.set_user_datacCstj�}|j||�|S)aCreate a Gtk.TreeIter instance with the given user_data specific for this model.

        Use this method to create Gtk.TreeIter instance instead of directly calling
        Gtk.Treeiter(), this will ensure proper reference managment of wrapped used_data.
        )rZTreeIterr>)r*rr
rrr�create_tree_iter�sz!GenericTreeModel.create_tree_itercCs"|dkrdS|j|�}d|fSdS)zyInternal creation of a (bool, TreeIter) pair for returning directly
        back to the view interfacing with this model.NFT)FN)r?)r*�datar.rrr�_create_tree_iter�s
z"GenericTreeModel._create_tree_iterNcs.tt|�j|�t|�}||jkr*|j|=dS)a�Notify the model a row has been deleted.

        Use the node parameter to ensure the user_data reference associated
        with the path is properly freed by this model.

        :Parameters:
            path : Gtk.TreePath
                Path to the row that has been deleted.
            node : object
                Python object used as the node returned from "on_get_iter". This is
                optional but ensures the model will not leak references to this object.
        N)r%r"�row_deletedrr()r*�path�nodeZnode_id)r+rrrB�s

zGenericTreeModel.row_deletedrcCs|j�S)zInternal method.)�on_get_flags)r*rrr�do_get_flags�szGenericTreeModel.do_get_flagscCs|j�S)zInternal method.)�on_get_n_columns)r*rrr�do_get_n_columns�sz!GenericTreeModel.do_get_n_columnscCs
|j|�S)zInternal method.)�on_get_column_type)r*�indexrrr�do_get_column_type�sz#GenericTreeModel.do_get_column_typeFcCs|j|j|��S)zInternal method.)rA�on_get_iter)r*rCrrr�do_get_iter�szGenericTreeModel.do_get_itercCs8|dkr|jd�}n|j|j|��}|j||�|dk	S)zInternal method.N)�on_iter_nextr3r>)r*r
Z	next_datarrr�do_iter_next�s
zGenericTreeModel.do_iter_nextcCs*|j|j|��}|dkrdStj|�SdS)zInternal method.N)�on_get_pathr3rZTreePath)r*r
rCrrr�do_get_path�szGenericTreeModel.do_get_pathcCs|j|j|�|�S)zInternal method.)�on_get_valuer3)r*r
�columnrrr�do_get_value�szGenericTreeModel.do_get_valuecCs"|r|j|�nd}|j|j|��S)zInternal method.N)r3rA�on_iter_children)r*�parentr@rrr�do_iter_childrensz!GenericTreeModel.do_iter_childrencCs|j|j|��S)zInternal method.)�on_iter_has_childr3)r*rVrrr�do_iter_has_child	sz"GenericTreeModel.do_iter_has_childcCs"|dkr|jd�S|j|j|��S)zInternal method.N)�on_iter_n_childrenr3)r*r
rrr�do_iter_n_childrens
z#GenericTreeModel.do_iter_n_childrencCs2|dkr|jd|�}n|j|j|�|�}|j|�S)zInternal method.N)�on_iter_nth_childr3rA)r*rV�nr@rrr�do_iter_nth_childsz"GenericTreeModel.do_iter_nth_childcCs|j|j|j|���S)zInternal method.)rA�on_iter_parentr3)r*�childrrr�do_iter_parentszGenericTreeModel.do_iter_parentcCs|j|j|��dS)N)�on_ref_noder3)r*r
rrr�do_ref_node#szGenericTreeModel.do_ref_nodecCs|j|j|��dS)N)�
on_unref_noder3)r*r
rrr�
do_unref_node'szGenericTreeModel.do_unref_nodecCst�dS)zyOverridable.

        :Returns Gtk.TreeModelFlags:
            The flags for this model. See: Gtk.TreeModelFlags
        N)�NotImplementedError)r*rrrrE.szGenericTreeModel.on_get_flagscCst�dS)zZOverridable.

        :Returns:
            The number of columns for this model.
        N)rf)r*rrrrG6sz!GenericTreeModel.on_get_n_columnscCst�dS)zYOverridable.

        :Returns:
            The column type for the given index.
        N)rf)r*rJrrrrI>sz#GenericTreeModel.on_get_column_typecCst�dS)zcOverridable.

        :Returns:
            A python object (node) for the given TreePath.
        N)rf)r*rCrrrrLFszGenericTreeModel.on_get_itercCst�dS)z�Overridable.

        :Parameters:
            node : object
                Node at current level.

        :Returns:
            A python object (node) following the given node at the current level.
        N)rf)r*rDrrrrNNs
zGenericTreeModel.on_iter_nextcCst�dS)zSOverridable.

        :Returns:
            A TreePath for the given node.
        N)rf)r*rDrrrrPZszGenericTreeModel.on_get_pathcCst�dS)z�Overridable.

        :Parameters:
            node : object
            column : int
                Column index to get the value from.

        :Returns:
            The value of the column for the given node.N)rf)r*rDrSrrrrRbs
zGenericTreeModel.on_get_valuecCst�dS)z�Overridable.

        :Returns:
            The first child of parent or None if parent has no children.
            If parent is None, return the first node of the model.
        N)rf)r*rVrrrrUnsz!GenericTreeModel.on_iter_childrencCst�dS)zYOverridable.

        :Returns:
            True if the given node has children.
        N)rf)r*rDrrrrXwsz"GenericTreeModel.on_iter_has_childcCst�dS)z�Overridable.

        :Returns:
            The number of children for the given node. If node is None,
            return the number of top level nodes.
        N)rf)r*rDrrrrZsz#GenericTreeModel.on_iter_n_childrencCst�dS)ahOverridable.

        :Parameters:
            parent : object
            n : int
                Index of child within parent.

        :Returns:
            The child for the given parent index starting at 0. If parent None,
            return the top level node corresponding to "n".
            If "n" is larger then available nodes, return None.
        N)rf)r*rVr]rrrr\�s
z"GenericTreeModel.on_iter_nth_childcCst�dS)zjOverridable.

        :Returns:
            The parent node of child or None if child is a top level node.N)rf)r*r`rrrr_�szGenericTreeModel.on_iter_parentcCsdS)Nr)r*rDrrrrb�szGenericTreeModel.on_ref_nodecCsdS)Nr)r*rDrrrrd�szGenericTreeModel.on_unref_node)N)FN)FN)FN)FN)1rrr�__doc__rZProperty�boolr=r&r8r9r)r<r3r>r?rArBr!rFrHZTYPE_INVALIDrKrMrOrQrTrWrYr[r^rarcrerErGrIrLrNrPrRrUrXrZr\r_rbrd�
__classcell__rr)r+rr"FsR

					r")
rr:r0r
Z
gi.repositoryrrZ	Structurerrr!Z	TreeModelr"rrrr�<module>s

Zerion Mini Shell 1.0