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