%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/pygtkcompat/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/pygtkcompat/__pycache__/generictreemodel.cpython-312.pyc

�

��f/8���ddlZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	Gd�dej�Zej�dk(rd�Z
nd�Z
d	�ZGd
�deje	j�Zy)�N)�GObject)�Gtkc��eZdZdejfdej
fdej
fdej
fgZed��Zy)�
_CTreeIter�stamp�	user_data�
user_data2�
user_data3c��tjt��}tj|�jt
|�|z�S�N)�sys�	getsizeof�object�ctypes�POINTER�from_address�id)�cls�iter�offsets   �>/usr/lib/python3/dist-packages/pygtkcompat/generictreemodel.py�	from_iterz_CTreeIter.from_iter)s5�����v�x�(���~�~�c�"�/�/��4��6�0A�B�B�N)	�__name__�
__module__�__qualname__r�c_int�c_void_p�_fields_�classmethodr�rrrr#sO���&�,�,�'��f�o�o�.��v���/��v���/�1�H�
�C��Crr�PyPyc��td��)NzNot yet supported under PyPy��NotImplementedError)rs r�_get_user_data_as_pyobjectr&0s��!�"@�A�Arc��tj|�}tj|jj
tj�jSr)rrr�cast�contentsr�	py_object�value)r�citers  rr&r&3s9���$�$�T�*���{�{�5�>�>�3�3�V�5E�5E�F�L�L�Lrc����fd�}|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.
    c������fd�}|S)Nc�n��	�|i|��S#tjtj��Y�SxYwr)r
�
excepthook�exc_info)�args�kargs�default_return�funcs  ��r�wrapped_funcz9handle_exception.<locals>.decorator.<locals>.wrapped_funcAs9���
0��T�+�U�+�+��
0��������/�!�!�s��&4r!)r5r6r4s` �r�	decoratorz#handle_exception.<locals>.decorator@s���	"��rr!)r4r7s` r�handle_exceptionr88s���	��rc�x��eZdZdZej
ded��Z�fd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd/�fd�	Zed�d��Zed�d��Zeej*�d��Zed�d��Zed�d��Zed�d��Zed�d��Zed�d��Zed�d��Zed�d��Zed�d��Zed�d��Zed�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-�Z.d.�Z/�xZ0S)0�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�type�blurbc���tjdtj�tt
|��d|_t�|_	|j�y)zFInitialize. Make sure to call this from derived classes if overridden.zhpygtkcompat is deprecated, see https://gnome.pages.gitlab.gnome.org/pygobject for migration instructionsrN)�warnings�warn�gi�PyGIDeprecationWarning�superr:�__init__r�dict�
_held_refs�invalidate_iters)�self�	__class__s �rrDzGenericTreeModel.__init__nsY����
�
�A�CE�C\�C\�	]�
���.�0���
��&���	
���rc#�:K�tjdg�}|rz|j�}|�|j|���t	|j|��D�cgc]}|j
||���}}|jt|��|r�yyycc}w�w)zHDepth-first iteration of the entire TreeModel yielding the python nodes.N)	�collections�deque�popleft�
get_user_data�range�iter_n_children�iter_nth_child�
extendleft�reversed)rH�stack�it�i�childrens     r�iter_depth_firstz!GenericTreeModel.iter_depth_firstzs������!�!�4�&�)�������B��~��(�(��,�,�<A�$�BV�BV�WY�BZ�<[�\�q��+�+�B��2�\�H�\����X�h�/�0���]�s�AB�B�5B�Bc��d|_|jr7|j|jvr|j|j=d|_yy)z?Clear user data and its reference from the iter and this model.rN)rrrF�rHrs  r�invalidate_iterz GenericTreeModel.invalidate_iter�s<����
��>�>��~�~����0��O�O�D�N�N�3�!�D�N�rc�n�tjdd�|_|jj	�y)z�
        This method invalidates all TreeIter objects associated with this custom tree model
        and frees their locally pooled references.
        i�i���N)�random�randintrrF�clear�rHs rrGz!GenericTreeModel.invalidate_iters�s&��
