1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD 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
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GtkRecentFilter.html
27  * outPack = gtk
28  * outFile = RecentFilter
29  * strct   = GtkRecentFilter
30  * realStrct=
31  * ctorStrct=
32  * clss    = RecentFilter
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_recent_filter_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * structWrap:
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module gtk.RecentFilter;
54 
55 public  import gtkc.gtktypes;
56 
57 private import gtkc.gtk;
58 private import glib.ConstructionException;
59 private import gobject.ObjectG;
60 
61 
62 private import glib.Str;
63 
64 
65 
66 private import gobject.ObjectG;
67 
68 /**
69  * A GtkRecentFilter can be used to restrict the files being shown
70  * in a GtkRecentChooser. Files can be filtered based on their name
71  * (with gtk_recent_filter_add_pattern()), on their mime type (with
72  * gtk_file_filter_add_mime_type()), on the application that has
73  * registered them (with gtk_recent_filter_add_application()), or by
74  * a custom filter function (with gtk_recent_filter_add_custom()).
75  *
76  * Filtering by mime type handles aliasing and subclassing of mime
77  * types; e.g. a filter for text/plain also matches a file with mime
78  * type application/rtf, since application/rtf is a subclass of text/plain.
79  * Note that GtkRecentFilter allows wildcards for the subtype of a
80  * mime type, so you can e.g. filter for image/+*.
81  *
82  * Normally, filters are used by adding them to a GtkRecentChooser,
83  * see gtk_recent_chooser_add_filter(), but it is also possible to
84  * manually use a filter on a file with gtk_recent_filter_filter().
85  *
86  * Recently used files are supported since GTK+ 2.10.
87  *
88  * GtkRecentFilter as GtkBuildable
89  *
90  * The GtkRecentFilter implementation of the GtkBuildable interface
91  * supports adding rules using the <mime-types>, <patterns> and
92  * <applications> elements and listing the rules within. Specifying
93  * a <mime-type>, <pattern> or <application> is the same
94  * as calling gtk_recent_filter_add_mime_type(), gtk_recent_filter_add_pattern()
95  * or gtk_recent_filter_add_application().
96  *
97  * $(DDOC_COMMENT example)
98  */
99 public class RecentFilter : ObjectG
100 {
101 	
102 	/** the main Gtk struct */
103 	protected GtkRecentFilter* gtkRecentFilter;
104 	
105 	
106 	public GtkRecentFilter* getRecentFilterStruct()
107 	{
108 		return gtkRecentFilter;
109 	}
110 	
111 	
112 	/** the main Gtk struct as a void* */
113 	protected override void* getStruct()
114 	{
115 		return cast(void*)gtkRecentFilter;
116 	}
117 	
118 	/**
119 	 * Sets our main struct and passes it to the parent class
120 	 */
121 	public this (GtkRecentFilter* gtkRecentFilter)
122 	{
123 		super(cast(GObject*)gtkRecentFilter);
124 		this.gtkRecentFilter = gtkRecentFilter;
125 	}
126 	
127 	protected override void setStruct(GObject* obj)
128 	{
129 		super.setStruct(obj);
130 		gtkRecentFilter = cast(GtkRecentFilter*)obj;
131 	}
132 	
133 	/**
134 	 */
135 	
136 	/**
137 	 * Creates a new GtkRecentFilter with no rules added to it.
138 	 * Such filter does not accept any recently used resources, so is not
139 	 * particularly useful until you add rules with
140 	 * gtk_recent_filter_add_pattern(), gtk_recent_filter_add_mime_type(),
141 	 * gtk_recent_filter_add_application(), gtk_recent_filter_add_age().
142 	 * Since 2.10
143 	 * Throws: ConstructionException GTK+ fails to create the object.
144 	 */
145 	public this ()
146 	{
147 		// GtkRecentFilter * gtk_recent_filter_new (void);
148 		auto p = gtk_recent_filter_new();
149 		if(p is null)
150 		{
151 			throw new ConstructionException("null returned by gtk_recent_filter_new()");
152 		}
153 		this(cast(GtkRecentFilter*) p);
154 	}
155 	
156 	/**
157 	 * Gets the human-readable name for the filter.
158 	 * See gtk_recent_filter_set_name().
159 	 * Since 2.10
160 	 * Returns: the name of the filter, or NULL. The returned string is owned by the filter object and should not be freed.
161 	 */
162 	public string getName()
163 	{
164 		// const gchar * gtk_recent_filter_get_name (GtkRecentFilter *filter);
165 		return Str.toString(gtk_recent_filter_get_name(gtkRecentFilter));
166 	}
167 	
168 	/**
169 	 * Sets the human-readable name of the filter; this is the string
170 	 * that will be displayed in the recently used resources selector
171 	 * user interface if there is a selectable list of filters.
172 	 * Since 2.10
173 	 * Params:
174 	 * name = then human readable name of filter
175 	 */
176 	public void setName(string name)
177 	{
178 		// void gtk_recent_filter_set_name (GtkRecentFilter *filter,  const gchar *name);
179 		gtk_recent_filter_set_name(gtkRecentFilter, Str.toStringz(name));
180 	}
181 	
182 	/**
183 	 * Adds a rule that allows resources based on their registered MIME type.
184 	 * Since 2.10
185 	 * Params:
186 	 * mimeType = a MIME type
187 	 */
188 	public void addMimeType(string mimeType)
189 	{
190 		// void gtk_recent_filter_add_mime_type (GtkRecentFilter *filter,  const gchar *mime_type);
191 		gtk_recent_filter_add_mime_type(gtkRecentFilter, Str.toStringz(mimeType));
192 	}
193 	
194 	/**
195 	 * Adds a rule that allows resources based on a pattern matching their
196 	 * display name.
197 	 * Since 2.10
198 	 * Params:
199 	 * pattern = a file pattern
200 	 */
201 	public void addPattern(string pattern)
202 	{
203 		// void gtk_recent_filter_add_pattern (GtkRecentFilter *filter,  const gchar *pattern);
204 		gtk_recent_filter_add_pattern(gtkRecentFilter, Str.toStringz(pattern));
205 	}
206 	
207 	/**
208 	 * Adds a rule allowing image files in the formats supported
209 	 * by GdkPixbuf.
210 	 * Since 2.10
211 	 */
212 	public void addPixbufFormats()
213 	{
214 		// void gtk_recent_filter_add_pixbuf_formats  (GtkRecentFilter *filter);
215 		gtk_recent_filter_add_pixbuf_formats(gtkRecentFilter);
216 	}
217 	
218 	/**
219 	 * Adds a rule that allows resources based on the name of the application
220 	 * that has registered them.
221 	 * Since 2.10
222 	 * Params:
223 	 * application = an application name
224 	 */
225 	public void addApplication(string application)
226 	{
227 		// void gtk_recent_filter_add_application (GtkRecentFilter *filter,  const gchar *application);
228 		gtk_recent_filter_add_application(gtkRecentFilter, Str.toStringz(application));
229 	}
230 	
231 	/**
232 	 * Adds a rule that allows resources based on the name of the group
233 	 * to which they belong
234 	 * Since 2.10
235 	 * Params:
236 	 * group = a group name
237 	 */
238 	public void addGroup(string group)
239 	{
240 		// void gtk_recent_filter_add_group (GtkRecentFilter *filter,  const gchar *group);
241 		gtk_recent_filter_add_group(gtkRecentFilter, Str.toStringz(group));
242 	}
243 	
244 	/**
245 	 * Adds a rule that allows resources based on their age - that is, the number
246 	 * of days elapsed since they were last modified.
247 	 * Since 2.10
248 	 * Params:
249 	 * days = number of days
250 	 */
251 	public void addAge(int days)
252 	{
253 		// void gtk_recent_filter_add_age (GtkRecentFilter *filter,  gint days);
254 		gtk_recent_filter_add_age(gtkRecentFilter, days);
255 	}
256 	
257 	/**
258 	 * Adds a rule to a filter that allows resources based on a custom callback
259 	 * function. The bitfield needed which is passed in provides information
260 	 * about what sorts of information that the filter function needs;
261 	 * this allows GTK+ to avoid retrieving expensive information when
262 	 * it isn't needed by the filter.
263 	 * Since 2.10
264 	 * Params:
265 	 * needed = bitfield of flags indicating the information that the custom
266 	 * filter function needs.
267 	 * func = callback function; if the function returns TRUE, then
268 	 * the file will be displayed.
269 	 * data = data to pass to func
270 	 * dataDestroy = function to call to free data when it is no longer needed.
271 	 */
272 	public void addCustom(GtkRecentFilterFlags needed, GtkRecentFilterFunc func, void* data, GDestroyNotify dataDestroy)
273 	{
274 		// void gtk_recent_filter_add_custom (GtkRecentFilter *filter,  GtkRecentFilterFlags needed,  GtkRecentFilterFunc func,  gpointer data,  GDestroyNotify data_destroy);
275 		gtk_recent_filter_add_custom(gtkRecentFilter, needed, func, data, dataDestroy);
276 	}
277 	
278 	/**
279 	 * Gets the fields that need to be filled in for the structure
280 	 * passed to gtk_recent_filter_filter()
281 	 * This function will not typically be used by applications; it
282 	 * is intended principally for use in the implementation of
283 	 * GtkRecentChooser.
284 	 * Since 2.10
285 	 * Returns: bitfield of flags indicating needed fields when calling gtk_recent_filter_filter()
286 	 */
287 	public GtkRecentFilterFlags getNeeded()
288 	{
289 		// GtkRecentFilterFlags gtk_recent_filter_get_needed (GtkRecentFilter *filter);
290 		return gtk_recent_filter_get_needed(gtkRecentFilter);
291 	}
292 	
293 	/**
294 	 * Tests whether a file should be displayed according to filter.
295 	 * The GtkRecentFilterInfo structure filter_info should include
296 	 * the fields returned from gtk_recent_filter_get_needed().
297 	 * This function will not typically be used by applications; it
298 	 * is intended principally for use in the implementation of
299 	 * GtkRecentChooser.
300 	 * Since 2.10
301 	 * Params:
302 	 * filter = a GtkRecentFilter
303 	 * filterInfo = a GtkRecentFilterInfo structure containing information
304 	 * about a recently used resource
305 	 * Returns: TRUE if the file should be displayed
306 	 */
307 	public int filter(GtkRecentFilterInfo* filterInfo)
308 	{
309 		// gboolean gtk_recent_filter_filter (GtkRecentFilter *filter,  const GtkRecentFilterInfo *filter_info);
310 		return gtk_recent_filter_filter(gtkRecentFilter, filterInfo);
311 	}
312 }