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 module gobject.Value; 26 27 private import glib.Str; 28 private import glib.Variant; 29 private import glib.VariantType; 30 private import gobject.ObjectG; 31 private import gobject.ParamSpec; 32 private import gobject.Type; 33 private import gobject.TypeInstance; 34 private import gobject.c.functions; 35 public import gobject.c.types; 36 public import gtkc.gobjecttypes; 37 private import std.traits; 38 39 40 /** 41 * An opaque structure used to hold different types of values. 42 * The data within the structure has protected scope: it is accessible only 43 * to functions within a #GTypeValueTable structure, or implementations of 44 * the g_value_*() API. That is, code portions which implement new fundamental 45 * types. 46 * #GValue users cannot make any assumptions about how data is stored 47 * within the 2 element @data union, and the @g_type member should 48 * only be accessed through the G_VALUE_TYPE() macro. 49 */ 50 public class Value 51 { 52 /** the main Gtk struct */ 53 protected GValue* gValue; 54 protected bool ownedRef; 55 56 /** Get the main Gtk struct */ 57 public GValue* getValueStruct(bool transferOwnership = false) 58 { 59 if (transferOwnership) 60 ownedRef = false; 61 return gValue; 62 } 63 64 /** the main Gtk struct as a void* */ 65 protected void* getStruct() 66 { 67 return cast(void*)gValue; 68 } 69 70 /** 71 * Sets our main struct and passes it to the parent class. 72 */ 73 public this (GValue* gValue, bool ownedRef = false) 74 { 75 this.gValue = gValue; 76 this.ownedRef = ownedRef; 77 } 78 79 /** */ 80 public this() 81 { 82 this(new GValue); 83 } 84 85 /** */ 86 this(GOBJECT)(GOBJECT obj) 87 if ( is(GOBJECT == class) && hasMember!(GOBJECT, "getType") ) 88 { 89 this(); 90 init(GOBJECT.getType()); 91 92 static if ( is(GOBJECT : ObjectG) ) 93 { 94 setObject(obj); 95 } 96 else 97 { 98 if ( Type.isA(gValue.gType, GType.BOXED) ) 99 setBoxed(obj.tupleof[0]); 100 else 101 setPointer(obj.tupleof[0]); 102 } 103 } 104 105 106 /** */ 107 this(string value) 108 { 109 this(); 110 init(GType.STRING); 111 setString(value); 112 } 113 114 /** */ 115 this(BOOL)(BOOL value) 116 if( isBoolean!BOOL ) 117 { 118 this(); 119 init(GType.BOOLEAN); 120 setBoolean(value); 121 } 122 123 /** */ 124 this(INT)(INT value) 125 if ( isIntegral!INT ) 126 { 127 this(); 128 129 static if ( is(OriginalType!INT == int) ) 130 { 131 init(GType.INT); 132 setInt(value); 133 } 134 else static if ( is(OriginalType!INT == uint) ) 135 { 136 init(GType.UINT); 137 setUint(value); 138 } 139 else static if ( is(OriginalType!INT == long) ) 140 { 141 init(GType.INT64); 142 setInt64(value); 143 } 144 else static if ( is(OriginalType!INT == ulong) ) 145 { 146 init(GType.UINT64); 147 setUint64(value); 148 } 149 else 150 { 151 init(GType.INT); 152 setInt(value); 153 } 154 } 155 156 /** */ 157 this(FLOAT)(FLOAT value) 158 if ( isFloatingPoint!FLOAT ) 159 { 160 this(); 161 162 static if ( is( FLOAT == float ) ) 163 { 164 init(GType.FLOAT); 165 setFloat(value); 166 } 167 else 168 { 169 init(GType.DOUBLE); 170 setDouble(value); 171 } 172 } 173 174 /** 175 * The GType of the contianed value. 176 */ 177 public @property GType gType() 178 { 179 return gValue.gType; 180 } 181 182 /** 183 * Retrieves a TYPE from Value, the Value must contain the appropriate type. 184 */ 185 public TYPE get(TYPE)() 186 { 187 static if ( is(TYPE == bool) ) 188 return getBoolean(); 189 else static if ( is(TYPE == byte) ) 190 return getSchar(); 191 else static if ( is(TYPE == ubyte) ) 192 return getUchar(); 193 else static if ( is(TYPE == int) ) 194 return getInt(); 195 else static if ( is(TYPE == uint) ) 196 return getUint(); 197 else static if ( is(TYPE == long) ) 198 return getInt64(); 199 else static if ( is(TYPE == ulong) ) 200 return getUint64(); 201 else static if ( is(TYPE == float) ) 202 return getFloat(); 203 else static if ( is(TYPE == double) ) 204 return getDouble(); 205 else static if ( is(TYPE == string) ) 206 return getString(); 207 else static if ( is(TYPE == string[]) ) 208 return Str.toStringArray(cast(const(char*)*)getPointer()); 209 else static if ( is(TYPE == enum) ) 210 return cast(TYPE)(Type.isA(gValue.gType, GType.ENUM) ? getEnum() : getFlags()); 211 else static if ( isPointer!TYPE ) 212 return cast(TYPE)(Type.isA(gValue.gType, GType.POINTER) ? getPointer() : (Type.isA(gValue.gType, GType.BOXED) ? getBoxed() : g_value_get_object(gValue))); 213 else static if ( is(TYPE == interface) ) 214 return cast(TYPE)getObject(); 215 else static if ( is(TYPE == class) ) 216 { 217 static if ( is(TYPE == Variant) ) 218 return getVariant(); 219 else static if ( is(TYPE== ParamSpec) ) 220 return getParam(); 221 else static if ( is(TYPE : ObjectG) ) 222 return cast(TYPE)getObject(); 223 else 224 return ObjectG.getDObject!(TYPE)(cast(typeof(TYPE.tupleof[0]))(Type.isA(gValue.gType, GType.POINTER) ? getPointer() : (Type.isA(gValue.gType, GType.BOXED) ? getBoxed() : g_value_get_object(gValue)))); 225 } 226 } 227 228 /** 229 */ 230 231 /** */ 232 public static GType getType() 233 { 234 return g_value_get_type(); 235 } 236 237 /** 238 * Copies the value of @src_value into @dest_value. 239 * 240 * Params: 241 * destValue = An initialized #GValue structure of the same type as @src_value. 242 */ 243 public void copy(Value destValue) 244 { 245 g_value_copy(gValue, (destValue is null) ? null : destValue.getValueStruct()); 246 } 247 248 /** 249 * Get the contents of a %G_TYPE_BOXED derived #GValue. Upon getting, 250 * the boxed value is duplicated and needs to be later freed with 251 * g_boxed_free(), e.g. like: g_boxed_free (G_VALUE_TYPE (@value), 252 * return_value); 253 * 254 * Returns: boxed contents of @value 255 */ 256 public void* dupBoxed() 257 { 258 return g_value_dup_boxed(gValue); 259 } 260 261 /** 262 * Get the contents of a %G_TYPE_OBJECT derived #GValue, increasing 263 * its reference count. If the contents of the #GValue are %NULL, then 264 * %NULL will be returned. 265 * 266 * Returns: object content of @value, 267 * should be unreferenced when no longer needed. 268 */ 269 public ObjectG dupObject() 270 { 271 auto p = g_value_dup_object(gValue); 272 273 if(p is null) 274 { 275 return null; 276 } 277 278 return ObjectG.getDObject!(ObjectG)(cast(GObject*) p, true); 279 } 280 281 /** 282 * Get the contents of a %G_TYPE_PARAM #GValue, increasing its 283 * reference count. 284 * 285 * Returns: #GParamSpec content of @value, should be unreferenced when 286 * no longer needed. 287 */ 288 public ParamSpec dupParam() 289 { 290 auto p = g_value_dup_param(gValue); 291 292 if(p is null) 293 { 294 return null; 295 } 296 297 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p); 298 } 299 300 /** 301 * Get a copy the contents of a %G_TYPE_STRING #GValue. 302 * 303 * Returns: a newly allocated copy of the string content of @value 304 */ 305 public string dupString() 306 { 307 auto retStr = g_value_dup_string(gValue); 308 309 scope(exit) Str.freeString(retStr); 310 return Str.toString(retStr); 311 } 312 313 /** 314 * Get the contents of a variant #GValue, increasing its refcount. The returned 315 * #GVariant is never floating. 316 * 317 * Returns: variant contents of @value (may be %NULL); 318 * should be unreffed using g_variant_unref() when no longer needed 319 * 320 * Since: 2.26 321 */ 322 public Variant dupVariant() 323 { 324 auto p = g_value_dup_variant(gValue); 325 326 if(p is null) 327 { 328 return null; 329 } 330 331 return new Variant(cast(GVariant*) p, true); 332 } 333 334 /** 335 * Determines if @value will fit inside the size of a pointer value. 336 * This is an internal function introduced mainly for C marshallers. 337 * 338 * Returns: %TRUE if @value will fit inside a pointer value. 339 */ 340 public bool fitsPointer() 341 { 342 return g_value_fits_pointer(gValue) != 0; 343 } 344 345 /** 346 * Get the contents of a %G_TYPE_BOOLEAN #GValue. 347 * 348 * Returns: boolean contents of @value 349 */ 350 public bool getBoolean() 351 { 352 return g_value_get_boolean(gValue) != 0; 353 } 354 355 /** 356 * Get the contents of a %G_TYPE_BOXED derived #GValue. 357 * 358 * Returns: boxed contents of @value 359 */ 360 public void* getBoxed() 361 { 362 return g_value_get_boxed(gValue); 363 } 364 365 /** 366 * Do not use this function; it is broken on platforms where the %char 367 * type is unsigned, such as ARM and PowerPC. See g_value_get_schar(). 368 * 369 * Get the contents of a %G_TYPE_CHAR #GValue. 370 * 371 * Deprecated: This function's return type is broken, see g_value_get_schar() 372 * 373 * Returns: character contents of @value 374 */ 375 public char getChar() 376 { 377 return g_value_get_char(gValue); 378 } 379 380 /** 381 * Get the contents of a %G_TYPE_DOUBLE #GValue. 382 * 383 * Returns: double contents of @value 384 */ 385 public double getDouble() 386 { 387 return g_value_get_double(gValue); 388 } 389 390 /** 391 * Get the contents of a %G_TYPE_ENUM #GValue. 392 * 393 * Returns: enum contents of @value 394 */ 395 public int getEnum() 396 { 397 return g_value_get_enum(gValue); 398 } 399 400 /** 401 * Get the contents of a %G_TYPE_FLAGS #GValue. 402 * 403 * Returns: flags contents of @value 404 */ 405 public uint getFlags() 406 { 407 return g_value_get_flags(gValue); 408 } 409 410 /** 411 * Get the contents of a %G_TYPE_FLOAT #GValue. 412 * 413 * Returns: float contents of @value 414 */ 415 public float getFloat() 416 { 417 return g_value_get_float(gValue); 418 } 419 420 /** 421 * Get the contents of a %G_TYPE_GTYPE #GValue. 422 * 423 * Returns: the #GType stored in @value 424 * 425 * Since: 2.12 426 */ 427 public GType getGtype() 428 { 429 return g_value_get_gtype(gValue); 430 } 431 432 /** 433 * Get the contents of a %G_TYPE_INT #GValue. 434 * 435 * Returns: integer contents of @value 436 */ 437 public int getInt() 438 { 439 return g_value_get_int(gValue); 440 } 441 442 /** 443 * Get the contents of a %G_TYPE_INT64 #GValue. 444 * 445 * Returns: 64bit integer contents of @value 446 */ 447 public long getInt64() 448 { 449 return g_value_get_int64(gValue); 450 } 451 452 /** 453 * Get the contents of a %G_TYPE_LONG #GValue. 454 * 455 * Returns: long integer contents of @value 456 */ 457 public glong getLong() 458 { 459 return g_value_get_long(gValue); 460 } 461 462 /** 463 * Get the contents of a %G_TYPE_OBJECT derived #GValue. 464 * 465 * Returns: object contents of @value 466 */ 467 public ObjectG getObject() 468 { 469 auto p = g_value_get_object(gValue); 470 471 if(p is null) 472 { 473 return null; 474 } 475 476 return ObjectG.getDObject!(ObjectG)(cast(GObject*) p); 477 } 478 479 /** 480 * Get the contents of a %G_TYPE_PARAM #GValue. 481 * 482 * Returns: #GParamSpec content of @value 483 */ 484 public ParamSpec getParam() 485 { 486 auto p = g_value_get_param(gValue); 487 488 if(p is null) 489 { 490 return null; 491 } 492 493 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p); 494 } 495 496 /** 497 * Get the contents of a pointer #GValue. 498 * 499 * Returns: pointer contents of @value 500 */ 501 public void* getPointer() 502 { 503 return g_value_get_pointer(gValue); 504 } 505 506 /** 507 * Get the contents of a %G_TYPE_CHAR #GValue. 508 * 509 * Returns: signed 8 bit integer contents of @value 510 * 511 * Since: 2.32 512 */ 513 public byte getSchar() 514 { 515 return g_value_get_schar(gValue); 516 } 517 518 /** 519 * Get the contents of a %G_TYPE_STRING #GValue. 520 * 521 * Returns: string content of @value 522 */ 523 public string getString() 524 { 525 return Str.toString(g_value_get_string(gValue)); 526 } 527 528 /** 529 * Get the contents of a %G_TYPE_UCHAR #GValue. 530 * 531 * Returns: unsigned character contents of @value 532 */ 533 public char getUchar() 534 { 535 return g_value_get_uchar(gValue); 536 } 537 538 /** 539 * Get the contents of a %G_TYPE_UINT #GValue. 540 * 541 * Returns: unsigned integer contents of @value 542 */ 543 public uint getUint() 544 { 545 return g_value_get_uint(gValue); 546 } 547 548 /** 549 * Get the contents of a %G_TYPE_UINT64 #GValue. 550 * 551 * Returns: unsigned 64bit integer contents of @value 552 */ 553 public ulong getUint64() 554 { 555 return g_value_get_uint64(gValue); 556 } 557 558 /** 559 * Get the contents of a %G_TYPE_ULONG #GValue. 560 * 561 * Returns: unsigned long integer contents of @value 562 */ 563 public gulong getUlong() 564 { 565 return g_value_get_ulong(gValue); 566 } 567 568 /** 569 * Get the contents of a variant #GValue. 570 * 571 * Returns: variant contents of @value (may be %NULL) 572 * 573 * Since: 2.26 574 */ 575 public Variant getVariant() 576 { 577 auto p = g_value_get_variant(gValue); 578 579 if(p is null) 580 { 581 return null; 582 } 583 584 return new Variant(cast(GVariant*) p); 585 } 586 587 /** 588 * Initializes @value with the default value of @type. 589 * 590 * Params: 591 * gType = Type the #GValue should hold values of. 592 * 593 * Returns: the #GValue structure that has been passed in 594 */ 595 public Value init(GType gType) 596 { 597 auto p = g_value_init(gValue, gType); 598 599 if(p is null) 600 { 601 return null; 602 } 603 604 return ObjectG.getDObject!(Value)(cast(GValue*) p); 605 } 606 607 /** 608 * Initializes and sets @value from an instantiatable type via the 609 * value_table's collect_value() function. 610 * 611 * Note: The @value will be initialised with the exact type of 612 * @instance. If you wish to set the @value's type to a different GType 613 * (such as a parent class GType), you need to manually call 614 * g_value_init() and g_value_set_instance(). 615 * 616 * Params: 617 * instance_ = the instance 618 * 619 * Since: 2.42 620 */ 621 public void initFromInstance(TypeInstance instance_) 622 { 623 g_value_init_from_instance(gValue, (instance_ is null) ? null : instance_.getTypeInstanceStruct()); 624 } 625 626 /** 627 * Returns the value contents as pointer. This function asserts that 628 * g_value_fits_pointer() returned %TRUE for the passed in value. 629 * This is an internal function introduced mainly for C marshallers. 630 * 631 * Returns: the value contents as pointer 632 */ 633 public void* peekPointer() 634 { 635 return g_value_peek_pointer(gValue); 636 } 637 638 /** 639 * Clears the current value in @value and resets it to the default value 640 * (as if the value had just been initialized). 641 * 642 * Returns: the #GValue structure that has been passed in 643 */ 644 public Value reset() 645 { 646 auto p = g_value_reset(gValue); 647 648 if(p is null) 649 { 650 return null; 651 } 652 653 return ObjectG.getDObject!(Value)(cast(GValue*) p, true); 654 } 655 656 /** 657 * Set the contents of a %G_TYPE_BOOLEAN #GValue to @v_boolean. 658 * 659 * Params: 660 * vBoolean = boolean value to be set 661 */ 662 public void setBoolean(bool vBoolean) 663 { 664 g_value_set_boolean(gValue, vBoolean); 665 } 666 667 /** 668 * Set the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed. 669 * 670 * Params: 671 * vBoxed = boxed value to be set 672 */ 673 public void setBoxed(void* vBoxed) 674 { 675 g_value_set_boxed(gValue, vBoxed); 676 } 677 678 /** 679 * This is an internal function introduced mainly for C marshallers. 680 * 681 * Deprecated: Use g_value_take_boxed() instead. 682 * 683 * Params: 684 * vBoxed = duplicated unowned boxed value to be set 685 */ 686 public void setBoxedTakeOwnership(void* vBoxed) 687 { 688 g_value_set_boxed_take_ownership(gValue, vBoxed); 689 } 690 691 /** 692 * Set the contents of a %G_TYPE_CHAR #GValue to @v_char. 693 * 694 * Deprecated: This function's input type is broken, see g_value_set_schar() 695 * 696 * Params: 697 * vChar = character value to be set 698 */ 699 public void setChar(char vChar) 700 { 701 g_value_set_char(gValue, vChar); 702 } 703 704 /** 705 * Set the contents of a %G_TYPE_DOUBLE #GValue to @v_double. 706 * 707 * Params: 708 * vDouble = double value to be set 709 */ 710 public void setDouble(double vDouble) 711 { 712 g_value_set_double(gValue, vDouble); 713 } 714 715 /** 716 * Set the contents of a %G_TYPE_ENUM #GValue to @v_enum. 717 * 718 * Params: 719 * vEnum = enum value to be set 720 */ 721 public void setEnum(int vEnum) 722 { 723 g_value_set_enum(gValue, vEnum); 724 } 725 726 /** 727 * Set the contents of a %G_TYPE_FLAGS #GValue to @v_flags. 728 * 729 * Params: 730 * vFlags = flags value to be set 731 */ 732 public void setFlags(uint vFlags) 733 { 734 g_value_set_flags(gValue, vFlags); 735 } 736 737 /** 738 * Set the contents of a %G_TYPE_FLOAT #GValue to @v_float. 739 * 740 * Params: 741 * vFloat = float value to be set 742 */ 743 public void setFloat(float vFloat) 744 { 745 g_value_set_float(gValue, vFloat); 746 } 747 748 /** 749 * Set the contents of a %G_TYPE_GTYPE #GValue to @v_gtype. 750 * 751 * Params: 752 * vGtype = #GType to be set 753 * 754 * Since: 2.12 755 */ 756 public void setGtype(GType vGtype) 757 { 758 g_value_set_gtype(gValue, vGtype); 759 } 760 761 /** 762 * Sets @value from an instantiatable type via the 763 * value_table's collect_value() function. 764 * 765 * Params: 766 * instance_ = the instance 767 */ 768 public void setInstance(void* instance_) 769 { 770 g_value_set_instance(gValue, instance_); 771 } 772 773 /** 774 * Set the contents of a %G_TYPE_INT #GValue to @v_int. 775 * 776 * Params: 777 * vInt = integer value to be set 778 */ 779 public void setInt(int vInt) 780 { 781 g_value_set_int(gValue, vInt); 782 } 783 784 /** 785 * Set the contents of a %G_TYPE_INT64 #GValue to @v_int64. 786 * 787 * Params: 788 * vInt64 = 64bit integer value to be set 789 */ 790 public void setInt64(long vInt64) 791 { 792 g_value_set_int64(gValue, vInt64); 793 } 794 795 /** 796 * Set the contents of a %G_TYPE_LONG #GValue to @v_long. 797 * 798 * Params: 799 * vLong = long integer value to be set 800 */ 801 public void setLong(glong vLong) 802 { 803 g_value_set_long(gValue, vLong); 804 } 805 806 /** 807 * Set the contents of a %G_TYPE_OBJECT derived #GValue to @v_object. 808 * 809 * g_value_set_object() increases the reference count of @v_object 810 * (the #GValue holds a reference to @v_object). If you do not wish 811 * to increase the reference count of the object (i.e. you wish to 812 * pass your current reference to the #GValue because you no longer 813 * need it), use g_value_take_object() instead. 814 * 815 * It is important that your #GValue holds a reference to @v_object (either its 816 * own, or one it has taken) to ensure that the object won't be destroyed while 817 * the #GValue still exists). 818 * 819 * Params: 820 * vObject = object value to be set 821 */ 822 public void setObject(ObjectG vObject) 823 { 824 g_value_set_object(gValue, (vObject is null) ? null : vObject.getObjectGStruct()); 825 } 826 827 /** 828 * This is an internal function introduced mainly for C marshallers. 829 * 830 * Deprecated: Use g_value_take_object() instead. 831 * 832 * Params: 833 * vObject = object value to be set 834 */ 835 public void setObjectTakeOwnership(void* vObject) 836 { 837 g_value_set_object_take_ownership(gValue, vObject); 838 } 839 840 /** 841 * Set the contents of a %G_TYPE_PARAM #GValue to @param. 842 * 843 * Params: 844 * param = the #GParamSpec to be set 845 */ 846 public void setParam(ParamSpec param) 847 { 848 g_value_set_param(gValue, (param is null) ? null : param.getParamSpecStruct()); 849 } 850 851 /** 852 * This is an internal function introduced mainly for C marshallers. 853 * 854 * Deprecated: Use g_value_take_param() instead. 855 * 856 * Params: 857 * param = the #GParamSpec to be set 858 */ 859 public void setParamTakeOwnership(ParamSpec param) 860 { 861 g_value_set_param_take_ownership(gValue, (param is null) ? null : param.getParamSpecStruct()); 862 } 863 864 /** 865 * Set the contents of a pointer #GValue to @v_pointer. 866 * 867 * Params: 868 * vPointer = pointer value to be set 869 */ 870 public void setPointer(void* vPointer) 871 { 872 g_value_set_pointer(gValue, vPointer); 873 } 874 875 /** 876 * Set the contents of a %G_TYPE_CHAR #GValue to @v_char. 877 * 878 * Params: 879 * vChar = signed 8 bit integer to be set 880 * 881 * Since: 2.32 882 */ 883 public void setSchar(byte vChar) 884 { 885 g_value_set_schar(gValue, vChar); 886 } 887 888 /** 889 * Set the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed. 890 * The boxed value is assumed to be static, and is thus not duplicated 891 * when setting the #GValue. 892 * 893 * Params: 894 * vBoxed = static boxed value to be set 895 */ 896 public void setStaticBoxed(void* vBoxed) 897 { 898 g_value_set_static_boxed(gValue, vBoxed); 899 } 900 901 /** 902 * Set the contents of a %G_TYPE_STRING #GValue to @v_string. 903 * The string is assumed to be static, and is thus not duplicated 904 * when setting the #GValue. 905 * 906 * Params: 907 * vString = static string to be set 908 */ 909 public void setStaticString(string vString) 910 { 911 g_value_set_static_string(gValue, Str.toStringz(vString)); 912 } 913 914 /** 915 * Set the contents of a %G_TYPE_STRING #GValue to @v_string. 916 * 917 * Params: 918 * vString = caller-owned string to be duplicated for the #GValue 919 */ 920 public void setString(string vString) 921 { 922 g_value_set_string(gValue, Str.toStringz(vString)); 923 } 924 925 /** 926 * This is an internal function introduced mainly for C marshallers. 927 * 928 * Deprecated: Use g_value_take_string() instead. 929 * 930 * Params: 931 * vString = duplicated unowned string to be set 932 */ 933 public void setStringTakeOwnership(string vString) 934 { 935 g_value_set_string_take_ownership(gValue, Str.toStringz(vString)); 936 } 937 938 /** 939 * Set the contents of a %G_TYPE_UCHAR #GValue to @v_uchar. 940 * 941 * Params: 942 * vUchar = unsigned character value to be set 943 */ 944 public void setUchar(char vUchar) 945 { 946 g_value_set_uchar(gValue, vUchar); 947 } 948 949 /** 950 * Set the contents of a %G_TYPE_UINT #GValue to @v_uint. 951 * 952 * Params: 953 * vUint = unsigned integer value to be set 954 */ 955 public void setUint(uint vUint) 956 { 957 g_value_set_uint(gValue, vUint); 958 } 959 960 /** 961 * Set the contents of a %G_TYPE_UINT64 #GValue to @v_uint64. 962 * 963 * Params: 964 * vUint64 = unsigned 64bit integer value to be set 965 */ 966 public void setUint64(ulong vUint64) 967 { 968 g_value_set_uint64(gValue, vUint64); 969 } 970 971 /** 972 * Set the contents of a %G_TYPE_ULONG #GValue to @v_ulong. 973 * 974 * Params: 975 * vUlong = unsigned long integer value to be set 976 */ 977 public void setUlong(gulong vUlong) 978 { 979 g_value_set_ulong(gValue, vUlong); 980 } 981 982 /** 983 * Set the contents of a variant #GValue to @variant. 984 * If the variant is floating, it is consumed. 985 * 986 * Params: 987 * variant = a #GVariant, or %NULL 988 * 989 * Since: 2.26 990 */ 991 public void setVariant(Variant variant) 992 { 993 g_value_set_variant(gValue, (variant is null) ? null : variant.getVariantStruct()); 994 } 995 996 /** 997 * Sets the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed 998 * and takes over the ownership of the callers reference to @v_boxed; 999 * the caller doesn't have to unref it any more. 1000 * 1001 * Params: 1002 * vBoxed = duplicated unowned boxed value to be set 1003 * 1004 * Since: 2.4 1005 */ 1006 public void takeBoxed(void* vBoxed) 1007 { 1008 g_value_take_boxed(gValue, vBoxed); 1009 } 1010 1011 /** 1012 * Sets the contents of a %G_TYPE_OBJECT derived #GValue to @v_object 1013 * and takes over the ownership of the callers reference to @v_object; 1014 * the caller doesn't have to unref it any more (i.e. the reference 1015 * count of the object is not increased). 1016 * 1017 * If you want the #GValue to hold its own reference to @v_object, use 1018 * g_value_set_object() instead. 1019 * 1020 * Params: 1021 * vObject = object value to be set 1022 * 1023 * Since: 2.4 1024 */ 1025 public void takeObject(void* vObject) 1026 { 1027 g_value_take_object(gValue, vObject); 1028 } 1029 1030 /** 1031 * Sets the contents of a %G_TYPE_PARAM #GValue to @param and takes 1032 * over the ownership of the callers reference to @param; the caller 1033 * doesn't have to unref it any more. 1034 * 1035 * Params: 1036 * param = the #GParamSpec to be set 1037 * 1038 * Since: 2.4 1039 */ 1040 public void takeParam(ParamSpec param) 1041 { 1042 g_value_take_param(gValue, (param is null) ? null : param.getParamSpecStruct()); 1043 } 1044 1045 /** 1046 * Sets the contents of a %G_TYPE_STRING #GValue to @v_string. 1047 * 1048 * Params: 1049 * vString = string to take ownership of 1050 * 1051 * Since: 2.4 1052 */ 1053 public void takeString(string vString) 1054 { 1055 g_value_take_string(gValue, Str.toStringz(vString)); 1056 } 1057 1058 /** 1059 * Set the contents of a variant #GValue to @variant, and takes over 1060 * the ownership of the caller's reference to @variant; 1061 * the caller doesn't have to unref it any more (i.e. the reference 1062 * count of the variant is not increased). 1063 * 1064 * If @variant was floating then its floating reference is converted to 1065 * a hard reference. 1066 * 1067 * If you want the #GValue to hold its own reference to @variant, use 1068 * g_value_set_variant() instead. 1069 * 1070 * This is an internal function introduced mainly for C marshallers. 1071 * 1072 * Params: 1073 * variant = a #GVariant, or %NULL 1074 * 1075 * Since: 2.26 1076 */ 1077 public void takeVariant(Variant variant) 1078 { 1079 g_value_take_variant(gValue, (variant is null) ? null : variant.getVariantStruct(true)); 1080 } 1081 1082 /** 1083 * Tries to cast the contents of @src_value into a type appropriate 1084 * to store in @dest_value, e.g. to transform a %G_TYPE_INT value 1085 * into a %G_TYPE_FLOAT value. Performing transformations between 1086 * value types might incur precision lossage. Especially 1087 * transformations into strings might reveal seemingly arbitrary 1088 * results and shouldn't be relied upon for production code (such 1089 * as rcfile value or object property serialization). 1090 * 1091 * Params: 1092 * destValue = Target value. 1093 * 1094 * Returns: Whether a transformation rule was found and could be applied. 1095 * Upon failing transformations, @dest_value is left untouched. 1096 */ 1097 public bool transform(Value destValue) 1098 { 1099 return g_value_transform(gValue, (destValue is null) ? null : destValue.getValueStruct()) != 0; 1100 } 1101 1102 /** 1103 * Clears the current value in @value (if any) and "unsets" the type, 1104 * this releases all resources associated with this GValue. An unset 1105 * value is the same as an uninitialized (zero-filled) #GValue 1106 * structure. 1107 */ 1108 public void unset() 1109 { 1110 g_value_unset(gValue); 1111 } 1112 1113 /** 1114 * Registers a value transformation function for use in g_value_transform(). 1115 * A previously registered transformation function for @src_type and @dest_type 1116 * will be replaced. 1117 * 1118 * Params: 1119 * srcType = Source type. 1120 * destType = Target type. 1121 * transformFunc = a function which transforms values of type @src_type 1122 * into value of type @dest_type 1123 */ 1124 public static void registerTransformFunc(GType srcType, GType destType, GValueTransform transformFunc) 1125 { 1126 g_value_register_transform_func(srcType, destType, transformFunc); 1127 } 1128 1129 /** 1130 * Returns whether a #GValue of type @src_type can be copied into 1131 * a #GValue of type @dest_type. 1132 * 1133 * Params: 1134 * srcType = source type to be copied. 1135 * destType = destination type for copying. 1136 * 1137 * Returns: %TRUE if g_value_copy() is possible with @src_type and @dest_type. 1138 */ 1139 public static bool typeCompatible(GType srcType, GType destType) 1140 { 1141 return g_value_type_compatible(srcType, destType) != 0; 1142 } 1143 1144 /** 1145 * Check whether g_value_transform() is able to transform values 1146 * of type @src_type into values of type @dest_type. Note that for 1147 * the types to be transformable, they must be compatible or a 1148 * transformation function must be registered. 1149 * 1150 * Params: 1151 * srcType = Source type. 1152 * destType = Target type. 1153 * 1154 * Returns: %TRUE if the transformation is possible, %FALSE otherwise. 1155 */ 1156 public static bool typeTransformable(GType srcType, GType destType) 1157 { 1158 return g_value_type_transformable(srcType, destType) != 0; 1159 } 1160 1161 /** 1162 * Creates a new #GParamSpecBoolean instance specifying a %G_TYPE_BOOLEAN 1163 * property. In many cases, it may be more appropriate to use an enum with 1164 * g_param_spec_enum(), both to improve code clarity by using explicitly named 1165 * values, and to allow for more values to be added in future without breaking 1166 * API. 1167 * 1168 * See g_param_spec_internal() for details on property names. 1169 * 1170 * Params: 1171 * name = canonical name of the property specified 1172 * nick = nick name for the property specified 1173 * blurb = description of the property specified 1174 * defaultValue = default value for the property specified 1175 * flags = flags for the property specified 1176 * 1177 * Returns: a newly created parameter specification 1178 */ 1179 public static ParamSpec paramSpecBoolean(string name, string nick, string blurb, bool defaultValue, GParamFlags flags) 1180 { 1181 auto p = g_param_spec_boolean(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), defaultValue, flags); 1182 1183 if(p is null) 1184 { 1185 return null; 1186 } 1187 1188 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1189 } 1190 1191 /** 1192 * Creates a new #GParamSpecBoxed instance specifying a %G_TYPE_BOXED 1193 * derived property. 1194 * 1195 * See g_param_spec_internal() for details on property names. 1196 * 1197 * Params: 1198 * name = canonical name of the property specified 1199 * nick = nick name for the property specified 1200 * blurb = description of the property specified 1201 * boxedType = %G_TYPE_BOXED derived type of this property 1202 * flags = flags for the property specified 1203 * 1204 * Returns: a newly created parameter specification 1205 */ 1206 public static ParamSpec paramSpecBoxed(string name, string nick, string blurb, GType boxedType, GParamFlags flags) 1207 { 1208 auto p = g_param_spec_boxed(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), boxedType, flags); 1209 1210 if(p is null) 1211 { 1212 return null; 1213 } 1214 1215 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1216 } 1217 1218 /** 1219 * Creates a new #GParamSpecChar instance specifying a %G_TYPE_CHAR property. 1220 * 1221 * Params: 1222 * name = canonical name of the property specified 1223 * nick = nick name for the property specified 1224 * blurb = description of the property specified 1225 * minimum = minimum value for the property specified 1226 * maximum = maximum value for the property specified 1227 * defaultValue = default value for the property specified 1228 * flags = flags for the property specified 1229 * 1230 * Returns: a newly created parameter specification 1231 */ 1232 public static ParamSpec paramSpecChar(string name, string nick, string blurb, byte minimum, byte maximum, byte defaultValue, GParamFlags flags) 1233 { 1234 auto p = g_param_spec_char(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1235 1236 if(p is null) 1237 { 1238 return null; 1239 } 1240 1241 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1242 } 1243 1244 /** 1245 * Creates a new #GParamSpecDouble instance specifying a %G_TYPE_DOUBLE 1246 * property. 1247 * 1248 * See g_param_spec_internal() for details on property names. 1249 * 1250 * Params: 1251 * name = canonical name of the property specified 1252 * nick = nick name for the property specified 1253 * blurb = description of the property specified 1254 * minimum = minimum value for the property specified 1255 * maximum = maximum value for the property specified 1256 * defaultValue = default value for the property specified 1257 * flags = flags for the property specified 1258 * 1259 * Returns: a newly created parameter specification 1260 */ 1261 public static ParamSpec paramSpecDouble(string name, string nick, string blurb, double minimum, double maximum, double defaultValue, GParamFlags flags) 1262 { 1263 auto p = g_param_spec_double(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1264 1265 if(p is null) 1266 { 1267 return null; 1268 } 1269 1270 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1271 } 1272 1273 /** 1274 * Creates a new #GParamSpecEnum instance specifying a %G_TYPE_ENUM 1275 * property. 1276 * 1277 * See g_param_spec_internal() for details on property names. 1278 * 1279 * Params: 1280 * name = canonical name of the property specified 1281 * nick = nick name for the property specified 1282 * blurb = description of the property specified 1283 * enumType = a #GType derived from %G_TYPE_ENUM 1284 * defaultValue = default value for the property specified 1285 * flags = flags for the property specified 1286 * 1287 * Returns: a newly created parameter specification 1288 */ 1289 public static ParamSpec paramSpecEnum(string name, string nick, string blurb, GType enumType, int defaultValue, GParamFlags flags) 1290 { 1291 auto p = g_param_spec_enum(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), enumType, defaultValue, flags); 1292 1293 if(p is null) 1294 { 1295 return null; 1296 } 1297 1298 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1299 } 1300 1301 /** 1302 * Creates a new #GParamSpecFlags instance specifying a %G_TYPE_FLAGS 1303 * property. 1304 * 1305 * See g_param_spec_internal() for details on property names. 1306 * 1307 * Params: 1308 * name = canonical name of the property specified 1309 * nick = nick name for the property specified 1310 * blurb = description of the property specified 1311 * flagsType = a #GType derived from %G_TYPE_FLAGS 1312 * defaultValue = default value for the property specified 1313 * flags = flags for the property specified 1314 * 1315 * Returns: a newly created parameter specification 1316 */ 1317 public static ParamSpec paramSpecFlags(string name, string nick, string blurb, GType flagsType, uint defaultValue, GParamFlags flags) 1318 { 1319 auto p = g_param_spec_flags(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), flagsType, defaultValue, flags); 1320 1321 if(p is null) 1322 { 1323 return null; 1324 } 1325 1326 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1327 } 1328 1329 /** 1330 * Creates a new #GParamSpecFloat instance specifying a %G_TYPE_FLOAT property. 1331 * 1332 * See g_param_spec_internal() for details on property names. 1333 * 1334 * Params: 1335 * name = canonical name of the property specified 1336 * nick = nick name for the property specified 1337 * blurb = description of the property specified 1338 * minimum = minimum value for the property specified 1339 * maximum = maximum value for the property specified 1340 * defaultValue = default value for the property specified 1341 * flags = flags for the property specified 1342 * 1343 * Returns: a newly created parameter specification 1344 */ 1345 public static ParamSpec paramSpecFloat(string name, string nick, string blurb, float minimum, float maximum, float defaultValue, GParamFlags flags) 1346 { 1347 auto p = g_param_spec_float(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1348 1349 if(p is null) 1350 { 1351 return null; 1352 } 1353 1354 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1355 } 1356 1357 /** 1358 * Creates a new #GParamSpecGType instance specifying a 1359 * %G_TYPE_GTYPE property. 1360 * 1361 * See g_param_spec_internal() for details on property names. 1362 * 1363 * Params: 1364 * name = canonical name of the property specified 1365 * nick = nick name for the property specified 1366 * blurb = description of the property specified 1367 * isAType = a #GType whose subtypes are allowed as values 1368 * of the property (use %G_TYPE_NONE for any type) 1369 * flags = flags for the property specified 1370 * 1371 * Returns: a newly created parameter specification 1372 * 1373 * Since: 2.10 1374 */ 1375 public static ParamSpec paramSpecGtype(string name, string nick, string blurb, GType isAType, GParamFlags flags) 1376 { 1377 auto p = g_param_spec_gtype(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), isAType, flags); 1378 1379 if(p is null) 1380 { 1381 return null; 1382 } 1383 1384 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1385 } 1386 1387 /** 1388 * Creates a new #GParamSpecInt instance specifying a %G_TYPE_INT property. 1389 * 1390 * See g_param_spec_internal() for details on property names. 1391 * 1392 * Params: 1393 * name = canonical name of the property specified 1394 * nick = nick name for the property specified 1395 * blurb = description of the property specified 1396 * minimum = minimum value for the property specified 1397 * maximum = maximum value for the property specified 1398 * defaultValue = default value for the property specified 1399 * flags = flags for the property specified 1400 * 1401 * Returns: a newly created parameter specification 1402 */ 1403 public static ParamSpec paramSpecInt(string name, string nick, string blurb, int minimum, int maximum, int defaultValue, GParamFlags flags) 1404 { 1405 auto p = g_param_spec_int(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1406 1407 if(p is null) 1408 { 1409 return null; 1410 } 1411 1412 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1413 } 1414 1415 /** 1416 * Creates a new #GParamSpecInt64 instance specifying a %G_TYPE_INT64 property. 1417 * 1418 * See g_param_spec_internal() for details on property names. 1419 * 1420 * Params: 1421 * name = canonical name of the property specified 1422 * nick = nick name for the property specified 1423 * blurb = description of the property specified 1424 * minimum = minimum value for the property specified 1425 * maximum = maximum value for the property specified 1426 * defaultValue = default value for the property specified 1427 * flags = flags for the property specified 1428 * 1429 * Returns: a newly created parameter specification 1430 */ 1431 public static ParamSpec paramSpecInt64(string name, string nick, string blurb, long minimum, long maximum, long defaultValue, GParamFlags flags) 1432 { 1433 auto p = g_param_spec_int64(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1434 1435 if(p is null) 1436 { 1437 return null; 1438 } 1439 1440 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1441 } 1442 1443 /** 1444 * Creates a new #GParamSpecLong instance specifying a %G_TYPE_LONG property. 1445 * 1446 * See g_param_spec_internal() for details on property names. 1447 * 1448 * Params: 1449 * name = canonical name of the property specified 1450 * nick = nick name for the property specified 1451 * blurb = description of the property specified 1452 * minimum = minimum value for the property specified 1453 * maximum = maximum value for the property specified 1454 * defaultValue = default value for the property specified 1455 * flags = flags for the property specified 1456 * 1457 * Returns: a newly created parameter specification 1458 */ 1459 public static ParamSpec paramSpecLong(string name, string nick, string blurb, glong minimum, glong maximum, glong defaultValue, GParamFlags flags) 1460 { 1461 auto p = g_param_spec_long(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1462 1463 if(p is null) 1464 { 1465 return null; 1466 } 1467 1468 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1469 } 1470 1471 /** 1472 * Creates a new #GParamSpecBoxed instance specifying a %G_TYPE_OBJECT 1473 * derived property. 1474 * 1475 * See g_param_spec_internal() for details on property names. 1476 * 1477 * Params: 1478 * name = canonical name of the property specified 1479 * nick = nick name for the property specified 1480 * blurb = description of the property specified 1481 * objectType = %G_TYPE_OBJECT derived type of this property 1482 * flags = flags for the property specified 1483 * 1484 * Returns: a newly created parameter specification 1485 */ 1486 public static ParamSpec paramSpecObject(string name, string nick, string blurb, GType objectType, GParamFlags flags) 1487 { 1488 auto p = g_param_spec_object(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), objectType, flags); 1489 1490 if(p is null) 1491 { 1492 return null; 1493 } 1494 1495 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1496 } 1497 1498 /** 1499 * Creates a new property of type #GParamSpecOverride. This is used 1500 * to direct operations to another paramspec, and will not be directly 1501 * useful unless you are implementing a new base type similar to GObject. 1502 * 1503 * Params: 1504 * name = the name of the property. 1505 * overridden = The property that is being overridden 1506 * 1507 * Returns: the newly created #GParamSpec 1508 * 1509 * Since: 2.4 1510 */ 1511 public static ParamSpec paramSpecOverride(string name, ParamSpec overridden) 1512 { 1513 auto p = g_param_spec_override(Str.toStringz(name), (overridden is null) ? null : overridden.getParamSpecStruct()); 1514 1515 if(p is null) 1516 { 1517 return null; 1518 } 1519 1520 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p); 1521 } 1522 1523 /** 1524 * Creates a new #GParamSpecParam instance specifying a %G_TYPE_PARAM 1525 * property. 1526 * 1527 * See g_param_spec_internal() for details on property names. 1528 * 1529 * Params: 1530 * name = canonical name of the property specified 1531 * nick = nick name for the property specified 1532 * blurb = description of the property specified 1533 * paramType = a #GType derived from %G_TYPE_PARAM 1534 * flags = flags for the property specified 1535 * 1536 * Returns: a newly created parameter specification 1537 */ 1538 public static ParamSpec paramSpecParam(string name, string nick, string blurb, GType paramType, GParamFlags flags) 1539 { 1540 auto p = g_param_spec_param(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), paramType, flags); 1541 1542 if(p is null) 1543 { 1544 return null; 1545 } 1546 1547 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1548 } 1549 1550 /** 1551 * Creates a new #GParamSpecPointer instance specifying a pointer property. 1552 * Where possible, it is better to use g_param_spec_object() or 1553 * g_param_spec_boxed() to expose memory management information. 1554 * 1555 * See g_param_spec_internal() for details on property names. 1556 * 1557 * Params: 1558 * name = canonical name of the property specified 1559 * nick = nick name for the property specified 1560 * blurb = description of the property specified 1561 * flags = flags for the property specified 1562 * 1563 * Returns: a newly created parameter specification 1564 */ 1565 public static ParamSpec paramSpecPointer(string name, string nick, string blurb, GParamFlags flags) 1566 { 1567 auto p = g_param_spec_pointer(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), flags); 1568 1569 if(p is null) 1570 { 1571 return null; 1572 } 1573 1574 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1575 } 1576 1577 /** 1578 * Creates a new #GParamSpecString instance. 1579 * 1580 * See g_param_spec_internal() for details on property names. 1581 * 1582 * Params: 1583 * name = canonical name of the property specified 1584 * nick = nick name for the property specified 1585 * blurb = description of the property specified 1586 * defaultValue = default value for the property specified 1587 * flags = flags for the property specified 1588 * 1589 * Returns: a newly created parameter specification 1590 */ 1591 public static ParamSpec paramSpecString(string name, string nick, string blurb, string defaultValue, GParamFlags flags) 1592 { 1593 auto p = g_param_spec_string(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), Str.toStringz(defaultValue), flags); 1594 1595 if(p is null) 1596 { 1597 return null; 1598 } 1599 1600 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1601 } 1602 1603 /** 1604 * Creates a new #GParamSpecUChar instance specifying a %G_TYPE_UCHAR property. 1605 * 1606 * Params: 1607 * name = canonical name of the property specified 1608 * nick = nick name for the property specified 1609 * blurb = description of the property specified 1610 * minimum = minimum value for the property specified 1611 * maximum = maximum value for the property specified 1612 * defaultValue = default value for the property specified 1613 * flags = flags for the property specified 1614 * 1615 * Returns: a newly created parameter specification 1616 */ 1617 public static ParamSpec paramSpecUchar(string name, string nick, string blurb, ubyte minimum, ubyte maximum, ubyte defaultValue, GParamFlags flags) 1618 { 1619 auto p = g_param_spec_uchar(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1620 1621 if(p is null) 1622 { 1623 return null; 1624 } 1625 1626 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1627 } 1628 1629 /** 1630 * Creates a new #GParamSpecUInt instance specifying a %G_TYPE_UINT property. 1631 * 1632 * See g_param_spec_internal() for details on property names. 1633 * 1634 * Params: 1635 * name = canonical name of the property specified 1636 * nick = nick name for the property specified 1637 * blurb = description of the property specified 1638 * minimum = minimum value for the property specified 1639 * maximum = maximum value for the property specified 1640 * defaultValue = default value for the property specified 1641 * flags = flags for the property specified 1642 * 1643 * Returns: a newly created parameter specification 1644 */ 1645 public static ParamSpec paramSpecUint(string name, string nick, string blurb, uint minimum, uint maximum, uint defaultValue, GParamFlags flags) 1646 { 1647 auto p = g_param_spec_uint(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1648 1649 if(p is null) 1650 { 1651 return null; 1652 } 1653 1654 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1655 } 1656 1657 /** 1658 * Creates a new #GParamSpecUInt64 instance specifying a %G_TYPE_UINT64 1659 * property. 1660 * 1661 * See g_param_spec_internal() for details on property names. 1662 * 1663 * Params: 1664 * name = canonical name of the property specified 1665 * nick = nick name for the property specified 1666 * blurb = description of the property specified 1667 * minimum = minimum value for the property specified 1668 * maximum = maximum value for the property specified 1669 * defaultValue = default value for the property specified 1670 * flags = flags for the property specified 1671 * 1672 * Returns: a newly created parameter specification 1673 */ 1674 public static ParamSpec paramSpecUint64(string name, string nick, string blurb, ulong minimum, ulong maximum, ulong defaultValue, GParamFlags flags) 1675 { 1676 auto p = g_param_spec_uint64(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1677 1678 if(p is null) 1679 { 1680 return null; 1681 } 1682 1683 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1684 } 1685 1686 /** 1687 * Creates a new #GParamSpecULong instance specifying a %G_TYPE_ULONG 1688 * property. 1689 * 1690 * See g_param_spec_internal() for details on property names. 1691 * 1692 * Params: 1693 * name = canonical name of the property specified 1694 * nick = nick name for the property specified 1695 * blurb = description of the property specified 1696 * minimum = minimum value for the property specified 1697 * maximum = maximum value for the property specified 1698 * defaultValue = default value for the property specified 1699 * flags = flags for the property specified 1700 * 1701 * Returns: a newly created parameter specification 1702 */ 1703 public static ParamSpec paramSpecUlong(string name, string nick, string blurb, gulong minimum, gulong maximum, gulong defaultValue, GParamFlags flags) 1704 { 1705 auto p = g_param_spec_ulong(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), minimum, maximum, defaultValue, flags); 1706 1707 if(p is null) 1708 { 1709 return null; 1710 } 1711 1712 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1713 } 1714 1715 /** 1716 * Creates a new #GParamSpecUnichar instance specifying a %G_TYPE_UINT 1717 * property. #GValue structures for this property can be accessed with 1718 * g_value_set_uint() and g_value_get_uint(). 1719 * 1720 * See g_param_spec_internal() for details on property names. 1721 * 1722 * Params: 1723 * name = canonical name of the property specified 1724 * nick = nick name for the property specified 1725 * blurb = description of the property specified 1726 * defaultValue = default value for the property specified 1727 * flags = flags for the property specified 1728 * 1729 * Returns: a newly created parameter specification 1730 */ 1731 public static ParamSpec paramSpecUnichar(string name, string nick, string blurb, dchar defaultValue, GParamFlags flags) 1732 { 1733 auto p = g_param_spec_unichar(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), defaultValue, flags); 1734 1735 if(p is null) 1736 { 1737 return null; 1738 } 1739 1740 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1741 } 1742 1743 /** 1744 * Creates a new #GParamSpecValueArray instance specifying a 1745 * %G_TYPE_VALUE_ARRAY property. %G_TYPE_VALUE_ARRAY is a 1746 * %G_TYPE_BOXED type, as such, #GValue structures for this property 1747 * can be accessed with g_value_set_boxed() and g_value_get_boxed(). 1748 * 1749 * See g_param_spec_internal() for details on property names. 1750 * 1751 * Params: 1752 * name = canonical name of the property specified 1753 * nick = nick name for the property specified 1754 * blurb = description of the property specified 1755 * elementSpec = a #GParamSpec describing the elements contained in 1756 * arrays of this property, may be %NULL 1757 * flags = flags for the property specified 1758 * 1759 * Returns: a newly created parameter specification 1760 */ 1761 public static ParamSpec paramSpecValueArray(string name, string nick, string blurb, ParamSpec elementSpec, GParamFlags flags) 1762 { 1763 auto p = g_param_spec_value_array(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), (elementSpec is null) ? null : elementSpec.getParamSpecStruct(), flags); 1764 1765 if(p is null) 1766 { 1767 return null; 1768 } 1769 1770 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p); 1771 } 1772 1773 /** 1774 * Creates a new #GParamSpecVariant instance specifying a #GVariant 1775 * property. 1776 * 1777 * If @default_value is floating, it is consumed. 1778 * 1779 * See g_param_spec_internal() for details on property names. 1780 * 1781 * Params: 1782 * name = canonical name of the property specified 1783 * nick = nick name for the property specified 1784 * blurb = description of the property specified 1785 * type = a #GVariantType 1786 * defaultValue = a #GVariant of type @type to 1787 * use as the default value, or %NULL 1788 * flags = flags for the property specified 1789 * 1790 * Returns: the newly created #GParamSpec 1791 * 1792 * Since: 2.26 1793 */ 1794 public static ParamSpec paramSpecVariant(string name, string nick, string blurb, VariantType type, Variant defaultValue, GParamFlags flags) 1795 { 1796 auto p = g_param_spec_variant(Str.toStringz(name), Str.toStringz(nick), Str.toStringz(blurb), (type is null) ? null : type.getVariantTypeStruct(), (defaultValue is null) ? null : defaultValue.getVariantStruct(true), flags); 1797 1798 if(p is null) 1799 { 1800 return null; 1801 } 1802 1803 return ObjectG.getDObject!(ParamSpec)(cast(GParamSpec*) p, true); 1804 } 1805 1806 /** 1807 * Return a newly allocated string, which describes the contents of a 1808 * #GValue. The main purpose of this function is to describe #GValue 1809 * contents for debugging output, the way in which the contents are 1810 * described may change between different GLib versions. 1811 * 1812 * Params: 1813 * value = #GValue which contents are to be described. 1814 * 1815 * Returns: Newly allocated string. 1816 */ 1817 public static string strdupValueContents(Value value) 1818 { 1819 auto retStr = g_strdup_value_contents((value is null) ? null : value.getValueStruct()); 1820 1821 scope(exit) Str.freeString(retStr); 1822 return Str.toString(retStr); 1823 } 1824 }