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 * Description 77 * GParamSpec is an object structure that encapsulates the metadata 78 * required to specify parameters, such as e.g. GObject properties. 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 * Sets value to its default value as specified in pspec. 176 * Params: 177 * value = a GValue of correct type for pspec 178 */ 179 public void gParamValueSetDefault(Value value) 180 { 181 // void g_param_value_set_default (GParamSpec *pspec, GValue *value); 182 g_param_value_set_default(gParamSpec, (value is null) ? null : value.getValueStruct()); 183 } 184 185 /** 186 * Checks whether value contains the default value as specified in pspec. 187 * Params: 188 * value = a GValue of correct type for pspec 189 * Returns: whether value contains the canonical default for this pspec 190 */ 191 public int gParamValueDefaults(Value value) 192 { 193 // gboolean g_param_value_defaults (GParamSpec *pspec, GValue *value); 194 return g_param_value_defaults(gParamSpec, (value is null) ? null : value.getValueStruct()); 195 } 196 197 /** 198 * Ensures that the contents of value comply with the specifications 199 * set out by pspec. For example, a GParamSpecInt might require 200 * that integers stored in value may not be smaller than -42 and not be 201 * greater than +42. If value contains an integer outside of this range, 202 * it is modified accordingly, so the resulting value will fit into the 203 * range -42 .. +42. 204 * Params: 205 * value = a GValue of correct type for pspec 206 * Returns: whether modifying value was necessary to ensure validity 207 */ 208 public int gParamValueValidate(Value value) 209 { 210 // gboolean g_param_value_validate (GParamSpec *pspec, GValue *value); 211 return g_param_value_validate(gParamSpec, (value is null) ? null : value.getValueStruct()); 212 } 213 214 /** 215 * Transforms src_value into dest_value if possible, and then 216 * validates dest_value, in order for it to conform to pspec. If 217 * strict_validation is TRUE this function will only succeed if the 218 * transformed dest_value complied to pspec without modifications. 219 * See also g_value_type_transformable(), g_value_transform() and 220 * g_param_value_validate(). 221 * Params: 222 * srcValue = souce GValue 223 * destValue = destination GValue of correct type for pspec 224 * strictValidation = TRUE requires dest_value to conform to pspec 225 * without modifications 226 * Returns: TRUE if transformation and validation were successful, FALSE otherwise and dest_value is left untouched. 227 */ 228 public int gParamValueConvert(Value srcValue, Value destValue, int strictValidation) 229 { 230 // gboolean g_param_value_convert (GParamSpec *pspec, const GValue *src_value, GValue *dest_value, gboolean strict_validation); 231 return g_param_value_convert(gParamSpec, (srcValue is null) ? null : srcValue.getValueStruct(), (destValue is null) ? null : destValue.getValueStruct(), strictValidation); 232 } 233 234 /** 235 * Compares value1 with value2 according to pspec, and return -1, 0 or +1, 236 * if value1 is found to be less than, equal to or greater than value2, 237 * respectively. 238 * Params: 239 * value1 = a GValue of correct type for pspec 240 * value2 = a GValue of correct type for pspec 241 * Returns: -1, 0 or +1, for a less than, equal to or greater than result 242 */ 243 public int gParamValuesCmp(Value value1, Value value2) 244 { 245 // gint g_param_values_cmp (GParamSpec *pspec, const GValue *value1, const GValue *value2); 246 return g_param_values_cmp(gParamSpec, (value1 is null) ? null : value1.getValueStruct(), (value2 is null) ? null : value2.getValueStruct()); 247 } 248 249 /** 250 * Get the name of a GParamSpec. 251 * Returns: the name of pspec. 252 */ 253 public string getName() 254 { 255 // const gchar * g_param_spec_get_name (GParamSpec *pspec); 256 return Str.toString(g_param_spec_get_name(gParamSpec)); 257 } 258 259 /** 260 * Get the nickname of a GParamSpec. 261 * Returns: the nickname of pspec. 262 */ 263 public string getNick() 264 { 265 // const gchar * g_param_spec_get_nick (GParamSpec *pspec); 266 return Str.toString(g_param_spec_get_nick(gParamSpec)); 267 } 268 269 /** 270 * Get the short description of a GParamSpec. 271 * Returns: the short description of pspec. 272 */ 273 public string getBlurb() 274 { 275 // const gchar * g_param_spec_get_blurb (GParamSpec *pspec); 276 return Str.toString(g_param_spec_get_blurb(gParamSpec)); 277 } 278 279 /** 280 * Gets back user data pointers stored via g_param_spec_set_qdata(). 281 * Params: 282 * quark = a GQuark, naming the user data pointer 283 * Returns: the user data pointer set, or NULL. [transfer none] 284 */ 285 public void* getQdata(GQuark quark) 286 { 287 // gpointer g_param_spec_get_qdata (GParamSpec *pspec, GQuark quark); 288 return g_param_spec_get_qdata(gParamSpec, quark); 289 } 290 291 /** 292 * Sets an opaque, named pointer on a GParamSpec. The name is 293 * specified through a GQuark (retrieved e.g. via 294 * g_quark_from_static_string()), and the pointer can be gotten back 295 * from the pspec with g_param_spec_get_qdata(). Setting a 296 * previously set user data pointer, overrides (frees) the old pointer 297 * set, using NULL as pointer essentially removes the data stored. 298 * Params: 299 * quark = a GQuark, naming the user data pointer 300 * data = an opaque user data pointer 301 */ 302 public void setQdata(GQuark quark, void* data) 303 { 304 // void g_param_spec_set_qdata (GParamSpec *pspec, GQuark quark, gpointer data); 305 g_param_spec_set_qdata(gParamSpec, quark, data); 306 } 307 308 /** 309 * This function works like g_param_spec_set_qdata(), but in addition, 310 * a void (*destroy) (gpointer) function may be 311 * specified which is called with data as argument when the pspec is 312 * finalized, or the data is being overwritten by a call to 313 * g_param_spec_set_qdata() with the same quark. 314 * Params: 315 * quark = a GQuark, naming the user data pointer 316 * data = an opaque user data pointer 317 * destroy = function to invoke with data as argument, when data needs to 318 * be freed 319 */ 320 public void setQdataFull(GQuark quark, void* data, GDestroyNotify destroy) 321 { 322 // void g_param_spec_set_qdata_full (GParamSpec *pspec, GQuark quark, gpointer data, GDestroyNotify destroy); 323 g_param_spec_set_qdata_full(gParamSpec, quark, data, destroy); 324 } 325 326 /** 327 * Gets back user data pointers stored via g_param_spec_set_qdata() 328 * and removes the data from pspec without invoking its destroy() 329 * function (if any was set). Usually, calling this function is only 330 * required to update user data pointers with a destroy notifier. 331 * Params: 332 * quark = a GQuark, naming the user data pointer 333 * Returns: the user data pointer set, or NULL. [transfer none] 334 */ 335 public void* stealQdata(GQuark quark) 336 { 337 // gpointer g_param_spec_steal_qdata (GParamSpec *pspec, GQuark quark); 338 return g_param_spec_steal_qdata(gParamSpec, quark); 339 } 340 341 /** 342 * If the paramspec redirects operations to another paramspec, 343 * returns that paramspec. Redirect is used typically for 344 * providing a new implementation of a property in a derived 345 * type while preserving all the properties from the parent 346 * type. Redirection is established by creating a property 347 * of type GParamSpecOverride. See g_object_class_override_property() 348 * for an example of the use of this capability. 349 * Since 2.4 350 * Returns: paramspec to which requests on this paramspec should be redirected, or NULL if none. [transfer none] 351 */ 352 public ParamSpec getRedirectTarget() 353 { 354 // GParamSpec * g_param_spec_get_redirect_target (GParamSpec *pspec); 355 auto p = g_param_spec_get_redirect_target(gParamSpec); 356 357 if(p is null) 358 { 359 return null; 360 } 361 362 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p); 363 } 364 365 /** 366 * Creates a new GParamSpec instance. 367 * A property name consists of segments consisting of ASCII letters and 368 * digits, separated by either the '-' or '_' character. The first 369 * character of a property name must be a letter. Names which violate these 370 * rules lead to undefined behaviour. 371 * When creating and looking up a GParamSpec, either separator can be 372 * used, but they cannot be mixed. Using '-' is considerably more 373 * efficient and in fact required when using property names as detail 374 * strings for signals. 375 * Beyond the name, GParamSpecs have two more descriptive 376 * strings associated with them, the nick, which should be suitable 377 * for use as a label for the property in a property editor, and the 378 * blurb, which should be a somewhat longer description, suitable for 379 * e.g. a tooltip. The nick and blurb should ideally be localized. 380 * Params: 381 * paramType = the GType for the property; must be derived from G_TYPE_PARAM 382 * name = the canonical name of the property 383 * nick = the nickname of the property 384 * blurb = a short description of the property 385 * flags = a combination of GParamFlags 386 * Returns: a newly allocated GParamSpec instance 387 */ 388 public static void* internal(GType paramType, string name, string nick, string blurb, GParamFlags flags) 389 { 390 // gpointer g_param_spec_internal (GType param_type, const gchar *name, const gchar *nick, const gchar *blurb, GParamFlags flags); 391 return g_param_spec_internal(paramType, Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), flags); 392 } 393 394 /** 395 * Registers name as the name of a new static type derived from 396 * G_TYPE_PARAM. The type system uses the information contained in 397 * the GParamSpecTypeInfo structure pointed to by info to manage the 398 * GParamSpec type and its instances. 399 * Params: 400 * name = 0-terminated string used as the name of the new GParamSpec type. 401 * pspecInfo = The GParamSpecTypeInfo for this GParamSpec type. 402 * Returns: The new type identifier. 403 */ 404 public static GType gParamTypeRegisterStatic(string name, GParamSpecTypeInfo* pspecInfo) 405 { 406 // GType g_param_type_register_static (const gchar *name, const GParamSpecTypeInfo *pspec_info); 407 return g_param_type_register_static(Str.toStringz(name), pspecInfo); 408 } 409 }