]> Pileus Git - ~andy/gtk/blob - gtk/gtkrecentfilter.h
stylecontext: Do invalidation on first resize container
[~andy/gtk] / gtk / gtkrecentfilter.h
1 /* GTK - The GIMP Toolkit
2  * gtkrecentfilter.h - Filter object for recently used resources
3  * Copyright (C) 2006, Emmanuele Bassi
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef __GTK_RECENT_FILTER_H__
20 #define __GTK_RECENT_FILTER_H__
21
22 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
23 #error "Only <gtk/gtk.h> can be included directly."
24 #endif
25
26 #include <glib-object.h>
27
28 G_BEGIN_DECLS
29
30 #define GTK_TYPE_RECENT_FILTER          (gtk_recent_filter_get_type ())
31 #define GTK_RECENT_FILTER(obj)          (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_FILTER, GtkRecentFilter))
32 #define GTK_IS_RECENT_FILTER(obj)       (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_FILTER))
33
34 typedef struct _GtkRecentFilter         GtkRecentFilter;
35 typedef struct _GtkRecentFilterInfo     GtkRecentFilterInfo;
36
37 /**
38  * GtkRecentFilterFlags:
39  * @GTK_RECENT_FILTER_URI: the URI of the file being tested
40  * @GTK_RECENT_FILTER_DISPLAY_NAME: the string that will be used to
41  *  display the file in the recent chooser
42  * @GTK_RECENT_FILTER_MIME_TYPE: the mime type of the file
43  * @GTK_RECENT_FILTER_APPLICATION: the list of applications that have
44  *  registered the file
45  * @GTK_RECENT_FILTER_GROUP: the groups to which the file belongs to
46  * @GTK_RECENT_FILTER_AGE: the number of days elapsed since the file
47  *  has been registered
48  *
49  * These flags indicate what parts of a #GtkRecentFilterInfo struct
50  * are filled or need to be filled.
51  */
52 typedef enum {
53   GTK_RECENT_FILTER_URI          = 1 << 0,
54   GTK_RECENT_FILTER_DISPLAY_NAME = 1 << 1,
55   GTK_RECENT_FILTER_MIME_TYPE    = 1 << 2,
56   GTK_RECENT_FILTER_APPLICATION  = 1 << 3,
57   GTK_RECENT_FILTER_GROUP        = 1 << 4,
58   GTK_RECENT_FILTER_AGE          = 1 << 5
59 } GtkRecentFilterFlags;
60
61 /**
62  * GtkRecentFilterFunc:
63  * @filter_info: a #GtkRecentFilterInfo that is filled according
64  *  to the @needed flags passed to gtk_recent_filter_add_custom()
65  * @user_data: user data passed to gtk_recent_filter_add_custom()
66  *
67  * The type of function that is used with custom filters,
68  * see gtk_recent_filter_add_custom().
69  *
70  * Return value: %TRUE if the file should be displayed
71  */
72 typedef gboolean (*GtkRecentFilterFunc) (const GtkRecentFilterInfo *filter_info,
73                                          gpointer                   user_data);
74
75
76 /**
77  * GtkRecentFilterInfo:
78  *
79  * A GtkRecentFilterInfo struct is used
80  * to pass information about the tested file to gtk_recent_filter_filter().
81  */
82 struct _GtkRecentFilterInfo
83 {
84   GtkRecentFilterFlags contains;
85
86   const gchar *uri;
87   const gchar *display_name;
88   const gchar *mime_type;
89   const gchar **applications;
90   const gchar **groups;
91
92   gint age;
93 };
94
95 GType                 gtk_recent_filter_get_type (void) G_GNUC_CONST;
96
97 GtkRecentFilter *     gtk_recent_filter_new      (void);
98 void                  gtk_recent_filter_set_name (GtkRecentFilter *filter,
99                                                   const gchar     *name);
100 const gchar *         gtk_recent_filter_get_name (GtkRecentFilter *filter);
101
102 void gtk_recent_filter_add_mime_type      (GtkRecentFilter      *filter,
103                                            const gchar          *mime_type);
104 void gtk_recent_filter_add_pattern        (GtkRecentFilter      *filter,
105                                            const gchar          *pattern);
106 void gtk_recent_filter_add_pixbuf_formats (GtkRecentFilter      *filter);
107 void gtk_recent_filter_add_application    (GtkRecentFilter      *filter,
108                                            const gchar          *application);
109 void gtk_recent_filter_add_group          (GtkRecentFilter      *filter,
110                                            const gchar          *group);
111 void gtk_recent_filter_add_age            (GtkRecentFilter      *filter,
112                                            gint                  days);
113 void gtk_recent_filter_add_custom         (GtkRecentFilter      *filter,
114                                            GtkRecentFilterFlags  needed,
115                                            GtkRecentFilterFunc   func,
116                                            gpointer              data,
117                                            GDestroyNotify        data_destroy);
118
119 GtkRecentFilterFlags gtk_recent_filter_get_needed (GtkRecentFilter           *filter);
120 gboolean             gtk_recent_filter_filter     (GtkRecentFilter           *filter,
121                                                    const GtkRecentFilterInfo *filter_info);
122
123 G_END_DECLS
124
125 #endif /* ! __GTK_RECENT_FILTER_H__ */