summaryrefslogtreecommitdiff
path: root/docs/reference/pygtk-gtktreemodelsort.xml
blob: df98191367748c08c5b6553290263e60f667d47b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

<refentry id="class-gtktreemodelsort">
  <refnamediv>
    <refname>gtk.TreeModelSort</refname>
    <refpurpose>a tree model that is a sorted version of a child <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link></refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>gtk.TreeModelSort</classname></ooclass>
      <ooclass><classname><link
linkend="class-gobject">gobject.GObject</link></classname></ooclass>
      <ooclass><classname><link
linkend="class-gtktreemodel">gtk.TreeModel</link></classname></ooclass>
      <ooclass><classname><link
linkend="class-gtktreesortable">gtk.TreeSortable</link></classname></ooclass>
      <constructorsynopsis language="python">
	<methodname><link
linkend="constructor-gtktreemodelsort">gtk.TreeModelSort</link></methodname>
	<methodparam><parameter
		       role="keyword">child_model</parameter></methodparam>
      </constructorsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gtktreemodelsort--get-model">get_model</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gtktreemodelsort--convert-child-path-to-path">convert_child_path_to_path</link></methodname>
	<methodparam><parameter
		       role="keyword">child_path</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gtktreemodelsort--convert-child-iter-to-iter">convert_child_iter_to_iter</link></methodname>
	<methodparam><parameter
		       role="keyword">sort_iter</parameter></methodparam>
	<methodparam><parameter
		       role="keyword">child_iter</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gtktreemodelsort--convert-path-to-child-path">convert_path_to_child_path</link></methodname>
	<methodparam><parameter
		       role="keyword">sorted_path</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gtktreemodelsort--convert-iter-to-child-iter">convert_iter_to_child_iter</link></methodname>
	<methodparam><parameter
		       role="keyword">child_iter</parameter></methodparam>
	<methodparam><parameter
		       role="keyword">sorted_iter</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gtktreemodelsort--reset-default-sort-func">reset_default_sort_func</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gtktreemodelsort--clear-cache">clear_cache</link></methodname>
	<methodparam></methodparam>  </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtktreemodelsort--iter-is-valid">iter_is_valid</link></methodname>
	<methodparam><parameter
		       role="keyword">iter</parameter></methodparam>
      </methodsynopsis>
    </classsynopsis>

  </refsect1>

  <refsect1>
    <title>Ancestry</title>

<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
  +-- <link linkend="class-gtktreemodelsort">gtk.TreeModelSort</link> (implements <link linkend="class-gtktreemodel">gtk.TreeModel</link>, <link linkend="class-gtktreesortable">gtk.TreeSortable</link>)
</synopsis>

  </refsect1>

  <refsect1 id="properties-gtktreemodelsort">
    <title>gtk.TreeModelSort Properties</title>

    <blockquote role="properties">
      <informaltable pgwide="1" frame="none">
	<tgroup cols="3">
	  <colspec column="1" colwidth="1in"/>
	  <colspec column="2" colwidth="1in"/>
	  <colspec column="3" colwidth="4in"/>
	  <tbody>

	    <row valign="top">
	      <entry>"model"</entry>
	      <entry>Read-Write-Construct</entry>
	      <entry>The child model for the <link
linkend="class-gtktreemodelsort"><classname>gtk.TreeModelSort</classname></link> 
to sort.</entry>
	    </row>

	  </tbody>
	</tgroup>
      </informaltable>
    </blockquote>

  </refsect1>

  <refsect1 id="signal-prototypes-gtktreemodelsort">
    <title>gtk.TreeModelSort Signal Prototypes</title>

    <para><link linkend="signal-prototypes-gobject">gobject.GObject Signal Prototypes</link></para>
    <para><link linkend="signal-prototypes-gtktreesortable">gtk.TreeSortable Signal Prototypes</link></para>
    <para><link linkend="signal-prototypes-gtktreemodel">gtk.TreeModel Signal Prototypes</link></para>
  </refsect1>

  <refsect1>
    <title>Description</title>

    <para>A <link
