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