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  = gobject-GParamSpec.html
27  * outPack = gobject
28  * outFile = ParamSpec
29  * strct   = GParamSpec
30  * realStrct=
31  * ctorStrct=
32  * clss    = ParamSpec
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_param_spec_
41  * omit structs:
42  * omit prefixes:
43  * 	- g_param_spec_pool_
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- gobject.Value
49  * 	- glib.ListG
50  * structWrap:
51  * 	- GList* -> ListG
52  * 	- GParamSpec* -> ParamSpec
53  * 	- GValue* -> Value
54  * module aliases:
55  * local aliases:
56  * overrides:
57  */
58 
59 module gobject.ParamSpec;
60 
61 public  import gtkc.gobjecttypes;
62 
63 private import gtkc.gobject;
64 private import glib.ConstructionException;
65 private import gobject.ObjectG;
66 
67 
68 private import glib.Str;
69 private import gobject.Value;
70 private import glib.ListG;
71 
72 
73 
74 
75 /**
76  * GParamSpec is an object structure that encapsulates the metadata
77  * required to specify parameters, such as e.g. GObject properties.
78  *
79  * Parameter names need to start with a letter (a-z or A-Z). Subsequent
80  * characters can be letters, numbers or a '-'.
81  * All other characters are replaced by a '-' during construction.
82  * The result of this replacement is called the canonical name of the
83  * parameter.
84  */
85 public class ParamSpec
86 {
87 	
88 	/** the main Gtk struct */
89 	protected GParamSpec* gParamSpec;
90 	
91 	
92 	public GParamSpec* getParamSpecStruct()
93 	{
94 		return gParamSpec;
95 	}
96 	
97 	
98 	/** the main Gtk struct as a void* */
99 	protected void* getStruct()
100 	{
101 		return cast(void*)gParamSpec;
102 	}
103 	
104 	/**
105 	 * Sets our main struct and passes it to the parent class
106 	 */
107 	public this (GParamSpec* gParamSpec)
108 	{
109 		this.gParamSpec = gParamSpec;
110 	}
111 	
112 	/**
113 	 */
114 	
115 	/**
116 	 * Increments the reference count of pspec.
117 	 * Returns: the GParamSpec that was passed into this function
118 	 */
119 	public ParamSpec doref()
120 	{
121 		// GParamSpec * g_param_spec_ref (GParamSpec *pspec);
122 		auto p = g_param_spec_ref(gParamSpec);
123 		
124 		if(p is null)
125 		{
126 			return null;
127 		}
128 		
129 		return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p);
130 	}
131 	
132 	/**
133 	 * Decrements the reference count of a pspec.
134 	 */
135 	public void unref()
136 	{
137 		// void g_param_spec_unref (GParamSpec *pspec);
138 		g_param_spec_unref(gParamSpec);
139 	}
140 	
141 	/**
142 	 * The initial reference count of a newly created GParamSpec is 1,
143 	 * even though no one has explicitly called g_param_spec_ref() on it
144 	 * yet. So the initial reference count is flagged as "floating", until
145 	 * someone calls g_param_spec_ref (pspec); g_param_spec_sink
146 	 * (pspec); in sequence on it, taking over the initial
147 	 * reference count (thus ending up with a pspec that has a reference
148 	 * count of 1 still, but is not flagged "floating" anymore).
149 	 */
150 	public void sink()
151 	{
152 		// void g_param_spec_sink (GParamSpec *pspec);
153 		g_param_spec_sink(gParamSpec);
154 	}
155 	
156 	/**
157 	 * Convenience function to ref and sink a GParamSpec.
158 	 * Since 2.10
159 	 * Returns: the GParamSpec that was passed into this function
160 	 */
161 	public ParamSpec refSink()
162 	{
163 		// GParamSpec * g_param_spec_ref_sink (GParamSpec *pspec);
164 		auto p = g_param_spec_ref_sink(gParamSpec);
165 		
166 		if(p is null)
167 		{
168 			return null;
169 		}
170 		
171 		return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p);
172 	}
173 	
174 	/**
175 	 */
176 	public Value getDefaultValue()
177 	{
178 		// const GValue * g_param_spec_get_default_value (GParamSpec *param);
179 		auto p = g_param_spec_get_default_value(gParamSpec);
180 		
181 		if(p is null)
182 		{
183 			return null;
184 		}
185 		
186 		return ObjectG.getDObject!(Value)(cast(GValue*) p);
187 	}
188 	
189 	/**
190 	 * Sets value to its default value as specified in pspec.
191 	 * Params:
192 	 * value = a GValue of correct type for pspec
193 	 */
194 	public void gParamValueSetDefault(Value value)
195 	{
196 		// void g_param_value_set_default (GParamSpec *pspec,  GValue *value);
197 		g_param_value_set_default(gParamSpec, (value is null) ? null : value.getValueStruct());
198 	}
199 	
200 	/**
201 	 * Checks whether value contains the default value as specified in pspec.
202 	 * Params:
203 	 * value = a GValue of correct type for pspec
204 	 * Returns: whether value contains the canonical default for this pspec
205 	 */
206 	public int gParamValueDefaults(Value value)
207 	{
208 		// gboolean g_param_value_defaults (GParamSpec *pspec,  GValue *value);
209 		return g_param_value_defaults(gParamSpec, (value is null) ? null : value.getValueStruct());
210 	}
211 	
212 	/**
213 	 * Ensures that the contents of value comply with the specifications
214 	 * set out by pspec. For example, a GParamSpecInt might require
215 	 * that integers stored in value may not be smaller than -42 and not be
216 	 * greater than +42. If value contains an integer outside of this range,
217 	 * it is modified accordingly, so the resulting value will fit into the
218 	 * range -42 .. +42.
219 	 * Params:
220 	 * value = a GValue of correct type for pspec
221 	 * Returns: whether modifying value was necessary to ensure validity
222 	 */
223 	public int gParamValueValidate(Value value)
224 	{
225 		// gboolean g_param_value_validate (GParamSpec *pspec,  GValue *value);
226 		return g_param_value_validate(gParamSpec, (value is null) ? null : value.getValueStruct());
227 	}
228 	
229 	/**
230 	 * Transforms src_value into dest_value if possible, and then
231 	 * validates dest_value, in order for it to conform to pspec. If
232 	 * strict_validation is TRUE this function will only succeed if the
233 	 * transformed dest_value complied to pspec without modifications.
234 	 * See also g_value_type_transformable(), g_value_transform() and
235 	 * g_param_value_validate().
236 	 * Params:
237 	 * srcValue = souce GValue
238 	 * destValue = destination GValue of correct type for pspec
239 	 * strictValidation = TRUE requires dest_value to conform to pspec
240 	 * without modifications
241 	 * Returns: TRUE if transformation and validation were successful, FALSE otherwise and dest_value is left untouched.
242 	 */
243 	public int gParamValueConvert(Value srcValue, Value destValue, int strictValidation)
244 	{
245 		// gboolean g_param_value_convert (GParamSpec *pspec,  const GValue *src_value,  GValue *dest_value,  gboolean strict_validation);
246 		return g_param_value_convert(gParamSpec, (srcValue is null) ? null : srcValue.getValueStruct(), (destValue is null) ? null : destValue.getValueStruct(), strictValidation);
247 	}
248 	
249 	/**
250 	 * Compares value1 with value2 according to pspec, and return -1, 0 or +1,
251 	 * if value1 is found to be less than, equal to or greater than value2,
252 	 * respectively.
253 	 * Params:
254 	 * value1 = a GValue of correct type for pspec
255 	 * value2 = a GValue of correct type for pspec
256 	 * Returns: -1, 0 or +1, for a less than, equal to or greater than result
257 	 */
258 	public int gParamValuesCmp(Value value1, Value value2)
259 	{
260 		// gint g_param_values_cmp (GParamSpec *pspec,  const GValue *value1,  const GValue *value2);
261 		return g_param_values_cmp(gParamSpec, (value1 is null) ? null : value1.getValueStruct(), (value2 is null) ? null : value2.getValueStruct());
262 	}
263 	
264 	/**
265 	 * Get the name of a GParamSpec.
266 	 * The name is always an "interned" string (as per g_intern_string()).
267 	 * This allows for pointer-value comparisons.
268 	 * Returns: the name of pspec.
269 	 */
270 	public string getName()
271 	{
272 		// const gchar * g_param_spec_get_name (GParamSpec *pspec);
273 		return Str.toString(g_param_spec_get_name(gParamSpec));
274 	}
275 	
276 	/**
277 	 * Get the nickname of a GParamSpec.
278 	 * Returns: the nickname of pspec.
279 	 */
280 	public string getNick()
281 	{
282 		// const gchar * g_param_spec_get_nick (GParamSpec *pspec);
283 		return Str.toString(g_param_spec_get_nick(gParamSpec));
284 	}
285 	
286 	/**
287 	 * Get the short description of a GParamSpec.
288 	 * Returns: the short description of pspec.
289 	 */
290 	public string getBlurb()
291 	{
292 		// const gchar * g_param_spec_get_blurb (GParamSpec *pspec);
293 		return Str.toString(g_param_spec_get_blurb(gParamSpec));
294 	}
295 	
296 	/**
297 	 * Gets back user data pointers stored via g_param_spec_set_qdata().
298 	 * Params:
299 	 * quark = a GQuark, naming the user data pointer
300 	 * Returns: the user data pointer set, or NULL. [transfer none]
301 	 */
302 	public void* getQdata(GQuark quark)
303 	{
304 		// gpointer g_param_spec_get_qdata (GParamSpec *pspec,  GQuark quark);
305 		return g_param_spec_get_qdata(gParamSpec, quark);
306 	}
307 	
308 	/**
309 	 * Sets an opaque, named pointer on a GParamSpec. The name is
310 	 * specified through a GQuark (retrieved e.g. via
311 	 * g_quark_from_static_string()), and the pointer can be gotten back
312 	 * from the pspec with g_param_spec_get_qdata(). Setting a
313 	 * previously set user data pointer, overrides (frees) the old pointer
314 	 * set, using NULL as pointer essentially removes the data stored.
315 	 * Params:
316 	 * quark = a GQuark, naming the user data pointer
317 	 * data = an opaque user data pointer
318 	 */
319 	public void setQdata(GQuark quark, void* data)
320 	{
321 		// void g_param_spec_set_qdata (GParamSpec *pspec,  GQuark quark,  gpointer data);
322 		g_param_spec_set_qdata(gParamSpec, quark, data);
323 	}
324 	
325 	/**
326 	 * This function works like g_param_spec_set_qdata(), but in addition,
327 	 * a void (*destroy) (gpointer) function may be
328 	 * specified which is called with data as argument when the pspec is
329 	 * finalized, or the data is being overwritten by a call to
330 	 * g_param_spec_set_qdata() with the same quark.
331 	 * Params:
332 	 * quark = a GQuark, naming the user data pointer
333 	 * data = an opaque user data pointer
334 	 * destroy = function to invoke with data as argument, when data needs to
335 	 * be freed
336 	 */
337 	public void setQdataFull(GQuark quark, void* data, GDestroyNotify destroy)
338 	{
339 		// void g_param_spec_set_qdata_full (GParamSpec *pspec,  GQuark quark,  gpointer data,  GDestroyNotify destroy);
340 		g_param_spec_set_qdata_full(gParamSpec, quark, data, destroy);
341 	}
342 	
343 	/**
344 	 * Gets back user data pointers stored via g_param_spec_set_qdata()
345 	 * and removes the data from pspec without invoking its destroy()
346 	 * function (if any was set). Usually, calling this function is only
347 	 * required to update user data pointers with a destroy notifier.
348 	 * Params:
349 	 * quark = a GQuark, naming the user data pointer
350 	 * Returns: the user data pointer set, or NULL. [transfer none]
351 	 */
352 	public void* stealQdata(GQuark quark)
353 	{
354 		// gpointer g_param_spec_steal_qdata (GParamSpec *pspec,  GQuark quark);
355 		return g_param_spec_steal_qdata(gParamSpec, quark);
356 	}
357 	
358 	/**
359 	 * If the paramspec redirects operations to another paramspec,
360 	 * returns that paramspec. Redirect is used typically for
361 	 * providing a new implementation of a property in a derived
362 	 * type while preserving all the properties from the parent
363 	 * type. Redirection is established by creating a property
364 	 * of type GParamSpecOverride. See g_object_class_override_property()
365 	 * for an example of the use of this capability.
366 	 * Since 2.4
367 	 * Returns: paramspec to which requests on this paramspec should be redirected, or NULL if none. [transfer none]
368 	 */
369 	public ParamSpec getRedirectTarget()
370 	{
371 		// GParamSpec * g_param_spec_get_redirect_target (GParamSpec *pspec);
372 		auto p = g_param_spec_get_redirect_target(gParamSpec);
373 		
374 		if(p is null)
375 		{
376 			return null;
377 		}
378 		
379 		return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p);
380 	}
381 	
382 	/**
383 	 * Creates a new GParamSpec instance.
384 	 * A property name consists of segments consisting of ASCII letters and
385 	 * digits, separated by either the '-' or '_' character. The first
386 	 * character of a property name must be a letter. Names which violate these
387 	 * rules lead to undefined behaviour.
388 	 * When creating and looking up a GParamSpec, either separator can be
389 	 * used, but they cannot be mixed. Using '-' is considerably more
390 	 * efficient and in fact required when using property names as detail
391 	 * strings for signals.
392 	 * Beyond the name, GParamSpecs have two more descriptive
393 	 * strings associated with them, the nick, which should be suitable
394 	 * for use as a label for the property in a property editor, and the
395 	 * blurb, which should be a somewhat longer description, suitable for
396 	 * e.g. a tooltip. The nick and blurb should ideally be localized.
397 	 * Params:
398 	 * paramType = the GType for the property; must be derived from G_TYPE_PARAM
399 	 * name = the canonical name of the property
400 	 * nick = the nickname of the property
401 	 * blurb = a short description of the property
402 	 * flags = a combination of GParamFlags
403 	 * Returns: a newly allocated GParamSpec instance
404 	 */
405 	public static void* internal(GType paramType, string name, string nick, string blurb, GParamFlags flags)
406 	{
407 		// gpointer g_param_spec_internal (GType param_type,  const gchar *name,  const gchar *nick,  const gchar *blurb,  GParamFlags flags);
408 		return g_param_spec_internal(paramType, Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), flags);
409 	}
410 	
411 	/**
412 	 * Registers name as the name of a new static type derived from
413 	 * G_TYPE_PARAM. The type system uses the information contained in
414 	 * the GParamSpecTypeInfo structure pointed to by info to manage the
415 	 * GParamSpec type and its instances.
416 	 * Params:
417 	 * name = 0-terminated string used as the name of the new GParamSpec type.
418 	 * pspecInfo = The GParamSpecTypeInfo for this GParamSpec type.
419 	 * Returns: The new type identifier.
420 	 */
421 	public static GType gParamTypeRegisterStatic(string name, GParamSpecTypeInfo* pspecInfo)
422 	{
423 		// GType g_param_type_register_static (const gchar *name,  const GParamSpecTypeInfo *pspec_info);
424 		return g_param_type_register_static(Str.toStringz(name), pspecInfo);
425 	}
426 }