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 private import glib.Str;
62 
63 
64 private import gobject.ObjectG;
65 
66 /**
67  * A GtkRecentFilter can be used to restrict the files being shown
68  * in a GtkRecentChooser. Files can be filtered based on their name
69  * (with gtk_recent_filter_add_pattern()), on their mime type (with
70  * gtk_file_filter_add_mime_type()), on the application that has
71  * registered them (with gtk_recent_filter_add_application()), or by
72  * a custom filter function (with gtk_recent_filter_add_custom()).
73  *
74  * Filtering by mime type handles aliasing and subclassing of mime
75  * types; e.g. a filter for text/plain also matches a file with mime
76  * type application/rtf, since application/rtf is a subclass of text/plain.
77  * Note that GtkRecentFilter allows wildcards for the subtype of a
78  * mime type, so you can e.g. filter for image/+*.
79  *
80  * Normally, filters are used by adding them to a GtkRecentChooser,
81  * see gtk_recent_chooser_add_filter(), but it is also possible to
82  * manually use a filter on a file with gtk_recent_filter_filter().
83  *
84  * Recently used files are supported since GTK+ 2.10.
85  *
86  * GtkRecentFilter as GtkBuildable
87  *
88  * The GtkRecentFilter implementation of the GtkBuildable interface
89  * supports adding rules using the <mime-types>, <patterns> and
90  * <applications> elements and listing the rules within. Specifying
91  * a <mime-type>, <pattern> or <application> is the same
92  * as calling gtk_recent_filter_add_mime_type(), gtk_recent_filter_add_pattern()
93  * or gtk_recent_filter_add_application().
94  *
95  * $(DDOC_COMMENT example)
96  */
97 public class RecentFilter : ObjectG
98 {
99 	
100 	/** the main Gtk struct */
101 	protected GtkRecentFilter* gtkRecentFilter;
102 	
103 	
104 	/** Get the main Gtk struct */
105 	public GtkRecentFilter* getRecentFilterStruct()
106 	{
107 		return gtkRecentFilter;
108 	}
109 	
110 	
111 	/** the main Gtk struct as a void* */
112 	protected override void* getStruct()
113 	{
114 		return cast(void*)gtkRecentFilter;
115 	}
116 	
117 	/**
118 	 * Sets our main struct and passes it to the parent class
119 	 */
120 	public this (GtkRecentFilter* gtkRecentFilter)
121 	{
122 		super(cast(GObject*)gtkRecentFilter);
123 		this.gtkRecentFilter = gtkRecentFilter;
124 	}
125 	
126 	protected override void setStruct(GObject* obj)
127 	{
128 		super.setStruct(obj);
129 		gtkRecentFilter = cast(GtkRecentFilter*)obj;
130 	}
131 	
132 	/**
133 	 */
134 	
135 	/**
136 	 * Creates a new GtkRecentFilter with no rules added to it.
137 	 * Such filter does not accept any recently used resources, so is not
138 	 * particularly useful until you add rules with
139 	 * gtk_recent_filter_add_pattern(), gtk_recent_filter_add_mime_type(),
140 	 * gtk_recent_filter_add_application(), gtk_recent_filter_add_age().
141 	 * Since 2.10
142 	 * Throws: ConstructionException GTK+ fails to create the object.
143 	 */
144 	public this ()
145 	{
146 		// GtkRecentFilter * gtk_recent_filter_new (void);
147 		auto p = gtk_recent_filter_new();
148 		if(p is null)
149 		{
150 			throw new ConstructionException("null returned by gtk_recent_filter_new()");
151 		}
152 		this(cast(GtkRecentFilter*) p);
153 	}
154 	
155 	/**
156 	 * Gets the human-readable name for the filter.
157 	 * See gtk_recent_filter_set_name().
158 	 * Since 2.10
159 	 * Returns: the name of the filter, or NULL. The returned string is owned by the filter object and should not be freed.
160 	 */
161 	public string getName()
162 	{
163 		// const gchar * gtk_recent_filter_get_name (GtkRecentFilter *filter);
164 		return Str.toString(gtk_recent_filter_get_name(gtkRecentFilter));
165 	}
166 	
167 	/**
168 	 * Sets the human-readable name of the filter; this is the string
169 	 * that will be displayed in the recently used resources selector
170 	 * user interface if there is a selectable list of filters.
171 	 * Since 2.10
172 	 * Params:
173 	 * name = then human readable name of filter
174 	 */
175 	public void setName(string name)
176 	{
177 		// void gtk_recent_filter_set_name (GtkRecentFilter *filter,  const gchar *name);
178 		gtk_recent_filter_set_name(gtkRecentFilter, Str.toStringz(name));
179 	}
180 	
181 	/**
182 	 * Adds a rule that allows resources based on their registered MIME type.
183 	 * Since 2.10
184 	 * Params:
185 	 * mimeType = a MIME type
186 	 */
187 	public void addMimeType(string mimeType)
188 	{
189 		// void gtk_recent_filter_add_mime_type (GtkRecentFilter *filter,  const gchar *mime_type);
190 		gtk_recent_filter_add_mime_type(gtkRecentFilter, Str.toStringz(mimeType));
191 	}
192 	
193 	/**
194 	 * Adds a rule that allows resources based on a pattern matching their
195 	 * display name.
196 	 * Since 2.10
197 	 * Params:
198 	 * pattern = a file pattern
199 	 */
200 	public void addPattern(string pattern)
201 	{
202 		// void gtk_recent_filter_add_pattern (GtkRecentFilter *filter,  const gchar *pattern);
203 		gtk_recent_filter_add_pattern(gtkRecentFilter, Str.toStringz(pattern));
204 	}
205 	
206 	/**
207 	 * Adds a rule allowing image files in the formats supported
208 	 * by GdkPixbuf.
209 	 * Since 2.10
210 	 */
211 	public void addPixbufFormats()
212 	{
213 		// void gtk_recent_filter_add_pixbuf_formats  (GtkRecentFilter *filter);
214 		gtk_recent_filter_add_pixbuf_formats(gtkRecentFilter);
215 	}
216 	
217 	/**
218 	 * Adds a rule that allows resources based on the name of the application
219 	 * that has registered them.
220 	 * Since 2.10
221 	 * Params:
222 	 * application = an application name
223 	 */
224 	public void addApplication(string application)
225 	{
226 		// void gtk_recent_filter_add_application (GtkRecentFilter *filter,  const gchar *application);
227 		gtk_recent_filter_add_application(gtkRecentFilter, Str.toStringz(application));
228 	}
229 	
230 	/**
231 	 * Adds a rule that allows resources based on the name of the group
232 	 * to which they belong
233 	 * Since 2.10
234 	 * Params:
235 	 * group = a group name
236 	 */
237 	public void addGroup(string group)
238 	{
239 		// void gtk_recent_filter_add_group (GtkRecentFilter *filter,  const gchar *group);
240 		gtk_recent_filter_add_group(gtkRecentFilter, Str.toStringz(group));
241 	}
242 	
243 	/**
244 	 * Adds a rule that allows resources based on their age - that is, the number
245 	 * of days elapsed since they were last modified.
246 	 * Since 2.10
247 	 * Params:
248 	 * days = number of days
249 	 */
250 	public void addAge(int days)
251 	{
252 		// void gtk_recent_filter_add_age (GtkRecentFilter *filter,  gint days);
253 		gtk_recent_filter_add_age(gtkRecentFilter, days);
254 	}
255 	
256 	/**
257 	 * Adds a rule to a filter that allows resources based on a custom callback
258 	 * function. The bitfield needed which is passed in provides information
259 	 * about what sorts of information that the filter function needs;
260 	 * this allows GTK+ to avoid retrieving expensive information when
261 	 * it isn't needed by the filter.
262 	 * Since 2.10
263 	 * Params:
264 	 * needed = bitfield of flags indicating the information that the custom
265 	 * filter function needs.
266 	 * func = callback function; if the function returns TRUE, then
267 	 * the file will be displayed.
268 	 * data = data to pass to func
269 	 * dataDestroy = function to call to free data when it is no longer needed.
270 	 */
271 	public void addCustom(GtkRecentFilterFlags needed, GtkRecentFilterFunc func, void* data, GDestroyNotify dataDestroy)
272 	{
273 		// void gtk_recent_filter_add_custom (GtkRecentFilter *filter,  GtkRecentFilterFlags needed,  GtkRecentFilterFunc func,  gpointer data,  GDestroyNotify data_destroy);
274 		gtk_recent_filter_add_custom(gtkRecentFilter, needed, func, data, dataDestroy);
275 	}
276 	
277 	/**
278 	 * Gets the fields that need to be filled in for the structure
279 	 * passed to gtk_recent_filter_filter()
280 	 * This function will not typically be used by applications; it
281 	 * is intended principally for use in the implementation of
282 	 * GtkRecentChooser.
283 	 * Since 2.10
284 	 * Returns: bitfield of flags indicating needed fields when calling gtk_recent_filter_filter()
285 	 */
286 	public GtkRecentFilterFlags getNeeded()
287 	{
288 		// GtkRecentFilterFlags gtk_recent_filter_get_needed (GtkRecentFilter *filter);
289 		return gtk_recent_filter_get_needed(gtkRecentFilter);
290 	}
291 	
292 	/**
293 	 * Tests whether a file should be displayed according to filter.
294 	 * The GtkRecentFilterInfo structure filter_info should include
295 	 * the fields returned from gtk_recent_filter_get_needed().
296 	 * This function will not typically be used by applications; it
297 	 * is intended principally for use in the implementation of
298 	 * GtkRecentChooser.
299 	 * Since 2.10
300 	 * Params:
301 	 * filter = a GtkRecentFilter
302 	 * filterInfo = a GtkRecentFilterInfo structure containing information
303 	 * about a recently used resource
304 	 * Returns: TRUE if the file should be displayed
305 	 */
306 	public int filter(GtkRecentFilterInfo* filterInfo)
307 	{
308 		// gboolean gtk_recent_filter_filter (GtkRecentFilter *filter,  const GtkRecentFilterInfo *filter_info);
309 		return gtk_recent_filter_filter(gtkRecentFilter, filterInfo);
310 	}
311 }