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
16type AdjustmentClass struct {
17 _ structs.HostLayout
18
19 ParentClass gobject.InitiallyUnownedClass
20
21 xChanged uintptr
22
23 xValueChanged uintptr
24
25 xGtkReserved1 uintptr
26
27 xGtkReserved2 uintptr
28
29 xGtkReserved3 uintptr
30
31 xGtkReserved4 uintptr
32}
33
34func (x *AdjustmentClass) GoPointer() uintptr {
35 return uintptr(unsafe.Pointer(x))
36}
37
38// OverrideChanged sets the "changed" callback function.
39func (x *AdjustmentClass) OverrideChanged(cb func(*Adjustment)) {
40 if cb == nil {
41 x.xChanged = 0
42 } else {
43 x.xChanged = purego.NewCallback(func(AdjustmentVarp uintptr) {
44 cb(AdjustmentNewFromInternalPtr(AdjustmentVarp))
45 })
46 }
47}
48
49// GetChanged gets the "changed" callback function.
50func (x *AdjustmentClass) GetChanged() func(*Adjustment) {
51 if x.xChanged == 0 {
52 return nil
53 }
54 var rawCallback func(AdjustmentVarp uintptr)
55 purego.RegisterFunc(&rawCallback, x.xChanged)
56 return func(AdjustmentVar *Adjustment) {
57 rawCallback(AdjustmentVar.GoPointer())
58 }
59}
60
61// OverrideValueChanged sets the "value_changed" callback function.
62func (x *AdjustmentClass) OverrideValueChanged(cb func(*Adjustment)) {
63 if cb == nil {
64 x.xValueChanged = 0
65 } else {
66 x.xValueChanged = purego.NewCallback(func(AdjustmentVarp uintptr) {
67 cb(AdjustmentNewFromInternalPtr(AdjustmentVarp))
68 })
69 }
70}
71
72// GetValueChanged gets the "value_changed" callback function.
73func (x *AdjustmentClass) GetValueChanged() func(*Adjustment) {
74 if x.xValueChanged == 0 {
75 return nil
76 }
77 var rawCallback func(AdjustmentVarp uintptr)
78 purego.RegisterFunc(&rawCallback, x.xValueChanged)
79 return func(AdjustmentVar *Adjustment) {
80 rawCallback(AdjustmentVar.GoPointer())
81 }
82}
83
84// OverrideGtkReserved1 sets the "_gtk_reserved1" callback function.
85func (x *AdjustmentClass) OverrideGtkReserved1(cb func()) {
86 if cb == nil {
87 x.xGtkReserved1 = 0
88 } else {
89 x.xGtkReserved1 = purego.NewCallback(func() {
90 cb()
91 })
92 }
93}
94
95// GetGtkReserved1 gets the "_gtk_reserved1" callback function.
96func (x *AdjustmentClass) GetGtkReserved1() func() {
97 if x.xGtkReserved1 == 0 {
98 return nil
99 }
100 var rawCallback func()
101 purego.RegisterFunc(&rawCallback, x.xGtkReserved1)
102 return func() {
103 rawCallback()
104 }
105}
106
107// OverrideGtkReserved2 sets the "_gtk_reserved2" callback function.
108func (x *AdjustmentClass) OverrideGtkReserved2(cb func()) {
109 if cb == nil {
110 x.xGtkReserved2 = 0
111 } else {
112 x.xGtkReserved2 = purego.NewCallback(func() {
113 cb()
114 })
115 }
116}
117
118// GetGtkReserved2 gets the "_gtk_reserved2" callback function.
119func (x *AdjustmentClass) GetGtkReserved2() func() {
120 if x.xGtkReserved2 == 0 {
121 return nil
122 }
123 var rawCallback func()
124 purego.RegisterFunc(&rawCallback, x.xGtkReserved2)
125 return func() {
126 rawCallback()
127 }
128}
129
130// OverrideGtkReserved3 sets the "_gtk_reserved3" callback function.
131func (x *AdjustmentClass) OverrideGtkReserved3(cb func()) {
132 if cb == nil {
133 x.xGtkReserved3 = 0
134 } else {
135 x.xGtkReserved3 = purego.NewCallback(func() {
136 cb()
137 })
138 }
139}
140
141// GetGtkReserved3 gets the "_gtk_reserved3" callback function.
142func (x *AdjustmentClass) GetGtkReserved3() func() {
143 if x.xGtkReserved3 == 0 {
144 return nil
145 }
146 var rawCallback func()
147 purego.RegisterFunc(&rawCallback, x.xGtkReserved3)
148 return func() {
149 rawCallback()
150 }
151}
152
153// OverrideGtkReserved4 sets the "_gtk_reserved4" callback function.
154func (x *AdjustmentClass) OverrideGtkReserved4(cb func()) {
155 if cb == nil {
156 x.xGtkReserved4 = 0
157 } else {
158 x.xGtkReserved4 = purego.NewCallback(func() {
159 cb()
160 })
161 }
162}
163
164// GetGtkReserved4 gets the "_gtk_reserved4" callback function.
165func (x *AdjustmentClass) GetGtkReserved4() func() {
166 if x.xGtkReserved4 == 0 {
167 return nil
168 }
169 var rawCallback func()
170 purego.RegisterFunc(&rawCallback, x.xGtkReserved4)
171 return func() {
172 rawCallback()
173 }
174}
175
176// A model for a numeric value.
177//
178// The `GtkAdjustment` has an associated lower and upper bound.
179// It also contains step and page increments, and a page size.
180//
181// Adjustments are used within several GTK widgets, including
182// [class@Gtk.SpinButton], [class@Gtk.Viewport], [class@Gtk.Scrollbar]
183// and [class@Gtk.Scale].
184//
185// The `GtkAdjustment` object does not update the value itself. Instead
186// it is left up to the owner of the `GtkAdjustment` to control the value.
187type Adjustment struct {
188 gobject.InitiallyUnowned
189}
190
191var xAdjustmentGLibType func() types.GType
192
193func AdjustmentGLibType() types.GType {
194 return xAdjustmentGLibType()
195}
196
197func AdjustmentNewFromInternalPtr(ptr uintptr) *Adjustment {
198 cls := &Adjustment{}
199 cls.Ptr = ptr
200 return cls
201}
202
203var xNewAdjustment func(float64, float64, float64, float64, float64, float64) uintptr
204
205// Creates a new `GtkAdjustment`.
206func NewAdjustment(ValueVar float64, LowerVar float64, UpperVar float64, StepIncrementVar float64, PageIncrementVar float64, PageSizeVar float64) *Adjustment {
207 var cls *Adjustment
208
209 cret := xNewAdjustment(ValueVar, LowerVar, UpperVar, StepIncrementVar, PageIncrementVar, PageSizeVar)
210
211 if cret == 0 {
212 return nil
213 }
214 gobject.IncreaseRef(cret)
215 cls = &Adjustment{}
216 cls.Ptr = cret
217 return cls
218}
219
220var xAdjustmentClampPage func(uintptr, float64, float64)
221
222// Updates the value of the adjustment to ensure that the
223// given range is contained in the current page.
224//
225// The current page goes from `value` to `value` + `page-size`.
226// If the range is larger than the page size, then only the
227// start of it will be in the current page.
228//
229// A [signal@Gtk.Adjustment::value-changed] signal will be emitted
230// if the value is changed.
231func (x *Adjustment) ClampPage(LowerVar float64, UpperVar float64) {
232
233 xAdjustmentClampPage(x.GoPointer(), LowerVar, UpperVar)
234
235}
236
237var xAdjustmentConfigure func(uintptr, float64, float64, float64, float64, float64, float64)
238
239// Sets all properties of the adjustment at once.
240//
241// Use this function to avoid multiple emissions of the
242// [signal@Gtk.Adjustment::changed] signal. See
243// [method@Gtk.Adjustment.set_lower] for an alternative
244// way of compressing multiple emissions of
245// [signal@Gtk.Adjustment::changed] into one.
246func (x *Adjustment) Configure(ValueVar float64, LowerVar float64, UpperVar float64, StepIncrementVar float64, PageIncrementVar float64, PageSizeVar float64) {
247
248 xAdjustmentConfigure(x.GoPointer(), ValueVar, LowerVar, UpperVar, StepIncrementVar, PageIncrementVar, PageSizeVar)
249
250}
251
252var xAdjustmentGetLower func(uintptr) float64
253
254// Retrieves the minimum value of the adjustment.
255func (x *Adjustment) GetLower() float64 {
256
257 cret := xAdjustmentGetLower(x.GoPointer())
258 return cret
259}
260
261var xAdjustmentGetMinimumIncrement func(uintptr) float64
262
263// Gets the smaller of step increment and page increment.
264func (x *Adjustment) GetMinimumIncrement() float64 {
265
266 cret := xAdjustmentGetMinimumIncrement(x.GoPointer())
267 return cret
268}
269
270var xAdjustmentGetPageIncrement func(uintptr) float64
271
272// Retrieves the page increment of the adjustment.
273func (x *Adjustment) GetPageIncrement() float64 {
274
275 cret := xAdjustmentGetPageIncrement(x.GoPointer())
276 return cret
277}
278
279var xAdjustmentGetPageSize func(uintptr) float64
280
281// Retrieves the page size of the adjustment.
282func (x *Adjustment) GetPageSize() float64 {
283
284 cret := xAdjustmentGetPageSize(x.GoPointer())
285 return cret
286}
287
288var xAdjustmentGetStepIncrement func(uintptr) float64
289
290// Retrieves the step increment of the adjustment.
291func (x *Adjustment) GetStepIncrement() float64 {
292
293 cret := xAdjustmentGetStepIncrement(x.GoPointer())
294 return cret
295}
296
297var xAdjustmentGetUpper func(uintptr) float64
298
299// Retrieves the maximum value of the adjustment.
300func (x *Adjustment) GetUpper() float64 {
301
302 cret := xAdjustmentGetUpper(x.GoPointer())
303 return cret
304}
305
306var xAdjustmentGetValue func(uintptr) float64
307
308// Gets the current value of the adjustment.
309func (x *Adjustment) GetValue() float64 {
310
311 cret := xAdjustmentGetValue(x.GoPointer())
312 return cret
313}
314
315var xAdjustmentSetLower func(uintptr, float64)
316
317// Sets the minimum value of the adjustment.
318//
319// When setting multiple adjustment properties via their individual
320// setters, multiple [signal@Gtk.Adjustment::changed] signals will
321// be emitted. However, since the emission of the
322// [signal@Gtk.Adjustment::changed] signal is tied to the emission
323// of the ::notify signals of the changed properties, it’s possible
324// to compress the [signal@Gtk.Adjustment::changed] signals into one
325// by calling g_object_freeze_notify() and g_object_thaw_notify()
326// around the calls to the individual setters.
327//
328// Alternatively, using a single g_object_set() for all the properties
329// to change, or using [method@Gtk.Adjustment.configure] has the same effect.
330func (x *Adjustment) SetLower(LowerVar float64) {
331
332 xAdjustmentSetLower(x.GoPointer(), LowerVar)
333
334}
335
336var xAdjustmentSetPageIncrement func(uintptr, float64)
337
338// Sets the page increment of the adjustment.
339//
340// See [method@Gtk.Adjustment.set_lower] about how to compress
341// multiple emissions of the [signal@Gtk.Adjustment::changed]
342// signal when setting multiple adjustment properties.
343func (x *Adjustment) SetPageIncrement(PageIncrementVar float64) {
344
345 xAdjustmentSetPageIncrement(x.GoPointer(), PageIncrementVar)
346
347}
348
349var xAdjustmentSetPageSize func(uintptr, float64)
350
351// Sets the page size of the adjustment.
352//
353// See [method@Gtk.Adjustment.set_lower] about how to compress
354// multiple emissions of the [signal@Gtk.Adjustment::changed]
355// signal when setting multiple adjustment properties.
356func (x *Adjustment) SetPageSize(PageSizeVar float64) {
357
358 xAdjustmentSetPageSize(x.GoPointer(), PageSizeVar)
359
360}
361
362var xAdjustmentSetStepIncrement func(uintptr, float64)
363
364// Sets the step increment of the adjustment.
365//
366// See [method@Gtk.Adjustment.set_lower] about how to compress
367// multiple emissions of the [signal@Gtk.Adjustment::changed]
368// signal when setting multiple adjustment properties.
369func (x *Adjustment) SetStepIncrement(StepIncrementVar float64) {
370
371 xAdjustmentSetStepIncrement(x.GoPointer(), StepIncrementVar)
372
373}
374
375var xAdjustmentSetUpper func(uintptr, float64)
376
377// Sets the maximum value of the adjustment.
378//
379// Note that values will be restricted by `upper - page-size`
380// if the page-size property is nonzero.
381//
382// See [method@Gtk.Adjustment.set_lower] about how to compress
383// multiple emissions of the [signal@Gtk.Adjustment::changed]
384// signal when setting multiple adjustment properties.
385func (x *Adjustment) SetUpper(UpperVar float64) {
386
387 xAdjustmentSetUpper(x.GoPointer(), UpperVar)
388
389}
390
391var xAdjustmentSetValue func(uintptr, float64)
392
393// Sets the `GtkAdjustment` value.
394//
395// The value is clamped to lie between [property@Gtk.Adjustment:lower]
396// and [property@Gtk.Adjustment:upper].
397//
398// Note that for adjustments which are used in a `GtkScrollbar`,
399// the effective range of allowed values goes from
400// [property@Gtk.Adjustment:lower] to
401// [property@Gtk.Adjustment:upper] - [property@Gtk.Adjustment:page-size].
402func (x *Adjustment) SetValue(ValueVar float64) {
403
404 xAdjustmentSetValue(x.GoPointer(), ValueVar)
405
406}
407
408func (c *Adjustment) GoPointer() uintptr {
409 if c == nil {
410 return 0
411 }
412 return c.Ptr
413}
414
415func (c *Adjustment) SetGoPointer(ptr uintptr) {
416 c.Ptr = ptr
417}
418
419// SetPropertyLower sets the "lower" property.
420// The minimum value of the adjustment.
421func (x *Adjustment) SetPropertyLower(value float64) {
422 var v gobject.Value
423 v.Init(gobject.TypeDoubleVal)
424 v.SetDouble(value)
425 x.SetProperty("lower", &v)
426}
427
428// GetPropertyLower gets the "lower" property.
429// The minimum value of the adjustment.
430func (x *Adjustment) GetPropertyLower() float64 {
431 var v gobject.Value
432 x.GetProperty("lower", &v)
433 return v.GetDouble()
434}
435
436// SetPropertyPageIncrement sets the "page-increment" property.
437// The page increment of the adjustment.
438func (x *Adjustment) SetPropertyPageIncrement(value float64) {
439 var v gobject.Value
440 v.Init(gobject.TypeDoubleVal)
441 v.SetDouble(value)
442 x.SetProperty("page-increment", &v)
443}
444
445// GetPropertyPageIncrement gets the "page-increment" property.
446// The page increment of the adjustment.
447func (x *Adjustment) GetPropertyPageIncrement() float64 {
448 var v gobject.Value
449 x.GetProperty("page-increment", &v)
450 return v.GetDouble()
451}
452
453// SetPropertyPageSize sets the "page-size" property.
454// The page size of the adjustment.
455//
456// Note that the page-size is irrelevant and should be set to zero
457// if the adjustment is used for a simple scalar value, e.g. in a
458// `GtkSpinButton`.
459func (x *Adjustment) SetPropertyPageSize(value float64) {
460 var v gobject.Value
461 v.Init(gobject.TypeDoubleVal)
462 v.SetDouble(value)
463 x.SetProperty("page-size", &v)
464}
465
466// GetPropertyPageSize gets the "page-size" property.
467// The page size of the adjustment.
468//
469// Note that the page-size is irrelevant and should be set to zero
470// if the adjustment is used for a simple scalar value, e.g. in a
471// `GtkSpinButton`.
472func (x *Adjustment) GetPropertyPageSize() float64 {
473 var v gobject.Value
474 x.GetProperty("page-size", &v)
475 return v.GetDouble()
476}
477
478// SetPropertyStepIncrement sets the "step-increment" property.
479// The step increment of the adjustment.
480func (x *Adjustment) SetPropertyStepIncrement(value float64) {
481 var v gobject.Value
482 v.Init(gobject.TypeDoubleVal)
483 v.SetDouble(value)
484 x.SetProperty("step-increment", &v)
485}
486
487// GetPropertyStepIncrement gets the "step-increment" property.
488// The step increment of the adjustment.
489func (x *Adjustment) GetPropertyStepIncrement() float64 {
490 var v gobject.Value
491 x.GetProperty("step-increment", &v)
492 return v.GetDouble()
493}
494
495// SetPropertyUpper sets the "upper" property.
496// The maximum value of the adjustment.
497//
498// Note that values will be restricted by `upper - page-size` if the page-size
499// property is nonzero.
500func (x *Adjustment) SetPropertyUpper(value float64) {
501 var v gobject.Value
502 v.Init(gobject.TypeDoubleVal)
503 v.SetDouble(value)
504 x.SetProperty("upper", &v)
505}
506
507// GetPropertyUpper gets the "upper" property.
508// The maximum value of the adjustment.
509//
510// Note that values will be restricted by `upper - page-size` if the page-size
511// property is nonzero.
512func (x *Adjustment) GetPropertyUpper() float64 {
513 var v gobject.Value
514 x.GetProperty("upper", &v)
515 return v.GetDouble()
516}
517
518// SetPropertyValue sets the "value" property.
519// The value of the adjustment.
520func (x *Adjustment) SetPropertyValue(value float64) {
521 var v gobject.Value
522 v.Init(gobject.TypeDoubleVal)
523 v.SetDouble(value)
524 x.SetProperty("value", &v)
525}
526
527// GetPropertyValue gets the "value" property.
528// The value of the adjustment.
529func (x *Adjustment) GetPropertyValue() float64 {
530 var v gobject.Value
531 x.GetProperty("value", &v)
532 return v.GetDouble()
533}
534
535// Emitted when one or more of the `GtkAdjustment` properties have been
536// changed.
537//
538// Note that the [property@Gtk.Adjustment:value] property is
539// covered by the [signal@Gtk.Adjustment::value-changed] signal.
540func (x *Adjustment) ConnectChanged(cb *func(Adjustment)) uint {
541 cbPtr := uintptr(unsafe.Pointer(cb))
542 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
543 handlerID := gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr)
544 glib.SaveHandlerMapping(handlerID, cbPtr)
545 return handlerID
546 }
547
548 fcb := func(clsPtr uintptr) {
549 fa := Adjustment{}
550 fa.Ptr = clsPtr
551 cbFn := *cb
552
553 cbFn(fa)
554
555 }
556 cbRefPtr := purego.NewCallback(fcb)
557 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
558 handlerID := gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr)
559 glib.SaveHandlerMapping(handlerID, cbPtr)
560 return handlerID
561}
562
563// Emitted when the value has been changed.
564func (x *Adjustment) ConnectValueChanged(cb *func(Adjustment)) uint {
565 cbPtr := uintptr(unsafe.Pointer(cb))
566 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
567 handlerID := gobject.SignalConnect(x.GoPointer(), "value-changed", cbRefPtr)
568 glib.SaveHandlerMapping(handlerID, cbPtr)
569 return handlerID
570 }
571
572 fcb := func(clsPtr uintptr) {
573 fa := Adjustment{}
574 fa.Ptr = clsPtr
575 cbFn := *cb
576
577 cbFn(fa)
578
579 }
580 cbRefPtr := purego.NewCallback(fcb)
581 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
582 handlerID := gobject.SignalConnect(x.GoPointer(), "value-changed", cbRefPtr)
583 glib.SaveHandlerMapping(handlerID, cbPtr)
584 return handlerID
585}
586
587func init() {
588 core.SetPackageName("GTK", "gtk4")
589 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
590 var libs []uintptr
591 for _, libPath := range core.GetPaths("GTK") {
592 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
593 if err != nil {
594 panic(err)
595 }
596 libs = append(libs, lib)
597 }
598
599 core.PuregoSafeRegister(&xAdjustmentGLibType, libs, "gtk_adjustment_get_type")
600
601 core.PuregoSafeRegister(&xNewAdjustment, libs, "gtk_adjustment_new")
602
603 core.PuregoSafeRegister(&xAdjustmentClampPage, libs, "gtk_adjustment_clamp_page")
604 core.PuregoSafeRegister(&xAdjustmentConfigure, libs, "gtk_adjustment_configure")
605 core.PuregoSafeRegister(&xAdjustmentGetLower, libs, "gtk_adjustment_get_lower")
606 core.PuregoSafeRegister(&xAdjustmentGetMinimumIncrement, libs, "gtk_adjustment_get_minimum_increment")
607 core.PuregoSafeRegister(&xAdjustmentGetPageIncrement, libs, "gtk_adjustment_get_page_increment")
608 core.PuregoSafeRegister(&xAdjustmentGetPageSize, libs, "gtk_adjustment_get_page_size")
609 core.PuregoSafeRegister(&xAdjustmentGetStepIncrement, libs, "gtk_adjustment_get_step_increment")
610 core.PuregoSafeRegister(&xAdjustmentGetUpper, libs, "gtk_adjustment_get_upper")
611 core.PuregoSafeRegister(&xAdjustmentGetValue, libs, "gtk_adjustment_get_value")
612 core.PuregoSafeRegister(&xAdjustmentSetLower, libs, "gtk_adjustment_set_lower")
613 core.PuregoSafeRegister(&xAdjustmentSetPageIncrement, libs, "gtk_adjustment_set_page_increment")
614 core.PuregoSafeRegister(&xAdjustmentSetPageSize, libs, "gtk_adjustment_set_page_size")
615 core.PuregoSafeRegister(&xAdjustmentSetStepIncrement, libs, "gtk_adjustment_set_step_increment")
616 core.PuregoSafeRegister(&xAdjustmentSetUpper, libs, "gtk_adjustment_set_upper")
617 core.PuregoSafeRegister(&xAdjustmentSetValue, libs, "gtk_adjustment_set_value")
618
619}