alternative to assert
[gtkD.git] / gtkD / src / gtk / FileFilter.d
blob9d4935cc2d593829d8b0b558adcb3785ecee3d8f
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gtk-gtkfilefilter.html
26 * outPack = gtk
27 * outFile = FileFilter
28 * strct = GtkFileFilter
29 * realStrct=
30 * ctorStrct=
31 * clss = FileFilter
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_file_filter_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * structWrap:
47 * module aliases:
48 * local aliases:
51 module gtk.FileFilter;
53 version(noAssert)
55 version(Tango)
57 import tango.io.Stdout; // use the tango loging?
61 private import gtkc.gtktypes;
63 private import gtkc.gtk;
66 private import glib.Str;
71 /**
72 * Description
73 * A GtkFileFilter can be used to restrict the files being shown
74 * in a GtkFileChooser. Files can be filtered based on their name
75 * (with gtk_file_filter_add_pattern()), on their mime type (with
76 * gtk_file_filter_add_mime_type()), or by a custom filter function
77 * (with gtk_file_filter_add_custom()).
78 * Filtering by mime types handles aliasing and subclassing of mime
79 * types; e.g. a filter for text/plain also matches a file with mime
80 * type application/rtf, since application/rtf is a subclass of
81 * text/plain. Note that GtkFileFilter allows wildcards for the
82 * subtype of a mime type, so you can e.g. filter for image/+*.
83 * Normally, filters are used by adding them to a GtkFileChooser,
84 * see gtk_file_chooser_add_filter(), but it is also possible
85 * to manually use a filter on a file with gtk_file_filter_filter().
87 private import gtk.ObjectGtk;
88 public class FileFilter : ObjectGtk
91 /** the main Gtk struct */
92 protected GtkFileFilter* gtkFileFilter;
95 public GtkFileFilter* getFileFilterStruct()
97 return gtkFileFilter;
101 /** the main Gtk struct as a void* */
102 protected void* getStruct()
104 return cast(void*)gtkFileFilter;
108 * Sets our main struct and passes it to the parent class
110 public this (GtkFileFilter* gtkFileFilter)
112 version(noAssert)
114 if ( gtkFileFilter is null )
116 int zero = 0;
117 version(Tango)
119 Stdout("struct gtkFileFilter is null on constructor").newline;
121 else
123 printf("struct gtkFileFilter is null on constructor");
125 zero = zero / zero;
128 else
130 assert(gtkFileFilter !is null, "struct gtkFileFilter is null on constructor");
132 super(cast(GtkObject*)gtkFileFilter);
133 this.gtkFileFilter = gtkFileFilter;
144 * Creates a new GtkFileFilter with no rules added to it.
145 * Such a filter doesn't accept any files, so is not
146 * particularly useful until you add rules with
147 * gtk_file_filter_add_mime_type(), gtk_file_filter_add_pattern(),
148 * or gtk_file_filter_add_custom(). To create a filter
149 * that accepts any file, use:
150 * GtkFileFilter *filter = gtk_file_filter_new ();
151 * gtk_file_filter_add_pattern (filter, "*");
152 * Returns:
153 * a new GtkFileFilter
154 * Since 2.4
156 public this ()
158 // GtkFileFilter* gtk_file_filter_new (void);
159 this(cast(GtkFileFilter*)gtk_file_filter_new() );
163 * Sets the human-readable name of the filter; this is the string
164 * that will be displayed in the file selector user interface if
165 * there is a selectable list of filters.
166 * filter:
167 * a GtkFileFilter
168 * name:
169 * the human-readable-name for the filter, or NULL
170 * to remove any existing name.
171 * Since 2.4
173 public void setName(char[] name)
175 // void gtk_file_filter_set_name (GtkFileFilter *filter, const gchar *name);
176 gtk_file_filter_set_name(gtkFileFilter, Str.toStringz(name));
180 * Gets the human-readable name for the filter. See gtk_file_filter_set_name().
181 * filter:
182 * a GtkFileFilter
183 * Returns:
184 * The human-readable name of the filter,
185 * or NULL. This value is owned by GTK+ and must not
186 * be modified or freed.
187 * Since 2.4
189 public char[] getName()
191 // const gchar* gtk_file_filter_get_name (GtkFileFilter *filter);
192 return Str.toString(gtk_file_filter_get_name(gtkFileFilter) );
196 * Adds a rule allowing a given mime type to filter.
197 * filter:
198 * A GtkFileFilter
199 * mime_type:
200 * name of a MIME type
201 * Since 2.4
203 public void addMimeType(char[] mimeType)
205 // void gtk_file_filter_add_mime_type (GtkFileFilter *filter, const gchar *mime_type);
206 gtk_file_filter_add_mime_type(gtkFileFilter, Str.toStringz(mimeType));
210 * Adds a rule allowing a shell style glob to a filter.
211 * filter:
212 * a GtkFileFilter
213 * pattern:
214 * a shell style glob
215 * Since 2.4
217 public void addPattern(char[] pattern)
219 // void gtk_file_filter_add_pattern (GtkFileFilter *filter, const gchar *pattern);
220 gtk_file_filter_add_pattern(gtkFileFilter, Str.toStringz(pattern));
224 * Adds a rule allowing image files in the formats supported
225 * by GdkPixbuf.
226 * filter:
227 * a GtkFileFilter
228 * Since 2.6
230 public void addPixbufFormats()
232 // void gtk_file_filter_add_pixbuf_formats (GtkFileFilter *filter);
233 gtk_file_filter_add_pixbuf_formats(gtkFileFilter);
237 * Adds rule to a filter that allows files based on a custom callback
238 * function. The bitfield needed which is passed in provides information
239 * about what sorts of information that the filter function needs;
240 * this allows GTK+ to avoid retrieving expensive information when
241 * it isn't needed by the filter.
242 * filter:
243 * a GtkFileFilter
244 * needed:
245 * bitfield of flags indicating the information that the custom
246 * filter function needs.
247 * func:
248 * callback function; if the function returns TRUE, then
249 * the file will be displayed.
250 * data:
251 * data to pass to func
252 * notify:
253 * function to call to free data when it is no longer needed.
254 * Since 2.4
256 public void addCustom(GtkFileFilterFlags needed, GtkFileFilterFunc func, void* data, GDestroyNotify notify)
258 // void gtk_file_filter_add_custom (GtkFileFilter *filter, GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data, GDestroyNotify notify);
259 gtk_file_filter_add_custom(gtkFileFilter, needed, func, data, notify);
263 * Gets the fields that need to be filled in for the structure
264 * passed to gtk_file_filter_filter()
265 * This function will not typically be used by applications; it
266 * is intended principally for use in the implementation of
267 * GtkFileChooser.
268 * filter:
269 * a GtkFileFilter
270 * Returns:
271 * bitfield of flags indicating needed fields when
272 * calling gtk_file_filter_filter()
273 * Since 2.4
275 public GtkFileFilterFlags getNeeded()
277 // GtkFileFilterFlags gtk_file_filter_get_needed (GtkFileFilter *filter);
278 return gtk_file_filter_get_needed(gtkFileFilter);
282 * Tests whether a file should be displayed according to filter.
283 * The GtkFileFilterInfo structure filter_info should include
284 * the fields returned from gtk_file_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 * GtkFileChooser.
288 * filter:
289 * a GtkFileFilter
290 * filter_info:
291 * a GtkFileFilterInfo structure containing information
292 * about a file.
293 * Returns:
294 * TRUE if the file should be displayed
295 * Since 2.4
296 * See Also
297 * GtkFileChooser
299 public int filter(GtkFileFilterInfo* filterInfo)
301 // gboolean gtk_file_filter_filter (GtkFileFilter *filter, const GtkFileFilterInfo *filter_info);
302 return gtk_file_filter_filter(gtkFileFilter, filterInfo);