1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/glib"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16// Callback called by gtk_expression_watch() when the
17// expression value changes.
18type ExpressionNotify func(uintptr)
19
20// An opaque structure representing a watched `GtkExpression`.
21//
22// The contents of `GtkExpressionWatch` should only be accessed through the
23// provided API.
24type ExpressionWatch struct {
25 _ structs.HostLayout
26}
27
28var xExpressionWatchGLibType func() types.GType
29
30func ExpressionWatchGLibType() types.GType {
31 return xExpressionWatchGLibType()
32}
33
34func (x *ExpressionWatch) GoPointer() uintptr {
35 return uintptr(unsafe.Pointer(x))
36}
37
38var xExpressionWatchEvaluate func(uintptr, *gobject.Value) bool
39
40// Evaluates the watched expression and on success stores the result
41// in `value`.
42//
43// This is equivalent to calling [method@Gtk.Expression.evaluate] with the
44// expression and this pointer originally used to create `watch`.
45func (x *ExpressionWatch) Evaluate(ValueVar *gobject.Value) bool {
46
47 cret := xExpressionWatchEvaluate(x.GoPointer(), ValueVar)
48 return cret
49}
50
51var xExpressionWatchRef func(uintptr) *ExpressionWatch
52
53// Acquires a reference on the given `GtkExpressionWatch`.
54func (x *ExpressionWatch) Ref() *ExpressionWatch {
55
56 cret := xExpressionWatchRef(x.GoPointer())
57 return cret
58}
59
60var xExpressionWatchUnref func(uintptr)
61
62// Releases a reference on the given `GtkExpressionWatch`.
63//
64// If the reference was the last, the resources associated to `self` are
65// freed.
66func (x *ExpressionWatch) Unref() {
67
68 xExpressionWatchUnref(x.GoPointer())
69
70}
71
72var xExpressionWatchUnwatch func(uintptr)
73
74// Stops watching an expression.
75//
76// See [method@Gtk.Expression.watch] for how the watch
77// was established.
78func (x *ExpressionWatch) Unwatch() {
79
80 xExpressionWatchUnwatch(x.GoPointer())
81
82}
83
84var xNewParamSpecExpression func(string, string, string, gobject.ParamFlags) uintptr
85
86// Creates a new `GParamSpec` instance for a property holding a `GtkExpression`.
87//
88// See `g_param_spec_internal()` for details on the property strings.
89func NewParamSpecExpression(NameVar string, NickVar string, BlurbVar string, FlagsVar gobject.ParamFlags) *gobject.ParamSpec {
90 var cls *gobject.ParamSpec
91
92 cret := xNewParamSpecExpression(NameVar, NickVar, BlurbVar, FlagsVar)
93
94 if cret == 0 {
95 return nil
96 }
97 cls = &gobject.ParamSpec{}
98 cls.Ptr = cret
99 return cls
100}
101
102var xValueDupExpression func(*gobject.Value) uintptr
103
104// Retrieves the `GtkExpression` stored inside the given `value`, and acquires
105// a reference to it.
106func ValueDupExpression(ValueVar *gobject.Value) *Expression {
107 var cls *Expression
108
109 cret := xValueDupExpression(ValueVar)
110
111 if cret == 0 {
112 return nil
113 }
114 cls = &Expression{}
115 cls.Ptr = cret
116 return cls
117}
118
119var xValueGetExpression func(*gobject.Value) uintptr
120
121// Retrieves the `GtkExpression` stored inside the given `value`.
122func ValueGetExpression(ValueVar *gobject.Value) *Expression {
123 var cls *Expression
124
125 cret := xValueGetExpression(ValueVar)
126
127 if cret == 0 {
128 return nil
129 }
130 gobject.IncreaseRef(cret)
131 cls = &Expression{}
132 cls.Ptr = cret
133 return cls
134}
135
136var xValueSetExpression func(*gobject.Value, uintptr)
137
138// Stores the given `GtkExpression` inside `value`.
139//
140// The `GValue` will acquire a reference to the `expression`.
141func ValueSetExpression(ValueVar *gobject.Value, ExpressionVar *Expression) {
142
143 xValueSetExpression(ValueVar, ExpressionVar.GoPointer())
144
145}
146
147var xValueTakeExpression func(*gobject.Value, uintptr)
148
149// Stores the given `GtkExpression` inside `value`.
150//
151// This function transfers the ownership of the `expression` to the `GValue`.
152func ValueTakeExpression(ValueVar *gobject.Value, ExpressionVar *Expression) {
153
154 xValueTakeExpression(ValueVar, ExpressionVar.GoPointer())
155
156}
157
158// A variant of `GtkClosureExpression` using a C closure.
159type CClosureExpression struct {
160 Expression
161}
162
163var xCClosureExpressionGLibType func() types.GType
164
165func CClosureExpressionGLibType() types.GType {
166 return xCClosureExpressionGLibType()
167}
168
169func CClosureExpressionNewFromInternalPtr(ptr uintptr) *CClosureExpression {
170 cls := &CClosureExpression{}
171 cls.Ptr = ptr
172 return cls
173}
174
175var xNewCClosureExpression func(types.GType, uintptr, uint, uintptr, uintptr, uintptr, uintptr) uintptr
176
177// Creates a `GtkExpression` that calls `callback_func` when it is evaluated.
178//
179// This function is a variant of [ctor@Gtk.ClosureExpression.new] that
180// creates a `GClosure` by calling g_cclosure_new() with the given
181// `callback_func`, `user_data` and `user_destroy`.
182func NewCClosureExpression(ValueTypeVar types.GType, MarshalVar *gobject.ClosureMarshal, NParamsVar uint, ParamsVar uintptr, CallbackFuncVar *gobject.Callback, UserDataVar uintptr, UserDestroyVar *gobject.ClosureNotify) *CClosureExpression {
183 var cls *CClosureExpression
184
185 var MarshalVarRef uintptr
186 if MarshalVar != nil {
187 MarshalVarPtr := uintptr(unsafe.Pointer(MarshalVar))
188 if cbRefPtr, ok := glib.GetCallback(MarshalVarPtr); ok {
189 MarshalVarRef = cbRefPtr
190 } else {
191 fcb := func(arg0 *gobject.Closure, arg1 *gobject.Value, arg2 uint, arg3 []gobject.Value, arg4 uintptr, arg5 uintptr) {
192 cbFn := *MarshalVar
193 cbFn(arg0, arg1, arg2, arg3, arg4, arg5)
194 }
195 MarshalVarRef = purego.NewCallback(fcb)
196 glib.SaveCallbackWithClosure(MarshalVarPtr, MarshalVarRef, MarshalVar)
197 }
198 }
199
200 var CallbackFuncVarRef uintptr
201 if CallbackFuncVar != nil {
202 CallbackFuncVarPtr := uintptr(unsafe.Pointer(CallbackFuncVar))
203 if cbRefPtr, ok := glib.GetCallback(CallbackFuncVarPtr); ok {
204 CallbackFuncVarRef = cbRefPtr
205 } else {
206 fcb := func() {
207 cbFn := *CallbackFuncVar
208 cbFn()
209 }
210 CallbackFuncVarRef = purego.NewCallback(fcb)
211 glib.SaveCallbackWithClosure(CallbackFuncVarPtr, CallbackFuncVarRef, CallbackFuncVar)
212 }
213 }
214
215 var UserDestroyVarRef uintptr
216 if UserDestroyVar != nil {
217 UserDestroyVarPtr := uintptr(unsafe.Pointer(UserDestroyVar))
218 if cbRefPtr, ok := glib.GetCallback(UserDestroyVarPtr); ok {
219 UserDestroyVarRef = cbRefPtr
220 } else {
221 fcb := func(arg0 uintptr, arg1 *gobject.Closure) {
222 cbFn := *UserDestroyVar
223 cbFn(arg0, arg1)
224 }
225 UserDestroyVarRef = purego.NewCallback(fcb)
226 glib.SaveCallbackWithClosure(UserDestroyVarPtr, UserDestroyVarRef, UserDestroyVar)
227 }
228 }
229
230 cret := xNewCClosureExpression(ValueTypeVar, MarshalVarRef, NParamsVar, ParamsVar, CallbackFuncVarRef, UserDataVar, UserDestroyVarRef)
231
232 if cret == 0 {
233 return nil
234 }
235 cls = &CClosureExpression{}
236 cls.Ptr = cret
237 return cls
238}
239
240func (c *CClosureExpression) GoPointer() uintptr {
241 if c == nil {
242 return 0
243 }
244 return c.Ptr
245}
246
247func (c *CClosureExpression) SetGoPointer(ptr uintptr) {
248 c.Ptr = ptr
249}
250
251// An expression using a custom `GClosure` to compute the value from
252// its parameters.
253type ClosureExpression struct {
254 Expression
255}
256
257var xClosureExpressionGLibType func() types.GType
258
259func ClosureExpressionGLibType() types.GType {
260 return xClosureExpressionGLibType()
261}
262
263func ClosureExpressionNewFromInternalPtr(ptr uintptr) *ClosureExpression {
264 cls := &ClosureExpression{}
265 cls.Ptr = ptr
266 return cls
267}
268
269var xNewClosureExpression func(types.GType, *gobject.Closure, uint, uintptr) uintptr
270
271// Creates a `GtkExpression` that calls `closure` when it is evaluated.
272//
273// `closure` is called with the `this` object and the results of evaluating
274// the `params` expressions.
275func NewClosureExpression(ValueTypeVar types.GType, ClosureVar *gobject.Closure, NParamsVar uint, ParamsVar uintptr) *ClosureExpression {
276 var cls *ClosureExpression
277
278 cret := xNewClosureExpression(ValueTypeVar, ClosureVar, NParamsVar, ParamsVar)
279
280 if cret == 0 {
281 return nil
282 }
283 cls = &ClosureExpression{}
284 cls.Ptr = cret
285 return cls
286}
287
288func (c *ClosureExpression) GoPointer() uintptr {
289 if c == nil {
290 return 0
291 }
292 return c.Ptr
293}
294
295func (c *ClosureExpression) SetGoPointer(ptr uintptr) {
296 c.Ptr = ptr
297}
298
299// A constant value in a `GtkExpression`.
300type ConstantExpression struct {
301 Expression
302}
303
304var xConstantExpressionGLibType func() types.GType
305
306func ConstantExpressionGLibType() types.GType {
307 return xConstantExpressionGLibType()
308}
309
310func ConstantExpressionNewFromInternalPtr(ptr uintptr) *ConstantExpression {
311 cls := &ConstantExpression{}
312 cls.Ptr = ptr
313 return cls
314}
315
316var xNewConstantExpression func(types.GType, ...interface{}) uintptr
317
318// Creates a `GtkExpression` that evaluates to the
319// object given by the arguments.
320func NewConstantExpression(ValueTypeVar types.GType, varArgs ...interface{}) *ConstantExpression {
321 var cls *ConstantExpression
322
323 cret := xNewConstantExpression(ValueTypeVar, varArgs...)
324
325 if cret == 0 {
326 return nil
327 }
328 cls = &ConstantExpression{}
329 cls.Ptr = cret
330 return cls
331}
332
333var xNewConstantExpressionForValue func(*gobject.Value) uintptr
334
335// Creates an expression that always evaluates to the given `value`.
336func NewConstantExpressionForValue(ValueVar *gobject.Value) *ConstantExpression {
337 var cls *ConstantExpression
338
339 cret := xNewConstantExpressionForValue(ValueVar)
340
341 if cret == 0 {
342 return nil
343 }
344 cls = &ConstantExpression{}
345 cls.Ptr = cret
346 return cls
347}
348
349var xConstantExpressionGetValue func(uintptr) *gobject.Value
350
351// Gets the value that a constant expression evaluates to.
352func (x *ConstantExpression) GetValue() *gobject.Value {
353
354 cret := xConstantExpressionGetValue(x.GoPointer())
355 return cret
356}
357
358func (c *ConstantExpression) GoPointer() uintptr {
359 if c == nil {
360 return 0
361 }
362 return c.Ptr
363}
364
365func (c *ConstantExpression) SetGoPointer(ptr uintptr) {
366 c.Ptr = ptr
367}
368
369// Provides a way to describe references to values.
370//
371// An important aspect of expressions is that the value can be obtained
372// from a source that is several steps away. For example, an expression
373// may describe ‘the value of property A of `object1`, which is itself the
374// value of a property of `object2`’. And `object1` may not even exist yet
375// at the time that the expression is created. This is contrast to `GObject`
376// property bindings, which can only create direct connections between
377// the properties of two objects that must both exist for the duration
378// of the binding.
379//
380// An expression needs to be "evaluated" to obtain the value that it currently
381// refers to. An evaluation always happens in the context of a current object
382// called `this` (it mirrors the behavior of object-oriented languages),
383// which may or may not influence the result of the evaluation. Use
384// [method@Gtk.Expression.evaluate] for evaluating an expression.
385//
386// Various methods for defining expressions exist, from simple constants via
387// [ctor@Gtk.ConstantExpression.new] to looking up properties in a `GObject`
388// (even recursively) via [ctor@Gtk.PropertyExpression.new] or providing
389// custom functions to transform and combine expressions via
390// [ctor@Gtk.ClosureExpression.new].
391//
392// Here is an example of a complex expression:
393//
394// ```c
395//
396// color_expr = gtk_property_expression_new (GTK_TYPE_LIST_ITEM,
397// NULL, "item");
398// expression = gtk_property_expression_new (GTK_TYPE_COLOR,
399// color_expr, "name");
400//
401// ```
402//
403// when evaluated with `this` being a `GtkListItem`, it will obtain the
404// "item" property from the `GtkListItem`, and then obtain the "name" property
405// from the resulting object (which is assumed to be of type `GTK_TYPE_COLOR`).
406//
407// # A more concise way to describe this would be
408//
409// ```
410//
411// this->item->name
412//
413// ```
414//
415// The most likely place where you will encounter expressions is in the context
416// of list models and list widgets using them. For example, `GtkDropDown` is
417// evaluating a `GtkExpression` to obtain strings from the items in its model
418// that it can then use to match against the contents of its search entry.
419// `GtkStringFilter` is using a `GtkExpression` for similar reasons.
420//
421// By default, expressions are not paying attention to changes and evaluation is
422// just a snapshot of the current state at a given time. To get informed about
423// changes, an expression needs to be "watched" via a [struct@Gtk.ExpressionWatch],
424// which will cause a callback to be called whenever the value of the expression may
425// have changed; [method@Gtk.Expression.watch] starts watching an expression, and
426// [method@Gtk.ExpressionWatch.unwatch] stops.
427//
428// Watches can be created for automatically updating the property of an object,
429// similar to GObject's `GBinding` mechanism, by using [method@Gtk.Expression.bind].
430//
431// ## GtkExpression in GObject properties
432//
433// In order to use a `GtkExpression` as a `GObject` property, you must use the
434// [func@Gtk.param_spec_expression] when creating a `GParamSpec` to install in the
435// `GObject` class being defined; for instance:
436//
437// ```c
438// obj_props[PROP_EXPRESSION] =
439//
440// gtk_param_spec_expression ("expression",
441// "Expression",
442// "The expression used by the widget",
443// G_PARAM_READWRITE |
444// G_PARAM_STATIC_STRINGS |
445// G_PARAM_EXPLICIT_NOTIFY);
446//
447// ```
448//
449// When implementing the `GObjectClass.set_property` and `GObjectClass.get_property`
450// virtual functions, you must use [func@Gtk.value_get_expression], to retrieve the
451// stored `GtkExpression` from the `GValue` container, and [func@Gtk.value_set_expression],
452// to store the `GtkExpression` into the `GValue`; for instance:
453//
454// ```c
455//
456// // in set_property()...
457// case PROP_EXPRESSION:
458// foo_widget_set_expression (foo, gtk_value_get_expression (value));
459// break;
460//
461// // in get_property()...
462// case PROP_EXPRESSION:
463// gtk_value_set_expression (value, foo->expression);
464// break;
465//
466// ```
467//
468// ## GtkExpression in .ui files
469//
470// `GtkBuilder` has support for creating expressions. The syntax here can be used where
471// a `GtkExpression` object is needed like in a `<property>` tag for an expression
472// property, or in a `<binding name="property">` tag to bind a property to an expression.
473//
474// To create a property expression, use the `<lookup>` element. It can have a `type`
475// attribute to specify the object type, and a `name` attribute to specify the property
476// to look up. The content of `<lookup>` can either be a string that specifies the name
477// of the object to use, an element specifying an expression to provide an object, or
478// empty to use the `this` object.
479//
480// Example:
481//
482// ```xml
483//
484// <lookup name='search'>string_filter</lookup>
485//
486// ```
487//
488// Since the `<lookup>` element creates an expression and its element content can
489// itself be an expression, this means that `<lookup>` tags can also be nested.
490// This is a common idiom when dealing with `GtkListItem`s. See
491// [class@Gtk.BuilderListItemFactory] for an example of this technique.
492//
493// To create a constant expression, use the `<constant>` element. If the type attribute
494// is specified, the element content is interpreted as a value of that type. Otherwise,
495// it is assumed to be an object. For instance:
496//
497// ```xml
498//
499// <constant>string_filter</constant>
500// <constant type='gchararray'>Hello, world</constant>
501//
502// ```
503//
504// String (`type='gchararray'`) constants can be marked for translation with the
505// `translatable=` attribute, and will then be looked up in the
506// [property@Gtk.Builder:translation-domain] when the expression is constructed.
507//
508// ```xml
509//
510// <constant type='gchararray' translatable='yes'>I'm translatable!</constant>
511//
512// ```
513//
514// As with other translatable strings in [type@Gtk.Builder], constants can
515// also have a context and/or translation comment:
516//
517// ```xml
518//
519// <constant type='gchararray'
520// translatable='yes'
521// context='example'
522// comments='A sample string'>I'm translatable!</constant>
523//
524// ```
525//
526// To create a closure expression, use the `<closure>` element. The `function`
527// attribute specifies what function to use for the closure, and the `type`
528// attribute specifies its return type. The content of the element contains the
529// expressions for the parameters. For instance:
530//
531// ```xml
532//
533// <closure type='gchararray' function='combine_args_somehow'>
534// <constant type='gchararray'>File size:</constant>
535// <lookup type='GFile' name='size'>myfile</lookup>
536// </closure>
537//
538// ```
539//
540// To create a property binding, use the `<binding>` element in place of where a
541// `<property>` tag would ordinarily be used. The `name` and `object` attributes are
542// supported. The `name` attribute is required, and pertains to the applicable property
543// name. The `object` attribute is optional. If provided, it will use the specified object
544// as the `this` object when the expression is evaluated. Here is an example in which the
545// `label` property of a `GtkLabel` is bound to the `string` property of another arbitrary
546// object:
547//
548// ```xml
549//
550// <object class='GtkLabel'>
551// <binding name='label'>
552// <lookup name='string'>some_other_object</lookup>
553// </binding>
554// </object>
555//
556// ```
557type Expression struct {
558 Ptr uintptr
559}
560
561var xExpressionGLibType func() types.GType
562
563func ExpressionGLibType() types.GType {
564 return xExpressionGLibType()
565}
566
567func ExpressionNewFromInternalPtr(ptr uintptr) *Expression {
568 cls := &Expression{}
569 cls.Ptr = ptr
570 return cls
571}
572
573var xExpressionBind func(uintptr, uintptr, string, uintptr) *ExpressionWatch
574
575// Bind `target`'s property named `property` to `self`.
576//
577// The value that `self` evaluates to is set via `g_object_set()` on
578// `target`. This is repeated whenever `self` changes to ensure that
579// the object's property stays synchronized with `self`.
580//
581// If `self`'s evaluation fails, `target`'s `property` is not updated.
582// You can ensure that this doesn't happen by using a fallback
583// expression.
584//
585// Note that this function takes ownership of `self`. If you want
586// to keep it around, you should [method@Gtk.Expression.ref] it beforehand.
587func (x *Expression) Bind(TargetVar *gobject.Object, PropertyVar string, ThisVar *gobject.Object) *ExpressionWatch {
588
589 cret := xExpressionBind(x.GoPointer(), TargetVar.GoPointer(), PropertyVar, ThisVar.GoPointer())
590 return cret
591}
592
593var xExpressionEvaluate func(uintptr, uintptr, *gobject.Value) bool
594
595// Evaluates the given expression and on success stores the result
596// in @value.
597//
598// The `GType` of `value` will be the type given by
599// [method@Gtk.Expression.get_value_type].
600//
601// It is possible that expressions cannot be evaluated - for example
602// when the expression references objects that have been destroyed or
603// set to `NULL`. In that case `value` will remain empty and `FALSE`
604// will be returned.
605func (x *Expression) Evaluate(ThisVar *gobject.Object, ValueVar *gobject.Value) bool {
606
607 cret := xExpressionEvaluate(x.GoPointer(), ThisVar.GoPointer(), ValueVar)
608 return cret
609}
610
611var xExpressionGetValueType func(uintptr) types.GType
612
613// Gets the `GType` that this expression evaluates to.
614//
615// This type is constant and will not change over the lifetime
616// of this expression.
617func (x *Expression) GetValueType() types.GType {
618
619 cret := xExpressionGetValueType(x.GoPointer())
620 return cret
621}
622
623var xExpressionIsStatic func(uintptr) bool
624
625// Checks if the expression is static.
626//
627// A static expression will never change its result when
628// [method@Gtk.Expression.evaluate] is called on it with the same arguments.
629//
630// That means a call to [method@Gtk.Expression.watch] is not necessary because
631// it will never trigger a notify.
632func (x *Expression) IsStatic() bool {
633
634 cret := xExpressionIsStatic(x.GoPointer())
635 return cret
636}
637
638var xExpressionRef func(uintptr) uintptr
639
640// Acquires a reference on the given `GtkExpression`.
641func (x *Expression) Ref() *Expression {
642 var cls *Expression
643
644 cret := xExpressionRef(x.GoPointer())
645
646 if cret == 0 {
647 return nil
648 }
649 cls = &Expression{}
650 cls.Ptr = cret
651 return cls
652}
653
654var xExpressionUnref func(uintptr)
655
656// Releases a reference on the given `GtkExpression`.
657//
658// If the reference was the last, the resources associated to the `self` are
659// freed.
660func (x *Expression) Unref() {
661
662 xExpressionUnref(x.GoPointer())
663
664}
665
666var xExpressionWatch func(uintptr, uintptr, uintptr, uintptr, uintptr) *ExpressionWatch
667
668// Watch the given `expression` for changes.
669//
670// The @notify function will be called whenever the evaluation of `self`
671// may have changed.
672//
673// GTK cannot guarantee that the evaluation did indeed change when the @notify
674// gets invoked, but it guarantees the opposite: When it did in fact change,
675// the @notify will be invoked.
676func (x *Expression) Watch(ThisVar *gobject.Object, NotifyVar *ExpressionNotify, UserDataVar uintptr, UserDestroyVar *glib.DestroyNotify) *ExpressionWatch {
677
678 var NotifyVarRef uintptr
679 if NotifyVar != nil {
680 NotifyVarPtr := uintptr(unsafe.Pointer(NotifyVar))
681 if cbRefPtr, ok := glib.GetCallback(NotifyVarPtr); ok {
682 NotifyVarRef = cbRefPtr
683 } else {
684 fcb := func(arg0 uintptr) {
685 cbFn := *NotifyVar
686 cbFn(arg0)
687 }
688 NotifyVarRef = purego.NewCallback(fcb)
689 glib.SaveCallbackWithClosure(NotifyVarPtr, NotifyVarRef, NotifyVar)
690 }
691 }
692
693 var UserDestroyVarRef uintptr
694 if UserDestroyVar != nil {
695 UserDestroyVarPtr := uintptr(unsafe.Pointer(UserDestroyVar))
696 if cbRefPtr, ok := glib.GetCallback(UserDestroyVarPtr); ok {
697 UserDestroyVarRef = cbRefPtr
698 } else {
699 fcb := func(arg0 uintptr) {
700 cbFn := *UserDestroyVar
701 cbFn(arg0)
702 }
703 UserDestroyVarRef = purego.NewCallback(fcb)
704 glib.SaveCallbackWithClosure(UserDestroyVarPtr, UserDestroyVarRef, UserDestroyVar)
705 }
706 }
707
708 cret := xExpressionWatch(x.GoPointer(), ThisVar.GoPointer(), NotifyVarRef, UserDataVar, UserDestroyVarRef)
709 return cret
710}
711
712func (c *Expression) GoPointer() uintptr {
713 if c == nil {
714 return 0
715 }
716 return c.Ptr
717}
718
719func (c *Expression) SetGoPointer(ptr uintptr) {
720 c.Ptr = ptr
721}
722
723// A `GObject` value in a `GtkExpression`.
724type ObjectExpression struct {
725 Expression
726}
727
728var xObjectExpressionGLibType func() types.GType
729
730func ObjectExpressionGLibType() types.GType {
731 return xObjectExpressionGLibType()
732}
733
734func ObjectExpressionNewFromInternalPtr(ptr uintptr) *ObjectExpression {
735 cls := &ObjectExpression{}
736 cls.Ptr = ptr
737 return cls
738}
739
740var xNewObjectExpression func(uintptr) uintptr
741
742// Creates an expression evaluating to the given `object` with a weak reference.
743//
744// Once the `object` is disposed, it will fail to evaluate.
745//
746// This expression is meant to break reference cycles.
747//
748// If you want to keep a reference to `object`, use [ctor@Gtk.ConstantExpression.new].
749func NewObjectExpression(ObjectVar *gobject.Object) *ObjectExpression {
750 var cls *ObjectExpression
751
752 cret := xNewObjectExpression(ObjectVar.GoPointer())
753
754 if cret == 0 {
755 return nil
756 }
757 cls = &ObjectExpression{}
758 cls.Ptr = cret
759 return cls
760}
761
762var xObjectExpressionGetObject func(uintptr) uintptr
763
764// Gets the object that the expression evaluates to.
765func (x *ObjectExpression) GetObject() *gobject.Object {
766 var cls *gobject.Object
767
768 cret := xObjectExpressionGetObject(x.GoPointer())
769
770 if cret == 0 {
771 return nil
772 }
773 gobject.IncreaseRef(cret)
774 cls = &gobject.Object{}
775 cls.Ptr = cret
776 return cls
777}
778
779func (c *ObjectExpression) GoPointer() uintptr {
780 if c == nil {
781 return 0
782 }
783 return c.Ptr
784}
785
786func (c *ObjectExpression) SetGoPointer(ptr uintptr) {
787 c.Ptr = ptr
788}
789
790// A `GParamSpec` for properties holding a `GtkExpression`.
791type ParamSpecExpression struct {
792 gobject.ParamSpec
793}
794
795var xParamSpecExpressionGLibType func() types.GType
796
797func ParamSpecExpressionGLibType() types.GType {
798 return xParamSpecExpressionGLibType()
799}
800
801func ParamSpecExpressionNewFromInternalPtr(ptr uintptr) *ParamSpecExpression {
802 cls := &ParamSpecExpression{}
803 cls.Ptr = ptr
804 return cls
805}
806
807func (c *ParamSpecExpression) GoPointer() uintptr {
808 if c == nil {
809 return 0
810 }
811 return c.Ptr
812}
813
814func (c *ParamSpecExpression) SetGoPointer(ptr uintptr) {
815 c.Ptr = ptr
816}
817
818// A `GObject` property value in a `GtkExpression`.
819type PropertyExpression struct {
820 Expression
821}
822
823var xPropertyExpressionGLibType func() types.GType
824
825func PropertyExpressionGLibType() types.GType {
826 return xPropertyExpressionGLibType()
827}
828
829func PropertyExpressionNewFromInternalPtr(ptr uintptr) *PropertyExpression {
830 cls := &PropertyExpression{}
831 cls.Ptr = ptr
832 return cls
833}
834
835var xNewPropertyExpression func(types.GType, uintptr, string) uintptr
836
837// Creates an expression that looks up a property.
838//
839// The object to use is found by evaluating the `expression`,
840// or using the `this` argument when `expression` is `NULL`.
841//
842// If the resulting object conforms to `this_type`, its property named
843// `property_name` will be queried. Otherwise, this expression's
844// evaluation will fail.
845//
846// The given `this_type` must have a property with `property_name`.
847func NewPropertyExpression(ThisTypeVar types.GType, ExpressionVar *Expression, PropertyNameVar string) *PropertyExpression {
848 var cls *PropertyExpression
849
850 cret := xNewPropertyExpression(ThisTypeVar, ExpressionVar.GoPointer(), PropertyNameVar)
851
852 if cret == 0 {
853 return nil
854 }
855 cls = &PropertyExpression{}
856 cls.Ptr = cret
857 return cls
858}
859
860var xNewPropertyExpressionForPspec func(uintptr, uintptr) uintptr
861
862// Creates an expression that looks up a property.
863//
864// The object to use is found by evaluating the `expression`,
865// or using the `this` argument when `expression` is `NULL`.
866//
867// If the resulting object conforms to `this_type`, its
868// property specified by `pspec` will be queried.
869// Otherwise, this expression's evaluation will fail.
870func NewPropertyExpressionForPspec(ExpressionVar *Expression, PspecVar *gobject.ParamSpec) *PropertyExpression {
871 var cls *PropertyExpression
872
873 cret := xNewPropertyExpressionForPspec(ExpressionVar.GoPointer(), PspecVar.GoPointer())
874
875 if cret == 0 {
876 return nil
877 }
878 cls = &PropertyExpression{}
879 cls.Ptr = cret
880 return cls
881}
882
883var xPropertyExpressionGetExpression func(uintptr) uintptr
884
885// Gets the expression specifying the object of
886// a property expression.
887func (x *PropertyExpression) GetExpression() *Expression {
888 var cls *Expression
889
890 cret := xPropertyExpressionGetExpression(x.GoPointer())
891
892 if cret == 0 {
893 return nil
894 }
895 gobject.IncreaseRef(cret)
896 cls = &Expression{}
897 cls.Ptr = cret
898 return cls
899}
900
901var xPropertyExpressionGetPspec func(uintptr) uintptr
902
903// Gets the `GParamSpec` specifying the property of
904// a property expression.
905func (x *PropertyExpression) GetPspec() *gobject.ParamSpec {
906 var cls *gobject.ParamSpec
907
908 cret := xPropertyExpressionGetPspec(x.GoPointer())
909
910 if cret == 0 {
911 return nil
912 }
913 gobject.IncreaseRef(cret)
914 cls = &gobject.ParamSpec{}
915 cls.Ptr = cret
916 return cls
917}
918
919func (c *PropertyExpression) GoPointer() uintptr {
920 if c == nil {
921 return 0
922 }
923 return c.Ptr
924}
925
926func (c *PropertyExpression) SetGoPointer(ptr uintptr) {
927 c.Ptr = ptr
928}
929
930func init() {
931 core.SetPackageName("GTK", "gtk4")
932 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
933 var libs []uintptr
934 for _, libPath := range core.GetPaths("GTK") {
935 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
936 if err != nil {
937 panic(err)
938 }
939 libs = append(libs, lib)
940 }
941
942 core.PuregoSafeRegister(&xNewParamSpecExpression, libs, "gtk_param_spec_expression")
943 core.PuregoSafeRegister(&xValueDupExpression, libs, "gtk_value_dup_expression")
944 core.PuregoSafeRegister(&xValueGetExpression, libs, "gtk_value_get_expression")
945 core.PuregoSafeRegister(&xValueSetExpression, libs, "gtk_value_set_expression")
946 core.PuregoSafeRegister(&xValueTakeExpression, libs, "gtk_value_take_expression")
947
948 core.PuregoSafeRegister(&xExpressionWatchGLibType, libs, "gtk_expression_watch_get_type")
949
950 core.PuregoSafeRegister(&xExpressionWatchEvaluate, libs, "gtk_expression_watch_evaluate")
951 core.PuregoSafeRegister(&xExpressionWatchRef, libs, "gtk_expression_watch_ref")
952 core.PuregoSafeRegister(&xExpressionWatchUnref, libs, "gtk_expression_watch_unref")
953 core.PuregoSafeRegister(&xExpressionWatchUnwatch, libs, "gtk_expression_watch_unwatch")
954
955 core.PuregoSafeRegister(&xCClosureExpressionGLibType, libs, "gtk_cclosure_expression_get_type")
956
957 core.PuregoSafeRegister(&xNewCClosureExpression, libs, "gtk_cclosure_expression_new")
958
959 core.PuregoSafeRegister(&xClosureExpressionGLibType, libs, "gtk_closure_expression_get_type")
960
961 core.PuregoSafeRegister(&xNewClosureExpression, libs, "gtk_closure_expression_new")
962
963 core.PuregoSafeRegister(&xConstantExpressionGLibType, libs, "gtk_constant_expression_get_type")
964
965 core.PuregoSafeRegister(&xNewConstantExpression, libs, "gtk_constant_expression_new")
966 core.PuregoSafeRegister(&xNewConstantExpressionForValue, libs, "gtk_constant_expression_new_for_value")
967
968 core.PuregoSafeRegister(&xConstantExpressionGetValue, libs, "gtk_constant_expression_get_value")
969
970 core.PuregoSafeRegister(&xExpressionGLibType, libs, "gtk_expression_get_type")
971
972 core.PuregoSafeRegister(&xExpressionBind, libs, "gtk_expression_bind")
973 core.PuregoSafeRegister(&xExpressionEvaluate, libs, "gtk_expression_evaluate")
974 core.PuregoSafeRegister(&xExpressionGetValueType, libs, "gtk_expression_get_value_type")
975 core.PuregoSafeRegister(&xExpressionIsStatic, libs, "gtk_expression_is_static")
976 core.PuregoSafeRegister(&xExpressionRef, libs, "gtk_expression_ref")
977 core.PuregoSafeRegister(&xExpressionUnref, libs, "gtk_expression_unref")
978 core.PuregoSafeRegister(&xExpressionWatch, libs, "gtk_expression_watch")
979
980 core.PuregoSafeRegister(&xObjectExpressionGLibType, libs, "gtk_object_expression_get_type")
981
982 core.PuregoSafeRegister(&xNewObjectExpression, libs, "gtk_object_expression_new")
983
984 core.PuregoSafeRegister(&xObjectExpressionGetObject, libs, "gtk_object_expression_get_object")
985
986 core.PuregoSafeRegister(&xParamSpecExpressionGLibType, libs, "gtk_param_expression_get_type")
987
988 core.PuregoSafeRegister(&xPropertyExpressionGLibType, libs, "gtk_property_expression_get_type")
989
990 core.PuregoSafeRegister(&xNewPropertyExpression, libs, "gtk_property_expression_new")
991 core.PuregoSafeRegister(&xNewPropertyExpressionForPspec, libs, "gtk_property_expression_new_for_pspec")
992
993 core.PuregoSafeRegister(&xPropertyExpressionGetExpression, libs, "gtk_property_expression_get_expression")
994 core.PuregoSafeRegister(&xPropertyExpressionGetPspec, libs, "gtk_property_expression_get_pspec")
995
996}