linkend="class-gtktreemodelsort"><classname>gtk.TreeModelSort</classname></link> 
is a sorted model of its child model. A <link
linkend="class-gtktreemodelsort"><classname>gtk.TreeModelSort</classname></link> 
implements the <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link>
interface and the <link
linkend="class-gtktreesortable"><classname>gtk.TreeSortable</classname></link> 
interface to manage the sort functions.</para>

    <para>The <link
linkend="class-gtktreemodelsort"><classname>gtk.TreeModelSort</classname></link>
objects support the Python mapping and iterator protocols. See the <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link>
Description and the <ulink
url="http://www.pygtk.org/pygtk2tutorial/sec-TreeModelInterface.html#sec-PythonProtocolSupport">PyGTK
tutorial</ulink> for more information.</para>

  </refsect1>

  <refsect1 id="constructor-gtktreemodelsort">
    <title>Constructor</title>

    <programlisting><constructorsynopsis language="python">
	<methodname>gtk.TreeModelSort</methodname>
	<methodparam><parameter
		       role="keyword">child_model</parameter></methodparam>
      </constructorsynopsis></programlisting>
    <variablelist>
      <varlistentry>
	<term><parameter
role="keyword">child_model</parameter>&nbsp;:</term>
	<listitem><simpara>a child <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link></simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	<listitem><simpara>A new <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link>.</simpara></listitem>
      </varlistentry>
    </variablelist>

    <para>Creates a new <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link>,
with <parameter>child_model</parameter> as the child model.</para>

  </refsect1>

  <refsect1>
    <title>Methods</title>

    <refsect2 id="method-gtktreemodelsort--get-model">
      <title>gtk.TreeModelSort.get_model</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_model</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>the "child model" being
sorted</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_model</methodname>() method returns the
model that the <link
linkend="class-gtktreemodelsort"><classname>gtk.TreeModelSort</classname></link> 
is sorting.</para>

    </refsect2>

    <refsect2 id="method-gtktreemodelsort--convert-child-path-to-path">
      <title>gtk.TreeModelSort.convert_child_path_to_path</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>convert_child_path_to_path</methodname>
	  <methodparam><parameter
			 role="keyword">child_path</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter
role="keyword">child_path</parameter>&nbsp;:</term>
	  <listitem><simpara>A child tree path to
convert</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>A new tree path in the treemodelsort, or
<literal>None</literal></simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>convert_child_path_to_path</methodname>() method
converts the path in the child model specified by
<parameter>child_path</parameter> to a path relative to the treemodelsort.
That is, <parameter>child_path</parameter> points to a path in the child
model.  The returned path will point to the same row in the sorted model.
If <parameter>child_path</parameter> isn't a valid path on the child model,
then <literal>None</literal> is returned.</para>

    </refsect2>

    <refsect2 id="method-gtktreemodelsort--convert-child-iter-to-iter">
      <title>gtk.TreeModelSort.convert_child_iter_to_iter</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>convert_child_iter_to_iter</methodname>
	  <methodparam><parameter
			 role="keyword">sort_iter</parameter></methodparam>
	  <methodparam><parameter
			 role="keyword">child_iter</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter
role="keyword">sort_iter</parameter>&nbsp;:</term>
	  <listitem><simpara><literal>None</literal> or a <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link> for
backward compatibility.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter
role="keyword">child_iter</parameter>&nbsp;:</term>
	  <listitem><simpara>A valid <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>
pointing to a row on the child model</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>A <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>
pointing to the same path in the sorted model.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>convert_child_iter_to_iter</methodname>() method
returns a <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link> that
points to the row in the treemodelsort that corresponds to the row pointed
to by <parameter>child_iter</parameter>. <parameter>sort_iter</parameter>
parameter should be <literal>None</literal> but can specify a <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link> for
backward compatibility.</para>

    </refsect2>

    <refsect2 id="method-gtktreemodelsort--convert-path-to-child-path">
      <title>gtk.TreeModelSort.convert_path_to_child_path</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>convert_path_to_child_path</methodname>
	  <methodparam><parameter
			 role="keyword">sorted_path</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter
