-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGObject-2.0.d.ts
8540 lines (8230 loc) · 354 KB
/
GObject-2.0.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/** Generated with https://github.com/Gr3q/GIR2TS - If possible do not modify. */
declare namespace imports.gi.GObject {
/** This construct is only for enabling class multi-inheritance,
* use {@link Binding} instead.
*/
interface IBinding {
/**
* Flags to be used to control the #GBinding
*/
flags: BindingFlags;
/**
* The #GObject that should be used as the source of the binding
*/
source: Object;
/**
* The name of the property of #GBinding:source that should be used
* as the source of the binding.
*
* This should be in [canonical form][canonical-parameter-names] to get the
* best performance.
*/
source_property: string;
/**
* The #GObject that should be used as the target of the binding
*/
target: Object;
/**
* The name of the property of #GBinding:target that should be used
* as the target of the binding.
*
* This should be in [canonical form][canonical-parameter-names] to get the
* best performance.
*/
target_property: string;
/**
* Retrieves the #GObject instance used as the source of the binding.
*
* A #GBinding can outlive the source #GObject as the binding does not hold a
* strong reference to the source. If the source is destroyed before the
* binding then this function will return %NULL.
* @returns the source #GObject, or %NULL if the
* source does not exist any more.
*/
dup_source(): Object | null;
/**
* Retrieves the #GObject instance used as the target of the binding.
*
* A #GBinding can outlive the target #GObject as the binding does not hold a
* strong reference to the target. If the target is destroyed before the
* binding then this function will return %NULL.
* @returns the target #GObject, or %NULL if the
* target does not exist any more.
*/
dup_target(): Object | null;
/**
* Retrieves the flags passed when constructing the #GBinding.
* @returns the #GBindingFlags used by the #GBinding
*/
get_flags(): BindingFlags;
/**
* @deprecated
* Use {@link G.binding_dup_source} for a safer version of this
* function.
*
* Retrieves the #GObject instance used as the source of the binding.
*
* A #GBinding can outlive the source #GObject as the binding does not hold a
* strong reference to the source. If the source is destroyed before the
* binding then this function will return %NULL.
*
* Use {@link G.binding_dup_source} if the source or binding are used from different
* threads as otherwise the pointer returned from this function might become
* invalid if the source is finalized from another thread in the meantime.
* @returns the source #GObject, or %NULL if the
* source does not exist any more.
*/
get_source(): Object | null;
/**
* Retrieves the name of the property of #GBinding:source used as the source
* of the binding.
* @returns the name of the source property
*/
get_source_property(): string;
/**
* @deprecated
* Use {@link G.binding_dup_target} for a safer version of this
* function.
*
* Retrieves the #GObject instance used as the target of the binding.
*
* A #GBinding can outlive the target #GObject as the binding does not hold a
* strong reference to the target. If the target is destroyed before the
* binding then this function will return %NULL.
*
* Use {@link G.binding_dup_target} if the target or binding are used from different
* threads as otherwise the pointer returned from this function might become
* invalid if the target is finalized from another thread in the meantime.
* @returns the target #GObject, or %NULL if the
* target does not exist any more.
*/
get_target(): Object | null;
/**
* Retrieves the name of the property of #GBinding:target used as the target
* of the binding.
* @returns the name of the target property
*/
get_target_property(): string;
/**
* Explicitly releases the binding between the source and the target
* property expressed by #binding.
*
* This function will release the reference that is being held on
* the #binding instance if the binding is still bound; if you want to hold on
* to the #GBinding instance after calling {@link G.binding_unbind}, you will need
* to hold a reference to it.
*
* Note however that this function does not take ownership of #binding, it
* only unrefs the reference that was initially created by
* g_object_bind_property() and is owned by the binding.
*/
unbind(): void;
connect(signal: "notify::flags", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::source", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::source-property", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::target", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::target-property", callback: (owner: this, ...args: any) => void): number;
}
type BindingInitOptionsMixin = ObjectInitOptions &
Pick<IBinding,
"flags" |
"source" |
"source_property" |
"target" |
"target_property">;
export interface BindingInitOptions extends BindingInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link Binding} instead.
*/
type BindingMixin = IBinding & Object;
/**
* #GBinding is the representation of a binding between a property on a
* #GObject instance (or source) and another property on another #GObject
* instance (or target).
*
* Whenever the source property changes, the same value is applied to the
* target property; for instance, the following binding:
*
* |[<!-- language="C" -->
* g_object_bind_property (object1, "property-a",
* object2, "property-b",
* G_BINDING_DEFAULT);
* ]|
*
* will cause the property named "property-b" of #object2 to be updated
* every time {@link GObject.set} or the specific accessor changes the value of
* the property "property-a" of #object1.
*
* It is possible to create a bidirectional binding between two properties
* of two #GObject instances, so that if either property changes, the
* other is updated as well, for instance:
*
* |[<!-- language="C" -->
* g_object_bind_property (object1, "property-a",
* object2, "property-b",
* G_BINDING_BIDIRECTIONAL);
* ]|
*
* will keep the two properties in sync.
*
* It is also possible to set a custom transformation function (in both
* directions, in case of a bidirectional binding) to apply a custom
* transformation from the source value to the target value before
* applying it; for instance, the following binding:
*
* |[<!-- language="C" -->
* g_object_bind_property_full (adjustment1, "value",
* adjustment2, "value",
* G_BINDING_BIDIRECTIONAL,
* celsius_to_fahrenheit,
* fahrenheit_to_celsius,
* NULL, NULL);
* ]|
*
* will keep the "value" property of the two adjustments in sync; the
* #celsius_to_fahrenheit function will be called whenever the "value"
* property of #adjustment1 changes and will transform the current value
* of the property before applying it to the "value" property of #adjustment2.
*
* Vice versa, the #fahrenheit_to_celsius function will be called whenever
* the "value" property of #adjustment2 changes, and will transform the
* current value of the property before applying it to the "value" property
* of #adjustment1.
*
* Note that #GBinding does not resolve cycles by itself; a cycle like
*
* |[
* object1:propertyA -> object2:propertyB
* object2:propertyB -> object3:propertyC
* object3:propertyC -> object1:propertyA
* ]|
*
* might lead to an infinite loop. The loop, in this particular case,
* can be avoided if the objects emit the #GObject::notify signal only
* if the value has effectively been changed. A binding is implemented
* using the #GObject::notify signal, so it is susceptible to all the
* various ways of blocking a signal emission, like g_signal_stop_emission()
* or g_signal_handler_block().
*
* A binding will be severed, and the resources it allocates freed, whenever
* either one of the #GObject instances it refers to are finalized, or when
* the #GBinding instance loses its last reference.
*
* Bindings for languages with garbage collection can use
* g_binding_unbind() to explicitly release a binding between the source
* and target properties, instead of relying on the last reference on the
* binding, source, and target instances to drop.
*
* #GBinding is available since GObject 2.26
*/
interface Binding extends BindingMixin {}
class Binding {
public constructor(options?: Partial<BindingInitOptions>);
}
/** This construct is only for enabling class multi-inheritance,
* use {@link BindingGroup} instead.
*/
interface IBindingGroup {
/**
* The source object used for binding properties.
*/
source: Object;
/**
* Creates a binding between #source_property on the source object
* and #target_property on #target. Whenever the #source_property
* is changed the #target_property is updated using the same value.
* The binding flag %G_BINDING_SYNC_CREATE is automatically specified.
*
* See {@link GObject.bind_property} for more information.
* @param source_property the property on the source to bind
* @param target the target #GObject
* @param target_property the property on #target to bind
* @param flags the flags used to create the #GBinding
*/
bind(source_property: string, target: Object, target_property: string, flags: BindingFlags): void;
/**
* Creates a binding between #source_property on the source object and
* #target_property on #target, allowing you to set the transformation
* functions to be used by the binding. The binding flag
* %G_BINDING_SYNC_CREATE is automatically specified.
*
* This function is the language bindings friendly version of
* {@link G.binding_group_bind_property_full}, using #GClosures
* instead of function pointers.
*
* See g_object_bind_property_with_closures() for more information.
* @param source_property the property on the source to bind
* @param target the target #GObject
* @param target_property the property on #target to bind
* @param flags the flags used to create the #GBinding
* @param transform_to a #GClosure wrapping the
* transformation function from the source object to the #target,
* or %NULL to use the default
* @param transform_from a #GClosure wrapping the
* transformation function from the #target to the source object,
* or %NULL to use the default
*/
bind_full(source_property: string, target: Object, target_property: string, flags: BindingFlags, transform_to?: Closure | null, transform_from?: Closure | null): void;
/**
* Gets the source object used for binding properties.
* @returns a #GObject or %NULL.
*/
dup_source(): Object | null;
/**
* Sets #source as the source object used for creating property
* bindings. If there is already a source object all bindings from it
* will be removed.
*
* Note that all properties that have been bound must exist on #source.
* @param source the source #GObject,
* or %NULL to clear it
*/
set_source(source?: Object | null): void;
connect(signal: "notify::source", callback: (owner: this, ...args: any) => void): number;
}
type BindingGroupInitOptionsMixin = ObjectInitOptions &
Pick<IBindingGroup,
"source">;
export interface BindingGroupInitOptions extends BindingGroupInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link BindingGroup} instead.
*/
type BindingGroupMixin = IBindingGroup & Object;
/**
* The #GBindingGroup can be used to bind multiple properties
* from an object collectively.
*
* Use the various methods to bind properties from a single source
* object to multiple destination objects. Properties can be bound
* bidirectionally and are connected when the source object is set
* with {@link G.binding_group_set_source}.
*/
interface BindingGroup extends BindingGroupMixin {}
class BindingGroup {
public constructor(options?: Partial<BindingGroupInitOptions>);
/**
* Creates a new #GBindingGroup.
* @returns a new #GBindingGroup
*/
public static new(): BindingGroup;
}
/** This construct is only for enabling class multi-inheritance,
* use {@link InitiallyUnowned} instead.
*/
interface IInitiallyUnowned {
}
type InitiallyUnownedInitOptionsMixin = ObjectInitOptions
export interface InitiallyUnownedInitOptions extends InitiallyUnownedInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link InitiallyUnowned} instead.
*/
type InitiallyUnownedMixin = IInitiallyUnowned & Object;
/**
* A type for objects that have an initially floating reference.
*
* All the fields in the `GInitiallyUnowned` structure are private to the
* implementation and should never be accessed directly.
*/
interface InitiallyUnowned extends InitiallyUnownedMixin {}
class InitiallyUnowned {
public constructor(options?: Partial<InitiallyUnownedInitOptions>);
}
/** This construct is only for enabling class multi-inheritance,
* use {@link Object} instead.
*/
interface IObject {
/**
* Creates a binding between #source_property on #source and #target_property
* on #target.
*
* Whenever the #source_property is changed the #target_property is
* updated using the same value. For instance:
*
* |[<!-- language="C" -->
* g_object_bind_property (action, "active", widget, "sensitive", 0);
* ]|
*
* Will result in the "sensitive" property of the widget #GObject instance to be
* updated with the same value of the "active" property of the action #GObject
* instance.
*
* If #flags contains %G_BINDING_BIDIRECTIONAL then the binding will be mutual:
* if #target_property on #target changes then the #source_property on #source
* will be updated as well.
*
* The binding will automatically be removed when either the #source or the
* #target instances are finalized. To remove the binding without affecting the
* #source and the #target you can just call {@link GObject.unref} on the returned
* #GBinding instance.
*
* Removing the binding by calling g_object_unref() on it must only be done if
* the binding, #source and #target are only used from a single thread and it
* is clear that both #source and #target outlive the binding. Especially it
* is not safe to rely on this if the binding, #source or #target can be
* finalized from different threads. Keep another reference to the binding and
* use g_binding_unbind() instead to be on the safe side.
*
* A #GObject can have multiple bindings.
* @param source_property the property on #source to bind
* @param target the target #GObject
* @param target_property the property on #target to bind
* @param flags flags to pass to #GBinding
* @returns the #GBinding instance representing the
* binding between the two #GObject instances. The binding is released
* whenever the #GBinding reference count reaches zero.
*/
bind_property(source_property: string, target: Object, target_property: string, flags: BindingFlags): Binding;
/**
* Creates a binding between #source_property on #source and #target_property
* on #target, allowing you to set the transformation functions to be used by
* the binding.
*
* This function is the language bindings friendly version of
* {@link GObject.bind_property_full}, using #GClosures instead of
* function pointers.
* @param source_property the property on #source to bind
* @param target the target #GObject
* @param target_property the property on #target to bind
* @param flags flags to pass to #GBinding
* @param transform_to a #GClosure wrapping the transformation function
* from the #source to the #target, or %NULL to use the default
* @param transform_from a #GClosure wrapping the transformation function
* from the #target to the #source, or %NULL to use the default
* @returns the #GBinding instance representing the
* binding between the two #GObject instances. The binding is released
* whenever the #GBinding reference count reaches zero.
*/
bind_property_full(source_property: string, target: Object, target_property: string, flags: BindingFlags, transform_to: Closure, transform_from: Closure): Binding;
/**
* This function is intended for #GObject implementations to re-enforce
* a [floating][floating-ref] object reference. Doing this is seldom
* required: all #GInitiallyUnowneds are created with a floating reference
* which usually just needs to be sunken by calling {@link GObject.ref_sink}.
*/
force_floating(): void;
/**
* Increases the freeze count on #object. If the freeze count is
* non-zero, the emission of "notify" signals on #object is
* stopped. The signals are queued until the freeze count is decreased
* to zero. Duplicate notifications are squashed so that at most one
* {@link .notify} signal is emitted for each property modified while the
* object is frozen.
*
* This is necessary for accessors that modify multiple properties to prevent
* premature notification while the object is still being modified.
*/
freeze_notify(): void;
/**
* Gets a named field from the objects table of associations (see {@link GObject.set_data}).
* @param key name of the key for that association
* @returns the data if found,
* or %NULL if no such data exists.
*/
get_data(key: string): any | null;
/**
* Gets a property of an object.
*
* The #value can be:
*
* - an empty #GValue initialized by %G_VALUE_INIT, which will be
* automatically initialized with the expected type of the property
* (since GLib 2.60)
* - a #GValue initialized with the expected type of the property
* - a #GValue initialized with a type to which the expected type
* of the property can be transformed
*
* In general, a copy is made of the property contents and the caller is
* responsible for freeing the memory by calling {@link G.value_unset}.
*
* Note that g_object_get_property() is really intended for language
* bindings, g_object_get() is much more convenient for C programming.
* @param property_name the name of the property to get
* @param value return location for the property value
*/
// get_property(property_name: string, value: Value): void;
/**
* This function gets back user data pointers stored via
* {@link GObject.set_qdata}.
* @param quark A #GQuark, naming the user data pointer
* @returns The user data pointer set, or %NULL
*/
get_qdata(quark: GLib.Quark): any | null;
/**
* Gets #n_properties properties for an #object.
* Obtained properties will be set to #values. All properties must be valid.
* Warnings will be emitted and undefined behaviour may result if invalid
* properties are passed in.
* @param names the names of each property to get
* @param values the values of each property to get
*/
getv(names: string[], values: Value[]): void;
/**
* Checks whether #object has a [floating][floating-ref] reference.
* @returns %TRUE if #object has a floating reference
*/
is_floating(): boolean;
/**
* Emits a "notify" signal for the property #property_name on #object.
*
* When possible, eg. when signaling a property change from within the class
* that registered the property, you should use {@link GObject.notify_by_pspec}
* instead.
*
* Note that emission of the notify signal may be blocked with
* g_object_freeze_notify(). In this case, the signal emissions are queued
* and will be emitted (in reverse order) when g_object_thaw_notify() is
* called.
* @param property_name the name of a property installed on the class of #object.
*/
notify(property_name: string): void;
/**
* Emits a "notify" signal for the property specified by #pspec on #object.
*
* This function omits the property name lookup, hence it is faster than
* {@link GObject.notify}.
*
* One way to avoid using g_object_notify() from within the
* class that registered the properties, and using g_object_notify_by_pspec()
* instead, is to store the GParamSpec used with
* g_object_class_install_property() inside a static array, e.g.:
*
* |[<!-- language="C" -->
* typedef enum
* {
* PROP_FOO = 1,
* PROP_LAST
* } MyObjectProperty;
*
* static GParamSpec *properties[PROP_LAST];
*
* static void
* my_object_class_init (MyObjectClass *klass)
* {
* properties[PROP_FOO] = g_param_spec_int ("foo", "Foo", "The foo",
* 0, 100,
* 50,
* G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
* g_object_class_install_property (gobject_class,
* PROP_FOO,
* properties[PROP_FOO]);
* }
* ]|
*
* and then notify a change on the "foo" property with:
*
* |[<!-- language="C" -->
* g_object_notify_by_pspec (self, properties[PROP_FOO]);
* ]|
* @param pspec the #GParamSpec of a property installed on the class of #object.
*/
notify_by_pspec(pspec: ParamSpec): void;
/**
* Increases the reference count of #object.
*
* Since GLib 2.56, if `GLIB_VERSION_MAX_ALLOWED` is 2.56 or greater, the type
* of #object will be propagated to the return type (using the GCC typeof()
* extension), so any casting the caller needs to do on the return type must be
* explicit.
* @returns the same #object
*/
ref(): Object;
/**
* Increase the reference count of #object, and possibly remove the
* [floating][floating-ref] reference, if #object has a floating reference.
*
* In other words, if the object is floating, then this call "assumes
* ownership" of the floating reference, converting it to a normal
* reference by clearing the floating flag while leaving the reference
* count unchanged. If the object is not floating, then this call
* adds a new normal reference increasing the reference count by one.
*
* Since GLib 2.56, the type of #object will be propagated to the return type
* under the same conditions as for {@link GObject.ref}.
* @returns #object
*/
ref_sink(): Object;
/**
* Releases all references to other objects. This can be used to break
* reference cycles.
*
* This function should only be called from object system implementations.
*/
run_dispose(): void;
/**
* Each object carries around a table of associations from
* strings to pointers. This function lets you set an association.
*
* If the object already had an association with that name,
* the old association will be destroyed.
*
* Internally, the #key is converted to a #GQuark using {@link G.quark_from_string}.
* This means a copy of #key is kept permanently (even after #object has been
* finalized) — so it is recommended to only use a small, bounded set of values
* for #key in your program, to avoid the #GQuark storage growing unbounded.
* @param key name of the key
* @param data data to associate with that key
*/
set_data(key: string, data?: any | null): void;
/**
* Sets a property on an object.
* @param property_name the name of the property to set
* @param value the value
*/
// set_property(property_name: string, value: Value): void;
/**
* Remove a specified datum from the object's data associations,
* without invoking the association's destroy handler.
* @param key name of the key
* @returns the data if found, or %NULL
* if no such data exists.
*/
steal_data(key: string): any | null;
/**
* This function gets back user data pointers stored via
* {@link GObject.set_qdata} and removes the #data from object
* without invoking its destroy() function (if any was
* set).
* Usually, calling this function is only required to update
* user data pointers with a destroy notifier, for example:
* |[<!-- language="C" -->
* void
* object_add_to_user_list (GObject *object,
* const gchar *new_string)
* {
* // the quark, naming the object data
* GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
* // retrieve the old string list
* GList *list = g_object_steal_qdata (object, quark_string_list);
*
* // prepend new string
* list = g_list_prepend (list, g_strdup (new_string));
* // this changed 'list', so we need to set it again
* g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
* }
* static void
* free_string_list (gpointer data)
* {
* GList *node, *list = data;
*
* for (node = list; node; node = node->next)
* g_free (node->data);
* g_list_free (list);
* }
* ]|
* Using g_object_get_qdata() in the above example, instead of
* g_object_steal_qdata() would have left the destroy function set,
* and thus the partial string list would have been freed upon
* g_object_set_qdata_full().
* @param quark A #GQuark, naming the user data pointer
* @returns The user data pointer set, or %NULL
*/
steal_qdata(quark: GLib.Quark): any | null;
/**
* Reverts the effect of a previous call to
* {@link GObject.freeze_notify}. The freeze count is decreased on #object
* and when it reaches zero, queued "notify" signals are emitted.
*
* Duplicate notifications for each property are squashed so that at most one
* {@link .notify} signal is emitted for each property, in the reverse order
* in which they have been queued.
*
* It is an error to call this function when the freeze count is zero.
*/
thaw_notify(): void;
/**
* Decreases the reference count of #object. When its reference count
* drops to 0, the object is finalized (i.e. its memory is freed).
*
* If the pointer to the #GObject may be reused in future (for example, if it is
* an instance variable of another object), it is recommended to clear the
* pointer to %NULL rather than retain a dangling pointer to a potentially
* invalid #GObject instance. Use {@link G.clear_object} for this.
*/
unref(): void;
/**
* This function essentially limits the life time of the #closure to
* the life time of the object. That is, when the object is finalized,
* the #closure is invalidated by calling {@link G.closure_invalidate} on
* it, in order to prevent invocations of the closure with a finalized
* (nonexisting) object. Also, g_object_ref() and g_object_unref() are
* added as marshal guards to the #closure, to ensure that an extra
* reference count is held on #object during invocation of the
* #closure. Usually, this function will be called on closures that
* use this #object as closure data.
* @param closure #GClosure to watch
*/
watch_closure(closure: Closure): void;
/**
* The notify signal is emitted on an object when one of its properties has
* its value set through {@link GObject.set_property}, g_object_set(), et al.
*
* Note that getting this signal doesn’t itself guarantee that the value of
* the property has actually changed. When it is emitted is determined by the
* derived GObject class. If the implementor did not create the property with
* %G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results
* in ::notify being emitted, even if the new value is the same as the old.
* If they did pass %G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only
* when they explicitly call g_object_notify() or g_object_notify_by_pspec(),
* and common practice is to do that only when the value has actually changed.
*
* This signal is typically used to obtain change notification for a
* single property, by specifying the property name as a detail in the
* g_signal_connect() call, like this:
*
* |[<!-- language="C" -->
* g_signal_connect (text_view->buffer, "notify::paste-target-list",
* G_CALLBACK (gtk_text_view_target_list_notify),
* text_view)
* ]|
*
* It is important to note that you must use
* [canonical parameter names][canonical-parameter-names] as
* detail strings for the notify signal.
* @param signal
* @param callback Callback function
* - owner: owner of the emitted event
* - pspec: the #GParamSpec of the property which changed.
*
* @returns Callback ID
*/
connect(signal: "notify", callback: (owner: this, pspec: ParamSpec) => void): number;
}
type ObjectInitOptionsMixin = {};
export interface ObjectInitOptions extends ObjectInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link Object} instead.
*/
type ObjectMixin = IObject;
/**
* The base object type.
*
* All the fields in the `GObject` structure are private to the implementation
* and should never be accessed directly.
*
* Since GLib 2.72, all {@link s} are guaranteed to be aligned to at least the
* alignment of the largest basic GLib type (typically this is #guint64 or
* #gdouble). If you need larger alignment for an element in a #GObject, you
* should allocate it on the heap (aligned), or arrange for your #GObject to be
* appropriately padded. This guarantee applies to the #GObject (or derived)
* struct, the #GObjectClass (or derived) struct, and any private data allocated
* by {@link G.ADD_PRIVATE}.
*/
interface Object extends ObjectMixin {}
class Object {
public constructor(options?: Partial<ObjectInitOptions>);
/**
* Creates a new instance of a #GObject subtype and sets its properties.
*
* Construction parameters (see %G_PARAM_CONSTRUCT, %G_PARAM_CONSTRUCT_ONLY)
* which are not explicitly specified are set to their default values. Any
* private data for the object is guaranteed to be initialized with zeros, as
* per {@link G.type_create_instance}.
*
* Note that in C, small integer types in variable argument lists are promoted
* up to `gint` or `guint` as appropriate, and read back accordingly. `gint` is
* 32 bits on every platform on which GLib is currently supported. This means that
* you can use C expressions of type `gint` with g_object_new() and properties of
* type `gint` or `guint` or smaller. Specifically, you can use integer literals
* with these property types.
*
* When using property types of `gint64` or `guint64`, you must ensure that the
* value that you provide is 64 bit. This means that you should use a cast or
* make use of the %G_GINT64_CONSTANT or %G_GUINT64_CONSTANT macros.
*
* Similarly, `gfloat` is promoted to `gdouble`, so you must ensure that the value
* you provide is a `gdouble`, even for a property of type `gfloat`.
*
* Since GLib 2.72, all #GObjects are guaranteed to be aligned to at least the
* alignment of the largest basic GLib type (typically this is `guint64` or
* `gdouble`). If you need larger alignment for an element in a #GObject, you
* should allocate it on the heap (aligned), or arrange for your #GObject to be
* appropriately padded.
* @param object_type the type id of the #GObject subtype to instantiate
* @param first_property_name the name of the first property
* @returns a new instance of
* #object_type
*/
public static new(object_type: GObject.Type, first_property_name: string): Object;
/**
* Creates a new instance of a #GObject subtype and sets its properties.
*
* Construction parameters (see %G_PARAM_CONSTRUCT, %G_PARAM_CONSTRUCT_ONLY)
* which are not explicitly specified are set to their default values.
* @param object_type the type id of the #GObject subtype to instantiate
* @param first_property_name the name of the first property
* @param var_args the value of the first property, followed optionally by more
* name/value pairs, followed by %NULL
* @returns a new instance of #object_type
*/
public static new_valist(object_type: GObject.Type, first_property_name: string, var_args: any[]): Object;
/**
* Creates a new instance of a #GObject subtype and sets its properties using
* the provided arrays. Both arrays must have exactly #n_properties elements,
* and the names and values correspond by index.
*
* Construction parameters (see %G_PARAM_CONSTRUCT, %G_PARAM_CONSTRUCT_ONLY)
* which are not explicitly specified are set to their default values.
* @param object_type the object type to instantiate
* @param names the names of each property to be set
* @param values the values of each property to be set
* @returns a new instance of
* #object_type
*/
public static new_with_properties(object_type: GObject.Type, names: string[], values: Value[]): Object;
/**
* @deprecated
* Use {@link GObject.new_with_properties} instead.
* deprecated. See #GParameter for more information.
*
* Creates a new instance of a #GObject subtype and sets its properties.
*
* Construction parameters (see %G_PARAM_CONSTRUCT, %G_PARAM_CONSTRUCT_ONLY)
* which are not explicitly specified are set to their default values.
* @param object_type the type id of the #GObject subtype to instantiate
* @param parameters an array of #GParameter
* @returns a new instance of
* #object_type
*/
public static newv(object_type: GObject.Type, parameters: Parameter[]): Object;
public static compat_control(what: number, data?: any | null): number;
/**
* Find the #GParamSpec with the given name for an
* interface. Generally, the interface vtable passed in as #g_iface
* will be the default vtable from {@link G.type_default_interface_ref}, or,
* if you know the interface has already been loaded,
* g_type_default_interface_peek().
* @param g_iface any interface vtable for the
* interface, or the default vtable for the interface
* @param property_name name of a property to look up.
* @returns the #GParamSpec for the property of the
* interface with the name #property_name, or %NULL if no
* such property exists.
*/
public static interface_find_property(g_iface: TypeInterface, property_name: string): ParamSpec;
/**
* Add a property to an interface; this is only useful for interfaces
* that are added to GObject-derived types. Adding a property to an
* interface forces all objects classes with that interface to have a
* compatible property. The compatible property could be a newly
* created #GParamSpec, but normally
* {@link GObject.class_override_property} will be used so that the object
* class only needs to provide an implementation and inherits the
* property description, default value, bounds, and so forth from the
* interface property.
*
* This function is meant to be called from the interface's default
* vtable initialization function (the #class_init member of
* #GTypeInfo.) It must not be called after after #class_init has
* been called for any object types implementing this interface.
*
* If #pspec is a floating reference, it will be consumed.
* @param g_iface any interface vtable for the
* interface, or the default
* vtable for the interface.
* @param pspec the #GParamSpec for the new property
*/
public static interface_install_property(g_iface: TypeInterface, pspec: ParamSpec): void;
/**
* Lists the properties of an interface.Generally, the interface
* vtable passed in as #g_iface will be the default vtable from
* {@link G.type_default_interface_ref}, or, if you know the interface has
* already been loaded, g_type_default_interface_peek().
* @param g_iface any interface vtable for the
* interface, or the default vtable for the interface
* @returns a
* pointer to an array of pointers to #GParamSpec
* structures. The paramspecs are owned by GLib, but the
* array should be freed with {@link G.free} when you are done with
* it.
*
* location to store number of properties returned.
*/
public static interface_list_properties(g_iface: TypeInterface): [ ParamSpec[], number ];
}
/** This construct is only for enabling class multi-inheritance,
* use {@link ParamSpec} instead.
*/
interface IParamSpec {
/**
* name of this parameter: always an interned string
*/
readonly name: string;
/**
* #GParamFlags flags for this parameter
*/
readonly flags: ParamFlags;
/**
* the #GValue type for this parameter
*/
readonly value_type: GObject.Type;
/**
* #GType type that uses (introduces) this parameter
*/
readonly owner_type: GObject.Type;
/**
* Get the short description of a #GParamSpec.
* @returns the short description of #pspec.
*/
get_blurb(): string | null;
/**
* Gets the default value of #pspec as a pointer to a #GValue.
*
* The #GValue will remain valid for the life of #pspec.
* @returns a pointer to a #GValue which must not be modified
*/
get_default_value(): Value;
/**
* Get the name of a #GParamSpec.
*
* The name is always an "interned" string (as per {@link G.intern_string}).
* This allows for pointer-value comparisons.
* @returns the name of #pspec.
*/
get_name(): string;
/**
* Gets the GQuark for the name.
* @returns the GQuark for #pspec->name.
*/
get_name_quark(): GLib.Quark;
/**
* Get the nickname of a #GParamSpec.
* @returns the nickname of #pspec.
*/
get_nick(): string;
/**
* Gets back user data pointers stored via {@link G.param_spec_set_qdata}.
* @param quark a #GQuark, naming the user data pointer
* @returns the user data pointer set, or %NULL
*/
get_qdata(quark: GLib.Quark): any | null;
/**
* If the paramspec redirects operations to another paramspec,
* returns that paramspec. Redirect is used typically for
* providing a new implementation of a property in a derived
* type while preserving all the properties from the parent
* type. Redirection is established by creating a property
* of type #GParamSpecOverride. See {@link GObject.class_override_property}
* for an example of the use of this capability.
* @returns paramspec to which requests on this
* paramspec should be redirected, or %NULL if none.
*/
get_redirect_target(): ParamSpec | null;
/**
* Sets an opaque, named pointer on a #GParamSpec. The name is
* specified through a #GQuark (retrieved e.g. via
* {@link G.quark_from_static_string}), and the pointer can be gotten back
* from the #pspec with g_param_spec_get_qdata(). Setting a
* previously set user data pointer, overrides (frees) the old pointer
* set, using %NULL as pointer essentially removes the data stored.
* @param quark a #GQuark, naming the user data pointer
* @param data an opaque user data pointer
*/
set_qdata(quark: GLib.Quark, data?: any | null): void;
/**
* The initial reference count of a newly created #GParamSpec is 1,
* even though no one has explicitly called {@link G.param_spec_ref} on it
* yet. So the initial reference count is flagged as "floating", until
* someone calls `g_param_spec_ref (pspec); g_param_spec_sink
* (pspec);` in sequence on it, taking over the initial
* reference count (thus ending up with a #pspec that has a reference
* count of 1 still, but is not flagged "floating" anymore).
*/
sink(): void;
/**
* Gets back user data pointers stored via {@link G.param_spec_set_qdata}
* and removes the #data from #pspec without invoking its destroy()
* function (if any was set). Usually, calling this function is only
* required to update user data pointers with a destroy notifier.
* @param quark a #GQuark, naming the user data pointer
* @returns the user data pointer set, or %NULL
*/
steal_qdata(quark: GLib.Quark): any | null;
connect(signal: "notify::name", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::flags", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::value_type", callback: (owner: this, ...args: any) => void): number;
connect(signal: "notify::owner_type", callback: (owner: this, ...args: any) => void): number;
}
type ParamSpecInitOptionsMixin = {};
export interface ParamSpecInitOptions extends ParamSpecInitOptionsMixin {}
/** This construct is only for enabling class multi-inheritance,
* use {@link ParamSpec} instead.
*/
type ParamSpecMixin = IParamSpec;
/**
* #GParamSpec is an object structure that encapsulates the metadata
* required to specify parameters, such as e.g. #GObject properties.
*
* ## Parameter names # {#canonical-parameter-names}
*
* A property name consists of one or more segments consisting of ASCII letters
* and digits, separated by either the `-` or `_` character. The first
* character of a property name must be a letter. These are the same rules as
* for signal naming (see {@link G.signal_new}).
*
* When creating and looking up a #GParamSpec, either separator can be
* used, but they cannot be mixed. Using `-` is considerably more
* efficient, and is the ‘canonical form’. Using `_` is discouraged.
*/
interface ParamSpec extends ParamSpecMixin {}
class ParamSpec {