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