alternative to assert
[gtkD.git] / src / gobject / ParamSpec.d
bloba3f4b6860c89a9c5c5652ee6deb80895637f69c1
1 /*
2 * This file is part of duit.
4 * duit 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 * duit 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 duit; 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 = gobject-GParamSpec.html
26 * outPack = gobject
27 * outFile = ParamSpec
28 * strct = GParamSpec
29 * realStrct=
30 * ctorStrct=
31 * clss = ParamSpec
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_param_spec_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.Str
45 * - gobject.ParamSpec
46 * - gobject.Value
47 * - glib.ListG
48 * structWrap:
49 * - GList* -> ListG
50 * - GParamSpec* -> ParamSpec
51 * - GValue* -> Value
52 * local aliases:
55 module gobject.ParamSpec;
57 private import gobject.gobjecttypes;
59 private import lib.gobject;
61 private import glib.Str;
62 private import gobject.ParamSpec;
63 private import gobject.Value;
64 private import glib.ListG;
66 /**
67 * Description
68 * GParamSpec is an object structure that encapsulates the metadata
69 * required to specify parameters, such as e.g. GObject properties.
70 * Parameter names need to start with a letter (a-z or A-Z). Subsequent
71 * characters can be letters, numbers or a '-'.
72 * All other characters are replaced by a '-' during construction.
74 public class ParamSpec
77 /** the main Gtk struct */
78 protected GParamSpec* gParamSpec;
81 public GParamSpec* getParamSpecStruct()
83 return gParamSpec;
87 /** the main Gtk struct as a void* */
88 protected void* getStruct()
90 return cast(void*)gParamSpec;
93 /**
94 * Sets our main struct and passes it to the parent class
96 public this (GParamSpec* gParamSpec)
98 this.gParamSpec = gParamSpec;
120 * Increments the reference count of pspec.
121 * pspec:
122 * a valid GParamSpec
123 * Returns:
124 * the GParamSpec that was passed into this function
126 public ParamSpec ref()
128 // GParamSpec* g_param_spec_ref (GParamSpec *pspec);
129 return new ParamSpec( g_param_spec_ref(gParamSpec) );
133 * Decrements the reference count of a pspec.
134 * pspec:
135 * a valid GParamSpec
137 public void unref()
139 // void g_param_spec_unref (GParamSpec *pspec);
140 g_param_spec_unref(gParamSpec);
144 * The initial reference count of a newly created GParamSpec is 1, even
145 * though no one has explicitly called g_param_spec_ref() on it yet. So the
146 * initial reference count is flagged as "floating", until someone calls
147 * g_param_spec_ref (pspec); g_param_spec_sink (pspec);
148 * in sequence on it, taking over the initial reference count (thus
149 * ending up with a pspec that has a reference count of 1 still, but is
150 * not flagged "floating" anymore).
151 * pspec:
152 * a valid GParamSpec
154 public void sink()
156 // void g_param_spec_sink (GParamSpec *pspec);
157 g_param_spec_sink(gParamSpec);
161 * Convenience function to ref and sink a GParamSpec.
162 * pspec:
163 * a valid GParamSpec
164 * Returns:
165 * the GParamSpec that was passed into this function
166 * Since 2.10
168 public ParamSpec refSink()
170 // GParamSpec* g_param_spec_ref_sink (GParamSpec *pspec);
171 return new ParamSpec( g_param_spec_ref_sink(gParamSpec) );
175 * Sets value to its default value as specified in pspec.
176 * pspec:
177 * a valid GParamSpec
178 * value:
179 * a GValue of correct type for pspec
181 public void gParamValueSetDefault(Value value)
183 // void g_param_value_set_default (GParamSpec *pspec, GValue *value);
184 g_param_value_set_default(gParamSpec, (value is null) ? null : value.getValueStruct());
188 * Checks whether value contains the default value as specified in pspec.
189 * pspec:
190 * a valid GParamSpec
191 * value:
192 * a GValue of correct type for pspec
193 * Returns:
194 * whether value contains the canonical defualt for this pspec
196 public int gParamValueDefaults(Value value)
198 // gboolean g_param_value_defaults (GParamSpec *pspec, GValue *value);
199 return g_param_value_defaults(gParamSpec, (value is null) ? null : value.getValueStruct());
203 * Ensures that the contents of value comply with the specifications
204 * set out by pspec. For example, a GParamSpecInt might require
205 * that integers stored in value may not be smaller than -42 and not be
206 * greater than +42. If value contains an integer outside of this range,
207 * it is modified accordingly, so the resulting value will fit into the
208 * range -42 .. +42.
209 * pspec:
210 * a valid GParamSpec
211 * value:
212 * a GValue of correct type for pspec
213 * Returns:
214 * whether modifying value was necessary to ensure validity
216 public int gParamValueValidate(Value value)
218 // gboolean g_param_value_validate (GParamSpec *pspec, GValue *value);
219 return g_param_value_validate(gParamSpec, (value is null) ? null : value.getValueStruct());
223 * Transforms src_value into dest_value if possible, and then validates
224 * dest_value, in order for it to conform to pspec.
225 * If strict_validation is TRUE this function will only succeed if
226 * the transformed dest_value complied to pspec without modifications.
227 * See also g_value_type_transformable(), g_value_transform() and
228 * g_param_value_validate().
229 * pspec:
230 * a valid GParamSpec
231 * src_value:
232 * souce GValue
233 * dest_value:
234 * destination GValue of correct type for pspec
235 * strict_validation:
236 * TRUE requires dest_value to conform to pspec without modifications
237 * Returns:
238 * TRUE if transformation and validation were successful,
239 * FALSE otherwise and dest_value is left untouched.
241 public int gParamValueConvert(Value srcValue, Value destValue, int strictValidation)
243 // gboolean g_param_value_convert (GParamSpec *pspec, const GValue *src_value, GValue *dest_value, gboolean strict_validation);
244 return g_param_value_convert(gParamSpec, (srcValue is null) ? null : srcValue.getValueStruct(), (destValue is null) ? null : destValue.getValueStruct(), strictValidation);
248 * Compares value1 with value2 according to pspec, and return -1, 0 or +1,
249 * if value1 is found to be less than, equal to or greater than value2,
250 * respectively.
251 * pspec:
252 * a valid GParamSpec
253 * value1:
254 * a GValue of correct type for pspec
255 * value2:
256 * a GValue of correct type for pspec
257 * Returns:
258 * -1, 0 or +1, for a less than, equal to or greater than result
260 public int gParamValuesCmp(Value value1, Value value2)
262 // gint g_param_values_cmp (GParamSpec *pspec, const GValue *value1, const GValue *value2);
263 return g_param_values_cmp(gParamSpec, (value1 is null) ? null : value1.getValueStruct(), (value2 is null) ? null : value2.getValueStruct());
267 * Returns the name of a GParamSpec.
268 * pspec:
269 * a valid GParamSpec
270 * Returns:
271 * the name of pspec.
273 public char[] getName()
275 // const gchar* g_param_spec_get_name (GParamSpec *pspec);
276 return Str.toString(g_param_spec_get_name(gParamSpec) );
280 * Returns the nickname of a GParamSpec.
281 * pspec:
282 * a valid GParamSpec
283 * Returns:
284 * the nickname of pspec.
286 public char[] getNick()
288 // const gchar* g_param_spec_get_nick (GParamSpec *pspec);
289 return Str.toString(g_param_spec_get_nick(gParamSpec) );
293 * Returns the short description of a GParamSpec.
294 * pspec:
295 * a valid GParamSpec
296 * Returns:
297 * the short description of pspec.
299 public char[] getBlurb()
301 // const gchar* g_param_spec_get_blurb (GParamSpec *pspec);
302 return Str.toString(g_param_spec_get_blurb(gParamSpec) );
306 * Gets back user data pointers stored via g_param_spec_set_qdata().
307 * pspec:
308 * a valid GParamSpec
309 * quark:
310 * a GQuark, naming the user data pointer
311 * Returns:
312 * the user data pointer set, or NULL
314 public void* getQdata(GQuark quark)
316 // gpointer g_param_spec_get_qdata (GParamSpec *pspec, GQuark quark);
317 return g_param_spec_get_qdata(gParamSpec, quark);
321 * Sets an opaque, named pointer on a GParamSpec. The name is specified
322 * through a GQuark (retrieved e.g. via g_quark_from_static_string()), and
323 * the pointer can be gotten back from the pspec with g_param_spec_get_qdata().
324 * Setting a previously set user data pointer, overrides (frees)
325 * the old pointer set, using NULL as pointer essentially
326 * removes the data stored.
327 * pspec:
328 * the GParamSpec to set store a user data pointer
329 * quark:
330 * a GQuark, naming the user data pointer
331 * data:
332 * an opaque user data pointer
334 public void setQdata(GQuark quark, void* data)
336 // void g_param_spec_set_qdata (GParamSpec *pspec, GQuark quark, gpointer data);
337 g_param_spec_set_qdata(gParamSpec, quark, data);
341 * This function works like g_param_spec_set_qdata(), but in addition,
342 * a void (*destroy) (gpointer) function may be
343 * specified which is called with data as argument when the pspec is
344 * finalized, or the data is being overwritten by a call to
345 * g_param_spec_set_qdata() with the same quark.
346 * pspec:
347 * the GParamSpec to set store a user data pointer
348 * quark:
349 * a GQuark, naming the user data pointer
350 * data:
351 * an opaque user data pointer
352 * destroy:
353 * function to invoke with data as argument, when data needs to
354 * be freed
356 public void setQdataFull(GQuark quark, void* data, GDestroyNotify destroy)
358 // void g_param_spec_set_qdata_full (GParamSpec *pspec, GQuark quark, gpointer data, GDestroyNotify destroy);
359 g_param_spec_set_qdata_full(gParamSpec, quark, data, destroy);
363 * Gets back user data pointers stored via g_param_spec_set_qdata() and
364 * removes the data from pspec without invoking it's destroy() function
365 * (if any was set).
366 * Usually, calling this function is only required to update
367 * user data pointers with a destroy notifier.
368 * pspec:
369 * the GParamSpec to get a stored user data pointer from
370 * quark:
371 * a GQuark, naming the user data pointer
372 * Returns:
373 * the user data pointer set, or NULL
375 public void* stealQdata(GQuark quark)
377 // gpointer g_param_spec_steal_qdata (GParamSpec *pspec, GQuark quark);
378 return g_param_spec_steal_qdata(gParamSpec, quark);
382 * If the paramspec redirects operations to another paramspec,
383 * returns that paramspec. Redirect is used typically for
384 * providing a new implementation of a property in a derived
385 * type while preserving all the properties from the parent
386 * type. Redirection is established by creating a property
387 * of type GParamSpecOverride. See g_object_override_property()
388 * for an example of the use of this capability.
389 * pspec:
390 * a GParamSpec
391 * Returns:
392 * paramspec to which requests on this paramspec should
393 * be redirected, or NULL if none.
394 * Since 2.4
396 public ParamSpec getRedirectTarget()
398 // GParamSpec* g_param_spec_get_redirect_target (GParamSpec *pspec);
399 return new ParamSpec( g_param_spec_get_redirect_target(gParamSpec) );
403 * Creates a new GParamSpec instance.
404 * A property name consists of segments consisting of ASCII letters and
405 * digits, separated by either the '-' or '_' character. The first
406 * character of a property name must be a letter. Names which violate these
407 * rules lead to undefined behaviour.
408 * When creating and looking up a GParamSpec, either separator can be used,
409 * but they cannot be mixed. Using '-' is considerably more efficient and in
410 * fact required when using property names as detail strings for signals.
411 * param_type:
412 * the GType for the property; must be derived from G_TYPE_PARAM
413 * name:
414 * the canonical name of the property
415 * nick:
416 * the nickname of the property
417 * blurb:
418 * a short description of the property
419 * flags:
420 * a combination of GParamFlags
421 * Returns:
422 * a newly allocated GParamSpec instance
424 public static void* internal(GType paramType, char[] name, char[] nick, char[] blurb, GParamFlags flags)
426 // gpointer g_param_spec_internal (GType param_type, const gchar *name, const gchar *nick, const gchar *blurb, GParamFlags flags);
427 return g_param_spec_internal(paramType, Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), flags);
432 * Registers name as the name of a new static type derived from
433 * G_TYPE_PARAM. The type system uses the information contained in the
434 * GParamSpecTypeInfo structure pointed to by info to manage the GParamSpec
435 * type and its instances.
436 * name:
437 * 0-terminated string used as the name of the new GParamSpec type.
438 * pspec_info:
439 * The GParamSpecTypeInfo for this GParamSpec type.
440 * Returns:
441 * The new type identifier.
443 public static GType gParamTypeRegisterStatic(char[] name, GParamSpecTypeInfo* pspecInfo)
445 // GType g_param_type_register_static (const gchar *name, const GParamSpecTypeInfo *pspec_info);
446 return g_param_type_register_static(Str.toStringz(name), pspecInfo);
451 * Creates a new GParamSpecPool.
452 * If type_prefixing is TRUE, lookups in the newly created pool will
453 * allow to specify the owner as a colon-separated prefix of the property name,
454 * like "GtkContainer:border-width". This feature is deprecated, so you should
455 * always set type_prefixing to FALSE.
456 * type_prefixing:
457 * Whether the pool will support type-prefixed property names.
458 * Returns:
459 * a newly allocated GParamSpecPool.
461 public static GParamSpecPool* poolNew(int typePrefixing)
463 // GParamSpecPool* g_param_spec_pool_new (gboolean type_prefixing);
464 return g_param_spec_pool_new(typePrefixing);
468 * Inserts a GParamSpec in the pool.
469 * pool:
470 * a GParamSpecPool.
471 * pspec:
472 * the GParamSpec to insert
473 * owner_type:
474 * a GType identifying the owner of pspec
476 public static void poolInsert(GParamSpecPool* pool, ParamSpec pspec, GType ownerType)
478 // void g_param_spec_pool_insert (GParamSpecPool *pool, GParamSpec *pspec, GType owner_type);
479 g_param_spec_pool_insert(pool, (pspec is null) ? null : pspec.getParamSpecStruct(), ownerType);
483 * Removes a GParamSpec from the pool.
484 * pool:
485 * a GParamSpecPool
486 * pspec:
487 * the GParamSpec to remove
489 public static void poolRemove(GParamSpecPool* pool, ParamSpec pspec)
491 // void g_param_spec_pool_remove (GParamSpecPool *pool, GParamSpec *pspec);
492 g_param_spec_pool_remove(pool, (pspec is null) ? null : pspec.getParamSpecStruct());
496 * Looks up a GParamSpec in the pool.
497 * pool:
498 * a GParamSpecPool
499 * param_name:
500 * the name to look for
501 * owner_type:
502 * the owner to look for
503 * walk_ancestors:
504 * If TRUE, also try to find a GParamSpec with param_name
505 * owned by an ancestor of owner_type.
506 * Returns:
507 * The found GParamSpec, or NULL if no matching GParamSpec was found.
509 public static ParamSpec poolLookup(GParamSpecPool* pool, char[] paramName, GType ownerType, int walkAncestors)
511 // GParamSpec* g_param_spec_pool_lookup (GParamSpecPool *pool, const gchar *param_name, GType owner_type, gboolean walk_ancestors);
512 return new ParamSpec( g_param_spec_pool_lookup(pool, Str.toStringz(paramName), ownerType, walkAncestors) );
516 * Gets an array of all GParamSpecs owned by owner_type in the pool.
517 * pool:
518 * a GParamSpecPool
519 * owner_type:
520 * the owner to look for
521 * n_pspecs_p:
522 * return location for the length of the returned array
523 * Returns:
524 * a newly allocated array containing pointers to all
525 * GParamSpecs owned by owner_type in the pool
527 public static GParamSpec** poolList(GParamSpecPool* pool, GType ownerType, uint* nPspecsP)
529 // GParamSpec** g_param_spec_pool_list (GParamSpecPool *pool, GType owner_type, guint *n_pspecs_p);
530 return g_param_spec_pool_list(pool, ownerType, nPspecsP);
534 * Gets an GList of all GParamSpecs owned by owner_type in the pool.
535 * pool:
536 * a GParamSpecPool
537 * owner_type:
538 * the owner to look for
539 * Returns:
540 * a GList of all GParamSpecs owned by owner_type in
541 * the poolGParamSpecs.
542 * See Also
543 * g_object_class_install_property(), g_object_set(), g_object_get(),
544 * g_object_set_property(), g_object_get_property(), g_value_register_transform_func()
546 public static ListG poolListOwned(GParamSpecPool* pool, GType ownerType)
548 // GList* g_param_spec_pool_list_owned (GParamSpecPool *pool, GType owner_type);
549 return new ListG( g_param_spec_pool_list_owned(pool, ownerType) );