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
|
<?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-gtkrecentfilter">
<refnamediv>
<refname>gtk.RecentFilter</refname>
<refpurpose>A filter for selecting a subset of recently used files
(new in PyGTK 2.10)</refpurpose>
</refnamediv>
<refsect1>
<title>Synopsis</title>
<classsynopsis language="python">
<ooclass><classname>gtk.RecentFilter</classname></ooclass>
<ooclass><classname><link linkend="class-gtkobject">gtk.Object</link></classname></ooclass>
<constructorsynopsis language="python">
<methodname><link linkend="constructor-gtkrecentfilter">gtk.RecentFilter</link></methodname>
<methodparam></methodparam>
</constructorsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkrecentfilter--set-name">set_name</link></methodname>
<methodparam><parameter role="keyword">name</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkrecentfilter--get-name">get_name</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkrecentfilter--add-mime-type">add_mime_type</link></methodname>
<methodparam><parameter role="keyword">mime_type</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkrecentfilter--add-pattern">add_pattern</link></methodname>
<methodparam><parameter role="keyword">pattern</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkrecentfilter--add-pixbuf-formats">add_pixbuf_formats</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkrecentfilter--add-application">add_application</link></methodname>
<methodparam><parameter role="keyword">application</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkrecentfilter--add-group">add_group</link></methodname>
<methodparam><parameter role="keyword">group</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkrecentfilter--add-age">add_age</link></methodname>
<methodparam><parameter role="keyword">days</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkrecentfilter--add-custom">add_custom</link></methodname>
<methodparam><parameter role="keyword">needed</parameter></methodparam>
<methodparam><parameter role="keyword">func</parameter></methodparam>
<methodparam><parameter role="keyword">data</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkrecentfilter--get-needed">get_needed</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-gtkrecentfilter--filter">filter</link></methodname>
<methodparam><parameter role="keyword">filter_info</parameter></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-gtkrecentfilter">gtk.RecentFilter</link>
</synopsis>
</refsect1>
<refsect1 id="properties-gtkrecentfilter">
<title>gtk.RecentFilter Properties</title>
<para><link linkend="properties-gtkobject">gtk.Object Properties</link></para>
</refsect1>
<refsect1 id="signal-prototypes-gtkrecentfilter">
<title>gtk.RecentFilter 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>
<para>A <link
linkend="class-gtkrecentfilter"><classname>gtk.RecentFilter</classname></link>
can be used to restrict the files being shown in a <link
linkend="class-gtkrecentchooser"><classname>gtk.RecentChooser</classname></link>.
Files can be filtered based on their name (with the <link
linkend="method-gtkrecentfilter--add-pattern"><methodname>gtk.RecentFilter.add_pattern()</methodname></link>
method), on their mime type (with the <link
linkend="method-gtkfilefilter--add-mime-type"><methodname>gtk.FileFilter.add_mime_type()</methodname></link>
method), on the application that has registered them (with the <link
linkend="method-gtkrecentfilter--add-application"><methodname>gtk.RecentFilter.add_application()</methodname></link>
method), or by a custom filter function (with the <link
linkend="method-gtkrecentfilter--add-custom"><methodname>gtk.RecentFilter.add_custom()</methodname></link>
method).</para>
<para>Filtering by mime type handles aliasing and subclassing of mime
types; e.g. a filter for "text/plain" also matches a file with mime type
"application/rtf", since "application/rtf" is a subclass of
"text/plain". Note that <link
linkend="class-gtkrecentfilter"><classname>gtk.RecentFilter</classname></link>
allows wildcards for the subtype of a mime type, so you can e.g. filter
for "image/*".</para>
<para>Normally, filters are used by adding them to a <link
linkend="class-gtkrecentchooser"><classname>gtk.RecentChooser</classname></link>,
see the <link
linkend="method-gtkrecentchooser--add-filter"><methodname>gtk.RecentChooser.add_filter()</methodname></link>
method, but it is also possible to manually use a filter on a file with
the <link
linkend="method-gtkrecentfilter--filter"><methodname>gtk.RecentFilter.filter()</methodname></link>
method.</para>
<para>Recently used files are supported since GTK+ 2.10.</para>
</refsect1>
<refsect1>
<title>Constructor</title>
<refsect2 id="constructor-gtkrecentfilter">
<title>gtk.RecentFilter</title>
<programlisting><constructorsynopsis language="python">
<methodname>gtk.RecentFilter</methodname>
<methodparam></methodparam>
</constructorsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>a new <link
linkend="class-gtkrecentfilter"><classname>gtk.RecentFilter</classname></link></simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This constructor is available in PyGTK 2.10 and above.</para>
</note>
<para>Creates a new <link
linkend="class-gtkrecentfilter"><classname>gtk.RecentFilter</classname></link>
with no rules added to it. Such a filter does not accept any recently
used resources, so is not particularly useful until you add rules with
the <link
linkend="method-gtkrecentfilter--add-pattern"><methodname>gtk.RecentFilter.add_pattern()</methodname></link>,
<link
linkend="method-gtkrecentfilter--add-mime-type"><methodname>gtk.RecentFilter.add_mime_type()</methodname></link>,
<link
linkend="method-gtkrecentfilter--add-application"><methodname>gtk.RecentFilter.add_application()</methodname></link>,
<link
linkend="method-gtkrecentfilter--add-age"><methodname>gtk.RecentFilter.add_age()</methodname></link>
methods. To create a filter that accepts any recently used resource,
use:</para>
<para><informalexample><programlisting>
filter = gtk.RecentFilter()
filter.add_pattern("*")
</programlisting></informalexample></para>
</refsect2>
</refsect1>
<refsect1>
<title>Methods</title>
<refsect2 id="method-gtkrecentfilter--set-name">
<title>gtk.RecentFilter.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</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.10 and above.</para>
</note>
<para>Sets the human-readable name of the filter; this is the string
that will be displayed in the recently used resources selector user
interface if there is a selectable list of filters.</para>
</refsect2>
<refsect2 id="method-gtkrecentfilter--get-name">
<title>gtk.RecentFilter.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 name of the filter, or
<literal>None</literal>.</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.10 and above.</para>
</note>
<para>Returns the human-readable name for the filter. See the <link
linkend="method-gtkrecentfilter--set-name"><methodname>gtk.RecentFilter.set_name()</methodname></link>
method.</para>
</refsect2>
<refsect2 id="method-gtkrecentfilter--add-mime-type">
<title>gtk.RecentFilter.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>a MIME type</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.10 and above.</para>
</note>
<para>Adds a rule that filters resources based on their registered
MIME type.</para>
</refsect2>
<refsect2 id="method-gtkrecentfilter--add-pattern">
<title>gtk.RecentFilter.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 file pattern</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.10 and above.</para>
</note>
<para>Adds a rule that filters resources based on a pattern matching
their display name.</para>
</refsect2>
<refsect2 id="method-gtkrecentfilter--add-pixbuf-formats">
<title>gtk.RecentFilter.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.10 and above.</para>
</note>
<para>Adds a rule that filters image files based on the formats
supported by <link
linkend="class-gdkpixbuf"><classname>gtk.gdk.Pixbuf</classname></link>.</para>
</refsect2>
<refsect2 id="method-gtkrecentfilter--add-application">
<title>gtk.RecentFilter.add_application</title>
<programlisting><methodsynopsis language="python">
<methodname>add_application</methodname>
<methodparam><parameter role="keyword">application</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">application</parameter> :</term>
<listitem><simpara>an application name</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.10 and above.</para>
</note>
<para>Adds a rule that filters resources based on the name of the
application that has registered them.</para>
</refsect2>
<refsect2 id="method-gtkrecentfilter--add-group">
<title>gtk.RecentFilter.add_group</title>
<programlisting><methodsynopsis language="python">
<methodname>add_group</methodname>
<methodparam><parameter role="keyword">group</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">group</parameter> :</term>
<listitem><simpara>a group name</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.10 and above.</para>
</note>
<para>Adds a rule that filters resources based on the name of the
group to which they belong</para>
</refsect2>
<refsect2 id="method-gtkrecentfilter--add-age">
<title>gtk.RecentFilter.add_age</title>
<programlisting><methodsynopsis language="python">
<methodname>add_age</methodname>
<methodparam><parameter role="keyword">days</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">days</parameter> :</term>
<listitem><simpara>number of days</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.10 and above.</para>
</note>
<para>Adds a rule that filters resources based on their age -
that is, the number of days elapsed since they were last
modified.</para>
</refsect2>
<refsect2 id="method-gtkrecentfilter--add-custom">
<title>gtk.RecentFilter.add_custom</title>
<programlisting><methodsynopsis language="python">
<methodname>add_custom</methodname>
<methodparam><parameter role="keyword">needed</parameter></methodparam>
<methodparam><parameter role="keyword">func</parameter></methodparam>
<methodparam><parameter role="keyword">data</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">needed</parameter> :</term>
<listitem><simpara>a combination of the <xref
linkend="gtk-recent-filter-flags-constants"
endterm="gtk-recent-filter-flags-constants-title"></xref>
indicating the information that the custom filter function
needs.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">func</parameter> :</term>
<listitem><simpara>callback function; if the function returns <literal>True</literal>, then
the file will be displayed.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">data</parameter> :</term>
<listitem><simpara>data to pass to <parameter>func</parameter></simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.10 and above.</para>
</note>
<para>Adds a rule to a filter that filters resources based on a custom
callback function. <parameter>needed</parameter> is a combination of
the <xref linkend="gtk-recent-filter-flags-constants"
endterm="gtk-recent-filter-flags-constants-title"></xref> which
provides information about what sorts of information that the filter
function needs; this allows PyGTK to avoid retrieving expensive
information when it isn't needed by the filter.</para>
<para>The signature of the filter function is:</para>
<programlisting>
def func(filterinfo, user_data):
</programlisting>
<para>where <parameter>filterinfo</parameter> is a dict containing the
info requested by <parameter>needed</parameter> as key-value pairs and
<parameter>user_data</parameter> is <parameter>data</parameter>. The
possible <parameter>filterinfo</parameter> keys are: "uri",
"display_name", "mime_type", "applications", "age" and
"groups".</para>
</refsect2>
<refsect2 id="method-gtkrecentfilter--get-needed">
<title>gtk.RecentFilter.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 combination of the <xref
linkend="gtk-recent-filter-flags-constants"
endterm="gtk-recent-filter-flags-constants-title"></xref>
indicating what fields are used for filtering when calling the
<link
linkend="method-gtkrecentfilter--filter"><methodname>gtk.RecentFilter.filter()</methodname></link>
method</simpara></listitem>
</varlistentry>
</variablelist>
<note>
<para>This method is available in PyGTK 2.10 and above.</para>
</note>
<para>Returns a combination of the <xref
linkend="gtk-recent-filter-flags-constants"
endterm="gtk-recent-filter-flags-constants-title"></xref> indicating
what fields are used for filtering.</para>
<para>This method will not typically be used by applications; it is
intended principally for use in the implementation of <link
linkend="class-gtkrecentchooser"><classname>gtk.RecentChooser</classname></link>.</para>
</refsect2>
<refsect2 id="method-gtkrecentfilter--filter">
<title>gtk.RecentFilter.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 filter info dict containing information about
a recently used resource</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.10 and above.</para>
</note>
<para>Returns <literal>True</literal> if a file should be displayed.
<parameter>filter_info</parameter> is a dict that should include the
key-value pairs as specified by the return flags from the <link
linkend="method-gtkrecentfilter--get-needed"><methodname>gtk.RecentFilter.get_needed()</methodname></link>
method. The possible <parameter>filter_info</parameter> keys are:
"uri", "display_name", "mime_type", "applications", "age" and
"groups".</para>
<para>This method will not typically be used by applications; it is
intended principally for use in the implementation of <link
linkend="class-gtkrecentchooser"><classname>gtk.RecentChooser</classname></link>.</para>
</refsect2>
</refsect1>
</refentry>
|