1 /* GTK - The GIMP Toolkit
2 * gtkrecentchooser.c - Abstract interface for recent file selectors GUIs
4 * Copyright (C) 2006, Emmanuele Bassi
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.
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.
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.
24 #include "gtkrecentchooser.h"
25 #include "gtkrecentchooserprivate.h"
26 #include "gtkrecentmanager.h"
27 #include "gtkrecentaction.h"
28 #include "gtkactivatable.h"
30 #include "gtktypebuiltins.h"
31 #include "gtkprivate.h"
32 #include "gtkmarshalers.h"
44 static void gtk_recent_chooser_class_init (gpointer g_iface);
45 static gboolean recent_chooser_has_show_numbers (GtkRecentChooser *chooser);
47 static GQuark quark_gtk_related_action = 0;
48 static GQuark quark_gtk_use_action_appearance = 0;
49 static const gchar gtk_related_action_key[] = "gtk-related-action";
50 static const gchar gtk_use_action_appearance_key[] = "gtk-use-action-appearance";
53 static guint chooser_signals[LAST_SIGNAL] = { 0, };
56 gtk_recent_chooser_get_type (void)
58 static GType chooser_type = 0;
62 chooser_type = g_type_register_static_simple (G_TYPE_INTERFACE,
63 I_("GtkRecentChooser"),
64 sizeof (GtkRecentChooserIface),
65 (GClassInitFunc) gtk_recent_chooser_class_init,
68 g_type_interface_add_prerequisite (chooser_type, G_TYPE_OBJECT);
75 gtk_recent_chooser_class_init (gpointer g_iface)
77 GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
79 quark_gtk_related_action = g_quark_from_static_string (gtk_related_action_key);
80 quark_gtk_use_action_appearance = g_quark_from_static_string (gtk_use_action_appearance_key);
83 * GtkRecentChooser::selection-changed
84 * @chooser: the object which received the signal
86 * This signal is emitted when there is a change in the set of
87 * selected recently used resources. This can happen when a user
88 * modifies the selection with the mouse or the keyboard, or when
89 * explicitely calling functions to change the selection.
93 chooser_signals[SELECTION_CHANGED] =
94 g_signal_new (I_("selection-changed"),
97 G_STRUCT_OFFSET (GtkRecentChooserIface, selection_changed),
99 g_cclosure_marshal_VOID__VOID,
103 * GtkRecentChooser::item-activated
104 * @chooser: the object which received the signal
106 * This signal is emitted when the user "activates" a recent item
107 * in the recent chooser. This can happen by double-clicking on an item
108 * in the recently used resources list, or by pressing
109 * <keycap>Enter</keycap>.
113 chooser_signals[ITEM_ACTIVATED] =
114 g_signal_new (I_("item-activated"),
117 G_STRUCT_OFFSET (GtkRecentChooserIface, item_activated),
119 g_cclosure_marshal_VOID__VOID,
123 * GtkRecentChooser:recent-manager:
125 * The #GtkRecentManager instance used by the #GtkRecentChooser to
126 * display the list of recently used resources.
130 g_object_interface_install_property (g_iface,
131 g_param_spec_object ("recent-manager",
132 P_("Recent Manager"),
133 P_("The RecentManager object to use"),
134 GTK_TYPE_RECENT_MANAGER,
135 GTK_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
137 * GtkRecentManager:show-private:
139 * Whether this #GtkRecentChooser should display recently used resources
140 * marked with the "private" flag. Such resources should be considered
141 * private to the applications and groups that have added them.
145 g_object_interface_install_property (g_iface,
146 g_param_spec_boolean ("show-private",
148 P_("Whether the private items should be displayed"),
150 GTK_PARAM_READWRITE));
152 * GtkRecentChooser:show-tips:
154 * Whether this #GtkRecentChooser should display a tooltip containing the
155 * full path of the recently used resources.
159 g_object_interface_install_property (g_iface,
160 g_param_spec_boolean ("show-tips",
162 P_("Whether there should be a tooltip on the item"),
164 GTK_PARAM_READWRITE));
166 * GtkRecentChooser:show-icons:
168 * Whether this #GtkRecentChooser should display an icon near the item.
172 g_object_interface_install_property (g_iface,
173 g_param_spec_boolean ("show-icons",
175 P_("Whether there should be an icon near the item"),
177 GTK_PARAM_READWRITE));
179 * GtkRecentChooser:show-not-found:
181 * Whether this #GtkRecentChooser should display the recently used resources
182 * even if not present anymore. Setting this to %FALSE will perform a
183 * potentially expensive check on every local resource (every remote
184 * resource will always be displayed).
188 g_object_interface_install_property (g_iface,
189 g_param_spec_boolean ("show-not-found",
190 P_("Show Not Found"),
191 P_("Whether the items pointing to unavailable resources should be displayed"),
193 GTK_PARAM_READWRITE));
195 * GtkRecentChooser:select-multiple:
197 * Allow the user to select multiple resources.
201 g_object_interface_install_property (g_iface,
202 g_param_spec_boolean ("select-multiple",
203 P_("Select Multiple"),
204 P_("Whether to allow multiple items to be selected"),
206 GTK_PARAM_READWRITE));
208 * GtkRecentChooser:local-only:
210 * Whether this #GtkRecentChooser should display only local (file:)
215 g_object_interface_install_property (g_iface,
216 g_param_spec_boolean ("local-only",
218 P_("Whether the selected resource(s) should be limited to local file: URIs"),
220 GTK_PARAM_READWRITE));
222 * GtkRecentChooser:limit:
224 * The maximum number of recently used resources to be displayed,
225 * or -1 to display all items. By default, the
226 * GtkSetting:gtk-recent-files-limit setting is respected: you can
227 * override that limit on a particular instance of #GtkRecentChooser
228 * by setting this property.
232 g_object_interface_install_property (g_iface,
233 g_param_spec_int ("limit",
235 P_("The maximum number of items to be displayed"),
239 GTK_PARAM_READWRITE));
241 * GtkRecentChooser:sort-type:
243 * Sorting order to be used when displaying the recently used resources.
247 g_object_interface_install_property (g_iface,
248 g_param_spec_enum ("sort-type",
250 P_("The sorting order of the items displayed"),
251 GTK_TYPE_RECENT_SORT_TYPE,
252 GTK_RECENT_SORT_NONE,
253 GTK_PARAM_READWRITE));
255 * GtkRecentChooser:filter:
257 * The #GtkRecentFilter object to be used when displaying
258 * the recently used resources.
262 g_object_interface_install_property (g_iface,
263 g_param_spec_object ("filter",
265 P_("The current filter for selecting which resources are displayed"),
266 GTK_TYPE_RECENT_FILTER,
267 GTK_PARAM_READWRITE));
271 gtk_recent_chooser_error_quark (void)
273 return g_quark_from_static_string ("gtk-recent-chooser-error-quark");
277 * _gtk_recent_chooser_get_recent_manager:
278 * @chooser: a #GtkRecentChooser
280 * Gets the #GtkRecentManager used by @chooser.
282 * Return value: the recent manager for @chooser.
287 _gtk_recent_chooser_get_recent_manager (GtkRecentChooser *chooser)
289 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
291 return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_recent_manager (chooser);
295 * gtk_recent_chooser_set_show_private:
296 * @chooser: a #GtkRecentChooser
297 * @show_private: %TRUE to show private items, %FALSE otherwise
299 * Whether to show recently used resources marked registered as private.
304 gtk_recent_chooser_set_show_private (GtkRecentChooser *chooser,
305 gboolean show_private)
307 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
309 g_object_set (chooser, "show-private", show_private, NULL);
313 * gtk_recent_chooser_get_show_private:
314 * @chooser: a #GtkRecentChooser
316 * Returns whether @chooser should display recently used resources
317 * registered as private.
319 * Return value: %TRUE if the recent chooser should show private items,
325 gtk_recent_chooser_get_show_private (GtkRecentChooser *chooser)
327 gboolean show_private;
329 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
331 g_object_get (chooser, "show-private", &show_private, NULL);
337 * gtk_recent_chooser_set_show_not_found:
338 * @chooser: a #GtkRecentChooser
339 * @show_not_found: whether to show the local items we didn't find
341 * Sets whether @chooser should display the recently used resources that
342 * it didn't find. This only applies to local resources.
347 gtk_recent_chooser_set_show_not_found (GtkRecentChooser *chooser,
348 gboolean show_not_found)
350 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
352 g_object_set (chooser, "show-not-found", show_not_found, NULL);
356 * gtk_recent_chooser_get_show_not_found:
357 * @chooser: a #GtkRecentChooser
359 * Retrieves whether @chooser should show the recently used resources that
362 * Return value: %TRUE if the resources not found should be displayed, and
368 gtk_recent_chooser_get_show_not_found (GtkRecentChooser *chooser)
370 gboolean show_not_found;
372 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
374 g_object_get (chooser, "show-not-found", &show_not_found, NULL);
376 return show_not_found;
380 * gtk_recent_chooser_set_show_icons:
381 * @chooser: a #GtkRecentChooser
382 * @show_icons: whether to show an icon near the resource
384 * Sets whether @chooser should show an icon near the resource when
390 gtk_recent_chooser_set_show_icons (GtkRecentChooser *chooser,
393 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
395 g_object_set (chooser, "show-icons", show_icons, NULL);
399 * gtk_recent_chooser_get_show_icons:
400 * @chooser: a #GtkRecentChooser
402 * Retrieves whether @chooser should show an icon near the resource.
404 * Return value: %TRUE if the icons should be displayed, %FALSE otherwise.
409 gtk_recent_chooser_get_show_icons (GtkRecentChooser *chooser)
413 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
415 g_object_get (chooser, "show-icons", &show_icons, NULL);
421 * gtk_recent_chooser_set_select_multiple:
422 * @chooser: a #GtkRecentChooser
423 * @select_multiple: %TRUE if @chooser can select more than one item
425 * Sets whether @chooser can select multiple items.
430 gtk_recent_chooser_set_select_multiple (GtkRecentChooser *chooser,
431 gboolean select_multiple)
433 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
435 g_object_set (chooser, "select-multiple", select_multiple, NULL);
439 * gtk_recent_chooser_get_select_multiple:
440 * @chooser: a #GtkRecentChooser
442 * Gets whether @chooser can select multiple items.
444 * Return value: %TRUE if @chooser can select more than one item.
449 gtk_recent_chooser_get_select_multiple (GtkRecentChooser *chooser)
451 gboolean select_multiple;
453 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
455 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
457 return select_multiple;
461 * gtk_recent_chooser_set_local_only:
462 * @chooser: a #GtkRecentChooser
463 * @local_only: %TRUE if only local files can be shown
465 * Sets whether only local resources, that is resources using the file:// URI
466 * scheme, should be shown in the recently used resources selector. If
467 * @local_only is %TRUE (the default) then the shown resources are guaranteed
468 * to be accessible through the operating system native file system.
473 gtk_recent_chooser_set_local_only (GtkRecentChooser *chooser,
476 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
478 g_object_set (chooser, "local-only", local_only, NULL);
482 * gtk_recent_chooser_get_local_only:
483 * @chooser: a #GtkRecentChooser
485 * Gets whether only local resources should be shown in the recently used
486 * resources selector. See gtk_recent_chooser_set_local_only()
488 * Return value: %TRUE if only local resources should be shown.
493 gtk_recent_chooser_get_local_only (GtkRecentChooser *chooser)
497 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
499 g_object_get (chooser, "local-only", &local_only, NULL);
505 * gtk_recent_chooser_set_limit:
506 * @chooser: a #GtkRecentChooser
507 * @limit: a positive integer, or -1 for all items
509 * Sets the number of items that should be returned by
510 * gtk_recent_chooser_get_items() and gtk_recent_chooser_get_uris().
515 gtk_recent_chooser_set_limit (GtkRecentChooser *chooser,
518 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
520 g_object_set (chooser, "limit", limit, NULL);
524 * gtk_recent_chooser_get_limit:
525 * @chooser: a #GtkRecentChooser
527 * Gets the number of items returned by gtk_recent_chooser_get_items()
528 * and gtk_recent_chooser_get_uris().
530 * Return value: A positive integer, or -1 meaning that all items are
536 gtk_recent_chooser_get_limit (GtkRecentChooser *chooser)
540 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), 10);
542 g_object_get (chooser, "limit", &limit, NULL);
548 * gtk_recent_chooser_set_show_tips:
549 * @chooser: a #GtkRecentChooser
550 * @show_tips: %TRUE if tooltips should be shown
552 * Sets whether to show a tooltips containing the full path of each
553 * recently used resource in a #GtkRecentChooser widget.
558 gtk_recent_chooser_set_show_tips (GtkRecentChooser *chooser,
561 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
563 g_object_set (chooser, "show-tips", show_tips, NULL);
567 * gtk_recent_chooser_get_show_tips:
568 * @chooser: a #GtkRecentChooser
570 * Gets whether @chooser should display tooltips containing the full path
571 * of a recently user resource.
573 * Return value: %TRUE if the recent chooser should show tooltips,
579 gtk_recent_chooser_get_show_tips (GtkRecentChooser *chooser)
583 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
585 g_object_get (chooser, "show-tips", &show_tips, NULL);
591 recent_chooser_has_show_numbers (GtkRecentChooser *chooser)
595 /* This is the result of a minor screw up: the "show-numbers" property
596 * was removed from the GtkRecentChooser interface, but the accessors
597 * remained in the interface API; now we need to check whether the
598 * implementation of the RecentChooser interface has a "show-numbers"
599 * boolean property installed before accessing it, and avoid an
600 * assertion failure using a more graceful warning. This should really
601 * go away as soon as we can break API and remove these accessors.
603 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (chooser),
606 return (pspec && pspec->value_type == G_TYPE_BOOLEAN);
610 * gtk_recent_chooser_set_show_numbers:
611 * @chooser: a #GtkRecentChooser
612 * @show_numbers: %TRUE to show numbers, %FALSE otherwise
614 * Whether to show recently used resources prepended by a unique number.
616 * Deprecated: 2.12: Use gtk_recent_chooser_menu_set_show_numbers() instead.
621 gtk_recent_chooser_set_show_numbers (GtkRecentChooser *chooser,
622 gboolean show_numbers)
624 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
626 if (!recent_chooser_has_show_numbers (chooser))
628 g_warning ("Choosers of type `%s' do not support showing numbers",
629 G_OBJECT_TYPE_NAME (chooser));
634 g_object_set (chooser, "show-numbers", show_numbers, NULL);
638 * gtk_recent_chooser_get_show_numbers:
639 * @chooser: a #GtkRecentChooser
641 * Returns whether @chooser should display recently used resources
642 * prepended by a unique number.
644 * Deprecated: 2.12: use gtk_recent_chooser_menu_get_show_numbers() instead.
646 * Return value: %TRUE if the recent chooser should show display numbers,
652 gtk_recent_chooser_get_show_numbers (GtkRecentChooser *chooser)
655 gboolean show_numbers;
657 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
659 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (chooser),
661 if (!pspec || pspec->value_type != G_TYPE_BOOLEAN)
663 g_warning ("Choosers of type `%s' do not support showing numbers",
664 G_OBJECT_TYPE_NAME (chooser));
669 g_object_get (chooser, "show-numbers", &show_numbers, NULL);
676 * gtk_recent_chooser_set_sort_type:
677 * @chooser: a #GtkRecentChooser
678 * @sort_type: sort order that the chooser should use
680 * Changes the sorting order of the recently used resources list displayed by
686 gtk_recent_chooser_set_sort_type (GtkRecentChooser *chooser,
687 GtkRecentSortType sort_type)
689 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
691 g_object_set (chooser, "sort-type", sort_type, NULL);
695 * gtk_recent_chooser_get_sort_type:
696 * @chooser: a #GtkRecentChooser
698 * Gets the value set by gtk_recent_chooser_set_sort_type().
700 * Return value: the sorting order of the @chooser.
705 gtk_recent_chooser_get_sort_type (GtkRecentChooser *chooser)
707 GtkRecentSortType sort_type;
709 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), GTK_RECENT_SORT_NONE);
711 g_object_get (chooser, "sort-type", &sort_type, NULL);
717 * gtk_recent_chooser_set_sort_func:
718 * @chooser: a #GtkRecentChooser
719 * @sort_func: the comparison function
720 * @sort_data: user data to pass to @sort_func, or %NULL
721 * @data_destroy: destroy notifier for @sort_data, or %NULL
723 * Sets the comparison function used when sorting to be @sort_func. If
724 * the @chooser has the sort type set to #GTK_RECENT_SORT_CUSTOM then
725 * the chooser will sort using this function.
727 * To the comparison function will be passed two #GtkRecentInfo structs and
728 * @sort_data; @sort_func should return a positive integer if the first
729 * item comes before the second, zero if the two items are equal and
730 * a negative integer if the first item comes after the second.
735 gtk_recent_chooser_set_sort_func (GtkRecentChooser *chooser,
736 GtkRecentSortFunc sort_func,
738 GDestroyNotify data_destroy)
740 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
742 GTK_RECENT_CHOOSER_GET_IFACE (chooser)->set_sort_func (chooser,
749 * gtk_recent_chooser_set_current_uri:
750 * @chooser: a #GtkRecentChooser
752 * @error: return location for a #GError, or %NULL
754 * Sets @uri as the current URI for @chooser.
756 * Return value: %TRUE if the URI was found.
761 gtk_recent_chooser_set_current_uri (GtkRecentChooser *chooser,
765 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
767 return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->set_current_uri (chooser, uri, error);
771 * gtk_recent_chooser_get_current_uri:
772 * @chooser: a #GtkRecentChooser
774 * Gets the URI currently selected by @chooser.
776 * Return value: a newly allocated string holding a URI.
781 gtk_recent_chooser_get_current_uri (GtkRecentChooser *chooser)
783 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
785 return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_current_uri (chooser);
789 * gtk_recent_chooser_get_current_item:
790 * @chooser: a #GtkRecentChooser
792 * Gets the #GtkRecentInfo currently selected by @chooser.
794 * Return value: a #GtkRecentInfo. Use gtk_recent_info_unref() when
795 * when you have finished using it.
800 gtk_recent_chooser_get_current_item (GtkRecentChooser *chooser)
802 GtkRecentManager *manager;
803 GtkRecentInfo *retval;
806 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
808 uri = gtk_recent_chooser_get_current_uri (chooser);
812 manager = _gtk_recent_chooser_get_recent_manager (chooser);
813 retval = gtk_recent_manager_lookup_item (manager, uri, NULL);
820 * gtk_recent_chooser_select_uri:
821 * @chooser: a #GtkRecentChooser
823 * @error: return location for a #GError, or %NULL
825 * Selects @uri inside @chooser.
827 * Return value: %TRUE if @uri was found.
832 gtk_recent_chooser_select_uri (GtkRecentChooser *chooser,
836 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
838 return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->select_uri (chooser, uri, error);
842 * gtk_recent_chooser_unselect_uri:
843 * @chooser: a #GtkRecentChooser
846 * Unselects @uri inside @chooser.
851 gtk_recent_chooser_unselect_uri (GtkRecentChooser *chooser,
854 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
856 GTK_RECENT_CHOOSER_GET_IFACE (chooser)->unselect_uri (chooser, uri);
860 * gtk_recent_chooser_select_all:
861 * @chooser: a #GtkRecentChooser
863 * Selects all the items inside @chooser, if the @chooser supports
864 * multiple selection.
869 gtk_recent_chooser_select_all (GtkRecentChooser *chooser)
871 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
873 GTK_RECENT_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
877 * gtk_recent_chooser_unselect_all:
878 * @chooser: a #GtkRecentChooser
880 * Unselects all the items inside @chooser.
885 gtk_recent_chooser_unselect_all (GtkRecentChooser *chooser)
887 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
889 GTK_RECENT_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
893 * gtk_recent_chooser_get_items:
894 * @chooser: a #GtkRecentChooser
896 * Gets the list of recently used resources in form of #GtkRecentInfo objects.
898 * The return value of this function is affected by the "sort-type" and
899 * "limit" properties of @chooser.
901 * Return value: A newly allocated list of #GtkRecentInfo objects. You should
902 * use gtk_recent_info_unref() on every item of the list, and then free
903 * the list itself using g_list_free().
908 gtk_recent_chooser_get_items (GtkRecentChooser *chooser)
910 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
912 return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_items (chooser);
916 * gtk_recent_chooser_get_uris:
917 * @chooser: a #GtkRecentChooser
918 * @length: return location for a the length of the URI list, or %NULL
920 * Gets the URI of the recently used resources.
922 * The return value of this function is affected by the "sort-type" and "limit"
923 * properties of @chooser.
925 * Since the returned array is %NULL terminated, @length may be %NULL.
927 * Return value: A newly allocated, %NULL terminated array of strings. Use
928 * g_strfreev() to free it.
933 gtk_recent_chooser_get_uris (GtkRecentChooser *chooser,
940 items = gtk_recent_chooser_get_items (chooser);
942 n_items = g_list_length (items);
943 retval = g_new0 (gchar *, n_items + 1);
945 for (l = items, i = 0; l != NULL; l = l->next)
947 GtkRecentInfo *info = (GtkRecentInfo *) l->data;
950 g_assert (info != NULL);
952 uri = gtk_recent_info_get_uri (info);
953 g_assert (uri != NULL);
955 retval[i++] = g_strdup (uri);
962 g_list_foreach (items,
963 (GFunc) gtk_recent_info_unref,
971 * gtk_recent_chooser_add_filter:
972 * @chooser: a #GtkRecentChooser
973 * @filter: a #GtkRecentFilter
975 * Adds @filter to the list of #GtkRecentFilter objects held by @chooser.
977 * If no previous filter objects were defined, this function will call
978 * gtk_recent_chooser_set_filter().
983 gtk_recent_chooser_add_filter (GtkRecentChooser *chooser,
984 GtkRecentFilter *filter)
986 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
987 g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
989 GTK_RECENT_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
993 * gtk_recent_chooser_remove_filter:
994 * @chooser: a #GtkRecentChooser
995 * @filter: a #GtkRecentFilter
997 * Removes @filter from the list of #GtkRecentFilter objects held by @chooser.
1002 gtk_recent_chooser_remove_filter (GtkRecentChooser *chooser,
1003 GtkRecentFilter *filter)
1005 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
1006 g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
1008 GTK_RECENT_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
1012 * gtk_recent_chooser_list_filters:
1013 * @chooser: a #GtkRecentChooser
1015 * Gets the #GtkRecentFilter objects held by @chooser.
1017 * Return value: A singly linked list of #GtkRecentFilter objects. You
1018 * should just free the returned list using g_slist_free().
1023 gtk_recent_chooser_list_filters (GtkRecentChooser *chooser)
1025 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
1027 return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
1031 * gtk_recent_chooser_set_filter:
1032 * @chooser: a #GtkRecentChooser
1033 * @filter: a #GtkRecentFilter
1035 * Sets @filter as the current #GtkRecentFilter object used by @chooser
1036 * to affect the displayed recently used resources.
1041 gtk_recent_chooser_set_filter (GtkRecentChooser *chooser,
1042 GtkRecentFilter *filter)
1044 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
1045 g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
1047 g_object_set (G_OBJECT (chooser), "filter", filter, NULL);
1051 * gtk_recent_chooser_get_filter:
1052 * @chooser: a #GtkRecentChooser
1054 * Gets the #GtkRecentFilter object currently used by @chooser to affect
1055 * the display of the recently used resources.
1057 * Return value: a #GtkRecentFilter object.
1062 gtk_recent_chooser_get_filter (GtkRecentChooser *chooser)
1064 GtkRecentFilter *filter;
1066 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
1068 g_object_get (G_OBJECT (chooser), "filter", &filter, NULL);
1070 /* we need this hack because g_object_get() increases the refcount
1071 * of the returned object; see also gtk_file_chooser_get_filter()
1072 * inside gtkfilechooser.c
1075 g_object_unref (filter);
1081 _gtk_recent_chooser_item_activated (GtkRecentChooser *chooser)
1083 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
1085 g_signal_emit (chooser, chooser_signals[ITEM_ACTIVATED], 0);
1089 _gtk_recent_chooser_selection_changed (GtkRecentChooser *chooser)
1091 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
1093 g_signal_emit (chooser, chooser_signals[SELECTION_CHANGED], 0);
1097 _gtk_recent_chooser_update (GtkActivatable *activatable,
1099 const gchar *property_name)
1101 GtkRecentChooser *recent_chooser = GTK_RECENT_CHOOSER (activatable);
1102 GtkRecentChooser *action_chooser = GTK_RECENT_CHOOSER (action);
1103 GtkRecentAction *recent_action = GTK_RECENT_ACTION (action);
1105 if (strcmp (property_name, "show-numbers") == 0 && recent_chooser_has_show_numbers (recent_chooser))
1106 g_object_set (recent_chooser, "show-numbers",
1107 gtk_recent_action_get_show_numbers (recent_action), NULL);
1108 else if (strcmp (property_name, "show-private") == 0)
1109 gtk_recent_chooser_set_show_private (recent_chooser, gtk_recent_chooser_get_show_private (action_chooser));
1110 else if (strcmp (property_name, "show-not-found") == 0)
1111 gtk_recent_chooser_set_show_not_found (recent_chooser, gtk_recent_chooser_get_show_not_found (action_chooser));
1112 else if (strcmp (property_name, "show-tips") == 0)
1113 gtk_recent_chooser_set_show_tips (recent_chooser, gtk_recent_chooser_get_show_tips (action_chooser));
1114 else if (strcmp (property_name, "show-icons") == 0)
1115 gtk_recent_chooser_set_show_icons (recent_chooser, gtk_recent_chooser_get_show_icons (action_chooser));
1116 else if (strcmp (property_name, "limit") == 0)
1117 gtk_recent_chooser_set_limit (recent_chooser, gtk_recent_chooser_get_limit (action_chooser));
1118 else if (strcmp (property_name, "local-only") == 0)
1119 gtk_recent_chooser_set_local_only (recent_chooser, gtk_recent_chooser_get_local_only (action_chooser));
1120 else if (strcmp (property_name, "sort-type") == 0)
1121 gtk_recent_chooser_set_sort_type (recent_chooser, gtk_recent_chooser_get_sort_type (action_chooser));
1122 else if (strcmp (property_name, "filter") == 0)
1123 gtk_recent_chooser_set_filter (recent_chooser, gtk_recent_chooser_get_filter (action_chooser));
1127 _gtk_recent_chooser_sync_action_properties (GtkActivatable *activatable,
1130 GtkRecentChooser *recent_chooser = GTK_RECENT_CHOOSER (activatable);
1131 GtkRecentChooser *action_chooser = GTK_RECENT_CHOOSER (action);
1136 if (recent_chooser_has_show_numbers (recent_chooser))
1137 g_object_set (recent_chooser, "show-numbers",
1138 gtk_recent_action_get_show_numbers (GTK_RECENT_ACTION (action)),
1140 gtk_recent_chooser_set_show_private (recent_chooser, gtk_recent_chooser_get_show_private (action_chooser));
1141 gtk_recent_chooser_set_show_not_found (recent_chooser, gtk_recent_chooser_get_show_not_found (action_chooser));
1142 gtk_recent_chooser_set_show_tips (recent_chooser, gtk_recent_chooser_get_show_tips (action_chooser));
1143 gtk_recent_chooser_set_show_icons (recent_chooser, gtk_recent_chooser_get_show_icons (action_chooser));
1144 gtk_recent_chooser_set_limit (recent_chooser, gtk_recent_chooser_get_limit (action_chooser));
1145 gtk_recent_chooser_set_local_only (recent_chooser, gtk_recent_chooser_get_local_only (action_chooser));
1146 gtk_recent_chooser_set_sort_type (recent_chooser, gtk_recent_chooser_get_sort_type (action_chooser));
1147 gtk_recent_chooser_set_filter (recent_chooser, gtk_recent_chooser_get_filter (action_chooser));
1151 _gtk_recent_chooser_set_related_action (GtkRecentChooser *recent_chooser,
1154 GtkAction *prev_action;
1156 prev_action = g_object_get_qdata (G_OBJECT (recent_chooser), quark_gtk_related_action);
1158 if (prev_action == action)
1161 gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (recent_chooser), action);
1162 g_object_set_qdata (G_OBJECT (recent_chooser), quark_gtk_related_action, action);
1166 _gtk_recent_chooser_get_related_action (GtkRecentChooser *recent_chooser)
1168 return g_object_get_qdata (G_OBJECT (recent_chooser), quark_gtk_related_action);
1171 /* The default for use-action-appearance is TRUE, so we try to set the
1172 * qdata backwards for this case.
1175 _gtk_recent_chooser_set_use_action_appearance (GtkRecentChooser *recent_chooser,
1176 gboolean use_appearance)
1179 gboolean use_action_appearance;
1181 action = g_object_get_qdata (G_OBJECT (recent_chooser), quark_gtk_related_action);
1182 use_action_appearance = !GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (recent_chooser), quark_gtk_use_action_appearance));
1184 if (use_action_appearance != use_appearance)
1187 g_object_set_qdata (G_OBJECT (recent_chooser), quark_gtk_use_action_appearance, GINT_TO_POINTER (!use_appearance));
1189 gtk_activatable_sync_action_properties (GTK_ACTIVATABLE (recent_chooser), action);
1194 _gtk_recent_chooser_get_use_action_appearance (GtkRecentChooser *recent_chooser)
1196 return !GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (recent_chooser), quark_gtk_use_action_appearance));
1199 #define __GTK_RECENT_CHOOSER_C__
1200 #include "gtkaliasdef.c"