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 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
|
<?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-gtktreemodelfilter">
<refnamediv>
<refname>gtk.TreeModelFilter</refname>
<refpurpose>a <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link>
which hides parts of an underlying tree (new in PyGTK 2.4)</refpurpose>
</refnamediv>
<refsect1>
<title>Synopsis</title>
<classsynopsis language="python">
<ooclass><classname>gtk.TreeModelFilter</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-gtktreedragsource">gtk.TreeDragSource</link></classname></ooclass>
<methodsynopsis language="python">
<methodname><link linkend="method-gtktreemodelfilter--set-visible-func">set_visible_func</link></methodname>
<methodparam><parameter role="keyword">func</parameter></methodparam>
<methodparam><parameter role="keyword">data</parameter><initializer>None</initializer></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtktreemodelfilter--set-modify-func">set_modify_func</link></methodname>
<methodparam><parameter role="keyword">types</parameter></methodparam>
<methodparam><parameter role="keyword">func</parameter></methodparam>
<methodparam><parameter role="keyword">data</parameter><initializer>None</initializer></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtktreemodelfilter--set-visible-column">set_visible_column</link></methodname>
<methodparam><parameter role="keyword">column</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtktreemodelfilter--get-model">get_model</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtktreemodelfilter--convert-child-iter-to-iter">convert_child_iter_to_iter</link></methodname>
<methodparam><parameter role="keyword">child_iter</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtktreemodelfilter--convert-iter-to-child-iter">convert_iter_to_child_iter</link></methodname>
<methodparam><parameter role="keyword">filter_iter</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtktreemodelfilter--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-gtktreemodelfilter--convert-path-to-child-path">convert_path_to_child_path</link></methodname>
<methodparam><parameter role="keyword">filter_path</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtktreemodelfilter--refilter">refilter</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtktreemodelfilter--clear-cache">clear_cache</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
</classsynopsis>
</refsect1>
<refsect1>
<title>Ancestry</title>
<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
+-- <link linkend="class-gtktreemodelfilter">gtk.TreeModelFilter</link> (implements <link linkend="class-gtktreemodel">gtk.TreeModel</link>, <link linkend="class-gtktreedragsource">gtk.TreeDragSource</link>)
</synopsis>
</refsect1>
<refsect1 id="properties-gtktreemodelfilter">
<title>gtk.TreeModelFilter 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>"child-model"</entry>
<entry>Read-Write-Construct Only</entry>
<entry>The <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link> for
the filtermodel to filter. Available in GTK+ 2.4 and above.</entry>
</row>
<row valign="top">
<entry>"virtual-root"</entry>
<entry>Read-Write-Construct Only</entry>
<entry>The virtual root (relative to the child model) for this
filtermodel. Available in GTK+ 2.4 and above.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</blockquote>
</refsect1>
<refsect1 id="signal-prototypes-gtktreemodelfilter">
<title>gtk.TreeModelFilter Signal Prototypes</title>
<para><link linkend="signal-prototypes-gobject">gobject.GObject Signal Prototypes</link></para>
<para><link linkend="signal-prototypes-gtktreemodel">gtk.TreeModel Signal Prototypes</link></para>
</refsect1>
<refsect1>
<title>Description</title>
<note>
<para>This object is available in PyGTK 2.4 and above.</para>
</note>
<para>A <link
linkend="class-gtktreemodelfilter"><classname>gtk.TreeModelFilter</classname></link>
is a tree model which wraps another tree model, and can do the following
things:</para>
<itemizedlist>
<listitem>
<simpara>Filter specific rows, based on data from a "visible
column", a column storing booleans indicating whether the row should be
filtered or not, or based on the return value of a "visible function", which
gets a <parameter>model</parameter>, <parameter>iter</parameter> and
<parameter>user_data</parameter> and returns a boolean indicating whether
the row should be filtered or not.</simpara>
</listitem>
<listitem>
<simpara>Modify the "appearance" of the model, using a modify
function. This is extremely powerful and allows for just changing some
values and also for creating a completely different synthetic model based on
the child model. For example, you can create a model with columns
synthesized from the data in the child model.</simpara>
</listitem>
<listitem>
<simpara>Set a different root node, also known as a "virtual
root". You can pass in a tree path indicating the root node for the filter
at construction time.</simpara>
</listitem>
</itemizedlist>
<para>A <link linkend="class-gtktreemodelfilter"><classname>gtk.TreeModelFilter</classname></link> is
created using the <link linkend="method-gtktreemodel--filter-new"><methodname>gtk.TreeModel.filter_new</methodname>()</link> method. For example:</para>
<programlisting>
liststore = gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING)
modelfilter = liststore.filter_new()
</programlisting>
<para>The <link
linkend="class-gtktreemodelfilter"><classname>gtk.TreeModelFilter</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>
<title>Methods</title>
<refsect2 id="method-gtktreemodelfilter--set-visible-func">
<title>gtk.TreeModelFilter.set_visible_func</title>
<programlisting><methodsynopsis language="python">
<methodname>set_visible_func</methodname>
<methodparam><parameter role="keyword">func</parameter></methodparam>
<methodparam><parameter role="keyword">data</parameter><initializer>None</initializer></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">func</parameter> :</term>
<listitem><simpara>a function called to determine the visibility
of a row</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">data</parameter> :</term>
<listitem><simpara>User data to pass to
<literal>func</literal></simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>set_visible_func</methodname>() method sets the
visible function used when filtering the rows of the treemodel filter to the
value of <parameter>func</parameter>. <parameter>data</parameter> is the
user data that is passed to func (see below). This method will fail if the
<link
linkend="method-gtktreemodelfilter--set-visible-column"><methodname>set_visible_column</methodname>()</link>
method has already been called. The visible function signature is:</para>
<programlisting>
def visible_func(model, iter, user_data):
</programlisting>
<para>where <parameter>model</parameter> is the child <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link>,
<parameter>iter</parameter> is a <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>
pointing at a row in model and <parameter>user_data</parameter> is the data
parameter. The function should return <literal>True</literal> if the row
should be visible.</para>
</refsect2>
<refsect2 id="method-gtktreemodelfilter--set-modify-func">
<title>gtk.TreeModelFilter.set_modify_func</title>
<programlisting><methodsynopsis language="python">
<methodname>set_modify_func</methodname>
<methodparam><parameter role="keyword">types</parameter></methodparam>
<methodparam><parameter role="keyword">func</parameter></methodparam>
<methodparam><parameter role="keyword">data</parameter><initializer>None</initializer></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">types</parameter> :</term>
<listitem><simpara>a sequence containing the column
types</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">func</parameter> :</term>
<listitem><simpara>a function that is called to provide the data
for a specific row and column</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">data</parameter> :</term>
<listitem><simpara>user data to pass to the modify function, or
<literal>None</literal>.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>set_modify_func</methodname>() method uses the
list of column types specified by <parameter>types</parameter> and the
function specified by <parameter>func</parameter> to provide a synthetic
model based on the child model of the <link
linkend="class-gtktreemodelfilter"><classname>gtk.TreeModelFilter</classname></link>. <parameter>data</parameter>
is passed to <parameter>func</parameter> when it is
called. <parameter>func</parameter> is called for each data access to return
the data which should be displayed at the location specified using the
parameters of the modify function.</para>
<para>The signature of func is:</para>
<programlisting>
def func(<parameter>model</parameter>, <parameter>iter</parameter>, <parameter>column</parameter>, <parameter>user_data</parameter>)
</programlisting>
<para>where <parameter>model</parameter> is the <link
linkend="class-gtktreemodelfilter"><classname>gtk.TreeModelFilter</classname></link>,
<parameter>iter</parameter> is a <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>
pointing at a row in <parameter>model</parameter>,
<parameter>column</parameter> is the column number to provide the value for
and <parameter>user_data</parameter> is
<parameter>data</parameter>. <parameter>func</parameter> should returns the
generated value for the specified location in
<parameter>model</parameter>.</para>
<note>
<para>This method must be called before the <link
linkend="class-gtktreemodelfilter"><classname>gtk.TreeModelFilter</classname></link>
is associated with a <link
linkend="class-gtktreeview"><classname>gtk.TreeView</classname></link> and
before either of the <link
linkend="method-gtktreemodel--get-n-columns"><methodname>gtk.TreeModel.get_n_columns</methodname>()</link>
or <link
linkend="method-gtktreemodel--get-column-type"><methodname>gtk.TreeModel.get_column_type</methodname>()</link>
methods are called. Also this method can only be called once - there is no
way to change the modify function once it is set.</para>
</note>
<para>Since <parameter>func</parameter> is called for every access to
a value in <parameter>model</parameter>, it will be slow for models with a
large number of rows and/or columns.</para>
</refsect2>
<refsect2 id="method-gtktreemodelfilter--set-visible-column">
<title>gtk.TreeModelFilter.set_visible_column</title>
<programlisting><methodsynopsis language="python">
<methodname>set_visible_column</methodname>
<methodparam><parameter role="keyword">column</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">column</parameter> :</term>
<listitem><simpara>the number of the column containing the visible
information.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>set_visible_column</methodname>() method sets
the visible column setting to the value of
<parameter>column</parameter>. The visible column setting contains the
number of the "child-model" column that is used to determine the visibility
of the model rows. The specified column should be a column of type
<literal>gobject.TYPE_BOOLEAN</literal>, where <literal>True</literal> means
that a row is visible, and <literal>False</literal>, not visible. This
method will fail if the <link
linkend="method-gtktreemodelfilter--set-visible-func"><methodname>set_visible_func</methodname>()</link>
method has already been called.</para>
</refsect2>
<refsect2 id="method-gtktreemodelfilter--get-model">
<title>gtk.TreeModelFilter.get_model</title>
<programlisting><methodsynopsis language="python">
<methodname>get_model</methodname>
<methodparam></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the child <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link></simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>get_model</methodname>() method returns the
child <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link> of
the treemodel filter</para>
</refsect2>
<refsect2 id="method-gtktreemodelfilter--convert-child-iter-to-iter">
<title>gtk.TreeModelFilter.convert_child_iter_to_iter</title>
<programlisting><methodsynopsis language="python">
<methodname>convert_child_iter_to_iter</methodname>
<methodparam><parameter role="keyword">child_iter</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter
role="keyword">child_iter</parameter> :</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> :</term>
<listitem><simpara>a <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>
pointing to a row in the treemodel filter.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>convert_child_iter_to_iter</methodname>() method
returns a <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>
pointing to the row in the treemodel filter that corresponds to the child
treemodel row pointed to by the <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>
specified by <parameter>child_iter</parameter>.</para>
</refsect2>
<refsect2 id="method-gtktreemodelfilter--convert-iter-to-child-iter">
<title>gtk.TreeModelFilter.convert_iter_to_child_iter</title>
<programlisting><methodsynopsis language="python">
<methodname>convert_iter_to_child_iter</methodname>
<methodparam><parameter role="keyword">filter_iter</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter
role="keyword">filter_iter</parameter> :</term>
<listitem><simpara>A valid <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>
pointing to a row in the treemodel filter.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>a <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>
pointing to a row in the child treemodel.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>convert_iter_to_child_iter</methodname>() method
a <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>
pointing to the row in the child treemodel that corresponds to the treemodel
filter row pointed to by the <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>
specified by <parameter>filter_iter</parameter>.</para>
</refsect2>
<refsect2 id="method-gtktreemodelfilter--convert-child-path-to-path">
<title>gtk.TreeModelFilter.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> :</term>
<listitem><simpara>a tree path in the child treemodel to
convert.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>a treemodel filter tree path, or
<literal>None</literal>.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>convert_child_path_to_path</methodname>() method
returns a treemodel filter tree path that corresponds to the child treemodel
tree path specified by <parameter>child_path</parameter>. If
<parameter>child_path</parameter> isn't a valid path on the child model,
<literal>None</literal> is returned.</para>
</refsect2>
<refsect2 id="method-gtktreemodelfilter--convert-path-to-child-path">
<title>gtk.TreeModelFilter.convert_path_to_child_path</title>
<programlisting><methodsynopsis language="python">
<methodname>convert_path_to_child_path</methodname>
<methodparam><parameter role="keyword">filter_path</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter
role="keyword">filter_path</parameter> :</term>
<listitem><simpara>a treemodel filter tree path to
convert.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>a child treemodel tree path, or
<literal>None</literal>.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>convert_path_to_child_path</methodname>() method
returns a child treemodel tree path that corresponds to the treemodel filter
tree path specified by <parameter>filter_path</parameter>. If
<parameter>filter_path</parameter> does not point to a row in the child
model, <literal>None</literal> is returned.</para>
</refsect2>
<refsect2 id="method-gtktreemodelfilter--refilter">
<title>gtk.TreeModelFilter.refilter</title>
<programlisting><methodsynopsis language="python">
<methodname>refilter</methodname>
<methodparam></methodparam>
</methodsynopsis></programlisting>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>refilter</methodname>() method emits the <link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link>
"<link linkend="signal-gtktreemodel--row-changed">row-changed</link>" signal
for each row in the child model, thereby causing the filter to re-evaluate
whether a row is visible or not.</para>
</refsect2>
<refsect2 id="method-gtktreemodelfilter--clear-cache">
<title>gtk.TreeModelFilter.clear_cache</title>
<programlisting><methodsynopsis language="python">
<methodname>clear_cache</methodname>
<methodparam></methodparam>
</methodsynopsis></programlisting>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>clear_cache</methodname>() method clears the
treemodel filter of any cached iterators that haven't been reffed with the
<link
linkend="method-gtktreemodel--ref-node"><methodname>gtk.TreeModel.ref_node()</methodname></link>. This
might be useful if the child model being filtered 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 iters will be invalid. This
method should almost never be called by an application.</para>
</refsect2>
</refsect1>
</refentry>
|