Debian Codegraph @

gtk/src/recentfilter.hg

raw
1 /* Copyright (C) 2006 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 _CONFIGINCLUDE(gtkmmconfig.h)
18
19 #include <glibmm/object.h>
20
21 _DEFS(gtkmm,gtk)
22 _PINCLUDE(glibmm/private/object_p.h)
23
24 namespace Gtk
25 {
26
27 _WRAP_ENUM(RecentFilterFlags, GtkRecentFilterFlags, decl_prefix GTKMM_API)
28
29
30 /** RecentFilter can be used to restrict the files being shown
31 * in a RecentChooser. Files can be filtered based on their name
32 * (with add_pattern()), on their mime type (with add_mime_type()),
33 * on the application that has registered them (with add_application()),
34 * or by a custom filter function (with add_custom()).
35 *
36 * Filtering by mime type handles aliasing and subclassing of mime
37 * types; e.g. a filter for text/plain also matches a file with mime
38 * type application/rtf, since application/rtf is a subclass of text/plain.
39 * Note that RecentFilter allows wildcards for the subtype of a
40 * mime type, so you can e.g. filter for image/ *.
41 *
42 * Normally, filters are used by adding them to a RecentChooser,
43 * see RecentChooser::add_filter(), but it is also possible to
44 * manually use a filter on a file with filter().
45 *
46 * @newin{2,10}
47 *
48 * @ingroup RecentFiles
49 */
50 class GTKMM_API RecentFilter : public Glib::Object
51 {
52 _CLASS_GOBJECT(RecentFilter, GtkRecentFilter, GTK_RECENT_FILTER, Glib::Object, GObject, , , GTKMM_API)
53 _DERIVES_INITIALLY_UNOWNED()
54 protected:
55 _CTOR_DEFAULT
56
57 public:
58 _WRAP_CREATE()
59
60 _WRAP_METHOD(void set_name(const Glib::ustring& name), gtk_recent_filter_set_name)
61 _WRAP_METHOD(Glib::ustring get_name() const, gtk_recent_filter_get_name)
62
63 _WRAP_METHOD(void add_mime_type(const Glib::ustring& mime_type), gtk_recent_filter_add_mime_type)
64 _WRAP_METHOD(void add_pattern(const Glib::ustring& pattern), gtk_recent_filter_add_pattern)
65 _WRAP_METHOD(void add_pixbuf_formats(), gtk_recent_filter_add_pixbuf_formats)
66 _WRAP_METHOD(void add_application(const Glib::ustring& application), gtk_recent_filter_add_application)
67 _WRAP_METHOD(void add_group(const Glib::ustring& group), gtk_recent_filter_add_group)
68 _WRAP_METHOD(void add_age(int days), gtk_recent_filter_add_age)
69
70 /** A RecentFilter::Info class is used to pass information
71 * about the tested file to filter().
72 *
73 * - contains: Flags indicating which of the following fields need are filled
74 * - uri: the URI of the file being tested
75 * - display_name: the string that will be used to display the file in the recent chooser
76 * - mime_type: the mime type of the file
77 * - applications: the list of applications that have registered the file
78 * - groups: the groups to which the file belongs to
79 * - age: the number of days elapsed since the file has been registered
80 */
81 class Info
82 {
83 public:
84 Info();
85
86 ///This bitmask tells us which of the other variables contain useful information.
87 RecentFilterFlags contains;
88
89 Glib::ustring uri;
90 Glib::ustring display_name;
91 Glib::ustring mime_type;
92 std::list<Glib::ustring> applications;
93 std::list<Glib::ustring> groups;
94 int age;
95 };
96
97 /// For instance, bool on_custom(const Gtk::RecentFilter::Info& filter_info);
98 typedef sigc::slot<bool, const Info&> SlotCustom;
99
100 void add_custom(RecentFilterFlags needed, const SlotCustom& slot);
101 _IGNORE(gtk_recent_filter_add_custom)
102
103 _WRAP_METHOD(RecentFilterFlags get_needed() const, gtk_recent_filter_get_needed)
104
105 // Method is used by class RecentChooser implementors.
106 _IGNORE(gtk_recent_filter_filter)
107 //_WRAP_METHOD(bool filter(const GtkRecentFilterInfo* filter_info), gtk_recent_filter_filter)
108 };
109
110 } // namespace Gtk