�^�^�K��<��
������rc�4�|j|jk(S)zv
        :Returns:
            True if the gtk.TreeIter specified by iter is valid for the custom tree model.
        )rrZs  r�
iter_is_validzGenericTreeModel.iter_is_valid�s��
�z�z�T�Z�Z�'�'rc�b�|jr|j|jSt|�S)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.
        )�leak_referencesrFrr&rZs  rrNzGenericTreeModel.get_user_data�s+������?�?�4�>�>�2�2�-�d�3�3rc��t|�|_|�|j|�y|j|_|jr||j
|j<yy)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)rrr[rrdrF)rHrrs   r�
set_user_datazGenericTreeModel.set_user_data�sN���I������� � ��&����D�J��#�#�2;�������/�$rc�R�tj�}|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.
        )r�TreeIterrf)rHrrs   r�create_tree_iterz!GenericTreeModel.create_tree_iter�s$���|�|�~�����4��+��rc�2�|�y|j|�}d|fS)zyInternal creation of a (bool, TreeIter) pair for returning directly
        back to the view interfacing with this model.�FNT)ri)rH�datarUs   r�_create_tree_iterz"GenericTreeModel._create_tree_iter�s&���<� ��&�&�t�,�B��"�:�rNc�z��tt|�|�t|�}||jvr|j|=yy)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)rCr:�row_deletedrrF)rH�path�node�node_idrIs    �rrozGenericTreeModel.row_deleted�s;���	���1�$�7��T�(���d�o�o�%�����(�&rrc�"�|j�S��Internal method.)�on_get_flagsr`s r�do_get_flagszGenericTreeModel.do_get_flags�s��� � �"�"rc�"�|j�Srt)�on_get_n_columnsr`s r�do_get_n_columnsz!GenericTreeModel.do_get_n_columns�s���$�$�&�&rc�$�|j|�Srt)�on_get_column_type�rH�indexs  r�do_get_column_typez#GenericTreeModel.do_get_column_type�s���&�&�u�-�-rrkc�B�|j|j|��Srt)rm�on_get_iter�rHrps  r�do_get_iterzGenericTreeModel.do_get_iter�s ���%�%�d�&6�&6�t�&<�=�=rFc��|�|jd�}n |j|j|��}|j||�|duS�ruN)�on_iter_nextrNrf)rHr�	next_datas   r�do_iter_nextzGenericTreeModel.do_iter_next�sO���<��)�)�$�/�I��)�)�$�*<�*<�T�*B�C�I����4��+���$�$rc�r�|j|j|��}|�ytj|�Sr�)�on_get_pathrNr�TreePath)rHrrps   r�do_get_pathzGenericTreeModel.do_get_path�s6������ 2� 2�4� 8�9���<���<�<��%�%rc�D�|j|j|�|�Srt)�on_get_valuerN)rHr�columns   r�do_get_valuezGenericTreeModel.do_get_values"��� � ��!3�!3�D�!9�6�B�Brc�l�|r|j|�nd}|j|j|��Sr�)rNrm�on_iter_children)rH�parentrls   r�do_iter_childrenz!GenericTreeModel.do_iter_childrens4��.4�t�!�!�&�)����%�%�d�&;�&;�D�&A�B�Brc�B�|j|j|��Srt)�on_iter_has_childrN�rHr�s  r�do_iter_has_childz"GenericTreeModel.do_iter_has_childs ���%�%�d�&8�&8��&@�A�Arc�h�|�|jd�S|j|j|��Sr�)�on_iter_n_childrenrNrZs  r�do_iter_n_childrenz#GenericTreeModel.do_iter_n_childrens6���<��*�*�4�0�0��&�&�t�'9�'9�$�'?�@�@rc��|�|jd|�}n!|j|j|�|�}|j|�Sr�)�on_iter_nth_childrNrm)rHr��nrls    r�do_iter_nth_childz"GenericTreeModel.do_iter_nth_childsI���>��)�)�$��2�D��)�)�$�*<�*<�V�*D�a�H�D��%�%�d�+�+rc�`�|j|j|j|���Srt)rm�on_iter_parentrN�rH�childs  r�do_iter_parentzGenericTreeModel.do_iter_parent&s+���%�%�d�&9�&9�$�:L�:L�U�:S�&T�U�Urc�D�|j|j|��yr)�on_ref_noderNrZs  r�do_ref_nodezGenericTreeModel.do_ref_node+s������+�+�D�1�2rc�D�|j|j|��yr)�
