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
|
<?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-gtkfilefilter">
<refnamediv>
<refname>gtk.FileFilter</refname>
<refpurpose>a filter for selecting a file subset (new in PyGTK
2.4)</refpurpose>
</refnamediv>
<refsect1>
<title>Synopsis</title>
<classsynopsis language="python">
<ooclass><classname>gtk.FileFilter</classname></ooclass>
<ooclass><classname><link linkend="class-gtkobject">gtk.Object</link></classname></ooclass>
<constructorsynopsis language="python">
<methodname><link linkend="constructor-gtkfilefilter">gtk.FileFilter</link></methodname>
<methodparam></methodparam>
</constructorsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkfilefilter--set-name">set_name</link></methodname>
<methodparam><parameter role="keyword">name</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkfilefilter--get-name">get_name</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkfilefilter--add-mime-type">add_mime_type</link></methodname>
<methodparam><parameter role="keyword">mime_type</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkfilefilter--add-pattern">add_pattern</link></methodname>
<methodparam><parameter role="keyword">pattern</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkfilefilter--add-custom">add_custom</link></methodname>
<methodparam><parameter>needed</parameter></methodparam>
<methodparam><parameter>func</parameter></methodparam>
<methodparam><parameter>data</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkfilefilter--get-needed">get_needed</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkfilefilter--filter">filter</link></methodname>
<methodparam><parameter role="keyword">filter_info</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkfilefilter--add-pixbuf-formats">add_pixbuf_formats</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
</classsynopsis>
</refsect1>
<refsect1>
<title>Ancestry</title>
<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
+-- <link linkend="class-gtkobject">gtk.Object</link>
+-- <link linkend="class-gtkfilefilter">gtk.FileFilter</link>
</synopsis>
</refsect1>
<refsect1 id="properties-gtkfilefilter">
<title>gtk.FileFilter Properties</title>
<para><link linkend="properties-gtkobject">gtk.Object Properties</link></para>
</refsect1>
<refsect1 id="signal-prototypes-gtkfilefilter">
<title>gtk.FileFilter Signal Prototypes</title>
<para><link linkend="signal-prototypes-gobject">gobject.GObject Signal Prototypes</link></para>
<para><link linkend="signal-prototypes-gtkobject">gtk.Object Signal Prototypes</link></para>
</refsect1>
<refsect1>
<title>Description</title>
<note>
<para>This widget is available in PyGTK 2.4 and above.</para>
</note>
<para>A <link
linkend="class-gtkfilefilter"><classname>gtk.FileFilter</classname></link>
is an object that filters files based on a set of rules that it
contains. The categories of information that <link
linkend="class-gtkfilefilter"><classname>gtk.FileFilter</classname></link>
uses to accept or reject the file are given by the <xref
linkend="gtk-filefilter-flags-constants"
endterm="gtk-filefilter-flags-constants-title"></xref>:</para>
<variablelist>
<varlistentry>
<term><literal>gtk.FILE_FILTER_FILENAME</literal></term>
<listitem>
<simpara>The full path name of the file.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>gtk.FILE_FILTER_URI</literal></term>
<listitem>
<simpara>The URI of the file.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>gtk.FILE_FILTER_DISPLAY_NAME</literal></term>
<listitem>
<simpara>The simple name of the file as displayed in a file
chooser.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>gtk.FILE_FILTER_MIME_TYPE</literal></term>
<listitem>
<simpara>The MIME type of the file.</simpara>
</listitem>
</varlistentry>
</variablelist>
<para>The <link
linkend="method-gtkfilefilter--add-pattern"><methodname>add_pattern</methodname>()</link>
method adds a rule that only uses the display name
(<literal>gtk.FILE_FILTER_DISPLAY_NAME</literal>) for filtering. The
<link
linkend="method-gtkfilefilter--add-mime-type"><methodname>add_mime_type</methodname>()</link>
method adds a rule that only uses the mime type
(<literal>gtk.FILE_FILTER_MIME_TYPE</literal>) for filtering. To use the
file URI (<literal>gtk.FILE_FILTER_URI</literal>) or filename
(<literal>gtk.FILE_FILTER_FILENAME</literal>) you have to create a
custom filter rule using a callback function that is registered with the
<link
linkend="method-gtkfilefilter--add-custom"><methodname>add_custom</methodname>()</link>
method.</para>
<para>The pattern rule uses file globbing to match the file display
name:</para>
<itemizedlist>
<listitem>
<simpara>'*' matches any combination of characters e.g.. "a*c" matches
"abc", "a bridge tic", "aaabbbc" and so on.</simpara>
</listitem>
<listitem>
<simpara>'?' matches any single character e.g. "a?c" matches "abc",
aZc" and so on but not "abbc".</simpara>
</listitem>
<listitem>
<simpara>'[' and ']' enclose a set of characters that can be matched; ranges
of characters can be included by separating the start and end with a dash
(e.g. "a-z" include all the lowercase letters). e.g. "a[0-9]c" matches "a3c"
and "a9c" but not "a28c" or "abc".</simpara>
</listitem>
<listitem>
<simpara>'\' escapes the next character to allow "*", "?", "[" and "]"
to be matched literally.</simpara>
</listitem>
</itemizedlist>
<para>The MIME type requires an exact match (no pattern matching).</para>
</refsect1>
<refsect1 id="constructor-gtkfilefilter">
<title>Constructor</title>
<programlisting><constructorsynopsis language="python">
<methodname>gtk.FileFilter</methodname>
<methodparam></methodparam> </constructorsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>a new
<link linkend="class-gtkfilefilter"><classname>gtk.FileFilter</classname></link></simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This constructor is available in PyGTK 2.4 and above.</para>
</note>
<para>Creates a new <link
linkend="class-gtkfilefilter"><classname>gtk.FileFilter</classname></link>
with no rules added to it. Such a filter doesn't pass any files, so it's not
particularly useful until you add rules with the <link
linkend="method-gtkfilefilter--add-mime-type"><methodname>add_mime_type()</methodname></link>,
<link
linkend="method-gtkfilefilter--add-pattern"><methodname>add_pattern()</methodname></link>
or <link
linkend="method-gtkfilefilter--add-custom"><methodname>add_custom()</methodname></link>
methods. To create a filter that accepts any file, use:</para>
<programlisting>
filter = gtk.FileFilter()
filter.add_pattern("*")
</programlisting>
<para></para>
</refsect1>
<refsect1>
<title>Methods</title>
<refsect2 id="method-gtkfilefilter--set-name">
<title>gtk.FileFilter.set_name</title>
<programlisting><methodsynopsis language="python">
<methodname>set_name</methodname>
<methodparam><parameter role="keyword">name</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">name</parameter> :</term>
<listitem><simpara>the human-readable-name for the
filter.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>set_name</methodname>() method sets the
human-readable name of the filter to the string in
<parameter>name</parameter>. The string in <parameter>name</parameter> will
be displayed in the file chooser user interface if there is a selectable
list of filters.</para>
</refsect2>
<refsect2 id="method-gtkfilefilter--get-name">
<title>gtk.FileFilter.get_name</title>
<programlisting><methodsynopsis language="python">
<methodname>get_name</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>The human-readable name of the filter,
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>get_name</methodname>() method returns the
human-readable name for the filter or <literal>None</literal> if the name
has not been set. See the <link
linkend="method-gtkfilefilter--set-name"><methodname>set_name()</methodname></link>
method.</para>
</refsect2>
<refsect2 id="method-gtkfilefilter--add-mime-type">
<title>gtk.FileFilter.add_mime_type</title>
<programlisting><methodsynopsis language="python">
<methodname>add_mime_type</methodname>
<methodparam><parameter role="keyword">mime_type</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">mime_type</parameter> :</term>
<listitem><simpara>the name of a MIME type</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>add_mime_type</methodname>() method adds a rule
allowing the mime type specified by <parameter>mime_type</parameter> to be
matched. Sets the needs value to
<literal>gtk.FILE_FILTER_MIME_TYPE</literal> (see the <link
linkend="method-gtkfilefilter--get-needed"><methodname>get_needed</methodname>()</link>
method for more information).</para>
</refsect2>
<refsect2 id="method-gtkfilefilter--add-pattern">
<title>gtk.FileFilter.add_pattern</title>
<programlisting><methodsynopsis language="python">
<methodname>add_pattern</methodname>
<methodparam><parameter role="keyword">pattern</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">pattern</parameter> :</term>
<listitem><simpara>a shell style glob pattern</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>add_pattern</methodname>() method adds a rule
allowing the shell style glob pattern specified by
<parameter>pattern</parameter> to filter file names. Sets the needs value to
<literal>gtk.FILE_FILTER_DISPLAY_NAME</literal> (see the <link
linkend="method-gtkfilefilter--get-needed"><methodname>get_needed</methodname>()</link>
method for more information).</para>
<para>The pattern rule uses file globbing to match the file display
name:</para>
<itemizedlist>
<listitem>
<simpara>'*' matches any combination of characters e.g.. "a*c" matches
"abc", "a bridge tic", "aaabbbc" and so on.</simpara>
</listitem>
<listitem>
<simpara>'?' matches any single character e.g. "a?c" matches "abc",
aZc" and so on but not "abbc".</simpara>
</listitem>
<listitem>
<simpara>'[' and ']' enclose a set of characters that can be matched; ranges
of characters can be included by separating the start and end with a dash
(e.g. "a-z" include all the lowercase letters). e.g. "a[0-9]c" matches "a3c"
and "a9c" but not "a28c" or "abc".</simpara>
</listitem>
<listitem>
<simpara>'\' escapes the next character to allow "*", "?", "[" and "]"
to be matched literally.</simpara>
</listitem>
</itemizedlist>
</refsect2>
<refsect2 id="method-gtkfilefilter--add-custom">
<title>gtk.FileFilter.add_custom</title>
<programlisting><methodsynopsis language="python">
<methodname>add_custom</methodname>
<methodparam><parameter>needed</parameter></methodparam>
<methodparam><parameter>func</parameter></methodparam>
<methodparam><parameter>data</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter>needed</parameter> :</term>
<listitem><simpara>a bitfield of flags indicating the information
that the custom filter function needs.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter>func</parameter> :</term>
<listitem><simpara>a callback function; if the function returns
<literal>True</literal>, then the file will be displayed.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter>data</parameter> :</term>
<listitem><simpara>the data to pass to
<parameter>func</parameter></simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>add_custom</methodname>() method adds a rule to
a filter that allows files to be filtered based on a custom callback
function specified by <parameter>func</parameter>. The bitfield
<parameter>needed</parameter> provides information about what sorts of
information that the filter function needs; this allows GTK+ to avoid
retrieving expensive information when it isn't needed by the
filter. <parameter>needed</parameter> is a combination of:</para>
<variablelist>
<varlistentry>
<term><literal>gtk.FILE_FILTER_FILENAME</literal></term>
<listitem>
<simpara>The full path name of the file.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>gtk.FILE_FILTER_URI</literal></term>
<listitem>
<simpara>The URI of the file.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>gtk.FILE_FILTER_DISPLAY_NAME</literal></term>
<listitem>
<simpara>The simple name of the file as displayed in a file
chooser.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>gtk.FILE_FILTER_MIME_TYPE</literal></term>
<listitem>
<simpara>The MIME type of the file.</simpara>
</listitem>
</varlistentry>
</variablelist>
<para>The signature of <parameter>func</parameter> is:</para>
<programlisting>
def filefilterfunction(filter_info, data):
</programlisting>
<para>where <parameter>filter_info</parameter> is a 4-tuple where each
item is either a string or <literal>None</literal>. The strings correspond
to: the full pathname of the file, the URI of the file, the display name of
the file and the MIME type of the file. <parameter>data</parameter> is the
value passed in as the <parameter>data</parameter> parameter in the
<methodname>add_custom</methodname>() method. Using a custom filter function
is the only way to filter files based on file URIs or full file
pathnames.</para>
</refsect2>
<refsect2 id="method-gtkfilefilter--get-needed">
<title>gtk.FileFilter.get_needed</title>
<programlisting><methodsynopsis language="python">
<methodname>get_needed</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>a bitfield of flags indicating the needed fields
when calling <link
linkend="method-gtkfilefilter--filter"><methodname>filter()</methodname></link></simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>get_needed</methodname>() method returns the
information that is needed by the <link
linkend="class-gtkfilefilter"><classname>gtk.FileFilter</classname></link>
to filter the file info using the <link
linkend="method-gtkfilefilter--filter"><methodname>filter()</methodname></link></para>
<para>This method is not typically used by applications; it is
intended principally for use in the implementation of <link
linkend="class-gtkfilechooser"><classname>gtk.FileChooser</classname></link>.</para>
</refsect2>
<refsect2 id="method-gtkfilefilter--filter">
<title>gtk.FileFilter.filter</title>
<programlisting><methodsynopsis language="python">
<methodname>filter</methodname>
<methodparam><parameter role="keyword">filter_info</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">filter_info</parameter> :</term>
<listitem><simpara>a 4-tuple containing the information
about a file.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara><literal>True</literal> if the file should be
displayed</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.4 and above.</para>
</note>
<para>The <methodname>filter</methodname>() method tests whether a file should be displayed according to the file filter rules.
The 4-tuple <parameter>filter_info</parameter> should include
the fields returned from the <link linkend="method-gtkfilefilter--get-needed"><methodname>get_needed()</methodname></link> method:</para>
<itemizedlist>
<listitem>
<simpara>the full pathname of the file if needs includes
<literal>gtk.FILE_FILTER_FILENAME</literal></simpara>
</listitem>
<listitem>
<simpara>the URI of the file is needs includes
<literal>gtk.FILE_FILTER_URI</literal></simpara>
</listitem>
<listitem>
<simpara>the display name (without the path) if the file if needs
includes <literal>gtk.FILE_FILTER_DISPLAY_NAME</literal></simpara>
</listitem>
<listitem>
<simpara>the MIME type of the file if needs includes
<literal>gtk.FILE_FILTER_MIME_TYPE</literal></simpara>
</listitem>
</itemizedlist>
<para>This method will not typically be used by applications; it is
intended principally for use in the implementation of <link
linkend="class-gtkfilechooser"><classname>gtk.FileChooser</classname></link>.</para>
</refsect2>
<refsect2 id="method-gtkfilefilter--add-pixbuf-formats">
<title>gtk.FileFilter.add_pixbuf_formats</title>
<programlisting><methodsynopsis language="python">
<methodname>add_pixbuf_formats</methodname>
<methodparam></methodparam>
</methodsynopsis></programlisting>
<note>
<para>This method is available in PyGTK 2.6 and above.</para>
</note>
<para>The <methodname>add_pixbuf_formats</methodname>() method adds a
rule allowing image files in the formats supported by <link
linkend="class-gdkpixbuf"><classname>gtk.gdk.Pixbuf</classname></link>.</para>
</refsect2>
</refsect1>
</refentry>
|