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"
37 * SECTION:gtkrecentchooser
38 * @Short_description: Interface implemented by widgets displaying recently
40 * @Title: GtkRecentChooser
41 * @See_also: #GtkRecentManager, #GtkRecentChooserDialog,
42 * #GtkRecentChooserWidget, #GtkRecentChooserMenu
44 * #GtkRecentChooser is an interface that can be implemented by widgets
45 * displaying the list of recently used files. In GTK+, the main objects
46 * that implement this interface are #GtkRecentChooserWidget,
47 * #GtkRecentChooserDialog and #GtkRecentChooserMenu.
49 * Recently used files are supported since GTK+ 2.10.
61 static void gtk_recent_chooser_class_init (gpointer g_iface);
62 static gboolean recent_chooser_has_show_numbers (GtkRecentChooser *chooser);
64 static GQuark quark_gtk_related_action = 0;
65 static GQuark quark_gtk_use_action_appearance = 0;
66 static const gchar gtk_related_action_key[] = "gtk-related-action";
67 static const gchar gtk_use_action_appearance_key[] = "gtk-use-action-appearance";
70 static guint chooser_signals[LAST_SIGNAL] = { 0, };
73 gtk_recent_chooser_get_type (void)
75 static GType chooser_type = 0;
79 chooser_type = g_type_register_static_simple (G_TYPE_INTERFACE,
80 I_("GtkRecentChooser"),
81 sizeof (GtkRecentChooserIface),
82 (GClassInitFunc) gtk_recent_chooser_class_init,
85 g_type_interface_add_prerequisite (chooser_type, G_TYPE_OBJECT);
92 gtk_recent_chooser_class_init (gpointer g_iface)
94 GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
96 quark_gtk_related_action = g_quark_from_static_string (gtk_related_action_key);
97 quark_gtk_use_action_appearance = g_quark_from_static_string (gtk_use_action_appearance_key);
100 * GtkRecentChooser::selection-changed
101 * @chooser: the object which received the signal
103 * This signal is emitted when there is a change in the set of
104 * selected recently used resources. This can happen when a user
105 * modifies the selection with the mouse or the keyboard, or when
106 * explicitely calling functions to change the selection.
110 chooser_signals[SELECTION_CHANGED] =
111 g_signal_new (I_("selection-changed"),
114 G_STRUCT_OFFSET (GtkRecentChooserIface, selection_changed),
116 g_cclosure_marshal_VOID__VOID,
120 * GtkRecentChooser::item-activated
121 * @chooser: the object which received the signal
123 * This signal is emitted when the user "activates" a recent item
124 * in the recent chooser. This can happen by double-clicking on an item
125 * in the recently used resources list, or by pressing
126 * <keycap>Enter</keycap>.
130 chooser_signals[ITEM_ACTIVATED] =
131 g_signal_new (I_("item-activated"),
134 G_STRUCT_OFFSET (GtkRecentChooserIface, item_activated),
136 g_cclosure_marshal_VOID__VOID,
140 * GtkRecentChooser:recent-manager:
142 * The #GtkRecentManager instance used by the #GtkRecentChooser to
143 * display the list of recently used resources.
147 g_object_interface_install_property (g_iface,
148 g_param_spec_object ("recent-manager",
149 P_("Recent Manager"),
150 P_("The RecentManager object to use"),
151 GTK_TYPE_RECENT_MANAGER,
152 GTK_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
154 * GtkRecentManager:show-private:
156 * Whether this #GtkRecentChooser should display recently used resources
157 * marked with the "private" flag. Such resources should be considered
158 * private to the applications and groups that have added them.
162 g_object_interface_install_property (g_iface,
163 g_param_spec_boolean ("show-private",
165 P_("Whether the private items should be displayed"),
167 GTK_PARAM_READWRITE));
169 * GtkRecentChooser:show-tips:
171 * Whether this #GtkRecentChooser should display a tooltip containing the
172 * full path of the recently used resources.
176 g_object_interface_install_property (g_iface,
177 g_param_spec_boolean ("show-tips",
179 P_("Whether there should be a tooltip on the item"),
181 GTK_PARAM_READWRITE));
183 * GtkRecentChooser:show-icons:
185 * Whether this #GtkRecentChooser should display an icon near the item.
189 g_object_interface_install_property (g_iface,
190 g_param_spec_boolean ("show-icons",
192 P_("Whether there should be an icon near the item"),
194 GTK_PARAM_READWRITE));
196 * GtkRecentChooser:show-not-found:
198 * Whether this #GtkRecentChooser should display the recently used resources
199 * even if not present anymore. Setting this to %FALSE will perform a
200 * potentially expensive check on every local resource (every remote
201 * resource will always be displayed).
205 g_object_interface_install_property (g_iface,
206 g_param_spec_boolean ("show-not-found",
207 P_("Show Not Found"),
208 P_("Whether the items pointing to unavailable resources should be displayed"),
210 GTK_PARAM_READWRITE));
212 * GtkRecentChooser:select-multiple:
214 * Allow the user to select multiple resources.
218 g_object_interface_install_property (g_iface,
219 g_param_spec_boolean ("select-multiple",
220 P_("Select Multiple"),
221 P_("Whether to allow multiple items to be selected"),
223 GTK_PARAM_READWRITE));
225 * GtkRecentChooser:local-only:
227 * Whether this #GtkRecentChooser should display only local (file:)
232 g_object_interface_install_property (g_iface,
233 g_param_spec_boolean ("local-only",
235 P_("Whether the selected resource(s) should be limited to local file: URIs"),
237 GTK_PARAM_READWRITE));
239 * GtkRecentChooser:limit:
241 * The maximum number of recently used resources to be displayed,
242 * or -1 to display all items. By default, the
243 * GtkSetting:gtk-recent-files-limit setting is respected: you can
244 * override that limit on a particular instance of #GtkRecentChooser
245 * by setting this property.
249 g_object_interface_install_property (g_iface,
250 g_param_spec_int ("limit",
252 P_("The maximum number of items to be displayed"),
256 GTK_PARAM_READWRITE));
258 * GtkRecentChooser:sort-type:
260 * Sorting order to be used when displaying the recently used resources.
264 g_object_interface_install_property (g_iface,
265 g_param_spec_enum ("sort-type",
267 P_("The sorting order of the items displayed"),
268 GTK_TYPE_RECENT_SORT_TYPE,
269 GTK_RECENT_SORT_NONE,
270 GTK_PARAM_READWRITE));
272 * GtkRecentChooser:filter:
274 * The #GtkRecentFilter object to be used when displaying
275 * the recently used resources.
279 g_object_interface_install_property (g_iface,
280 g_param_spec_object ("filter",
282 P_("The current filter for selecting which resources are displayed"),
283 GTK_TYPE_RECENT_FILTER,
284 GTK_PARAM_READWRITE));
288 gtk_recent_chooser_error_quark (void)
290 return g_quark_from_static_string ("gtk-recent-chooser-error-quark");
294 * _gtk_recent_chooser_get_recent_manager:
295 * @chooser: a #GtkRecentChooser
297 * Gets the #GtkRecentManager used by @chooser.
299 * Return value: the recent manager for @chooser.
304 _gtk_recent_chooser_get_recent_manager (GtkRecentChooser *chooser)
306 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
308 return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_recent_manager (chooser);
312 * gtk_recent_chooser_set_show_private:
313 * @chooser: a #GtkRecentChooser
314 * @show_private: %TRUE to show private items, %FALSE otherwise
316 * Whether to show recently used resources marked registered as private.
321 gtk_recent_chooser_set_show_private (GtkRecentChooser *chooser,
322 gboolean show_private)
324 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
326 g_object_set (chooser, "show-private", show_private, NULL);
330 * gtk_recent_chooser_get_show_private:
331 * @chooser: a #GtkRecentChooser
333 * Returns whether @chooser should display recently used resources
334 * registered as private.
336 * Return value: %TRUE if the recent chooser should show private items,
342 gtk_recent_chooser_get_show_private (GtkRecentChooser *chooser)
344 gboolean show_private;
346 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
348 g_object_get (chooser, "show-private", &show_private, NULL);
354 * gtk_recent_chooser_set_show_not_found:
355 * @chooser: a #GtkRecentChooser
356 * @show_not_found: whether to show the local items we didn't find
358 * Sets whether @chooser should display the recently used resources that
359 * it didn't find. This only applies to local resources.
364 gtk_recent_chooser_set_show_not_found (GtkRecentChooser *chooser,
365 gboolean show_not_found)
367 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
369 g_object_set (chooser, "show-not-found", show_not_found, NULL);
373 * gtk_recent_chooser_get_show_not_found:
374 * @chooser: a #GtkRecentChooser
376 * Retrieves whether @chooser should show the recently used resources that
379 * Return value: %TRUE if the resources not found should be displayed, and
385 gtk_recent_chooser_get_show_not_found (GtkRecentChooser *chooser)
387 gboolean show_not_found;
389 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
391 g_object_get (chooser, "show-not-found", &show_not_found, NULL);
393 return show_not_found;
397 * gtk_recent_chooser_set_show_icons:
398 * @chooser: a #GtkRecentChooser
399 * @show_icons: whether to show an icon near the resource
401 * Sets whether @chooser should show an icon near the resource when
407 gtk_recent_chooser_set_show_icons (GtkRecentChooser *chooser,
410 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
412 g_object_set (chooser, "show-icons", show_icons, NULL);
416 * gtk_recent_chooser_get_show_icons:
417 * @chooser: a #GtkRecentChooser
419 * Retrieves whether @chooser should show an icon near the resource.
421 * Return value: %TRUE if the icons should be displayed, %FALSE otherwise.
426 gtk_recent_chooser_get_show_icons (GtkRecentChooser *chooser)
430 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
432 g_object_get (chooser, "show-icons", &show_icons, NULL);
438 * gtk_recent_chooser_set_select_multiple:
439 * @chooser: a #GtkRecentChooser
440 * @select_multiple: %TRUE if @chooser can select more than one item
442 * Sets whether @chooser can select multiple items.
447 gtk_recent_chooser_set_select_multiple (GtkRecentChooser *chooser,
448 gboolean select_multiple)
450 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
452 g_object_set (chooser, "select-multiple", select_multiple, NULL);
456 * gtk_recent_chooser_get_select_multiple:
457 * @chooser: a #GtkRecentChooser
459 * Gets whether @chooser can select multiple items.
461 * Return value: %TRUE if @chooser can select more than one item.
466 gtk_recent_chooser_get_select_multiple (GtkRecentChooser *chooser)
468 gboolean select_multiple;
470 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
472 g_object_get (chooser, "select-multiple", &select_multiple, NULL);
474 return select_multiple;
478 * gtk_recent_chooser_set_local_only:
479 * @chooser: a #GtkRecentChooser
480 * @local_only: %TRUE if only local files can be shown
482 * Sets whether only local resources, that is resources using the file:// URI
483 * scheme, should be shown in the recently used resources selector. If
484 * @local_only is %TRUE (the default) then the shown resources are guaranteed
485 * to be accessible through the operating system native file system.
490 gtk_recent_chooser_set_local_only (GtkRecentChooser *chooser,
493 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
495 g_object_set (chooser, "local-only", local_only, NULL);
499 * gtk_recent_chooser_get_local_only:
500 * @chooser: a #GtkRecentChooser
502 * Gets whether only local resources should be shown in the recently used
503 * resources selector. See gtk_recent_chooser_set_local_only()
505 * Return value: %TRUE if only local resources should be shown.
510 gtk_recent_chooser_get_local_only (GtkRecentChooser *chooser)
514 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
516 g_object_get (chooser, "local-only", &local_only, NULL);
522 * gtk_recent_chooser_set_limit:
523 * @chooser: a #GtkRecentChooser
524 * @limit: a positive integer, or -1 for all items
526 * Sets the number of items that should be returned by
527 * gtk_recent_chooser_get_items() and gtk_recent_chooser_get_uris().
532 gtk_recent_chooser_set_limit (GtkRecentChooser *chooser,
535 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
537 g_object_set (chooser, "limit", limit, NULL);
541 * gtk_recent_chooser_get_limit:
542 * @chooser: a #GtkRecentChooser
544 * Gets the number of items returned by gtk_recent_chooser_get_items()
545 * and gtk_recent_chooser_get_uris().
547 * Return value: A positive integer, or -1 meaning that all items are
553 gtk_recent_chooser_get_limit (GtkRecentChooser *chooser)
557 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), 10);
559 g_object_get (chooser, "limit", &limit, NULL);
565 * gtk_recent_chooser_set_show_tips:
566 * @chooser: a #GtkRecentChooser
567 * @show_tips: %TRUE if tooltips should be shown
569 * Sets whether to show a tooltips containing the full path of each
570 * recently used resource in a #GtkRecentChooser widget.
575 gtk_recent_chooser_set_show_tips (GtkRecentChooser *chooser,
578 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
580 g_object_set (chooser, "show-tips", show_tips, NULL);
584 * gtk_recent_chooser_get_show_tips:
585 * @chooser: a #GtkRecentChooser
587 * Gets whether @chooser should display tooltips containing the full path
588 * of a recently user resource.
590 * Return value: %TRUE if the recent chooser should show tooltips,
596 gtk_recent_chooser_get_show_tips (GtkRecentChooser *chooser)
600 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
602 g_object_get (chooser, "show-tips", &show_tips, NULL);
608 recent_chooser_has_show_numbers (GtkRecentChooser *chooser)
612 /* This is the result of a minor screw up: the "show-numbers" property
613 * was removed from the GtkRecentChooser interface, but the accessors
614 * remained in the interface API; now we need to check whether the
615 * implementation of the RecentChooser interface has a "show-numbers"
616 * boolean property installed before accessing it, and avoid an
617 * assertion failure using a more graceful warning. This should really
618 * go away as soon as we can break API and remove these accessors.
620 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (chooser),
623 return (pspec && pspec->value_type == G_TYPE_BOOLEAN);
627 * gtk_recent_chooser_set_sort_type:
628 * @chooser: a #GtkRecentChooser
629 * @sort_type: sort order that the chooser should use
631 * Changes the sorting order of the recently used resources list displayed by
637 gtk_recent_chooser_set_sort_type (GtkRecentChooser *chooser,
638 GtkRecentSortType sort_type)
640 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
642 g_object_set (chooser, "sort-type", sort_type, NULL);
646 * gtk_recent_chooser_get_sort_type:
647 * @chooser: a #GtkRecentChooser
649 * Gets the value set by gtk_recent_chooser_set_sort_type().
651 * Return value: the sorting order of the @chooser.
656 gtk_recent_chooser_get_sort_type (GtkRecentChooser *chooser)
658 GtkRecentSortType sort_type;
660 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), GTK_RECENT_SORT_NONE);
662 g_object_get (chooser, "sort-type", &sort_type, NULL);
668 * gtk_recent_chooser_set_sort_func:
669 * @chooser: a #GtkRecentChooser
670 * @sort_func: the comparison function
671 * @sort_data: (allow-none): user data to pass to @sort_func, or %NULL
672 * @data_destroy: (allow-none): destroy notifier for @sort_data, or %NULL
674 * Sets the comparison function used when sorting to be @sort_func. If
675 * the @chooser has the sort type set to #GTK_RECENT_SORT_CUSTOM then
676 * the chooser will sort using this function.
678 * To the comparison function will be passed two #GtkRecentInfo structs and
679 * @sort_data; @sort_func should return a positive integer if the first
680 * item comes before the second, zero if the two items are equal and
681 * a negative integer if the first item comes after the second.
686 gtk_recent_chooser_set_sort_func (GtkRecentChooser *chooser,
687 GtkRecentSortFunc sort_func,
689 GDestroyNotify data_destroy)
691 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
693 GTK_RECENT_CHOOSER_GET_IFACE (chooser)->set_sort_func (chooser,
700 * gtk_recent_chooser_set_current_uri:
701 * @chooser: a #GtkRecentChooser
703 * @error: (allow-none): return location for a #GError, or %NULL
705 * Sets @uri as the current URI for @chooser.
707 * Return value: %TRUE if the URI was found.
712 gtk_recent_chooser_set_current_uri (GtkRecentChooser *chooser,
716 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
718 return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->set_current_uri (chooser, uri, error);
722 * gtk_recent_chooser_get_current_uri:
723 * @chooser: a #GtkRecentChooser
725 * Gets the URI currently selected by @chooser.
727 * Return value: a newly allocated string holding a URI.
732 gtk_recent_chooser_get_current_uri (GtkRecentChooser *chooser)
734 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
736 return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_current_uri (chooser);
740 * gtk_recent_chooser_get_current_item:
741 * @chooser: a #GtkRecentChooser
743 * Gets the #GtkRecentInfo currently selected by @chooser.
745 * Return value: a #GtkRecentInfo. Use gtk_recent_info_unref() when
746 * when you have finished using it.
751 gtk_recent_chooser_get_current_item (GtkRecentChooser *chooser)
753 GtkRecentManager *manager;
754 GtkRecentInfo *retval;
757 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
759 uri = gtk_recent_chooser_get_current_uri (chooser);
763 manager = _gtk_recent_chooser_get_recent_manager (chooser);
764 retval = gtk_recent_manager_lookup_item (manager, uri, NULL);
771 * gtk_recent_chooser_select_uri:
772 * @chooser: a #GtkRecentChooser
774 * @error: (allow-none): return location for a #GError, or %NULL
776 * Selects @uri inside @chooser.
778 * Return value: %TRUE if @uri was found.
783 gtk_recent_chooser_select_uri (GtkRecentChooser *chooser,
787 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
789 return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->select_uri (chooser, uri, error);
793 * gtk_recent_chooser_unselect_uri:
794 * @chooser: a #GtkRecentChooser
797 * Unselects @uri inside @chooser.
802 gtk_recent_chooser_unselect_uri (GtkRecentChooser *chooser,
805 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
807 GTK_RECENT_CHOOSER_GET_IFACE (chooser)->unselect_uri (chooser, uri);
811 * gtk_recent_chooser_select_all:
812 * @chooser: a #GtkRecentChooser
814 * Selects all the items inside @chooser, if the @chooser supports
815 * multiple selection.
820 gtk_recent_chooser_select_all (GtkRecentChooser *chooser)
822 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
824 GTK_RECENT_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
828 * gtk_recent_chooser_unselect_all:
829 * @chooser: a #GtkRecentChooser
831 * Unselects all the items inside @chooser.
836 gtk_recent_chooser_unselect_all (GtkRecentChooser *chooser)
838 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
840 GTK_RECENT_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
844 * gtk_recent_chooser_get_items:
845 * @chooser: a #GtkRecentChooser
847 * Gets the list of recently used resources in form of #GtkRecentInfo objects.
849 * The return value of this function is affected by the "sort-type" and
850 * "limit" properties of @chooser.
852 * Return value: (element-type GtkRecentInfo) (transfer full): A newly allocated
853 * list of #GtkRecentInfo objects. You should
854 * use gtk_recent_info_unref() on every item of the list, and then free
855 * the list itself using g_list_free().
860 gtk_recent_chooser_get_items (GtkRecentChooser *chooser)
862 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
864 return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_items (chooser);
868 * gtk_recent_chooser_get_uris:
869 * @chooser: a #GtkRecentChooser
870 * @length: (allow-none): return location for a the length of the URI list, or %NULL
872 * Gets the URI of the recently used resources.
874 * The return value of this function is affected by the "sort-type" and "limit"
875 * properties of @chooser.
877 * Since the returned array is %NULL terminated, @length may be %NULL.
879 * Return value: A newly allocated, %NULL terminated array of strings. Use
880 * g_strfreev() to free it.
885 gtk_recent_chooser_get_uris (GtkRecentChooser *chooser,
892 items = gtk_recent_chooser_get_items (chooser);
894 n_items = g_list_length (items);
895 retval = g_new0 (gchar *, n_items + 1);
897 for (l = items, i = 0; l != NULL; l = l->next)
899 GtkRecentInfo *info = (GtkRecentInfo *) l->data;
902 g_assert (info != NULL);
904 uri = gtk_recent_info_get_uri (info);
905 g_assert (uri != NULL);
907 retval[i++] = g_strdup (uri);
914 g_list_foreach (items,
915 (GFunc) gtk_recent_info_unref,
923 * gtk_recent_chooser_add_filter:
924 * @chooser: a #GtkRecentChooser
925 * @filter: a #GtkRecentFilter
927 * Adds @filter to the list of #GtkRecentFilter objects held by @chooser.
929 * If no previous filter objects were defined, this function will call
930 * gtk_recent_chooser_set_filter().
935 gtk_recent_chooser_add_filter (GtkRecentChooser *chooser,
936 GtkRecentFilter *filter)
938 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
939 g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
941 GTK_RECENT_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
945 * gtk_recent_chooser_remove_filter:
946 * @chooser: a #GtkRecentChooser
947 * @filter: a #GtkRecentFilter
949 * Removes @filter from the list of #GtkRecentFilter objects held by @chooser.
954 gtk_recent_chooser_remove_filter (GtkRecentChooser *chooser,
955 GtkRecentFilter *filter)
957 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
958 g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
960 GTK_RECENT_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
964 * gtk_recent_chooser_list_filters:
965 * @chooser: a #GtkRecentChooser
967 * Gets the #GtkRecentFilter objects held by @chooser.
969 * Return value: (element-type GtkRecentFilter) (transfer container): A singly linked list
970 * of #GtkRecentFilter objects. You
971 * should just free the returned list using g_slist_free().
976 gtk_recent_chooser_list_filters (GtkRecentChooser *chooser)
978 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
980 return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
984 * gtk_recent_chooser_set_filter:
985 * @chooser: a #GtkRecentChooser
986 * @filter: a #GtkRecentFilter
988 * Sets @filter as the current #GtkRecentFilter object used by @chooser
989 * to affect the displayed recently used resources.
994 gtk_recent_chooser_set_filter (GtkRecentChooser *chooser,
995 GtkRecentFilter *filter)
997 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
998 g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
1000 g_object_set (G_OBJECT (chooser), "filter", filter, NULL);
1004 * gtk_recent_chooser_get_filter:
1005 * @chooser: a #GtkRecentChooser
1007 * Gets the #GtkRecentFilter object currently used by @chooser to affect
1008 * the display of the recently used resources.
1010 * Return value: a #GtkRecentFilter object.
1015 gtk_recent_chooser_get_filter (GtkRecentChooser *chooser)
1017 GtkRecentFilter *filter;
1019 g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
1021 g_object_get (G_OBJECT (chooser), "filter", &filter, NULL);
1023 /* we need this hack because g_object_get() increases the refcount
1024 * of the returned object; see also gtk_file_chooser_get_filter()
1025 * inside gtkfilechooser.c
1028 g_object_unref (filter);
1034 _gtk_recent_chooser_item_activated (GtkRecentChooser *chooser)
1036 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
1038 g_signal_emit (chooser, chooser_signals[ITEM_ACTIVATED], 0);
1042 _gtk_recent_chooser_selection_changed (GtkRecentChooser *chooser)
1044 g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
1046 g_signal_emit (chooser, chooser_signals[SELECTION_CHANGED], 0);
1050 _gtk_recent_chooser_update (GtkActivatable *activatable,
1052 const gchar *property_name)
1054 GtkRecentChooser *recent_chooser = GTK_RECENT_CHOOSER (activatable);
1055 GtkRecentChooser *action_chooser = GTK_RECENT_CHOOSER (action);
1056 GtkRecentAction *recent_action = GTK_RECENT_ACTION (action);
1058 if (strcmp (property_name, "show-numbers") == 0 && recent_chooser_has_show_numbers (recent_chooser))
1059 g_object_set (recent_chooser, "show-numbers",
1060 gtk_recent_action_get_show_numbers (recent_action), NULL);
1061 else if (strcmp (property_name, "show-private") == 0)
1062 gtk_recent_chooser_set_show_private (recent_chooser, gtk_recent_chooser_get_show_private (action_chooser));
1063 else if (strcmp (property_name, "show-not-found") == 0)
1064 gtk_recent_chooser_set_show_not_found (recent_chooser, gtk_recent_chooser_get_show_not_found (action_chooser));
1065 else if (strcmp (property_name, "show-tips") == 0)
1066 gtk_recent_chooser_set_show_tips (recent_chooser, gtk_recent_chooser_get_show_tips (action_chooser));
1067 else if (strcmp (property_name, "show-icons") == 0)
1068 gtk_recent_chooser_set_show_icons (recent_chooser, gtk_recent_chooser_get_show_icons (action_chooser));
1069 else if (strcmp (property_name, "limit") == 0)
1070 gtk_recent_chooser_set_limit (recent_chooser, gtk_recent_chooser_get_limit (action_chooser));
1071 else if (strcmp (property_name, "local-only") == 0)
1072 gtk_recent_chooser_set_local_only (recent_chooser, gtk_recent_chooser_get_local_only (action_chooser));
1073 else if (strcmp (property_name, "sort-type") == 0)
1074 gtk_recent_chooser_set_sort_type (recent_chooser, gtk_recent_chooser_get_sort_type (action_chooser));
1075 else if (strcmp (property_name, "filter") == 0)
1076 gtk_recent_chooser_set_filter (recent_chooser, gtk_recent_chooser_get_filter (action_chooser));
1080 _gtk_recent_chooser_sync_action_properties (GtkActivatable *activatable,
1083 GtkRecentChooser *recent_chooser = GTK_RECENT_CHOOSER (activatable);
1084 GtkRecentChooser *action_chooser = GTK_RECENT_CHOOSER (action);
1089 if (recent_chooser_has_show_numbers (recent_chooser))
1090 g_object_set (recent_chooser, "show-numbers",
1091 gtk_recent_action_get_show_numbers (GTK_RECENT_ACTION (action)),
1093 gtk_recent_chooser_set_show_private (recent_chooser, gtk_recent_chooser_get_show_private (action_chooser));
1094 gtk_recent_chooser_set_show_not_found (recent_chooser, gtk_recent_chooser_get_show_not_found (action_chooser));
1095 gtk_recent_chooser_set_show_tips (recent_chooser, gtk_recent_chooser_get_show_tips (action_chooser));
1096 gtk_recent_chooser_set_show_icons (recent_chooser, gtk_recent_chooser_get_show_icons (action_chooser));
1097 gtk_recent_chooser_set_limit (recent_chooser, gtk_recent_chooser_get_limit (action_chooser));
1098 gtk_recent_chooser_set_local_only (recent_chooser, gtk_recent_chooser_get_local_only (action_chooser));
1099 gtk_recent_chooser_set_sort_type (recent_chooser, gtk_recent_chooser_get_sort_type (action_chooser));
1100 gtk_recent_chooser_set_filter (recent_chooser, gtk_recent_chooser_get_filter (action_chooser));
1104 _gtk_recent_chooser_set_related_action (GtkRecentChooser *recent_chooser,
1107 GtkAction *prev_action;
1109 prev_action = g_object_get_qdata (G_OBJECT (recent_chooser), quark_gtk_related_action);
1111 if (prev_action == action)
1114 gtk_activatable_do_set_related_action (GTK_ACTIVATABLE (recent_chooser), action);
1115 g_object_set_qdata (G_OBJECT (recent_chooser), quark_gtk_related_action, action);
1119 _gtk_recent_chooser_get_related_action (GtkRecentChooser *recent_chooser)
1121 return g_object_get_qdata (G_OBJECT (recent_chooser), quark_gtk_related_action);
1124 /* The default for use-action-appearance is TRUE, so we try to set the
1125 * qdata backwards for this case.
1128 _gtk_recent_chooser_set_use_action_appearance (GtkRecentChooser *recent_chooser,
1129 gboolean use_appearance)
1132 gboolean use_action_appearance;
1134 action = g_object_get_qdata (G_OBJECT (recent_chooser), quark_gtk_related_action);
1135 use_action_appearance = !GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (recent_chooser), quark_gtk_use_action_appearance));
1137 if (use_action_appearance != use_appearance)
1140 g_object_set_qdata (G_OBJECT (recent_chooser), quark_gtk_use_action_appearance, GINT_TO_POINTER (!use_appearance));
1142 gtk_activatable_sync_action_properties (GTK_ACTIVATABLE (recent_chooser), action);
1147 _gtk_recent_chooser_get_use_action_appearance (GtkRecentChooser *recent_chooser)
1149 return !GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (recent_chooser), quark_gtk_use_action_appearance));
1152 #define __GTK_RECENT_CHOOSER_C__
1153 #include "gtkaliasdef.c"