]> Pileus Git - ~andy/gtk/blob - gtk/gtkrecentchooser.c
Add a GtkPrintOperation::show-preview property
[~andy/gtk] / gtk / gtkrecentchooser.c
1 /* GTK - The GIMP Toolkit
2  * gtkrecentchooser.c - Abstract interface for recent file selectors GUIs
3  *
4  * Copyright (C) 2006, Emmanuele Bassi
5  * 
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 #include "config.h"
23
24 #include "gtkrecentchooser.h"
25 #include "gtkrecentchooserprivate.h"
26 #include "gtkrecentmanager.h"
27 #include "gtkintl.h"
28 #include "gtktypebuiltins.h"
29 #include "gtkprivate.h"
30 #include "gtkmarshalers.h"
31 #include "gtkalias.h"
32
33
34 enum
35 {
36   ITEM_ACTIVATED,
37   SELECTION_CHANGED,
38
39   LAST_SIGNAL
40 };
41
42 static void gtk_recent_chooser_class_init (gpointer g_iface);
43
44 static guint chooser_signals[LAST_SIGNAL] = { 0, };
45
46 GType
47 gtk_recent_chooser_get_type (void)
48 {
49   static GType chooser_type = 0;
50   
51   if (!chooser_type)
52     {
53       chooser_type = g_type_register_static_simple (G_TYPE_INTERFACE,
54                                                     I_("GtkRecentChooser"),
55                                                     sizeof (GtkRecentChooserIface),
56                                                     (GClassInitFunc) gtk_recent_chooser_class_init,
57                                                     0, NULL, 0);
58       
59       g_type_interface_add_prerequisite (chooser_type, GTK_TYPE_OBJECT);
60     }
61   
62   return chooser_type;
63 }
64
65 static void
66 gtk_recent_chooser_class_init (gpointer g_iface)
67 {
68   GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
69   
70   /**
71    * GtkRecentChooser::selection-changed
72    * @chooser: the object which received the signal
73    *
74    * This signal is emitted when there is a change in the set of
75    * selected recently used resources.  This can happen when a user
76    * modifies the selection with the mouse or the keyboard, or when
77    * explicitely calling functions to change the selection.
78    *
79    * Since: 2.10
80    */
81   chooser_signals[SELECTION_CHANGED] =
82     g_signal_new (I_("selection-changed"),
83                   iface_type,
84                   G_SIGNAL_RUN_LAST,
85                   G_STRUCT_OFFSET (GtkRecentChooserIface, selection_changed),
86                   NULL, NULL,
87                   g_cclosure_marshal_VOID__VOID,
88                   G_TYPE_NONE, 0);
89    
90   /**
91    * GtkRecentChooser::item-activated
92    * @chooser: the object which received the signal
93    *
94    * This signal is emitted when the user "activates" a recent item
95    * in the recent chooser.  This can happen by double-clicking on an item
96    * in the recently used resources list, or by pressing
97    * <keycap>Enter</keycap>.
98    *
99    * Since: 2.10
100    */
101   chooser_signals[ITEM_ACTIVATED] =
102     g_signal_new (I_("item-activated"),
103                   iface_type,
104                   G_SIGNAL_RUN_LAST,
105                   G_STRUCT_OFFSET (GtkRecentChooserIface, item_activated),
106                   NULL, NULL,
107                   g_cclosure_marshal_VOID__VOID,
108                   G_TYPE_NONE, 0);
109  
110   g_object_interface_install_property (g_iface,
111                                        g_param_spec_object ("recent-manager",
112                                                             P_("Recent Manager"),
113                                                             P_("The RecentManager object to use"),
114                                                             GTK_TYPE_RECENT_MANAGER,
115                                                             G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
116   g_object_interface_install_property (g_iface,
117                                        g_param_spec_boolean ("show-private",
118                                                              P_("Show Private"),
119                                                              P_("Whether the private items should be displayed"),
120                                                              FALSE,
121                                                              G_PARAM_READWRITE));
122   g_object_interface_install_property (g_iface,
123                                        g_param_spec_boolean ("show-tips",
124                                                              P_("Show Tooltips"),
125                                                              P_("Whether there should be a tooltip on the item"),
126                                                              FALSE,
127                                                              G_PARAM_READWRITE));
128   g_object_interface_install_property (g_iface,
129                                        g_param_spec_boolean ("show-icons",
130                                                              P_("Show Icons"),
131                                                              P_("Whether there should be an icon near the item"),
132                                                              TRUE,
133                                                              G_PARAM_READWRITE));
134   g_object_interface_install_property (g_iface,
135                                        g_param_spec_boolean ("show-not-found",
136                                                              P_("Show Not Found"),
137                                                              P_("Whether the items pointing to unavailable resources should be displayed"),
138                                                              FALSE,
139                                                              G_PARAM_READWRITE));
140   g_object_interface_install_property (g_iface,
141                                        g_param_spec_boolean ("select-multiple",
142                                                              P_("Select Multiple"),
143                                                              P_("Whether to allow multiple items to be selected"),
144                                                              FALSE,
145                                                              G_PARAM_READWRITE));
146   g_object_interface_install_property (g_iface,
147                                        g_param_spec_boolean ("local-only",
148                                                              P_("Local only"),
149                                                              P_("Whether the selected resource(s) should be limited to local file: URIs"),
150                                                              TRUE,
151                                                              G_PARAM_READWRITE));
152   g_object_interface_install_property (g_iface,
153                                        g_param_spec_int ("limit",
154                                                          P_("Limit"),
155                                                          P_("The maximum number of items to be displayed"),
156                                                          -1,
157                                                          G_MAXINT,
158                                                          -1,
159                                                          G_PARAM_READWRITE));
160   g_object_interface_install_property (g_iface,
161                                        g_param_spec_enum ("sort-type",
162                                                           P_("Sort Type"),
163                                                           P_("The sorting order of the items displayed"),
164                                                           GTK_TYPE_RECENT_SORT_TYPE,
165                                                           GTK_RECENT_SORT_NONE,
166                                                           G_PARAM_READWRITE));
167   g_object_interface_install_property (g_iface,
168                                        g_param_spec_object ("filter",
169                                                             P_("Filter"),
170                                                             P_("The current filter for selecting which resources are displayed"),
171                                                             GTK_TYPE_RECENT_FILTER,
172                                                             G_PARAM_READWRITE));
173 }
174
175 GQuark
176 gtk_recent_chooser_error_quark (void)
177 {
178   return g_quark_from_static_string ("gtk-recent-chooser-error-quark");
179 }
180
181 /**
182  * _gtk_recent_chooser_get_recent_manager:
183  * @chooser: a #GtkRecentChooser
184  *
185  * Gets the #GtkRecentManager used by @chooser.
186  *
187  * Return value: the recent manager for @chooser.
188  *
189  * Since: 2.10
190  */
191 GtkRecentManager *
192 _gtk_recent_chooser_get_recent_manager (GtkRecentChooser *chooser)
193 {
194   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
195   
196   return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_recent_manager (chooser);
197 }
198
199 /**
200  * gtk_recent_chooser_set_show_private:
201  * @chooser: a #GtkRecentChooser
202  * @show_private: %TRUE to show private items, %FALSE otherwise
203  *
204  * Whether to show recently used resources marked registered as private.
205  *
206  * Since: 2.10
207  */
208 void
209 gtk_recent_chooser_set_show_private (GtkRecentChooser *chooser,
210                                      gboolean          show_private)
211 {
212   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
213   
214   g_object_set (chooser, "show-private", show_private, NULL);
215 }
216
217 /**
218  * gtk_recent_chooser_get_show_private:
219  * @chooser: a #GtkRecentChooser
220  *
221  * Returns whether @chooser should display recently used resources
222  * registered as private.
223  *
224  * Return value: %TRUE if the recent chooser should show private items,
225  *   %FALSE otherwise.
226  *
227  * Since: 2.10
228  */
229 gboolean
230 gtk_recent_chooser_get_show_private (GtkRecentChooser *chooser)
231 {
232   gboolean show_private;
233   
234   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
235   
236   g_object_get (chooser, "show-private", &show_private, NULL);
237   
238   return show_private;
239 }
240
241 /**
242  * gtk_recent_chooser_set_show_not_found:
243  * @chooser: a #GtkRecentChooser
244  * @show_not_found: whether to show the local items we didn't find
245  *
246  * Sets whether @chooser should display the recently used resources that
247  * it didn't find.  This only applies to local resources.
248  *
249  * Since: 2.10
250  */
251 void
252 gtk_recent_chooser_set_show_not_found (GtkRecentChooser *chooser,
253                                        gboolean          show_not_found)
254 {
255   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
256   
257   g_object_set (chooser, "show-not-found", show_not_found, NULL);
258 }
259
260 /**
261  * gtk_recent_chooser_get_show_not_found:
262  * @chooser: a #GtkRecentChooser
263  *
264  * Retrieves whether @chooser should show the recently used resources that
265  * were not found.
266  *
267  * Return value: %TRUE if the resources not found should be displayed, and
268  *   %FALSE otheriwse.
269  *
270  * Since: 2.10
271  */
272 gboolean
273 gtk_recent_chooser_get_show_not_found (GtkRecentChooser *chooser)
274 {
275   gboolean show_not_found;
276   
277   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
278   
279   g_object_get (chooser, "show-not-found", &show_not_found, NULL);
280   
281   return show_not_found;
282 }
283
284 /**
285  * gtk_recent_chooser_set_show_icons:
286  * @chooser: a #GtkRecentChooser
287  * @show_icons: whether to show an icon near the resource
288  *
289  * Sets whether @chooser should show an icon near the resource when
290  * displaying it.
291  *
292  * Since: 2.10
293  */
294 void
295 gtk_recent_chooser_set_show_icons (GtkRecentChooser *chooser,
296                                    gboolean          show_icons)
297 {
298   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
299   
300   g_object_set (chooser, "show-icons", show_icons, NULL);
301 }
302
303 /**
304  * gtk_recent_chooser_get_show_icons:
305  * @chooser: a #GtkRecentChooser
306  *
307  * Retrieves whether @chooser should show an icon near the resource.
308  *
309  * Return value: %TRUE if the icons should be displayed, %FALSE otherwise.
310  *
311  * Since: 2.10
312  */
313 gboolean
314 gtk_recent_chooser_get_show_icons (GtkRecentChooser *chooser)
315 {
316   gboolean show_icons;
317   
318   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
319   
320   g_object_get (chooser, "show-icons", &show_icons, NULL);
321   
322   return show_icons;
323 }
324
325 /**
326  * gtk_recent_chooser_set_select_multiple:
327  * @chooser: a #GtkRecentChooser
328  * @select_multiple: %TRUE if @chooser can select more than one item
329  *
330  * Sets whether @chooser can select multiple items.
331  *
332  * Since: 2.10
333  */
334 void
335 gtk_recent_chooser_set_select_multiple (GtkRecentChooser *chooser,
336                                         gboolean          select_multiple)
337 {
338   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
339   
340   g_object_set (chooser, "select-multiple", select_multiple, NULL);
341 }
342
343 /**
344  * gtk_recent_chooser_get_select_multiple:
345  * @chooser: a #GtkRecentChooser
346  *
347  * Gets whether @chooser can select multiple items.
348  *
349  * Return value: %TRUE if @chooser can select more than one item.
350  *
351  * Since: 2.10
352  */
353 gboolean
354 gtk_recent_chooser_get_select_multiple (GtkRecentChooser *chooser)
355 {
356   gboolean select_multiple;
357   
358   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
359   
360   g_object_get (chooser, "select-multiple", &select_multiple, NULL);
361   
362   return select_multiple;
363 }
364
365 /**
366  * gtk_recent_chooser_set_local_only:
367  * @chooser: a #GtkRecentChooser
368  * @local_only: %TRUE if only local files can be shown
369  * 
370  * Sets whether only local resources, that is resources using the file:// URI
371  * scheme, should be shown in the recently used resources selector.  If
372  * @local_only is %TRUE (the default) then the shown resources are guaranteed
373  * to be accessible through the operating system native file system.
374  *
375  * Since: 2.10
376  */
377 void
378 gtk_recent_chooser_set_local_only (GtkRecentChooser *chooser,
379                                    gboolean          local_only)
380 {
381   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
382
383   g_object_set (chooser, "local-only", local_only, NULL);
384 }
385
386 /**
387  * gtk_recent_chooser_get_local_only:
388  * @chooser: a #GtkRecentChooser
389  *
390  * Gets whether only local resources should be shown in the recently used
391  * resources selector.  See gtk_recent_chooser_set_local_only()
392  *
393  * Return value: %TRUE if only local resources should be shown.
394  *
395  * Since: 2.10
396  */
397 gboolean
398 gtk_recent_chooser_get_local_only (GtkRecentChooser *chooser)
399 {
400   gboolean local_only;
401
402   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
403
404   g_object_get (chooser, "local-only", &local_only, NULL);
405
406   return local_only;
407 }
408
409 /**
410  * gtk_recent_chooser_set_limit:
411  * @chooser: a #GtkRecentChooser
412  * @limit: a positive integer, or -1 for all items
413  *
414  * Sets the number of items that should be returned by
415  * gtk_recent_chooser_get_items() and gtk_recent_chooser_get_uris().
416  *
417  * Since: 2.10
418  */
419 void
420 gtk_recent_chooser_set_limit (GtkRecentChooser *chooser,
421                               gint              limit)
422 {
423   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
424   
425   g_object_set (chooser, "limit", limit, NULL);
426 }
427
428 /**
429  * gtk_recent_chooser_get_limit:
430  * @chooser: a #GtkRecentChooser
431  *
432  * Gets the number of items returned by gtk_recent_chooser_get_items()
433  * and gtk_recent_chooser_get_uris().
434  *
435  * Return value: A positive integer, or -1 meaning that all items are
436  *   returned.
437  *
438  * Since: 2.10
439  */
440 gint
441 gtk_recent_chooser_get_limit (GtkRecentChooser *chooser)
442 {
443   gint limit;
444   
445   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), 10);
446   
447   g_object_get (chooser, "limit", &limit, NULL);
448   
449   return limit;
450 }
451
452 /**
453  * gtk_recent_chooser_set_show_tips:
454  * @chooser: a #GtkRecentChooser
455  * @show_tips: %TRUE if tooltips should be shown
456  *
457  * Sets whether to show a tooltips on the widget.
458  *
459  * Since: 2.10
460  */
461 void
462 gtk_recent_chooser_set_show_tips (GtkRecentChooser *chooser,
463                                   gboolean          show_tips)
464 {
465   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
466   
467   g_object_set (chooser, "show-tips", show_tips, NULL);
468 }
469
470 /**
471  * gtk_recent_chooser_get_show_tips:
472  * @chooser: a #GtkRecentChooser
473  *
474  * Gets whether @chooser should display tooltips.
475  *
476  * Return value: %TRUE if the recent chooser should show tooltips,
477  *   %FALSE otherwise.
478  *
479  * Since: 2.10
480  */
481 gboolean
482 gtk_recent_chooser_get_show_tips (GtkRecentChooser *chooser)
483 {
484   gboolean show_tips;
485   
486   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
487   
488   g_object_get (chooser, "show-tips", &show_tips, NULL);
489   
490   return show_tips;
491 }
492
493 /**
494  * gtk_recent_chooser_set_show_numbers:
495  * @chooser: a #GtkRecentChooser
496  * @show_numbers: %TRUE to show numbers, %FALSE otherwise
497  *
498  * Whether to show recently used resources prepended by a unique number.
499  *
500  * Since: 2.10
501  */
502 void
503 gtk_recent_chooser_set_show_numbers (GtkRecentChooser *chooser,
504                                      gboolean          show_numbers)
505 {
506   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
507   
508   g_object_set (chooser, "show-numbers", show_numbers, NULL);
509 }
510
511 /**
512  * gtk_recent_chooser_get_show_numbers:
513  * @chooser: a #GtkRecentChooser
514  *
515  * Returns whether @chooser should display recently used resources
516  * prepended by a unique number.
517  *
518  * Return value: %TRUE if the recent chooser should show display numbers,
519  *   %FALSE otherwise.
520  *
521  * Since: 2.10
522  */
523 gboolean
524 gtk_recent_chooser_get_show_numbers (GtkRecentChooser *chooser)
525 {
526   gboolean show_numbers;
527   
528   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
529   
530   g_object_get (chooser, "show-numbers", &show_numbers, NULL);
531   
532   return show_numbers;
533 }
534
535
536 /**
537  * gtk_recent_chooser_set_sort_type:
538  * @chooser: a #GtkRecentChooser
539  * @sort_type: sort order that the chooser should use
540  *
541  * Changes the sorting order of the recently used resources list displayed by
542  * @chooser.
543  *
544  * Since: 2.10
545  */
546 void
547 gtk_recent_chooser_set_sort_type (GtkRecentChooser  *chooser,
548                                   GtkRecentSortType  sort_type)
549 {  
550   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
551   
552   g_object_set (chooser, "sort-type", sort_type, NULL);
553 }
554
555 /**
556  * gtk_recent_chooser_get_sort_type:
557  * @chooser: a #GtkRecentChooser
558  *
559  * Gets the value set by gtk_recent_chooser_set_sort_type().
560  *
561  * Return value: the sorting order of the @chooser.
562  *
563  * Since: 2.10
564  */
565 GtkRecentSortType
566 gtk_recent_chooser_get_sort_type (GtkRecentChooser *chooser)
567 {
568   GtkRecentSortType sort_type;
569   
570   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), GTK_RECENT_SORT_NONE);
571   
572   g_object_get (chooser, "sort-type", &sort_type, NULL);
573
574   return sort_type;
575 }
576
577 /**
578  * gtk_recent_chooser_set_sort_func:
579  * @chooser: a #GtkRecentChooser
580  * @sort_func: the comparison function
581  * @sort_data: user data to pass to @sort_func, or %NULL
582  * @data_destroy: destroy notifier for @sort_data, or %NULL
583  *
584  * Sets the comparison function used when sorting to be @sort_func.  If
585  * the @chooser has the sort type set to #GTK_RECENT_SORT_CUSTOM then
586  * the chooser will sort using this function.
587  *
588  * To the comparison function will be passed two #GtkRecentInfo structs and
589  * @sort_data;  @sort_func should return a positive integer if the first
590  * item comes before the second, zero if the two items are equal and
591  * a negative integer if the first item comes after the second.
592  *
593  * Since: 2.10
594  */
595 void
596 gtk_recent_chooser_set_sort_func  (GtkRecentChooser  *chooser,
597                                    GtkRecentSortFunc  sort_func,
598                                    gpointer           sort_data,
599                                    GDestroyNotify     data_destroy)
600 {
601   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
602   
603   GTK_RECENT_CHOOSER_GET_IFACE (chooser)->set_sort_func (chooser,
604                                                          sort_func,
605                                                          sort_data,
606                                                          data_destroy);
607 }
608
609 /**
610  * gtk_recent_chooser_set_current_uri:
611  * @chooser: a #GtkRecentChooser
612  * @uri: a URI
613  * @error: return location for a #GError, or %NULL
614  *
615  * Sets @uri as the current URI for @chooser.
616  *
617  * Return value: %TRUE if the URI was found.
618  *
619  * Since: 2.10
620  */
621 gboolean
622 gtk_recent_chooser_set_current_uri (GtkRecentChooser  *chooser,
623                                     const gchar       *uri,
624                                     GError           **error)
625 {
626   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
627   
628   return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->set_current_uri (chooser, uri, error);
629 }
630
631 /**
632  * gtk_recent_chooser_get_current_uri:
633  * @chooser: a #GtkRecentChooser
634  *
635  * Gets the URI currently selected by @chooser.
636  *
637  * Return value: a newly allocated string holding a URI.
638  *
639  * Since: 2.10
640  */
641 gchar *
642 gtk_recent_chooser_get_current_uri (GtkRecentChooser *chooser)
643 {
644   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
645   
646   return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_current_uri (chooser);
647 }
648
649 /**
650  * gtk_recent_chooser_get_current_item:
651  * @chooser: a #GtkRecentChooser
652  * 
653  * Gets the #GtkRecentInfo currently selected by @chooser.
654  *
655  * Return value: a #GtkRecentInfo.  Use gtk_recent_info_unref() when
656  *   when you have finished using it.
657  *
658  * Since: 2.10
659  */
660 GtkRecentInfo *
661 gtk_recent_chooser_get_current_item (GtkRecentChooser *chooser)
662 {
663   GtkRecentManager *manager;
664   GtkRecentInfo *retval;
665   gchar *uri;
666   
667   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
668   
669   uri = gtk_recent_chooser_get_current_uri (chooser);
670   if (!uri)
671     return NULL;
672   
673   manager = _gtk_recent_chooser_get_recent_manager (chooser);
674   retval = gtk_recent_manager_lookup_item (manager, uri, NULL);
675   g_free (uri);
676   
677   return retval;
678 }
679
680 /**
681  * gtk_recent_chooser_select_uri:
682  * @chooser: a #GtkRecentChooser
683  * @uri: a URI
684  * @error: return location for a #GError, or %NULL
685  *
686  * Selects @uri inside @chooser.
687  *
688  * Return value: %TRUE if @uri was found.
689  *
690  * Since: 2.10
691  */
692 gboolean
693 gtk_recent_chooser_select_uri (GtkRecentChooser  *chooser,
694                                const gchar       *uri,
695                                GError           **error)
696 {
697   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
698   
699   return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->select_uri (chooser, uri, error);
700 }
701
702 /**
703  * gtk_recent_chooser_unselect_uri:
704  * @chooser: a #GtkRecentChooser
705  * @uri: a URI
706  *
707  * Unselects @uri inside @chooser.
708  *
709  * Since: 2.10
710  */
711 void
712 gtk_recent_chooser_unselect_uri (GtkRecentChooser *chooser,
713                                  const gchar      *uri)
714 {
715   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
716   
717   GTK_RECENT_CHOOSER_GET_IFACE (chooser)->unselect_uri (chooser, uri);
718 }
719
720 /**
721  * gtk_recent_chooser_select_all:
722  * @chooser: a #GtkRecentChooser
723  *
724  * Selects all the items inside @chooser, if the @chooser supports
725  * multiple selection.
726  *
727  * Since: 2.10
728  */
729 void
730 gtk_recent_chooser_select_all (GtkRecentChooser *chooser)
731 {
732   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
733   
734   GTK_RECENT_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
735 }
736
737 /**
738  * gtk_recent_chooser_unselect_all:
739  * @chooser: a #GtkRecentChooser
740  *
741  * Unselects all the items inside @chooser.
742  * 
743  * Since: 2.10
744  */
745 void
746 gtk_recent_chooser_unselect_all (GtkRecentChooser *chooser)
747 {
748   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
749   
750   GTK_RECENT_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
751 }
752
753 /**
754  * gtk_recent_chooser_get_items:
755  * @chooser: a #GtkRecentChooser
756  *
757  * Gets the list of recently used resources in form of #GtkRecentInfo objects.
758  *
759  * The return value of this function is affected by the "sort-type" and
760  * "limit" properties of @chooser.
761  *
762  * Return value: A newly allocated list of #GtkRecentInfo objects.  You should
763  *   use gtk_recent_info_unref() on every item of the list, and then free
764  *   the list itself using g_list_free().
765  *
766  * Since: 2.10
767  */
768 GList *
769 gtk_recent_chooser_get_items (GtkRecentChooser *chooser)
770 {
771   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
772   
773   return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_items (chooser);
774 }
775
776 /**
777  * gtk_recent_chooser_get_uris:
778  * @chooser: a #GtkRecentChooser
779  * @length: return location for a the length of the URI list, or %NULL
780  *
781  * Gets the URI of the recently used resources.
782  *
783  * The return value of this function is affected by the "sort-type" and "limit"
784  * properties of @chooser.
785  *
786  * Since the returned array is %NULL terminated, @length may be %NULL.
787  * 
788  * Return value: A newly allocated, %NULL terminated array of strings. Use
789  *   g_strfreev() to free it.
790  *
791  * Since: 2.10
792  */
793 gchar **
794 gtk_recent_chooser_get_uris (GtkRecentChooser *chooser,
795                              gsize            *length)
796 {
797   GList *items, *l;
798   gchar **retval;
799   gsize n_items, i;
800   
801   items = gtk_recent_chooser_get_items (chooser);
802   if (!items)
803     return NULL;
804   
805   n_items = g_list_length (items);
806   retval = g_new0 (gchar *, n_items + 1);
807   
808   for (l = items, i = 0; l != NULL; l = l->next)
809     {
810       GtkRecentInfo *info = (GtkRecentInfo *) l->data;
811       const gchar *uri;
812       
813       g_assert (info != NULL);
814       
815       uri = gtk_recent_info_get_uri (info);
816       g_assert (uri != NULL);
817       
818       retval[i++] = g_strdup (uri);
819     }
820   retval[i] = NULL;
821   
822   if (length)
823     *length = i;
824   
825   g_list_foreach (items,
826                   (GFunc) gtk_recent_info_unref,
827                   NULL);
828   g_list_free (items);
829   
830   return retval;
831 }
832
833 /**
834  * gtk_recent_chooser_add_filter:
835  * @chooser: a #GtkRecentChooser
836  * @filter: a #GtkRecentFilter
837  *
838  * Adds @filter to the list of #GtkRecentFilter objects held by @chooser.
839  *
840  * If no previous filter objects were defined, this function will call
841  * gtk_recent_chooser_set_filter().
842  *
843  * Since: 2.10
844  */
845 void
846 gtk_recent_chooser_add_filter (GtkRecentChooser *chooser,
847                                GtkRecentFilter  *filter)
848 {
849   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
850   
851   GTK_RECENT_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
852 }
853
854 /**
855  * gtk_recent_chooser_remove_filter:
856  * @chooser: a #GtkRecentChooser
857  * @filter: a #GtkRecentFilter
858  *
859  * Removes @filter from the list of #GtkRecentFilter objects held by @chooser.
860  *
861  * Since: 2.10
862  */
863 void
864 gtk_recent_chooser_remove_filter (GtkRecentChooser *chooser,
865                                   GtkRecentFilter  *filter)
866 {
867   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
868   
869   GTK_RECENT_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
870 }
871
872 /**
873  * gtk_recent_chooser_list_filters:
874  * @chooser: a #GtkRecentChooser
875  *
876  * Gets the #GtkRecentFilter objects held by @chooser.
877  *
878  * Return value: A singly linked list of #GtkRecentFilter objects.  You
879  *   should just free the returned list using g_slist_free().
880  *
881  * Since: 2.10
882  */
883 GSList *
884 gtk_recent_chooser_list_filters (GtkRecentChooser *chooser)
885 {
886   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
887   
888   return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
889 }
890
891 /**
892  * gtk_recent_chooser_set_filter:
893  * @chooser: a #GtkRecentChooser
894  * @filter: a #GtkRecentFilter
895  *
896  * Sets @filter as the current #GtkRecentFilter object used by @chooser
897  * to affect the displayed recently used resources.
898  *
899  * Since: 2.10
900  */
901 void
902 gtk_recent_chooser_set_filter (GtkRecentChooser *chooser,
903                                GtkRecentFilter  *filter)
904 {
905   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
906   
907   g_object_set (G_OBJECT (chooser), "filter", filter, NULL);
908 }
909
910 /**
911  * gtk_recent_chooser_get_filter:
912  * @chooser: a #GtkRecentChooser
913  *
914  * Gets the #GtkRecentFilter object currently used by @chooser to affect
915  * the display of the recently used resources.
916  *
917  * Return value: a #GtkRecentFilter object.
918  *
919  * Since: 2.10
920  */
921 GtkRecentFilter *
922 gtk_recent_chooser_get_filter (GtkRecentChooser *chooser)
923 {
924   GtkRecentFilter *filter;
925   
926   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
927   
928   g_object_get (G_OBJECT (chooser), "filter", &filter, NULL);
929   
930   /* we need this hack because g_object_get() increases the refcount
931    * of the returned object; see also gtk_file_chooser_get_filter()
932    * inside gtkfilechooser.c
933    */
934   if (filter)
935     g_object_unref (filter);
936   
937   return filter;
938 }
939
940 void
941 _gtk_recent_chooser_item_activated (GtkRecentChooser *chooser)
942 {
943   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
944   
945   g_signal_emit (chooser, chooser_signals[ITEM_ACTIVATED], 0);
946 }
947
948 void
949 _gtk_recent_chooser_selection_changed (GtkRecentChooser *chooser)
950 {
951   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
952
953   g_signal_emit (chooser, chooser_signals[SELECTION_CHANGED], 0);
954 }
955
956 #define __GTK_RECENT_CHOOSER_C__
957 #include "gtkaliasdef.c"