alternative to assert
[gtkD.git] / gtkD / src / gobject / ParamSpec.d
bloba3cb5bcc39f1639250ec827a6b031994b6f1ab2d
1 /*
2 * This file is part of gtkD.
4 * gtkD 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 * gtkD 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 gtkD; 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 * module aliases:
53 * local aliases:
56 module gobject.ParamSpec;
58 version(noAssert)
60 version(Tango)
62 import tango.io.Stdout; // use the tango loging?
66 private import gtkc.gobjecttypes;
68 private import gtkc.gobject;
71 private import glib.Str;
72 private import gobject.ParamSpec;
73 private import gobject.Value;
74 private import glib.ListG;
79 /**
80 * Description
81 * GParamSpec is an object structure that encapsulates the metadata
82 * required to specify parameters, such as e.g. GObject properties.
83 * Parameter names need to start with a letter (a-z or A-Z). Subsequent
84 * characters can be letters, numbers or a '-'.
85 * All other characters are replaced by a '-' during construction.
86 * The result of this replacement is called the canonical name of the
87 * parameter.
89 public class ParamSpec
92 /** the main Gtk struct */
93 protected GParamSpec* gParamSpec;
96 public GParamSpec* getParamSpecStruct()
98 return gParamSpec;
102 /** the main Gtk struct as a void* */
103 protected void* getStruct()
105 return cast(void*)gParamSpec;
109 * Sets our main struct and passes it to the parent class
111 public this (GParamSpec* gParamSpec)
113 version(noAssert)
115 if ( gParamSpec is null )
117 int zero = 0;
118 version(Tango)
120 Stdout("struct gParamSpec is null on constructor").newline;
122 else
124 printf("struct gParamSpec is null on constructor");
126 zero = zero / zero;
129 else
131 assert(gParamSpec !is null, "struct gParamSpec is null on constructor");
133 this.gParamSpec = gParamSpec;
155 * Increments the reference count of pspec.
156 * pspec:
157 * a valid GParamSpec
158 * Returns:
159 * the GParamSpec that was passed into this function
161 public ParamSpec doref()
163 // GParamSpec* g_param_spec_ref (GParamSpec *pspec);
164 return new ParamSpec( g_param_spec_ref(gParamSpec) );
168 * Decrements the reference count of a pspec.
169 * pspec:
170 * a valid GParamSpec
172 public void unref()
174 // void g_param_spec_unref (GParamSpec *pspec);
175 g_param_spec_unref(gParamSpec);
179 * The initial reference count of a newly created GParamSpec is 1, even
180 * though no one has explicitly called g_param_spec_ref() on it yet. So the
181 * initial reference count is flagged as "floating", until someone calls
182 * g_param_spec_ref (pspec); g_param_spec_sink (pspec);
183 * in sequence on it, taking over the initial reference count (thus
184 * ending up with a pspec that has a reference count of 1 still, but is
185 * not flagged "floating" anymore).
186 * pspec:
187 * a valid GParamSpec
189 public void sink()
191 // void g_param_spec_sink (GParamSpec *pspec);
192 g_param_spec_sink(gParamSpec);
196 * Convenience function to ref and sink a GParamSpec.
197 * pspec:
198 * a valid GParamSpec
199 * Returns:
200 * the GParamSpec that was passed into this function
201 * Since 2.10
203 public ParamSpec refSink()
205 // GParamSpec* g_param_spec_ref_sink (GParamSpec *pspec);
206 return new ParamSpec( g_param_spec_ref_sink(gParamSpec) );
210 * Sets value to its default value as specified in pspec.
211 * pspec:
212 * a valid GParamSpec
213 * value:
214 * a GValue of correct type for pspec
216 public void gParamValueSetDefault(Value value)
218 // void g_param_value_set_default (GParamSpec *pspec, GValue *value);
219 g_param_value_set_default(gParamSpec, (value is null) ? null : value.getValueStruct());
223 * Checks whether value contains the default value as specified in pspec.
224 * pspec:
225 * a valid GParamSpec
226 * value:
227 * a GValue of correct type for pspec
228 * Returns:
229 * whether value contains the canonical default for this pspec
231 public int gParamValueDefaults(Value value)
233 // gboolean g_param_value_defaults (GParamSpec *pspec, GValue *value);
234 return g_param_value_defaults(gParamSpec, (value is null) ? null : value.getValueStruct());
238 * Ensures that the contents of value comply with the specifications
239 * set out by pspec. For example, a GParamSpecInt might require
240 * that integers stored in value may not be smaller than -42 and not be
241 * greater than +42. If value contains an integer outside of this range,
242 * it is modified accordingly, so the resulting value will fit into the
243 * range -42 .. +42.
244 * pspec:
245 * a valid GParamSpec
246 * value:
247 * a GValue of correct type for pspec
248 * Returns:
249 * whether modifying value was necessary to ensure validity
251 public int gParamValueValidate(Value value)
253 // gboolean g_param_value_validate (GParamSpec *pspec, GValue *value);
254 return g_param_value_validate(gParamSpec, (value is null) ? null : value.getValueStruct());
258 * Transforms src_value into dest_value if possible, and then validates
259 * dest_value, in order for it to conform to pspec.
260 * If strict_validation is TRUE this function will only succeed if
261 * the transformed dest_value complied to pspec without modifications.
262 * See also g_value_type_transformable(), g_value_transform() and
263 * g_param_value_validate().
264 * pspec:
265 * a valid GParamSpec
266 * src_value:
267 * souce GValue
268 * dest_value:
269 * destination GValue of correct type for pspec
270 * strict_validation:
271 * TRUE requires dest_value to conform to pspec without modifications
272 * Returns:
273 * TRUE if transformation and validation were successful,
274 * FALSE otherwise and dest_value is left untouched.
276 public int gParamValueConvert(Value srcValue, Value destValue, int strictValidation)
278 // gboolean g_param_value_convert (GParamSpec *pspec, const GValue *src_value, GValue *dest_value, gboolean strict_validation);
279 return g_param_value_convert(gParamSpec, (srcValue is null) ? null : srcValue.getValueStruct(), (destValue is null) ? null : destValue.getValueStruct(), strictValidation);
283 * Compares value1 with value2 according to pspec, and return -1, 0 or +1,
284 * if value1 is found to be less than, equal to or greater than value2,
285 * respectively.
286 * pspec:
287 * a valid GParamSpec
288 * value1:
289 * a GValue of correct type for pspec
290 * value2:
291 * a GValue of correct type for pspec
292 * Returns:
293 * -1, 0 or +1, for a less than, equal to or greater than result
295 public int gParamValuesCmp(Value value1, Value value2)
297 // gint g_param_values_cmp (GParamSpec *pspec, const GValue *value1, const GValue *value2);
298 return g_param_values_cmp(gParamSpec, (value1 is null) ? null : value1.getValueStruct(), (value2 is null) ? null : value2.getValueStruct());
302 * Returns the name of a GParamSpec.
303 * pspec:
304 * a valid GParamSpec
305 * Returns:
306 * the name of pspec.
308 public char[] getName()
310 // const gchar* g_param_spec_get_name (GParamSpec *pspec);
311 return Str.toString(g_param_spec_get_name(gParamSpec) );
315 * Returns the nickname of a GParamSpec.
316 * pspec:
317 * a valid GParamSpec
318 * Returns:
319 * the nickname of pspec.
321 public char[] getNick()
323 // const gchar* g_param_spec_get_nick (GParamSpec *pspec);
324 return Str.toString(g_param_spec_get_nick(gParamSpec) );
328 * Returns the short description of a GParamSpec.
329 * pspec:
330 * a valid GParamSpec
331 * Returns:
332 * the short description of pspec.
334 public char[] getBlurb()
336 // const gchar* g_param_spec_get_blurb (GParamSpec *pspec);
337 return Str.toString(g_param_spec_get_blurb(gParamSpec) );
341 * Gets back user data pointers stored via g_param_spec_set_qdata().
342 * pspec:
343 * a valid GParamSpec
344 * quark:
345 * a GQuark, naming the user data pointer
346 * Returns:
347 * the user data pointer set, or NULL
349 public void* getQdata(GQuark quark)
351 // gpointer g_param_spec_get_qdata (GParamSpec *pspec, GQuark quark);
352 return g_param_spec_get_qdata(gParamSpec, quark);
356 * Sets an opaque, named pointer on a GParamSpec. The name is specified
357 * through a GQuark (retrieved e.g. via g_quark_from_static_string()), and
358 * the pointer can be gotten back from the pspec with g_param_spec_get_qdata().
359 * Setting a previously set user data pointer, overrides (frees)
360 * the old pointer set, using NULL as pointer essentially
361 * removes the data stored.
362 * pspec:
363 * the GParamSpec to set store a user data pointer
364 * quark:
365 * a GQuark, naming the user data pointer
366 * data:
367 * an opaque user data pointer
369 public void setQdata(GQuark quark, void* data)
371 // void g_param_spec_set_qdata (GParamSpec *pspec, GQuark quark, gpointer data);
372 g_param_spec_set_qdata(gParamSpec, quark, data);
376 * This function works like g_param_spec_set_qdata(), but in addition,
377 * a void (*destroy) (gpointer) function may be
378 * specified which is called with data as argument when the pspec is
379 * finalized, or the data is being overwritten by a call to
380 * g_param_spec_set_qdata() with the same quark.
381 * pspec:
382 * the GParamSpec to set store a user data pointer
383 * quark:
384 * a GQuark, naming the user data pointer
385 * data:
386 * an opaque user data pointer
387 * destroy:
388 * function to invoke with data as argument, when data needs to
389 * be freed
391 public void setQdataFull(GQuark quark, void* data, GDestroyNotify destroy)
393 // void g_param_spec_set_qdata_full (GParamSpec *pspec, GQuark quark, gpointer data, GDestroyNotify destroy);
394 g_param_spec_set_qdata_full(gParamSpec, quark, data, destroy);
398 * Gets back user data pointers stored via g_param_spec_set_qdata() and
399 * removes the data from pspec without invoking it's destroy() function
400 * (if any was set).
401 * Usually, calling this function is only required to update
402 * user data pointers with a destroy notifier.
403 * pspec:
404 * the GParamSpec to get a stored user data pointer from
405 * quark:
406 * a GQuark, naming the user data pointer
407 * Returns:
408 * the user data pointer set, or NULL
410 public void* stealQdata(GQuark quark)
412 // gpointer g_param_spec_steal_qdata (GParamSpec *pspec, GQuark quark);
413 return g_param_spec_steal_qdata(gParamSpec, quark);
417 * If the paramspec redirects operations to another paramspec,
418 * returns that paramspec. Redirect is used typically for
419 * providing a new implementation of a property in a derived
420 * type while preserving all the properties from the parent
421 * type. Redirection is established by creating a property
422 * of type GParamSpecOverride. See g_object_override_property()
423 * for an example of the use of this capability.
424 * pspec:
425 * a GParamSpec
426 * Returns:
427 * paramspec to which requests on this paramspec should
428 * be redirected, or NULL if none.
429 * Since 2.4
431 public ParamSpec getRedirectTarget()
433 // GParamSpec* g_param_spec_get_redirect_target (GParamSpec *pspec);
434 return new ParamSpec( g_param_spec_get_redirect_target(gParamSpec) );
438 * Creates a new GParamSpec instance.
439 * A property name consists of segments consisting of ASCII letters and
440 * digits, separated by either the '-' or '_' character. The first
441 * character of a property name must be a letter. Names which violate these
442 * rules lead to undefined behaviour.
443 * When creating and looking up a GParamSpec, either separator can be used,
444 * but they cannot be mixed. Using '-' is considerably more efficient and in
445 * fact required when using property names as detail strings for signals.
446 * param_type:
447 * the GType for the property; must be derived from G_TYPE_PARAM
448 * name:
449 * the canonical name of the property
450 * nick:
451 * the nickname of the property
452 * blurb:
453 * a short description of the property
454 * flags:
455 * a combination of GParamFlags
456 * Returns:
457 * a newly allocated GParamSpec instance
459 public static void* internal(GType paramType, char[] name, char[] nick, char[] blurb, GParamFlags flags)
461 // gpointer g_param_spec_internal (GType param_type, const gchar *name, const gchar *nick, const gchar *blurb, GParamFlags flags);
462 return g_param_spec_internal(paramType, Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), flags);
467 * Registers name as the name of a new static type derived from
468 * G_TYPE_PARAM. The type system uses the information contained in the
469 * GParamSpecTypeInfo structure pointed to by info to manage the GParamSpec
470 * type and its instances.
471 * name:
472 * 0-terminated string used as the name of the new GParamSpec type.
473 * pspec_info:
474 * The GParamSpecTypeInfo for this GParamSpec type.
475 * Returns:
476 * The new type identifier.
478 public static GType gParamTypeRegisterStatic(char[] name, GParamSpecTypeInfo* pspecInfo)
480 // GType g_param_type_register_static (const gchar *name, const GParamSpecTypeInfo *pspec_info);
481 return g_param_type_register_static(Str.toStringz(name), pspecInfo);
486 * Creates a new GParamSpecPool.
487 * If type_prefixing is TRUE, lookups in the newly created pool will
488 * allow to specify the owner as a colon-separated prefix of the property name,
489 * like "GtkContainer:border-width". This feature is deprecated, so you should
490 * always set type_prefixing to FALSE.
491 * type_prefixing:
492 * Whether the pool will support type-prefixed property names.
493 * Returns:
494 * a newly allocated GParamSpecPool.
496 public static GParamSpecPool* poolNew(int typePrefixing)
498 // GParamSpecPool* g_param_spec_pool_new (gboolean type_prefixing);
499 return g_param_spec_pool_new(typePrefixing);
503 * Inserts a GParamSpec in the pool.
504 * pool:
505 * a GParamSpecPool.
506 * pspec:
507 * the GParamSpec to insert
508 * owner_type:
509 * a GType identifying the owner of pspec
511 public static void poolInsert(GParamSpecPool* pool, ParamSpec pspec, GType ownerType)
513 // void g_param_spec_pool_insert (GParamSpecPool *pool, GParamSpec *pspec, GType owner_type);
514 g_param_spec_pool_insert(pool, (pspec is null) ? null : pspec.getParamSpecStruct(), ownerType);
518 * Removes a GParamSpec from the pool.
519 * pool:
520 * a GParamSpecPool
521 * pspec:
522 * the GParamSpec to remove
524 public static void poolRemove(GParamSpecPool* pool, ParamSpec pspec)
526 // void g_param_spec_pool_remove (GParamSpecPool *pool, GParamSpec *pspec);
527 g_param_spec_pool_remove(pool, (pspec is null) ? null : pspec.getParamSpecStruct());
531 * Looks up a GParamSpec in the pool.
532 * pool:
533 * a GParamSpecPool
534 * param_name:
535 * the name to look for
536 * owner_type:
537 * the owner to look for
538 * walk_ancestors:
539 * If TRUE, also try to find a GParamSpec with param_name
540 * owned by an ancestor of owner_type.
541 * Returns:
542 * The found GParamSpec, or NULL if no matching GParamSpec was found.
544 public static ParamSpec poolLookup(GParamSpecPool* pool, char[] paramName, GType ownerType, int walkAncestors)
546 // GParamSpec* g_param_spec_pool_lookup (GParamSpecPool *pool, const gchar *param_name, GType owner_type, gboolean walk_ancestors);
547 return new ParamSpec( g_param_spec_pool_lookup(pool, Str.toStringz(paramName), ownerType, walkAncestors) );
551 * Gets an array of all GParamSpecs owned by owner_type in the pool.
552 * pool:
553 * a GParamSpecPool
554 * owner_type:
555 * the owner to look for
556 * n_pspecs_p:
557 * return location for the length of the returned array
558 * Returns:
559 * a newly allocated array containing pointers to all
560 * GParamSpecs owned by owner_type in the pool
562 public static GParamSpec** poolList(GParamSpecPool* pool, GType ownerType, uint* nPspecsP)
564 // GParamSpec** g_param_spec_pool_list (GParamSpecPool *pool, GType owner_type, guint *n_pspecs_p);
565 return g_param_spec_pool_list(pool, ownerType, nPspecsP);
569 * Gets an GList of all GParamSpecs owned by owner_type in the pool.
570 * pool:
571 * a GParamSpecPool
572 * owner_type:
573 * the owner to look for
574 * Returns:
575 * a GList of all GParamSpecs owned by owner_type in
576 * the poolGParamSpecs.
577 * See Also
578 * g_object_class_install_property(), g_object_set(), g_object_get(),
579 * g_object_set_property(), g_object_get_property(), g_value_register_transform_func()
581 public static ListG poolListOwned(GParamSpecPool* pool, GType ownerType)
583 // GList* g_param_spec_pool_list_owned (GParamSpecPool *pool, GType owner_type);
584 return new ListG( g_param_spec_pool_list_owned(pool, ownerType) );