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