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