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  */
53 
54 module gio.FileAttributeMatcher;
55 
56 public  import gtkc.giotypes;
57 
58 private import gtkc.gio;
59 private import glib.ConstructionException;
60 private import gobject.ObjectG;
61 
62 
63 private import glib.Str;
64 
65 
66 
67 private import gobject.Boxed;
68 
69 /**
70  * Description
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  * See GFileAttribute for more
75  * information on how GIO handles file attributes.
76  * To obtain a GFileInfo for a GFile, use g_file_query_info() (or its
77  * async variant). To obtain a GFileInfo for a file input or output
78  * stream, use g_file_input_stream_query_info() or
79  * g_file_output_stream_query_info() (or their async variants).
80  * To change the actual attributes of a file, you should then set the
81  * attribute in the GFileInfo and call g_file_set_attributes_from_info()
82  * or g_file_set_attributes_async() on a GFile.
83  * However, not all attributes can be changed in the file. For instance,
84  * the actual size of a file cannot be changed via g_file_info_set_size().
85  * You may call g_file_query_settable_attributes() and
86  * g_file_query_writable_namespaces() to discover the settable attributes
87  * of a particular file at runtime.
88  * GFileAttributeMatcher allows for searching through a GFileInfo for
89  * attributes.
90  */
91 public class FileAttributeMatcher : Boxed
92 {
93 	
94 	/** the main Gtk struct */
95 	protected GFileAttributeMatcher* gFileAttributeMatcher;
96 	
97 	
98 	public GFileAttributeMatcher* getFileAttributeMatcherStruct()
99 	{
100 		return gFileAttributeMatcher;
101 	}
102 	
103 	
104 	/** the main Gtk struct as a void* */
105 	protected void* getStruct()
106 	{
107 		return cast(void*)gFileAttributeMatcher;
108 	}
109 	
110 	/**
111 	 * Sets our main struct and passes it to the parent class
112 	 */
113 	public this (GFileAttributeMatcher* gFileAttributeMatcher)
114 	{
115 		this.gFileAttributeMatcher = gFileAttributeMatcher;
116 	}
117 	
118 	/**
119 	 */
120 	
121 	/**
122 	 * Creates a new file attribute matcher, which matches attributes
123 	 * against a given string. GFileAttributeMatchers are reference
124 	 * counted structures, and are created with a reference count of 1. If
125 	 * the number of references falls to 0, the GFileAttributeMatcher is
126 	 * automatically destroyed.
127 	 * The attribute string should be formatted with specific keys separated
128 	 * from namespaces with a double colon. Several "namespace::key" strings may be
129 	 * concatenated with a single comma (e.g. "standard::type,standard::is-hidden").
130 	 * The wildcard "*" may be used to match all keys and namespaces, or
131 	 * "namespace::*" will match all keys in a given namespace.
132 	 * Params:
133 	 * attributes = an attribute string to match.
134 	 * Throws: ConstructionException GTK+ fails to create the object.
135 	 */
136 	public this (string attributes)
137 	{
138 		// GFileAttributeMatcher * g_file_attribute_matcher_new (const char *attributes);
139 		auto p = g_file_attribute_matcher_new(Str.toStringz(attributes));
140 		if(p is null)
141 		{
142 			throw new ConstructionException("null returned by g_file_attribute_matcher_new(Str.toStringz(attributes))");
143 		}
144 		this(cast(GFileAttributeMatcher*) p);
145 	}
146 	
147 	/**
148 	 * References a file attribute matcher.
149 	 * Returns: a GFileAttributeMatcher.
150 	 */
151 	public FileAttributeMatcher doref()
152 	{
153 		// GFileAttributeMatcher * g_file_attribute_matcher_ref (GFileAttributeMatcher *matcher);
154 		auto p = g_file_attribute_matcher_ref(gFileAttributeMatcher);
155 		
156 		if(p is null)
157 		{
158 			return null;
159 		}
160 		
161 		return ObjectG.getDObject!(FileAttributeMatcher)(cast(GFileAttributeMatcher*) p);
162 	}
163 	
164 	/**
165 	 * Unreferences matcher. If the reference count falls below 1,
166 	 * the matcher is automatically freed.
167 	 */
168 	public void unref()
169 	{
170 		// void g_file_attribute_matcher_unref (GFileAttributeMatcher *matcher);
171 		g_file_attribute_matcher_unref(gFileAttributeMatcher);
172 	}
173 	
174 	/**
175 	 * Checks if an attribute will be matched by an attribute matcher. If
176 	 * the matcher was created with the "*" matching string, this function
177 	 * will always return TRUE.
178 	 * Params:
179 	 * attribute = a file attribute key.
180 	 * Returns: TRUE if attribute matches matcher. FALSE otherwise.
181 	 */
182 	public int matches(string attribute)
183 	{
184 		// gboolean g_file_attribute_matcher_matches (GFileAttributeMatcher *matcher,  const char *attribute);
185 		return g_file_attribute_matcher_matches(gFileAttributeMatcher, Str.toStringz(attribute));
186 	}
187 	
188 	/**
189 	 * Checks if a attribute matcher only matches a given attribute. Always
190 	 * returns FALSE if "*" was used when creating the matcher.
191 	 * Params:
192 	 * attribute = a file attribute key.
193 	 * Returns: TRUE if the matcher only matches attribute. FALSE otherwise.
194 	 */
195 	public int matchesOnly(string attribute)
196 	{
197 		// gboolean g_file_attribute_matcher_matches_only  (GFileAttributeMatcher *matcher,  const char *attribute);
198 		return g_file_attribute_matcher_matches_only(gFileAttributeMatcher, Str.toStringz(attribute));
199 	}
200 	
201 	/**
202 	 * Checks if the matcher will match all of the keys in a given namespace.
203 	 * This will always return TRUE if a wildcard character is in use (e.g. if
204 	 * matcher was created with "standard::*" and ns is "standard", or if matcher was created
205 	 * using "*" and namespace is anything.)
206 	 * TODO: this is awkwardly worded.
207 	 * Params:
208 	 * ns = a string containing a file attribute namespace.
209 	 * Returns: TRUE if the matcher matches all of the entries in the given ns, FALSE otherwise.
210 	 */
211 	public int enumerateNamespace(string ns)
212 	{
213 		// gboolean g_file_attribute_matcher_enumerate_namespace  (GFileAttributeMatcher *matcher,  const char *ns);
214 		return g_file_attribute_matcher_enumerate_namespace(gFileAttributeMatcher, Str.toStringz(ns));
215 	}
216 	
217 	/**
218 	 * Gets the next matched attribute from a GFileAttributeMatcher.
219 	 * Returns: a string containing the next attribute or NULL if no more attribute exist.
220 	 */
221 	public string enumerateNext()
222 	{
223 		// const char * g_file_attribute_matcher_enumerate_next  (GFileAttributeMatcher *matcher);
224 		return Str.toString(g_file_attribute_matcher_enumerate_next(gFileAttributeMatcher));
225 	}
226 }