]> Pileus Git - ~andy/gtk/blob - gtk/gtkrecentchooser.c
06b5fdd7649f8e3648a09999effd30580c59a618
[~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  * Do not use this function: use gtk_recent_chooser_menu_set_show_numbers()
501  * instead.
502  *
503  * Since: 2.10
504  */
505 void
506 gtk_recent_chooser_set_show_numbers (GtkRecentChooser *chooser,
507                                      gboolean          show_numbers)
508 {
509   GParamSpec *pspec;
510   
511   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
512
513   /* This is the result of a minor screw up: the "show-numbers" property
514    * was removed from the GtkRecentChooser interface, but the accessors
515    * remained in the interface API; now we need to check whether the
516    * implementation of the RecentChooser interface has a "show-numbers"
517    * boolean property installed before accessing it, and avoid an
518    * assertion failure using a more graceful warning.  This should really
519    * go away as soon as we can break API and remove these accessors.
520    */
521   pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (chooser),
522                                         "show-numbers");
523   if (!pspec || pspec->value_type != G_TYPE_BOOLEAN)
524     {
525       g_warning ("Choosers of type `%s' do not support showing numbers",
526                  G_OBJECT_TYPE_NAME (chooser));
527
528       return;
529     }
530   
531   g_object_set (chooser, "show-numbers", show_numbers, NULL);
532 }
533
534 /**
535  * gtk_recent_chooser_get_show_numbers:
536  * @chooser: a #GtkRecentChooser
537  *
538  * Returns whether @chooser should display recently used resources
539  * prepended by a unique number.
540  *
541  * Do not use this function: use gtk_recent_chooser_menu_get_show_numbers()
542  * instead.
543  *
544  * Return value: %TRUE if the recent chooser should show display numbers,
545  *   %FALSE otherwise.
546  *
547  * Since: 2.10
548  */
549 gboolean
550 gtk_recent_chooser_get_show_numbers (GtkRecentChooser *chooser)
551 {
552   GParamSpec *pspec;
553   gboolean show_numbers;
554   
555   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
556
557   pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (chooser),
558                                         "show-numbers");
559   if (!pspec || pspec->value_type != G_TYPE_BOOLEAN)
560     {
561       g_warning ("Choosers of type `%s' do not support showing numbers",
562                  G_OBJECT_TYPE_NAME (chooser));
563
564       return FALSE;
565     }
566   
567   g_object_get (chooser, "show-numbers", &show_numbers, NULL);
568   
569   return show_numbers;
570 }
571
572
573 /**
574  * gtk_recent_chooser_set_sort_type:
575  * @chooser: a #GtkRecentChooser
576  * @sort_type: sort order that the chooser should use
577  *
578  * Changes the sorting order of the recently used resources list displayed by
579  * @chooser.
580  *
581  * Since: 2.10
582  */
583 void
584 gtk_recent_chooser_set_sort_type (GtkRecentChooser  *chooser,
585                                   GtkRecentSortType  sort_type)
586 {  
587   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
588   
589   g_object_set (chooser, "sort-type", sort_type, NULL);
590 }
591
592 /**
593  * gtk_recent_chooser_get_sort_type:
594  * @chooser: a #GtkRecentChooser
595  *
596  * Gets the value set by gtk_recent_chooser_set_sort_type().
597  *
598  * Return value: the sorting order of the @chooser.
599  *
600  * Since: 2.10
601  */
602 GtkRecentSortType
603 gtk_recent_chooser_get_sort_type (GtkRecentChooser *chooser)
604 {
605   GtkRecentSortType sort_type;
606   
607   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), GTK_RECENT_SORT_NONE);
608   
609   g_object_get (chooser, "sort-type", &sort_type, NULL);
610
611   return sort_type;
612 }
613
614 /**
615  * gtk_recent_chooser_set_sort_func:
616  * @chooser: a #GtkRecentChooser
617  * @sort_func: the comparison function
618  * @sort_data: user data to pass to @sort_func, or %NULL
619  * @data_destroy: destroy notifier for @sort_data, or %NULL
620  *
621  * Sets the comparison function used when sorting to be @sort_func.  If
622  * the @chooser has the sort type set to #GTK_RECENT_SORT_CUSTOM then
623  * the chooser will sort using this function.
624  *
625  * To the comparison function will be passed two #GtkRecentInfo structs and
626  * @sort_data;  @sort_func should return a positive integer if the first
627  * item comes before the second, zero if the two items are equal and
628  * a negative integer if the first item comes after the second.
629  *
630  * Since: 2.10
631  */
632 void
633 gtk_recent_chooser_set_sort_func  (GtkRecentChooser  *chooser,
634                                    GtkRecentSortFunc  sort_func,
635                                    gpointer           sort_data,
636                                    GDestroyNotify     data_destroy)
637 {
638   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
639   
640   GTK_RECENT_CHOOSER_GET_IFACE (chooser)->set_sort_func (chooser,
641                                                          sort_func,
642                                                          sort_data,
643                                                          data_destroy);
644 }
645
646 /**
647  * gtk_recent_chooser_set_current_uri:
648  * @chooser: a #GtkRecentChooser
649  * @uri: a URI
650  * @error: return location for a #GError, or %NULL
651  *
652  * Sets @uri as the current URI for @chooser.
653  *
654  * Return value: %TRUE if the URI was found.
655  *
656  * Since: 2.10
657  */
658 gboolean
659 gtk_recent_chooser_set_current_uri (GtkRecentChooser  *chooser,
660                                     const gchar       *uri,
661                                     GError           **error)
662 {
663   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
664   
665   return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->set_current_uri (chooser, uri, error);
666 }
667
668 /**
669  * gtk_recent_chooser_get_current_uri:
670  * @chooser: a #GtkRecentChooser
671  *
672  * Gets the URI currently selected by @chooser.
673  *
674  * Return value: a newly allocated string holding a URI.
675  *
676  * Since: 2.10
677  */
678 gchar *
679 gtk_recent_chooser_get_current_uri (GtkRecentChooser *chooser)
680 {
681   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
682   
683   return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_current_uri (chooser);
684 }
685
686 /**
687  * gtk_recent_chooser_get_current_item:
688  * @chooser: a #GtkRecentChooser
689  * 
690  * Gets the #GtkRecentInfo currently selected by @chooser.
691  *
692  * Return value: a #GtkRecentInfo.  Use gtk_recent_info_unref() when
693  *   when you have finished using it.
694  *
695  * Since: 2.10
696  */
697 GtkRecentInfo *
698 gtk_recent_chooser_get_current_item (GtkRecentChooser *chooser)
699 {
700   GtkRecentManager *manager;
701   GtkRecentInfo *retval;
702   gchar *uri;
703   
704   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
705   
706   uri = gtk_recent_chooser_get_current_uri (chooser);
707   if (!uri)
708     return NULL;
709   
710   manager = _gtk_recent_chooser_get_recent_manager (chooser);
711   retval = gtk_recent_manager_lookup_item (manager, uri, NULL);
712   g_free (uri);
713   
714   return retval;
715 }
716
717 /**
718  * gtk_recent_chooser_select_uri:
719  * @chooser: a #GtkRecentChooser
720  * @uri: a URI
721  * @error: return location for a #GError, or %NULL
722  *
723  * Selects @uri inside @chooser.
724  *
725  * Return value: %TRUE if @uri was found.
726  *
727  * Since: 2.10
728  */
729 gboolean
730 gtk_recent_chooser_select_uri (GtkRecentChooser  *chooser,
731                                const gchar       *uri,
732                                GError           **error)
733 {
734   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
735   
736   return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->select_uri (chooser, uri, error);
737 }
738
739 /**
740  * gtk_recent_chooser_unselect_uri:
741  * @chooser: a #GtkRecentChooser
742  * @uri: a URI
743  *
744  * Unselects @uri inside @chooser.
745  *
746  * Since: 2.10
747  */
748 void
749 gtk_recent_chooser_unselect_uri (GtkRecentChooser *chooser,
750                                  const gchar      *uri)
751 {
752   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
753   
754   GTK_RECENT_CHOOSER_GET_IFACE (chooser)->unselect_uri (chooser, uri);
755 }
756
757 /**
758  * gtk_recent_chooser_select_all:
759  * @chooser: a #GtkRecentChooser
760  *
761  * Selects all the items inside @chooser, if the @chooser supports
762  * multiple selection.
763  *
764  * Since: 2.10
765  */
766 void
767 gtk_recent_chooser_select_all (GtkRecentChooser *chooser)
768 {
769   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
770   
771   GTK_RECENT_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
772 }
773
774 /**
775  * gtk_recent_chooser_unselect_all:
776  * @chooser: a #GtkRecentChooser
777  *
778  * Unselects all the items inside @chooser.
779  * 
780  * Since: 2.10
781  */
782 void
783 gtk_recent_chooser_unselect_all (GtkRecentChooser *chooser)
784 {
785   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
786   
787   GTK_RECENT_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
788 }
789
790 /**
791  * gtk_recent_chooser_get_items:
792  * @chooser: a #GtkRecentChooser
793  *
794  * Gets the list of recently used resources in form of #GtkRecentInfo objects.
795  *
796  * The return value of this function is affected by the "sort-type" and
797  * "limit" properties of @chooser.
798  *
799  * Return value: A newly allocated list of #GtkRecentInfo objects.  You should
800  *   use gtk_recent_info_unref() on every item of the list, and then free
801  *   the list itself using g_list_free().
802  *
803  * Since: 2.10
804  */
805 GList *
806 gtk_recent_chooser_get_items (GtkRecentChooser *chooser)
807 {
808   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
809   
810   return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_items (chooser);
811 }
812
813 /**
814  * gtk_recent_chooser_get_uris:
815  * @chooser: a #GtkRecentChooser
816  * @length: return location for a the length of the URI list, or %NULL
817  *
818  * Gets the URI of the recently used resources.
819  *
820  * The return value of this function is affected by the "sort-type" and "limit"
821  * properties of @chooser.
822  *
823  * Since the returned array is %NULL terminated, @length may be %NULL.
824  * 
825  * Return value: A newly allocated, %NULL terminated array of strings. Use
826  *   g_strfreev() to free it.
827  *
828  * Since: 2.10
829  */
830 gchar **
831 gtk_recent_chooser_get_uris (GtkRecentChooser *chooser,
832                              gsize            *length)
833 {
834   GList *items, *l;
835   gchar **retval;
836   gsize n_items, i;
837   
838   items = gtk_recent_chooser_get_items (chooser);
839   if (!items)
840     return NULL;
841   
842   n_items = g_list_length (items);
843   retval = g_new0 (gchar *, n_items + 1);
844   
845   for (l = items, i = 0; l != NULL; l = l->next)
846     {
847       GtkRecentInfo *info = (GtkRecentInfo *) l->data;
848       const gchar *uri;
849       
850       g_assert (info != NULL);
851       
852       uri = gtk_recent_info_get_uri (info);
853       g_assert (uri != NULL);
854       
855       retval[i++] = g_strdup (uri);
856     }
857   retval[i] = NULL;
858   
859   if (length)
860     *length = i;
861   
862   g_list_foreach (items,
863                   (GFunc) gtk_recent_info_unref,
864                   NULL);
865   g_list_free (items);
866   
867   return retval;
868 }
869
870 /**
871  * gtk_recent_chooser_add_filter:
872  * @chooser: a #GtkRecentChooser
873  * @filter: a #GtkRecentFilter
874  *
875  * Adds @filter to the list of #GtkRecentFilter objects held by @chooser.
876  *
877  * If no previous filter objects were defined, this function will call
878  * gtk_recent_chooser_set_filter().
879  *
880  * Since: 2.10
881  */
882 void
883 gtk_recent_chooser_add_filter (GtkRecentChooser *chooser,
884                                GtkRecentFilter  *filter)
885 {
886   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
887   g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
888   
889   GTK_RECENT_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
890 }
891
892 /**
893  * gtk_recent_chooser_remove_filter:
894  * @chooser: a #GtkRecentChooser
895  * @filter: a #GtkRecentFilter
896  *
897  * Removes @filter from the list of #GtkRecentFilter objects held by @chooser.
898  *
899  * Since: 2.10
900  */
901 void
902 gtk_recent_chooser_remove_filter (GtkRecentChooser *chooser,
903                                   GtkRecentFilter  *filter)
904 {
905   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
906   g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
907   
908   GTK_RECENT_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
909 }
910
911 /**
912  * gtk_recent_chooser_list_filters:
913  * @chooser: a #GtkRecentChooser
914  *
915  * Gets the #GtkRecentFilter objects held by @chooser.
916  *
917  * Return value: A singly linked list of #GtkRecentFilter objects.  You
918  *   should just free the returned list using g_slist_free().
919  *
920  * Since: 2.10
921  */
922 GSList *
923 gtk_recent_chooser_list_filters (GtkRecentChooser *chooser)
924 {
925   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
926   
927   return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
928 }
929
930 /**
931  * gtk_recent_chooser_set_filter:
932  * @chooser: a #GtkRecentChooser
933  * @filter: a #GtkRecentFilter
934  *
935  * Sets @filter as the current #GtkRecentFilter object used by @chooser
936  * to affect the displayed recently used resources.
937  *
938  * Since: 2.10
939  */
940 void
941 gtk_recent_chooser_set_filter (GtkRecentChooser *chooser,
942                                GtkRecentFilter  *filter)
943 {
944   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
945   g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
946   
947   g_object_set (G_OBJECT (chooser), "filter", filter, NULL);
948 }
949
950 /**
951  * gtk_recent_chooser_get_filter:
952  * @chooser: a #GtkRecentChooser
953  *
954  * Gets the #GtkRecentFilter object currently used by @chooser to affect
955  * the display of the recently used resources.
956  *
957  * Return value: a #GtkRecentFilter object.
958  *
959  * Since: 2.10
960  */
961 GtkRecentFilter *
962 gtk_recent_chooser_get_filter (GtkRecentChooser *chooser)
963 {
964   GtkRecentFilter *filter;
965   
966   g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
967   
968   g_object_get (G_OBJECT (chooser), "filter", &filter, NULL);
969   
970   /* we need this hack because g_object_get() increases the refcount
971    * of the returned object; see also gtk_file_chooser_get_filter()
972    * inside gtkfilechooser.c
973    */
974   if (filter)
975     g_object_unref (filter);
976   
977   return filter;
978 }
979
980 void
981 _gtk_recent_chooser_item_activated (GtkRecentChooser *chooser)
982 {
983   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
984   
985   g_signal_emit (chooser, chooser_signals[ITEM_ACTIVATED], 0);
986 }
987
988 void
989 _gtk_recent_chooser_selection_changed (GtkRecentChooser *chooser)
990 {
991   g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
992
993   g_signal_emit (chooser, chooser_signals[SELECTION_CHANGED], 0);
994 }
995
996 #define __GTK_RECENT_CHOOSER_C__
997 #include "gtkaliasdef.c"