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