on_unref_noderNrZs  r�
do_unref_nodezGenericTreeModel.do_unref_node/s�����4�-�-�d�3�4rc��t�)zyOverridable.

        :Returns Gtk.TreeModelFlags:
            The flags for this model. See: Gtk.TreeModelFlags
        r$r`s rrvzGenericTreeModel.on_get_flags6�
��"�!rc��t�)zZOverridable.

        :Returns:
            The number of columns for this model.
        r$r`s rryz!GenericTreeModel.on_get_n_columns>r�rc��t�)zYOverridable.

        :Returns:
            The column type for the given index.
        r$r}s  rr|z#GenericTreeModel.on_get_column_typeFr�rc��t�)zcOverridable.

        :Returns:
            A python object (node) for the given TreePath.
        r$r�s  rr�zGenericTreeModel.on_get_iterNr�rc��t�)z�Overridable.

        :Parameters:
            node : object
                Node at current level.

        :Returns:
            A python object (node) following the given node at the current level.
        r$�rHrqs  rr�zGenericTreeModel.on_iter_nextV�
��"�!rc��t�)zSOverridable.

        :Returns:
            A TreePath for the given node.
        r$r�s  rr�zGenericTreeModel.on_get_pathbr�rc��t�)z�Overridable.

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

        :Returns:
            The value of the column for the given node.r$)rHrqr�s   rr�zGenericTreeModel.on_get_valuejr�rc��t�)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.
        r$r�s  rr�z!GenericTreeModel.on_iter_childrenv�
��"�!rc��t�)zYOverridable.

        :Returns:
            True if the given node has children.
        r$r�s  rr�z"GenericTreeModel.on_iter_has_childr�rc��t�)z�Overridable.

        :Returns:
            The number of children for the given node. If node is None,
            return the number of top level nodes.
        r$r�s  rr�z#GenericTreeModel.on_iter_n_children�r�rc��t�)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.
        r$)rHr�r�s   rr�z"GenericTreeModel.on_iter_nth_child�s
��"�!rc��t�)zjOverridable.

        :Returns:
            The parent node of child or None if child is a top level node.r$r�s  rr�zGenericTreeModel.on_iter_parent�s
��
"�!rc��yrr!r�s  rr�zGenericTreeModel.on_ref_node����rc��yrr!r�s  rr�zGenericTreeModel.on_unref_node�r�rr)1rrr�__doc__r�Property�boolrdrDrXr[rGrbrNrfrirmror8rwrz�TYPE_INVALIDrr�r�r�r�r�r�r�r�r�r�r�rvryr|r�r�r�r�r�r�r�r�r�r�r��
__classcell__)rIs@rr:r:Ms
����0'�g�&�&�t�$�.i�j�O�
 �1�"� �(�	4�<� ��)�*�a��#��#��a��'��'��g�*�*�+�.�,�.��m�$�>�%�>��e��%��%��d��&��&��d��C��C��m�$�C�%�C�
�e��B��B��a��A��A��m�$�,�%�,��m�$�V�%�V��d��3��3��d��5��5�"�"�"�"�
"�"�
"�"�"�"�
"�"�
�
rr:)r
r]rKr�platformr?rA�
gi.repositoryrr�	Structurer�python_implementationr&r8�	TreeModelr:r!rr�<module>r�sv��,�
��
���
�!��	C��!�!�	C�"�8�!�!�#�v�-�B�M�
�*]
�w����
�
�]
r

Zerion Mini Shell 1.0