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  = GtkFileFilter.html
27  * outPack = gtk
28  * outFile = FileFilter
29  * strct   = GtkFileFilter
30  * realStrct=
31  * ctorStrct=
32  * clss    = FileFilter
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- BuildableIF
40  * prefixes:
41  * 	- gtk_file_filter_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- gtk.BuildableT
49  * 	- gtk.BuildableIF
50  * structWrap:
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module gtk.FileFilter;
57 
58 public  import gtkc.gtktypes;
59 
60 private import gtkc.gtk;
61 private import glib.ConstructionException;
62 private import gobject.ObjectG;
63 
64 
65 private import glib.Str;
66 private import gtk.BuildableT;
67 private import gtk.BuildableIF;
68 
69 
70 
71 private import gobject.ObjectG;
72 
73 /**
74  * A GtkFileFilter can be used to restrict the files being shown in a
75  * GtkFileChooser. Files can be filtered based on their name (with
76  * gtk_file_filter_add_pattern()), on their mime type (with
77  * gtk_file_filter_add_mime_type()), or by a custom filter function
78  * (with gtk_file_filter_add_custom()).
79  *
80  * Filtering by mime types handles aliasing and subclassing of mime
81  * types; e.g. a filter for text/plain also matches a file with mime
82  * type application/rtf, since application/rtf is a subclass of
83  * text/plain. Note that GtkFileFilter allows wildcards for the
84  * subtype of a mime type, so you can e.g. filter for image/+*.
85  *
86  * Normally, filters are used by adding them to a GtkFileChooser,
87  * see gtk_file_chooser_add_filter(), but it is also possible
88  * to manually use a filter on a file with gtk_file_filter_filter().
89  *
90  * GtkFileFilter as GtkBuildable
91  *
92  * The GtkFileFilter implementation of the GtkBuildable interface
93  * supports adding rules using the <mime-types>, <patterns> and
94  * <applications> elements and listing the rules within. Specifying
95  * a <mime-type> or <pattern> is the same
96  * as calling gtk_recent_filter_add_mime_type() or gtk_recent_filter_add_pattern()
97  *
98  * $(DDOC_COMMENT example)
99  */
100 public class FileFilter : ObjectG, BuildableIF
101 {
102 	
103 	/** the main Gtk struct */
104 	protected GtkFileFilter* gtkFileFilter;
105 	
106 	
107 	public GtkFileFilter* getFileFilterStruct()
108 	{
109 		return gtkFileFilter;
110 	}
111 	
112 	
113 	/** the main Gtk struct as a void* */
114 	protected override void* getStruct()
115 	{
116 		return cast(void*)gtkFileFilter;
117 	}
118 	
119 	/**
120 	 * Sets our main struct and passes it to the parent class
121 	 */
122 	public this (GtkFileFilter* gtkFileFilter)
123 	{
124 		super(cast(GObject*)gtkFileFilter);
125 		this.gtkFileFilter = gtkFileFilter;
126 	}
127 	
128 	protected override void setStruct(GObject* obj)
129 	{
130 		super.setStruct(obj);
131 		gtkFileFilter = cast(GtkFileFilter*)obj;
132 	}
133 	
134 	// add the Buildable capabilities
135 	mixin BuildableT!(GtkFileFilter);
136 	
137 	/**
138 	 */
139 	
140 	/**
141 	 * Creates a new GtkFileFilter with no rules added to it.
142 	 * Such a filter doesn't accept any files, so is not
143 	 * particularly useful until you add rules with
144 	 * gtk_file_filter_add_mime_type(), gtk_file_filter_add_pattern(),
145 	 * or gtk_file_filter_add_custom(). To create a filter
146 	 * Since 2.4
147 	 * Throws: ConstructionException GTK+ fails to create the object.
148 	 */
149 	public this ()
150 	{
151 		// GtkFileFilter * gtk_file_filter_new (void);
152 		auto p = gtk_file_filter_new();
153 		if(p is null)
154 		{
155 			throw new ConstructionException("null returned by gtk_file_filter_new()");
156 		}
157 		this(cast(GtkFileFilter*) p);
158 	}
159 	
160 	/**
161 	 * Sets the human-readable name of the filter; this is the string
162 	 * that will be displayed in the file selector user interface if
163 	 * there is a selectable list of filters.
164 	 * Since 2.4
165 	 * Params:
166 	 * name = the human-readable-name for the filter, or NULL
167 	 * to remove any existing name. [allow-none]
168 	 */
169 	public void setName(string name)
170 	{
171 		// void gtk_file_filter_set_name (GtkFileFilter *filter,  const gchar *name);
172 		gtk_file_filter_set_name(gtkFileFilter, Str.toStringz(name));
173 	}
174 	
175 	/**
176 	 * Gets the human-readable name for the filter. See gtk_file_filter_set_name().
177 	 * Since 2.4
178 	 * Returns: The human-readable name of the filter, or NULL. This value is owned by GTK+ and must not be modified or freed.
179 	 */
180 	public string getName()
181 	{
182 		// const gchar * gtk_file_filter_get_name (GtkFileFilter *filter);
183 		return Str.toString(gtk_file_filter_get_name(gtkFileFilter));
184 	}
185 	
186 	/**
187 	 * Adds a rule allowing a given mime type to filter.
188 	 * Since 2.4
189 	 * Params:
190 	 * mimeType = name of a MIME type
191 	 */
192 	public void addMimeType(string mimeType)
193 	{
194 		// void gtk_file_filter_add_mime_type (GtkFileFilter *filter,  const gchar *mime_type);
195 		gtk_file_filter_add_mime_type(gtkFileFilter, Str.toStringz(mimeType));
196 	}
197 	
198 	/**
199 	 * Adds a rule allowing a shell style glob to a filter.
200 	 * Since 2.4
201 	 * Params:
202 	 * pattern = a shell style glob
203 	 */
204 	public void addPattern(string pattern)
205 	{
206 		// void gtk_file_filter_add_pattern (GtkFileFilter *filter,  const gchar *pattern);
207 		gtk_file_filter_add_pattern(gtkFileFilter, Str.toStringz(pattern));
208 	}
209 	
210 	/**
211 	 * Adds a rule allowing image files in the formats supported
212 	 * by GdkPixbuf.
213 	 * Since 2.6
214 	 */
215 	public void addPixbufFormats()
216 	{
217 		// void gtk_file_filter_add_pixbuf_formats (GtkFileFilter *filter);
218 		gtk_file_filter_add_pixbuf_formats(gtkFileFilter);
219 	}
220 	
221 	/**
222 	 * Adds rule to a filter that allows files based on a custom callback
223 	 * function. The bitfield needed which is passed in provides information
224 	 * about what sorts of information that the filter function needs;
225 	 * this allows GTK+ to avoid retrieving expensive information when
226 	 * it isn't needed by the filter.
227 	 * Since 2.4
228 	 * Params:
229 	 * needed = bitfield of flags indicating the information that the custom
230 	 * filter function needs.
231 	 * func = callback function; if the function returns TRUE, then
232 	 * the file will be displayed.
233 	 * data = data to pass to func
234 	 * notify = function to call to free data when it is no longer needed.
235 	 */
236 	public void addCustom(GtkFileFilterFlags needed, GtkFileFilterFunc func, void* data, GDestroyNotify notify)
237 	{
238 		// void gtk_file_filter_add_custom (GtkFileFilter *filter,  GtkFileFilterFlags needed,  GtkFileFilterFunc func,  gpointer data,  GDestroyNotify notify);
239 		gtk_file_filter_add_custom(gtkFileFilter, needed, func, data, notify);
240 	}
241 	
242 	/**
243 	 * Gets the fields that need to be filled in for the structure
244 	 * passed to gtk_file_filter_filter()
245 	 * This function will not typically be used by applications; it
246 	 * is intended principally for use in the implementation of
247 	 * GtkFileChooser.
248 	 * Since 2.4
249 	 * Returns: bitfield of flags indicating needed fields when calling gtk_file_filter_filter()
250 	 */
251 	public GtkFileFilterFlags getNeeded()
252 	{
253 		// GtkFileFilterFlags gtk_file_filter_get_needed (GtkFileFilter *filter);
254 		return gtk_file_filter_get_needed(gtkFileFilter);
255 	}
256 	
257 	/**
258 	 * Tests whether a file should be displayed according to filter.
259 	 * The GtkFileFilterInfo structure filter_info should include
260 	 * the fields returned from gtk_file_filter_get_needed().
261 	 * This function will not typically be used by applications; it
262 	 * is intended principally for use in the implementation of
263 	 * GtkFileChooser.
264 	 * Since 2.4
265 	 * Params:
266 	 * filter = a GtkFileFilter
267 	 * filterInfo = a GtkFileFilterInfo structure containing information
268 	 * about a file.
269 	 * Returns: TRUE if the file should be displayed
270 	 */
271 	public int filter(GtkFileFilterInfo* filterInfo)
272 	{
273 		// gboolean gtk_file_filter_filter (GtkFileFilter *filter,  const GtkFileFilterInfo *filter_info);
274 		return gtk_file_filter_filter(gtkFileFilter, filterInfo);
275 	}
276 }