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