Your IP : 3.139.108.13


Current Path : /lib64/python2.7/site-packages/pygtkcompat/
Upload File :
Current File : //lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyc

�
RLZc@s�ddlZddlZddlZddlZddlmZddlmZdejfd��YZd�Z	d�Z
dejejfd	��YZdS(
i����N(tGObject(tGtkt
_CTreeItercBsMeZdejfdejfdejfdejfgZed��ZRS(tstampt	user_datat
user_data2t
user_data3cCs2tjt��}tj|�jt|�|�S(N(tsyst	getsizeoftobjecttctypestPOINTERtfrom_addresstid(tclstitertoffset((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyt	from_iter&s(t__name__t
__module__R
tc_inttc_void_pt_fields_tclassmethodR(((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyR s
cCs+tj|�}tj|jjtj�jS(N(RRR
tcasttcontentsRt	py_objecttvalue(Rtciter((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyt_get_user_data_as_pyobject,scs�fd�}|S(s]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��fd�}|S(Ncs2y�||�SWntjtj��nX�S(N(Rt
excepthooktexc_info(targstkargs(tdefault_returntfunc(sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytwrapped_func:s
((R#R$(R"(R#sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyt	decorator9s((R"R%((R"sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pythandle_exception1s
tGenericTreeModelcBsHeZdZejdededd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd,d�Zed�d��Zed�d��Zeej�d��Zeed,f�d��Zee�d��Zed,�d��Zed,�d��Zeed,f�d��Zee�d��Zed�d��Zeed,f�d��Z eed,f�d��Z!ed,�d��Z"ed,�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*�Z0d+�Z1RS(-sA 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.
    tdefaultttypetblurbs�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.cCs6tt|�j�d|_t�|_|j�dS(sFInitialize. Make sure to call this from derived classes if overridden.iN(tsuperR't__init__Rtdictt
_held_refstinvalidate_iters(tself((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyR,gs	ccs�tjdg�}xz|r�|j�}|dk	rD|j|�Vngt|j|��D]}|j||�^qZ}|jt	|��qWdS(sHDepth-first iteration of the entire TreeModel yielding the python nodes.N(
tcollectionstdequetNonetpopleftt
get_user_datatrangetiter_n_childrentiter_nth_childt
extendlefttreversed(R0tstacktittitchildren((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytiter_depth_firstrs	4cCsDd|_|jr@|j|jkr4|j|j=nd|_ndS(s?Clear user data and its reference from the iter and this model.iN(RRR.R3(R0R((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytinvalidate_iter|s
		cCs&tjdd�|_|jj�dS(s�
        This method invalidates all TreeIter objects associated with this custom tree model
        and frees their locally pooled references.
        i�i���N(trandomtrandintRR.tclear(R0((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyR/�scCs|j|jkS(sv
        :Returns:
            True if the gtk.TreeIter specified by iter is valid for the custom tree model.
        (R(R0R((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyt
iter_is_valid�scCs%|jr|j|jSt|�SdS(s�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(tleak_referencesR.RR(R0R((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyR5�s	cCsWt|�|_|dkr+|j|�n(|j|_|jrS||j|j<ndS(s�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(R
RR3R@RRER.(R0RR((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyt
set_user_data�s	cCs tj�}|j||�|S(sCreate 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.
        (RtTreeIterRF(R0RR((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytcreate_tree_iter�scCs3|dkrtdfS|j|�}t|fSdS(syInternal creation of a (bool, TreeIter) pair for returning directly
        back to the view interfacing with this model.N(R3tFalseRHtTrue(R0tdataR<((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyt_create_tree_iter�s
cCsBtt|�j|�t|�}||jkr>|j|=ndS(s�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'trow_deletedR
R.(R0tpathtnodetnode_id((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyRM�s
icCs
|j�S(sInternal method.(ton_get_flags(R0((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytdo_get_flags�scCs
|j�S(sInternal method.(ton_get_n_columns(R0((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytdo_get_n_columns�scCs
|j|�S(sInternal method.(ton_get_column_type(R0tindex((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytdo_get_column_type�scCs|j|j|��S(sInternal method.(RLton_get_iter(R0RN((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytdo_get_iter�scCsP|dkr|jd�}n|j|j|��}|j||�|dk	S(sInternal method.N(R3ton_iter_nextR5RF(R0Rt	next_data((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytdo_iter_next�s
cCs9|j|j|��}|dkr(dStj|�SdS(sInternal method.N(ton_get_pathR5R3RtTreePath(R0RRN((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytdo_get_path�scCs|j|j|�|�S(sInternal method.(ton_get_valueR5(R0Rtcolumn((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytdo_get_value�scCs1|r|j|�nd}|j|j|��S(sInternal method.N(R5R3RLton_iter_children(R0tparentRK((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytdo_iter_childrenscCs|j|j|��S(sInternal method.(ton_iter_has_childR5(R0Rd((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytdo_iter_has_child	scCs/|dkr|jd�S|j|j|��S(sInternal method.N(R3ton_iter_n_childrenR5(R0R((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytdo_iter_n_childrens
cCsI|dkr!|jd|�}n|j|j|�|�}|j|�S(sInternal method.N(R3ton_iter_nth_childR5RL(R0RdtnRK((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytdo_iter_nth_childscCs|j|j|j|���S(sInternal method.(RLton_iter_parentR5(R0tchild((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytdo_iter_parentscCs|j|j|��dS(N(ton_ref_nodeR5(R0R((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pytdo_ref_node#scCs|j|j|��dS(N(t
on_unref_nodeR5(R0R((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyt
do_unref_node'scCs
t�dS(syOverridable.

        :Returns Gtk.TreeModelFlags:
            The flags for this model. See: Gtk.TreeModelFlags
        N(tNotImplementedError(R0((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyRQ.scCs
t�dS(sZOverridable.

        :Returns:
            The number of columns for this model.
        N(Rt(R0((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyRS6scCs
t�dS(sYOverridable.

        :Returns:
            The column type for the given index.
        N(Rt(R0RV((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyRU>scCs
t�dS(scOverridable.

        :Returns:
            A python object (node) for the given TreePath.
        N(Rt(R0RN((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyRXFscCs
t�dS(s�Overridable.

        :Parameters:
            node : object
                Node at current level.

        :Returns:
            A python object (node) following the given node at the current level.
        N(Rt(R0RO((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyRZNs
cCs
t�dS(sSOverridable.

        :Returns:
            A TreePath for the given node.
        N(Rt(R0RO((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyR]ZscCs
t�dS(s�Overridable.

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

        :Returns:
            The value of the column for the given node.N(Rt(R0RORa((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyR`bs
cCs
t�dS(s�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(Rt(R0Rd((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyRcnscCs
t�dS(sYOverridable.

        :Returns:
            True if the given node has children.
        N(Rt(R0RO((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyRfwscCs
t�dS(s�Overridable.

        :Returns:
            The number of children for the given node. If node is None,
            return the number of top level nodes.
        N(Rt(R0RO((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyRhscCs
t�dS(shOverridable.

        :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(Rt(R0RdRk((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyRj�s
cCs
t�dS(sjOverridable.

        :Returns:
            The parent node of child or None if child is a top level node.N(Rt(R0Rn((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyRm�scCsdS(N((R0RO((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyRp�scCsdS(N((R0RO((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyRr�sN(2RRt__doc__RtPropertyRJtboolRER,R?R@R/RDR5RFRHRLR3RMR&RRRTtTYPE_INVALIDRWRIRYR\R_RbReRgRiRlRoRqRsRQRSRURXRZR]R`RcRfRhRjRmRpRr(((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyR'FsR			
						
																			(
RRAR1R
t
gi.repositoryRRt	StructureRRR&t	TreeModelR'(((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyt<module>s