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