ó §Zc@sžddlZddlZddlZddlZddlmZddlmZdejfd„ƒYZd„Z d„Z dejej fd „ƒ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_t classmethodR(((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„Z d „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( t collectionstdequetNonetpopleftt 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|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't row_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.(RLt on_get_iter(R0RN((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyt do_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(t on_get_pathR5R3RtTreePath(R0RRN((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyt do_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(t on_ref_nodeR5(R0R((sB/usr/lib64/python2.7/site-packages/pygtkcompat/generictreemodel.pyt do_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.pyts