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
27 * outFile = FileFilter
28 * strct = GtkFileFilter
51 module gtk
.FileFilter
;
57 import tango
.io
.Stdout
; // use the tango loging?
61 private import gtkc
.gtktypes
;
63 private import gtkc
.gtk
;
66 private import glib
.Str
;
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()
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
)
114 if ( gtkFileFilter
is null )
119 Stdout("struct gtkFileFilter is null on constructor").newline
;
123 printf("struct gtkFileFilter is null on constructor");
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, "*");
153 * a new GtkFileFilter
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.
169 * the human-readable-name for the filter, or NULL
170 * to remove any existing name.
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().
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.
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.
200 * name of a MIME type
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.
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
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.
245 * bitfield of flags indicating the information that the custom
246 * filter function needs.
248 * callback function; if the function returns TRUE, then
249 * the file will be displayed.
251 * data to pass to func
253 * function to call to free data when it is no longer needed.
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
271 * bitfield of flags indicating needed fields when
272 * calling gtk_file_filter_filter()
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
291 * a GtkFileFilterInfo structure containing information
294 * TRUE if the file should be displayed
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
);