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/glib"
13 "github.com/bnema/puregotk/v4/gobject"
14 "github.com/bnema/puregotk/v4/gobject/types"
15)
16
17type ATContextClass struct {
18 _ structs.HostLayout
19}
20
21func (x *ATContextClass) GoPointer() uintptr {
22 return uintptr(unsafe.Pointer(x))
23}
24
25// Communicates with platform-specific assistive technologies API.
26//
27// Each platform supported by GTK implements a `GtkATContext` subclass, and
28// is responsible for updating the accessible state in response to state
29// changes in `GtkAccessible`.
30type ATContext struct {
31 gobject.Object
32}
33
34var xATContextGLibType func() types.GType
35
36func ATContextGLibType() types.GType {
37 return xATContextGLibType()
38}
39
40func ATContextNewFromInternalPtr(ptr uintptr) *ATContext {
41 cls := &ATContext{}
42 cls.Ptr = ptr
43 return cls
44}
45
46var xATContextCreate func(AccessibleRole, uintptr, uintptr) uintptr
47
48// Creates a new `GtkATContext` instance for the given accessible role,
49// accessible instance, and display connection.
50//
51// The `GtkATContext` implementation being instantiated will depend on the
52// platform.
53func ATContextCreate(AccessibleRoleVar AccessibleRole, AccessibleVar Accessible, DisplayVar *gdk.Display) *ATContext {
54 var cls *ATContext
55
56 cret := xATContextCreate(AccessibleRoleVar, AccessibleVar.GoPointer(), DisplayVar.GoPointer())
57
58 if cret == 0 {
59 return nil
60 }
61 cls = &ATContext{}
62 cls.Ptr = cret
63 return cls
64}
65
66var xATContextGetAccessible func(uintptr) uintptr
67
68// Retrieves the `GtkAccessible` using this context.
69func (x *ATContext) GetAccessible() *AccessibleBase {
70 var cls *AccessibleBase
71
72 cret := xATContextGetAccessible(x.GoPointer())
73
74 if cret == 0 {
75 return nil
76 }
77 gobject.IncreaseRef(cret)
78 cls = &AccessibleBase{}
79 cls.Ptr = cret
80 return cls
81}
82
83var xATContextGetAccessibleRole func(uintptr) AccessibleRole
84
85// Retrieves the accessible role of this context.
86func (x *ATContext) GetAccessibleRole() AccessibleRole {
87
88 cret := xATContextGetAccessibleRole(x.GoPointer())
89 return cret
90}
91
92func (c *ATContext) GoPointer() uintptr {
93 if c == nil {
94 return 0
95 }
96 return c.Ptr
97}
98
99func (c *ATContext) SetGoPointer(ptr uintptr) {
100 c.Ptr = ptr
101}
102
103// Emitted when the attributes of the accessible for the
104// `GtkATContext` instance change.
105func (x *ATContext) ConnectStateChange(cb *func(ATContext)) uint {
106 cbPtr := uintptr(unsafe.Pointer(cb))
107 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
108 handlerID := gobject.SignalConnect(x.GoPointer(), "state-change", cbRefPtr)
109 glib.SaveHandlerMapping(handlerID, cbPtr)
110 return handlerID
111 }
112
113 fcb := func(clsPtr uintptr) {
114 fa := ATContext{}
115 fa.Ptr = clsPtr
116 cbFn := *cb
117
118 cbFn(fa)
119
120 }
121 cbRefPtr := purego.NewCallback(fcb)
122 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
123 handlerID := gobject.SignalConnect(x.GoPointer(), "state-change", cbRefPtr)
124 glib.SaveHandlerMapping(handlerID, cbPtr)
125 return handlerID
126}
127
128func init() {
129 core.SetPackageName("GTK", "gtk4")
130 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
131 var libs []uintptr
132 for _, libPath := range core.GetPaths("GTK") {
133 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
134 if err != nil {
135 panic(err)
136 }
137 libs = append(libs, lib)
138 }
139
140 core.PuregoSafeRegister(&xATContextGLibType, libs, "gtk_at_context_get_type")
141
142 core.PuregoSafeRegister(&xATContextCreate, libs, "gtk_at_context_create")
143
144 core.PuregoSafeRegister(&xATContextGetAccessible, libs, "gtk_at_context_get_accessible")
145 core.PuregoSafeRegister(&xATContextGetAccessibleRole, libs, "gtk_at_context_get_accessible_role")
146
147}