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 = 27 * outPack = gio 28 * outFile = FileAttributeMatcher 29 * strct = GFileAttributeMatcher 30 * realStrct= 31 * ctorStrct= 32 * clss = FileAttributeMatcher 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_file_attribute_matcher_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * structWrap: 48 * - GFileAttributeMatcher* -> FileAttributeMatcher 49 * module aliases: 50 * local aliases: 51 * overrides: 52 * - toString 53 */ 54 55 module gio.FileAttributeMatcher; 56 57 public import gtkc.giotypes; 58 59 private import gtkc.gio; 60 private import glib.ConstructionException; 61 private import gobject.ObjectG; 62 63 64 private import glib.Str; 65 66 67 68 private import gobject.Boxed; 69 70 /** 71 * Functionality for manipulating basic metadata for files. GFileInfo 72 * implements methods for getting information that all files should 73 * contain, and allows for manipulation of extended attributes. 74 * 75 * See GFileAttribute for more 76 * information on how GIO handles file attributes. 77 * 78 * To obtain a GFileInfo for a GFile, use g_file_query_info() (or its 79 * async variant). To obtain a GFileInfo for a file input or output 80 * stream, use g_file_input_stream_query_info() or 81 * g_file_output_stream_query_info() (or their async variants). 82 * 83 * To change the actual attributes of a file, you should then set the 84 * attribute in the GFileInfo and call g_file_set_attributes_from_info() 85 * or g_file_set_attributes_async() on a GFile. 86 * 87 * However, not all attributes can be changed in the file. For instance, 88 * the actual size of a file cannot be changed via g_file_info_set_size(). 89 * You may call g_file_query_settable_attributes() and 90 * g_file_query_writable_namespaces() to discover the settable attributes 91 * of a particular file at runtime. 92 * 93 * GFileAttributeMatcher allows for searching through a GFileInfo for 94 * attributes. 95 */ 96 public class FileAttributeMatcher : Boxed 97 { 98 99 /** the main Gtk struct */ 100 protected GFileAttributeMatcher* gFileAttributeMatcher; 101 102 103 public GFileAttributeMatcher* getFileAttributeMatcherStruct() 104 { 105 return gFileAttributeMatcher; 106 } 107 108 109 /** the main Gtk struct as a void* */ 110 protected void* getStruct() 111 { 112 return cast(void*)gFileAttributeMatcher; 113 } 114 115 /** 116 * Sets our main struct and passes it to the parent class 117 */ 118 public this (GFileAttributeMatcher* gFileAttributeMatcher) 119 { 120 this.gFileAttributeMatcher = gFileAttributeMatcher; 121 } 122 123 /** 124 */ 125 126 /** 127 * Creates a new file attribute matcher, which matches attributes 128 * against a given string. GFileAttributeMatchers are reference 129 * counted structures, and are created with a reference count of 1. If 130 * the number of references falls to 0, the GFileAttributeMatcher is 131 * automatically destroyed. 132 * The attribute string should be formatted with specific keys separated 133 * from namespaces with a double colon. Several "namespace::key" strings may be 134 * concatenated with a single comma (e.g. "standard::type,standard::is-hidden"). 135 * The wildcard "*" may be used to match all keys and namespaces, or 136 * "namespace::*" will match all keys in a given namespace. 137 * Params: 138 * attributes = an attribute string to match. 139 * Throws: ConstructionException GTK+ fails to create the object. 140 */ 141 public this (string attributes) 142 { 143 // GFileAttributeMatcher * g_file_attribute_matcher_new (const char *attributes); 144 auto p = g_file_attribute_matcher_new(Str.toStringz(attributes)); 145 if(p is null) 146 { 147 throw new ConstructionException("null returned by g_file_attribute_matcher_new(Str.toStringz(attributes))"); 148 } 149 this(cast(GFileAttributeMatcher*) p); 150 } 151 152 /** 153 * References a file attribute matcher. 154 * Returns: a GFileAttributeMatcher. 155 */ 156 public FileAttributeMatcher doref() 157 { 158 // GFileAttributeMatcher * g_file_attribute_matcher_ref (GFileAttributeMatcher *matcher); 159 auto p = g_file_attribute_matcher_ref(gFileAttributeMatcher); 160 161 if(p is null) 162 { 163 return null; 164 } 165 166 return ObjectG.getDObject!(FileAttributeMatcher)(cast(GFileAttributeMatcher*) p); 167 } 168 169 /** 170 * Subtracts all attributes of subtract from matcher and returns 171 * a matcher that supports those attributes. 172 * Note that currently it is not possible to remove a single 173 * attribute when the matcher matches the whole namespace - or remove 174 * a namespace or attribute when the matcher matches everything. This 175 * is a limitation of the current implementation, but may be fixed 176 * in the future. 177 * Params: 178 * subtract = The matcher to subtract 179 * Returns: A file attribute matcher matching all attributes of matcher that are not matched by subtract 180 */ 181 public FileAttributeMatcher subtract(FileAttributeMatcher subtract) 182 { 183 // GFileAttributeMatcher * g_file_attribute_matcher_subtract (GFileAttributeMatcher *matcher, GFileAttributeMatcher *subtract); 184 auto p = g_file_attribute_matcher_subtract(gFileAttributeMatcher, (subtract is null) ? null : subtract.getFileAttributeMatcherStruct()); 185 186 if(p is null) 187 { 188 return null; 189 } 190 191 return ObjectG.getDObject!(FileAttributeMatcher)(cast(GFileAttributeMatcher*) p); 192 } 193 194 /** 195 * Unreferences matcher. If the reference count falls below 1, 196 * the matcher is automatically freed. 197 */ 198 public void unref() 199 { 200 // void g_file_attribute_matcher_unref (GFileAttributeMatcher *matcher); 201 g_file_attribute_matcher_unref(gFileAttributeMatcher); 202 } 203 204 /** 205 * Checks if an attribute will be matched by an attribute matcher. If 206 * the matcher was created with the "*" matching string, this function 207 * will always return TRUE. 208 * Params: 209 * attribute = a file attribute key. 210 * Returns: TRUE if attribute matches matcher. FALSE otherwise. 211 */ 212 public int matches(string attribute) 213 { 214 // gboolean g_file_attribute_matcher_matches (GFileAttributeMatcher *matcher, const char *attribute); 215 return g_file_attribute_matcher_matches(gFileAttributeMatcher, Str.toStringz(attribute)); 216 } 217 218 /** 219 * Checks if a attribute matcher only matches a given attribute. Always 220 * returns FALSE if "*" was used when creating the matcher. 221 * Params: 222 * attribute = a file attribute key. 223 * Returns: TRUE if the matcher only matches attribute. FALSE otherwise. 224 */ 225 public int matchesOnly(string attribute) 226 { 227 // gboolean g_file_attribute_matcher_matches_only (GFileAttributeMatcher *matcher, const char *attribute); 228 return g_file_attribute_matcher_matches_only(gFileAttributeMatcher, Str.toStringz(attribute)); 229 } 230 231 /** 232 * Checks if the matcher will match all of the keys in a given namespace. 233 * This will always return TRUE if a wildcard character is in use (e.g. if 234 * matcher was created with "standard::*" and ns is "standard", or if matcher was created 235 * using "*" and namespace is anything.) 236 * TODO: this is awkwardly worded. 237 * Params: 238 * ns = a string containing a file attribute namespace. 239 * Returns: TRUE if the matcher matches all of the entries in the given ns, FALSE otherwise. 240 */ 241 public int enumerateNamespace(string ns) 242 { 243 // gboolean g_file_attribute_matcher_enumerate_namespace (GFileAttributeMatcher *matcher, const char *ns); 244 return g_file_attribute_matcher_enumerate_namespace(gFileAttributeMatcher, Str.toStringz(ns)); 245 } 246 247 /** 248 * Gets the next matched attribute from a GFileAttributeMatcher. 249 * Returns: a string containing the next attribute or NULL if no more attribute exist. 250 */ 251 public string enumerateNext() 252 { 253 // const char * g_file_attribute_matcher_enumerate_next (GFileAttributeMatcher *matcher); 254 return Str.toString(g_file_attribute_matcher_enumerate_next(gFileAttributeMatcher)); 255 } 256 257 /** 258 * Prints what the matcher is matching against. The format will be 259 * equal to the format passed to g_file_attribute_matcher_new(). 260 * The output however, might not be identical, as the matcher may 261 * decide to use a different order or omit needless parts. 262 * Since 2.32 263 * Returns: a string describing the attributes the matcher matches against or NULL if matcher was NULL. 264 */ 265 public override string toString() 266 { 267 // char * g_file_attribute_matcher_to_string (GFileAttributeMatcher *matcher); 268 return Str.toString(g_file_attribute_matcher_to_string(gFileAttributeMatcher)); 269 } 270 }