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