1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5 "unsafe"
6
7 "github.com/ebitengine/purego"
8
9 "github.com/bnema/puregotk/pkg/core"
10 "github.com/bnema/puregotk/v4/glib"
11 "github.com/bnema/puregotk/v4/gobject"
12 "github.com/bnema/puregotk/v4/gobject/types"
13)
14
15// A function used with gtk_text_tag_table_foreach(),
16// to iterate over every `GtkTextTag` inside a `GtkTextTagTable`.
17type TextTagTableForeach func(uintptr, uintptr)
18
19// Collects the tags in a `GtkTextBuffer`.
20//
21// You may wish to begin by reading the
22// [text widget conceptual overview](section-text-widget.html),
23// which gives an overview of all the objects and data types
24// related to the text widget and how they work together.
25//
26// # GtkTextTagTables as GtkBuildable
27//
28// The `GtkTextTagTable` implementation of the `GtkBuildable` interface
29// supports adding tags by specifying “tag” as the “type” attribute
30// of a `<child>` element.
31//
32// An example of a UI definition fragment specifying tags:
33// ```xml
34// <object class="GtkTextTagTable">
35//
36// <child type="tag">
37// <object class="GtkTextTag"/>
38// </child>
39//
40// </object>
41// ```
42type TextTagTable struct {
43 gobject.Object
44}
45
46var xTextTagTableGLibType func() types.GType
47
48func TextTagTableGLibType() types.GType {
49 return xTextTagTableGLibType()
50}
51
52func TextTagTableNewFromInternalPtr(ptr uintptr) *TextTagTable {
53 cls := &TextTagTable{}
54 cls.Ptr = ptr
55 return cls
56}
57
58var xNewTextTagTable func() uintptr
59
60// Creates a new `GtkTextTagTable`.
61//
62// The table contains no tags by default.
63func NewTextTagTable() *TextTagTable {
64 var cls *TextTagTable
65
66 cret := xNewTextTagTable()
67
68 if cret == 0 {
69 return nil
70 }
71 cls = &TextTagTable{}
72 cls.Ptr = cret
73 return cls
74}
75
76var xTextTagTableAdd func(uintptr, uintptr) bool
77
78// Add a tag to the table.
79//
80// The tag is assigned the highest priority in the table.
81//
82// @tag must not be in a tag table already, and may not have
83// the same name as an already-added tag.
84func (x *TextTagTable) Add(TagVar *TextTag) bool {
85
86 cret := xTextTagTableAdd(x.GoPointer(), TagVar.GoPointer())
87 return cret
88}
89
90var xTextTagTableForeach func(uintptr, uintptr, uintptr)
91
92// Calls @func on each tag in @table, with user data @data.
93//
94// Note that the table may not be modified while iterating
95// over it (you can’t add/remove tags).
96func (x *TextTagTable) Foreach(FuncVar *TextTagTableForeach, DataVar uintptr) {
97
98 var FuncVarRef uintptr
99 if FuncVar != nil {
100 FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
101 if cbRefPtr, ok := glib.GetCallback(FuncVarPtr); ok {
102 FuncVarRef = cbRefPtr
103 } else {
104 fcb := func(arg0 uintptr, arg1 uintptr) {
105 cbFn := *FuncVar
106 cbFn(arg0, arg1)
107 }
108 FuncVarRef = purego.NewCallback(fcb)
109 glib.SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
110 }
111 }
112
113 xTextTagTableForeach(x.GoPointer(), FuncVarRef, DataVar)
114
115}
116
117var xTextTagTableGetSize func(uintptr) int
118
119// Returns the size of the table (number of tags)
120func (x *TextTagTable) GetSize() int {
121
122 cret := xTextTagTableGetSize(x.GoPointer())
123 return cret
124}
125
126var xTextTagTableLookup func(uintptr, string) uintptr
127
128// Look up a named tag.
129func (x *TextTagTable) Lookup(NameVar string) *TextTag {
130 var cls *TextTag
131
132 cret := xTextTagTableLookup(x.GoPointer(), NameVar)
133
134 if cret == 0 {
135 return nil
136 }
137 gobject.IncreaseRef(cret)
138 cls = &TextTag{}
139 cls.Ptr = cret
140 return cls
141}
142
143var xTextTagTableRemove func(uintptr, uintptr)
144
145// Remove a tag from the table.
146//
147// If a `GtkTextBuffer` has @table as its tag table, the tag is
148// removed from the buffer. The table’s reference to the tag is
149// removed, so the tag will end up destroyed if you don’t have
150// a reference to it.
151func (x *TextTagTable) Remove(TagVar *TextTag) {
152
153 xTextTagTableRemove(x.GoPointer(), TagVar.GoPointer())
154
155}
156
157func (c *TextTagTable) GoPointer() uintptr {
158 if c == nil {
159 return 0
160 }
161 return c.Ptr
162}
163
164func (c *TextTagTable) SetGoPointer(ptr uintptr) {
165 c.Ptr = ptr
166}
167
168// Emitted every time a new tag is added in the `GtkTextTagTable`.
169func (x *TextTagTable) ConnectTagAdded(cb *func(TextTagTable, uintptr)) uint {
170 cbPtr := uintptr(unsafe.Pointer(cb))
171 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
172 handlerID := gobject.SignalConnect(x.GoPointer(), "tag-added", cbRefPtr)
173 glib.SaveHandlerMapping(handlerID, cbPtr)
174 return handlerID
175 }
176
177 fcb := func(clsPtr uintptr, TagVarp uintptr) {
178 fa := TextTagTable{}
179 fa.Ptr = clsPtr
180 cbFn := *cb
181
182 cbFn(fa, TagVarp)
183
184 }
185 cbRefPtr := purego.NewCallback(fcb)
186 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
187 handlerID := gobject.SignalConnect(x.GoPointer(), "tag-added", cbRefPtr)
188 glib.SaveHandlerMapping(handlerID, cbPtr)
189 return handlerID
190}
191
192// Emitted every time a tag in the `GtkTextTagTable` changes.
193func (x *TextTagTable) ConnectTagChanged(cb *func(TextTagTable, uintptr, bool)) uint {
194 cbPtr := uintptr(unsafe.Pointer(cb))
195 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
196 handlerID := gobject.SignalConnect(x.GoPointer(), "tag-changed", cbRefPtr)
197 glib.SaveHandlerMapping(handlerID, cbPtr)
198 return handlerID
199 }
200
201 fcb := func(clsPtr uintptr, TagVarp uintptr, SizeChangedVarp bool) {
202 fa := TextTagTable{}
203 fa.Ptr = clsPtr
204 cbFn := *cb
205
206 cbFn(fa, TagVarp, SizeChangedVarp)
207
208 }
209 cbRefPtr := purego.NewCallback(fcb)
210 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
211 handlerID := gobject.SignalConnect(x.GoPointer(), "tag-changed", cbRefPtr)
212 glib.SaveHandlerMapping(handlerID, cbPtr)
213 return handlerID
214}
215
216// Emitted every time a tag is removed from the `GtkTextTagTable`.
217//
218// The @tag is still valid by the time the signal is emitted, but
219// it is not associated with a tag table any more.
220func (x *TextTagTable) ConnectTagRemoved(cb *func(TextTagTable, uintptr)) uint {
221 cbPtr := uintptr(unsafe.Pointer(cb))
222 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
223 handlerID := gobject.SignalConnect(x.GoPointer(), "tag-removed", cbRefPtr)
224 glib.SaveHandlerMapping(handlerID, cbPtr)
225 return handlerID
226 }
227
228 fcb := func(clsPtr uintptr, TagVarp uintptr) {
229 fa := TextTagTable{}
230 fa.Ptr = clsPtr
231 cbFn := *cb
232
233 cbFn(fa, TagVarp)
234
235 }
236 cbRefPtr := purego.NewCallback(fcb)
237 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
238 handlerID := gobject.SignalConnect(x.GoPointer(), "tag-removed", cbRefPtr)
239 glib.SaveHandlerMapping(handlerID, cbPtr)
240 return handlerID
241}
242
243// Gets the ID of the @buildable object.
244//
245// `GtkBuilder` sets the name based on the ID attribute
246// of the `<object>` tag used to construct the @buildable.
247func (x *TextTagTable) GetBuildableId() string {
248
249 cret := XGtkBuildableGetBuildableId(x.GoPointer())
250 return cret
251}
252
253func init() {
254 core.SetPackageName("GTK", "gtk4")
255 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
256 var libs []uintptr
257 for _, libPath := range core.GetPaths("GTK") {
258 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
259 if err != nil {
260 panic(err)
261 }
262 libs = append(libs, lib)
263 }
264
265 core.PuregoSafeRegister(&xTextTagTableGLibType, libs, "gtk_text_tag_table_get_type")
266
267 core.PuregoSafeRegister(&xNewTextTagTable, libs, "gtk_text_tag_table_new")
268
269 core.PuregoSafeRegister(&xTextTagTableAdd, libs, "gtk_text_tag_table_add")
270 core.PuregoSafeRegister(&xTextTagTableForeach, libs, "gtk_text_tag_table_foreach")
271 core.PuregoSafeRegister(&xTextTagTableGetSize, libs, "gtk_text_tag_table_get_size")
272 core.PuregoSafeRegister(&xTextTagTableLookup, libs, "gtk_text_tag_table_lookup")
273 core.PuregoSafeRegister(&xTextTagTableRemove, libs, "gtk_text_tag_table_remove")
274
275}