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