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