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/gdk"
12 "github.com/bnema/puregotk/v4/gobject/types"
13)
14
15// The list of virtual functions for the `GtkSymbolicPaintable` interface.
16// No function must be implemented, default implementations exist for each one.
17type SymbolicPaintableInterface struct {
18 _ structs.HostLayout
19
20 GIface uintptr
21
22 xSnapshotSymbolic uintptr
23}
24
25func (x *SymbolicPaintableInterface) GoPointer() uintptr {
26 return uintptr(unsafe.Pointer(x))
27}
28
29// OverrideSnapshotSymbolic sets the "snapshot_symbolic" callback function.
30// Snapshot the paintable using the given colors.
31//
32// See `GtkSymbolicPaintable::snapshot_symbolic()` for details.
33// If this function is not implemented, [vfunc@Gdk.Paintable.snapshot]
34// will be called.
35func (x *SymbolicPaintableInterface) OverrideSnapshotSymbolic(cb func(SymbolicPaintable, *gdk.Snapshot, float64, float64, []gdk.RGBA, uint)) {
36 if cb == nil {
37 x.xSnapshotSymbolic = 0
38 } else {
39 x.xSnapshotSymbolic = purego.NewCallback(func(PaintableVarp uintptr, SnapshotVarp uintptr, WidthVarp float64, HeightVarp float64, ColorsVarp []gdk.RGBA, NColorsVarp uint) {
40 cb(&SymbolicPaintableBase{Ptr: PaintableVarp}, gdk.SnapshotNewFromInternalPtr(SnapshotVarp), WidthVarp, HeightVarp, ColorsVarp, NColorsVarp)
41 })
42 }
43}
44
45// GetSnapshotSymbolic gets the "snapshot_symbolic" callback function.
46// Snapshot the paintable using the given colors.
47//
48// See `GtkSymbolicPaintable::snapshot_symbolic()` for details.
49// If this function is not implemented, [vfunc@Gdk.Paintable.snapshot]
50// will be called.
51func (x *SymbolicPaintableInterface) GetSnapshotSymbolic() func(SymbolicPaintable, *gdk.Snapshot, float64, float64, []gdk.RGBA, uint) {
52 if x.xSnapshotSymbolic == 0 {
53 return nil
54 }
55 var rawCallback func(PaintableVarp uintptr, SnapshotVarp uintptr, WidthVarp float64, HeightVarp float64, ColorsVarp []gdk.RGBA, NColorsVarp uint)
56 purego.RegisterFunc(&rawCallback, x.xSnapshotSymbolic)
57 return func(PaintableVar SymbolicPaintable, SnapshotVar *gdk.Snapshot, WidthVar float64, HeightVar float64, ColorsVar []gdk.RGBA, NColorsVar uint) {
58 rawCallback(PaintableVar.GoPointer(), SnapshotVar.GoPointer(), WidthVar, HeightVar, ColorsVar, NColorsVar)
59 }
60}
61
62// An interface that supports symbolic colors in paintables.
63//
64// `GdkPaintable`s implementing the interface will have the
65// [vfunc@Gtk.SymbolicPaintable.snapshot_symbolic] function called and
66// have the colors for drawing symbolic icons passed. At least 4 colors are guaranteed
67// to be passed every time.
68//
69// These 4 colors are the foreground color, and the colors to use for errors, warnings
70// and success information in that order.
71//
72// More colors may be added in the future.
73type SymbolicPaintable interface {
74 GoPointer() uintptr
75 SetGoPointer(uintptr)
76 SnapshotSymbolic(SnapshotVar *gdk.Snapshot, WidthVar float64, HeightVar float64, ColorsVar []gdk.RGBA, NColorsVar uint)
77}
78
79var xSymbolicPaintableGLibType func() types.GType
80
81func SymbolicPaintableGLibType() types.GType {
82 return xSymbolicPaintableGLibType()
83}
84
85type SymbolicPaintableBase struct {
86 Ptr uintptr
87}
88
89func (x *SymbolicPaintableBase) GoPointer() uintptr {
90 if x == nil {
91 return 0
92 }
93 return x.Ptr
94}
95
96func (x *SymbolicPaintableBase) SetGoPointer(ptr uintptr) {
97 x.Ptr = ptr
98}
99
100// Snapshots the paintable with the given colors.
101//
102// If less than 4 colors are provided, GTK will pad the array with default
103// colors.
104func (x *SymbolicPaintableBase) SnapshotSymbolic(SnapshotVar *gdk.Snapshot, WidthVar float64, HeightVar float64, ColorsVar []gdk.RGBA, NColorsVar uint) {
105
106 XGtkSymbolicPaintableSnapshotSymbolic(x.GoPointer(), SnapshotVar.GoPointer(), WidthVar, HeightVar, ColorsVar, NColorsVar)
107
108}
109
110var XGtkSymbolicPaintableSnapshotSymbolic func(uintptr, uintptr, float64, float64, []gdk.RGBA, uint)
111
112func init() {
113 core.SetPackageName("GTK", "gtk4")
114 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
115 var libs []uintptr
116 for _, libPath := range core.GetPaths("GTK") {
117 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
118 if err != nil {
119 panic(err)
120 }
121 libs = append(libs, lib)
122 }
123
124 core.PuregoSafeRegister(&xSymbolicPaintableGLibType, libs, "gtk_symbolic_paintable_get_type")
125
126 core.PuregoSafeRegister(&XGtkSymbolicPaintableSnapshotSymbolic, libs, "gtk_symbolic_paintable_snapshot_symbolic")
127
128}