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