role="keyword">sorted_path</parameter>&nbsp;:</term>
	  <listitem><simpara>a path in the sorted model</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a new path in the child model, or
<literal>None</literal></simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>convert_path_to_child_path</methodname>() method
returns a path in the child model that refers to the same row as the path in
the sorted model specified by <parameter>sorted_path</parameter>. That is,
<parameter>sorted_path</parameter> points to a location in treemodelsort and
the returned path will point to the same location in the child model. If
<parameter>sorted_path</parameter> does not point to a location in the child
model, <literal>None</literal> is returned.</para>

    </refsect2>

    <refsect2 id="method-gtktreemodelsort--convert-iter-to-child-iter">
      <title>gtk.TreeModelSort.convert_iter_to_child_iter</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>convert_iter_to_child_iter</methodname>
	  <methodparam><parameter
			 role="keyword">child_iter</parameter></methodparam>
	  <methodparam><parameter
			 role="keyword">sorted_iter</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter
role="keyword">child_iter</parameter>&nbsp;:</term>
	  <listitem><simpara><literal>None</literal> or a <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link> for
backward compatibility.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter
role="keyword">sorted_iter</parameter>&nbsp;:</term>
	  <listitem><simpara>A valid <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>
pointing to a row on
<parameter>tree_model_sort</parameter>.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>A <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link> that
points to a row in the child model</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>convert_iter_to_child_iter</methodname>() method
returns a <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link> that
points to the row in the child model that is the same row pointed to by
<parameter>sorted_iter</parameter> in the treemodelsort.
<parameter>child_iter</parameter> should be <literal>None</literal> but can
specify a <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link> for
backward compatibility.</para>

    </refsect2>

    <refsect2 id="method-gtktreemodelsort--reset-default-sort-func">
      <title>gtk.TreeModelSort.reset_default_sort_func</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>reset_default_sort_func</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>

      <para>The <methodname>reset_default_sort_func</methodname>() method
resets the default sort function to be in the 'unsorted' state.  That is, it
is in the same order as the child model. It will re-sort the model to be in
the same order as the child model only if the <link
linkend="class-gtktreemodelsort"><classname>gtk.TreeModelSort</classname></link> 
is in 'unsorted' state.</para>

    </refsect2>

    <refsect2 id="method-gtktreemodelsort--clear-cache">
      <title>gtk.TreeModelSort.clear_cache</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>clear_cache</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>

      <para>The <methodname>clear_cache</methodname>() method clears the
treemodelsort of any cached iterators that haven't been reffed with the
<link
linkend="method-gtktreemodel--ref-node"><methodname>ref_node</methodname>()</link>
method.  This might be useful if the child model being sorted is static (and
doesn't change often) and there has been a lot of unreffed access to nodes.
As a side effect of this function, all unreffed <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>
objects will be invalid.</para>

    </refsect2>

    <refsect2 id="method-gtktreemodelsort--iter-is-valid">
      <title>gtk.TreeModelSort.iter_is_valid</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>iter_is_valid</methodname>
	  <methodparam><parameter role="keyword">iter</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter>iter</parameter>&nbsp;:</term>
	  <listitem><simpara>A <link
	  linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara><literal>True</literal> if
	  <parameter>iter</parameter> is valid</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.2 and above.</para>
      </note>

      <para>The <methodname>iter_is_valid</methodname>() method checks if
the <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>
specified by <parameter>iter</parameter> is valid for the treemodel
sort.</para>

      <warning>
	<para>This method is slow. Only use it for debugging and/or testing
purposes.</para>
      </warning>

    </refsect2>

  </refsect1>

</refentry>