]> Pileus Git - ~andy/gtk/blob - gtk/gtkrecentfilter.h
Added GtkBuildable support for adding rules to GtkRecentFilter
[~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, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
22 #error "Only <gtk/gtk.h> can be included directly."
23 #endif
24
25 #ifndef __GTK_RECENT_FILTER_H__
26 #define __GTK_RECENT_FILTER_H__
27
28 #include <glib-object.h>
29
30 G_BEGIN_DECLS
31
32 #define GTK_TYPE_RECENT_FILTER          (gtk_recent_filter_get_type ())
33 #define GTK_RECENT_FILTER(obj)          (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_FILTER, GtkRecentFilter))
34 #define GTK_IS_RECENT_FILTER(obj)       (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_FILTER))
35
36 typedef struct _GtkRecentFilter         GtkRecentFilter;
37 typedef struct _GtkRecentFilterInfo     GtkRecentFilterInfo;
38
39 /**
40  * GtkRecentFilterFlags:
41  * @GTK_RECENT_FILTER_URI: the URI of the file being tested
42  * @GTK_RECENT_FILTER_DISPLAY_NAME: the string that will be used to
43  *  display the file in the recent chooser
44  * @GTK_RECENT_FILTER_MIME_TYPE: the mime type of the file
45  * @GTK_RECENT_FILTER_APPLICATION: the list of applications that have
46  *  registered the file
47  * @GTK_RECENT_FILTER_GROUP: the groups to which the file belongs to
48  * @GTK_RECENT_FILTER_AGE: the number of days elapsed since the file
49  *  has been registered
50  *
51  * These flags indicate what parts of a #GtkRecentFilterInfo struct
52  * are filled or need to be filled.
53  */
54 typedef enum {
55   GTK_RECENT_FILTER_URI          = 1 << 0,
56   GTK_RECENT_FILTER_DISPLAY_NAME = 1 << 1,
57   GTK_RECENT_FILTER_MIME_TYPE    = 1 << 2,
58   GTK_RECENT_FILTER_APPLICATION  = 1 << 3,
59   GTK_RECENT_FILTER_GROUP        = 1 << 4,
60   GTK_RECENT_FILTER_AGE          = 1 << 5
61 } GtkRecentFilterFlags;
62
63 /**
64  * GtkRecentFilterFunc:
65  * @filter_info: a #GtkRecentFilterInfo that is filled according
66  *  to the @needed flags passed to gtk_recent_filter_add_custom()
67  * @user_data: user data passed to gtk_recent_filter_add_custom()
68  *
69  * The type of function that is used with custom filters,
70  * see gtk_recent_filter_add_custom().
71  *
72  * Return value: %TRUE if the file should be displayed
73  */
74 typedef gboolean (*GtkRecentFilterFunc) (const GtkRecentFilterInfo *filter_info,
75                                          gpointer                   user_data);
76
77
78 /**
79  * GtkRecentFilterInfo:
80  *
81  * A GtkRecentFilterInfo struct is used
82  * to pass information about the tested file to gtk_recent_filter_filter().
83  */
84 struct _GtkRecentFilterInfo
85 {
86   GtkRecentFilterFlags contains;
87
88   const gchar *uri;
89   const gchar *display_name;
90   const gchar *mime_type;
91   const gchar **applications;
92   const gchar **groups;
93
94   gint age;
95 };
96
97 GType                 gtk_recent_filter_get_type (void) G_GNUC_CONST;
98
99 GtkRecentFilter *     gtk_recent_filter_new      (void);
100 void                  gtk_recent_filter_set_name (GtkRecentFilter *filter,
101                                                   const gchar     *name);
102 G_CONST_RETURN gchar *gtk_recent_filter_get_name (GtkRecentFilter *filter);
103
104 void gtk_recent_filter_add_mime_type      (GtkRecentFilter      *filter,
105                                            const gchar          *mime_type);
106 void gtk_recent_filter_add_pattern        (GtkRecentFilter      *filter,
107                                            const gchar          *pattern);
108 void gtk_recent_filter_add_pixbuf_formats (GtkRecentFilter      *filter);
109 void gtk_recent_filter_add_application    (GtkRecentFilter      *filter,
110                                            const gchar          *application);
111 void gtk_recent_filter_add_group          (GtkRecentFilter      *filter,
112                                            const gchar          *group);
113 void gtk_recent_filter_add_age            (GtkRecentFilter      *filter,
114                                            gint                  days);
115 void gtk_recent_filter_add_custom         (GtkRecentFilter      *filter,
116                                            GtkRecentFilterFlags  needed,
117                                            GtkRecentFilterFunc   func,
118                                            gpointer              data,
119                                            GDestroyNotify        data_destroy);
120
121 GtkRecentFilterFlags gtk_recent_filter_get_needed (GtkRecentFilter           *filter);
122 gboolean             gtk_recent_filter_filter     (GtkRecentFilter           *filter,
123                                                    const GtkRecentFilterInfo *filter_info);
124
125 G_END_DECLS
126
127 #endif /* ! __GTK_RECENT_FILTER_H__ */