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// Contains methods to let `GtkBuilder` construct an object from
17// a `GtkBuilder` UI definition.
18type BuildableIface struct {
19 _ structs.HostLayout
20
21 GIface uintptr
22
23 xSetId uintptr
24
25 xGetId uintptr
26
27 xAddChild uintptr
28
29 xSetBuildableProperty uintptr
30
31 xConstructChild uintptr
32
33 xCustomTagStart uintptr
34
35 xCustomTagEnd uintptr
36
37 xCustomFinished uintptr
38
39 xParserFinished uintptr
40
41 xGetInternalChild uintptr
42}
43
44func (x *BuildableIface) GoPointer() uintptr {
45 return uintptr(unsafe.Pointer(x))
46}
47
48// OverrideSetId sets the "set_id" callback function.
49// Stores the id attribute given in the `GtkBuilder` UI definition.
50//
51// `GtkWidget` stores the name as object data. Implement this method if your
52// object has some notion of “ID” and it makes sense to map the XML id
53// attribute to it.
54func (x *BuildableIface) OverrideSetId(cb func(Buildable, string)) {
55 if cb == nil {
56 x.xSetId = 0
57 } else {
58 x.xSetId = purego.NewCallback(func(BuildableVarp uintptr, IdVarp string) {
59 cb(&BuildableBase{Ptr: BuildableVarp}, IdVarp)
60 })
61 }
62}
63
64// GetSetId gets the "set_id" callback function.
65// Stores the id attribute given in the `GtkBuilder` UI definition.
66//
67// `GtkWidget` stores the name as object data. Implement this method if your
68// object has some notion of “ID” and it makes sense to map the XML id
69// attribute to it.
70func (x *BuildableIface) GetSetId() func(Buildable, string) {
71 if x.xSetId == 0 {
72 return nil
73 }
74 var rawCallback func(BuildableVarp uintptr, IdVarp string)
75 purego.RegisterFunc(&rawCallback, x.xSetId)
76 return func(BuildableVar Buildable, IdVar string) {
77 rawCallback(BuildableVar.GoPointer(), IdVar)
78 }
79}
80
81// OverrideGetId sets the "get_id" callback function.
82// The getter corresponding to @set_id. Implement this
83//
84// if you implement @set_id.
85func (x *BuildableIface) OverrideGetId(cb func(Buildable) string) {
86 if cb == nil {
87 x.xGetId = 0
88 } else {
89 x.xGetId = purego.NewCallback(func(BuildableVarp uintptr) string {
90 return cb(&BuildableBase{Ptr: BuildableVarp})
91 })
92 }
93}
94
95// GetGetId gets the "get_id" callback function.
96// The getter corresponding to @set_id. Implement this
97//
98// if you implement @set_id.
99func (x *BuildableIface) GetGetId() func(Buildable) string {
100 if x.xGetId == 0 {
101 return nil
102 }
103 var rawCallback func(BuildableVarp uintptr) string
104 purego.RegisterFunc(&rawCallback, x.xGetId)
105 return func(BuildableVar Buildable) string {
106 return rawCallback(BuildableVar.GoPointer())
107 }
108}
109
110// OverrideAddChild sets the "add_child" callback function.
111// Adds a child. The @type parameter can be used to
112//
113// differentiate the kind of child. `GtkWidget` implements this
114// to add event controllers to the widget, `GtkNotebook` uses
115// the @type to distinguish between page labels (of type "page-label")
116// and normal children.
117func (x *BuildableIface) OverrideAddChild(cb func(Buildable, *Builder, *gobject.Object, string)) {
118 if cb == nil {
119 x.xAddChild = 0
120 } else {
121 x.xAddChild = purego.NewCallback(func(BuildableVarp uintptr, BuilderVarp uintptr, ChildVarp uintptr, TypeVarp string) {
122 cb(&BuildableBase{Ptr: BuildableVarp}, BuilderNewFromInternalPtr(BuilderVarp), gobject.ObjectNewFromInternalPtr(ChildVarp), TypeVarp)
123 })
124 }
125}
126
127// GetAddChild gets the "add_child" callback function.
128// Adds a child. The @type parameter can be used to
129//
130// differentiate the kind of child. `GtkWidget` implements this
131// to add event controllers to the widget, `GtkNotebook` uses
132// the @type to distinguish between page labels (of type "page-label")
133// and normal children.
134func (x *BuildableIface) GetAddChild() func(Buildable, *Builder, *gobject.Object, string) {
135 if x.xAddChild == 0 {
136 return nil
137 }
138 var rawCallback func(BuildableVarp uintptr, BuilderVarp uintptr, ChildVarp uintptr, TypeVarp string)
139 purego.RegisterFunc(&rawCallback, x.xAddChild)
140 return func(BuildableVar Buildable, BuilderVar *Builder, ChildVar *gobject.Object, TypeVar string) {
141 rawCallback(BuildableVar.GoPointer(), BuilderVar.GoPointer(), ChildVar.GoPointer(), TypeVar)
142 }
143}
144
145// OverrideSetBuildableProperty sets the "set_buildable_property" callback function.
146// Sets a property of a buildable object.
147//
148// It is normally not necessary to implement this, g_object_set_property()
149// is used by default. `GtkWindow` implements this to delay showing itself
150// (i.e. setting the [property@Gtk.Widget:visible] property) until the whole
151// interface is created.
152func (x *BuildableIface) OverrideSetBuildableProperty(cb func(Buildable, *Builder, string, *gobject.Value)) {
153 if cb == nil {
154 x.xSetBuildableProperty = 0
155 } else {
156 x.xSetBuildableProperty = purego.NewCallback(func(BuildableVarp uintptr, BuilderVarp uintptr, NameVarp string, ValueVarp *gobject.Value) {
157 cb(&BuildableBase{Ptr: BuildableVarp}, BuilderNewFromInternalPtr(BuilderVarp), NameVarp, ValueVarp)
158 })
159 }
160}
161
162// GetSetBuildableProperty gets the "set_buildable_property" callback function.
163// Sets a property of a buildable object.
164//
165// It is normally not necessary to implement this, g_object_set_property()
166// is used by default. `GtkWindow` implements this to delay showing itself
167// (i.e. setting the [property@Gtk.Widget:visible] property) until the whole
168// interface is created.
169func (x *BuildableIface) GetSetBuildableProperty() func(Buildable, *Builder, string, *gobject.Value) {
170 if x.xSetBuildableProperty == 0 {
171 return nil
172 }
173 var rawCallback func(BuildableVarp uintptr, BuilderVarp uintptr, NameVarp string, ValueVarp *gobject.Value)
174 purego.RegisterFunc(&rawCallback, x.xSetBuildableProperty)
175 return func(BuildableVar Buildable, BuilderVar *Builder, NameVar string, ValueVar *gobject.Value) {
176 rawCallback(BuildableVar.GoPointer(), BuilderVar.GoPointer(), NameVar, ValueVar)
177 }
178}
179
180// OverrideConstructChild sets the "construct_child" callback function.
181// Constructs a child of a buildable that has been
182//
183// specified as “constructor” in the UI definition. This can be used to
184// reference a widget created in a `<ui>` tag which is outside
185// of the normal GtkBuilder UI definition hierarchy. A reference to the
186// constructed object is returned and becomes owned by the caller.
187func (x *BuildableIface) OverrideConstructChild(cb func(Buildable, *Builder, string) *gobject.Object) {
188 if cb == nil {
189 x.xConstructChild = 0
190 } else {
191 x.xConstructChild = purego.NewCallback(func(BuildableVarp uintptr, BuilderVarp uintptr, NameVarp string) uintptr {
192 ret := cb(&BuildableBase{Ptr: BuildableVarp}, BuilderNewFromInternalPtr(BuilderVarp), NameVarp)
193 if ret == nil {
194 return 0
195 }
196 return ret.GoPointer()
197 })
198 }
199}
200
201// GetConstructChild gets the "construct_child" callback function.
202// Constructs a child of a buildable that has been
203//
204// specified as “constructor” in the UI definition. This can be used to
205// reference a widget created in a `<ui>` tag which is outside
206// of the normal GtkBuilder UI definition hierarchy. A reference to the
207// constructed object is returned and becomes owned by the caller.
208func (x *BuildableIface) GetConstructChild() func(Buildable, *Builder, string) *gobject.Object {
209 if x.xConstructChild == 0 {
210 return nil
211 }
212 var rawCallback func(BuildableVarp uintptr, BuilderVarp uintptr, NameVarp string) uintptr
213 purego.RegisterFunc(&rawCallback, x.xConstructChild)
214 return func(BuildableVar Buildable, BuilderVar *Builder, NameVar string) *gobject.Object {
215 rawRet := rawCallback(BuildableVar.GoPointer(), BuilderVar.GoPointer(), NameVar)
216 if rawRet == 0 {
217 return nil
218 }
219 ret := &gobject.Object{}
220 ret.Ptr = rawRet
221 return ret
222 }
223}
224
225// OverrideCustomTagStart sets the "custom_tag_start" callback function.
226// Implement this if the buildable needs to parse
227//
228// content below `<child>`. To handle an element, the implementation
229// must fill in the @parser and @user_data and return %TRUE.
230// `GtkWidget` implements this to parse accessible attributes specified
231// in `<accessibility>` elements.
232// Note that @user_data must be freed in @custom_tag_end or @custom_finished.
233func (x *BuildableIface) OverrideCustomTagStart(cb func(Buildable, *Builder, *gobject.Object, string, *BuildableParser, *uintptr) bool) {
234 if cb == nil {
235 x.xCustomTagStart = 0
236 } else {
237 x.xCustomTagStart = purego.NewCallback(func(BuildableVarp uintptr, BuilderVarp uintptr, ChildVarp uintptr, TagnameVarp string, ParserVarp *BuildableParser, DataVarp *uintptr) bool {
238 return cb(&BuildableBase{Ptr: BuildableVarp}, BuilderNewFromInternalPtr(BuilderVarp), gobject.ObjectNewFromInternalPtr(ChildVarp), TagnameVarp, ParserVarp, DataVarp)
239 })
240 }
241}
242
243// GetCustomTagStart gets the "custom_tag_start" callback function.
244// Implement this if the buildable needs to parse
245//
246// content below `<child>`. To handle an element, the implementation
247// must fill in the @parser and @user_data and return %TRUE.
248// `GtkWidget` implements this to parse accessible attributes specified
249// in `<accessibility>` elements.
250// Note that @user_data must be freed in @custom_tag_end or @custom_finished.
251func (x *BuildableIface) GetCustomTagStart() func(Buildable, *Builder, *gobject.Object, string, *BuildableParser, *uintptr) bool {
252 if x.xCustomTagStart == 0 {
253 return nil
254 }
255 var rawCallback func(BuildableVarp uintptr, BuilderVarp uintptr, ChildVarp uintptr, TagnameVarp string, ParserVarp *BuildableParser, DataVarp *uintptr) bool
256 purego.RegisterFunc(&rawCallback, x.xCustomTagStart)
257 return func(BuildableVar Buildable, BuilderVar *Builder, ChildVar *gobject.Object, TagnameVar string, ParserVar *BuildableParser, DataVar *uintptr) bool {
258 return rawCallback(BuildableVar.GoPointer(), BuilderVar.GoPointer(), ChildVar.GoPointer(), TagnameVar, ParserVar, DataVar)
259 }
260}
261
262// OverrideCustomTagEnd sets the "custom_tag_end" callback function.
263// Called for the end tag of each custom element that is
264//
265// handled by the buildable (see @custom_tag_start).
266func (x *BuildableIface) OverrideCustomTagEnd(cb func(Buildable, *Builder, *gobject.Object, string, uintptr)) {
267 if cb == nil {
268 x.xCustomTagEnd = 0
269 } else {
270 x.xCustomTagEnd = purego.NewCallback(func(BuildableVarp uintptr, BuilderVarp uintptr, ChildVarp uintptr, TagnameVarp string, DataVarp uintptr) {
271 cb(&BuildableBase{Ptr: BuildableVarp}, BuilderNewFromInternalPtr(BuilderVarp), gobject.ObjectNewFromInternalPtr(ChildVarp), TagnameVarp, DataVarp)
272 })
273 }
274}
275
276// GetCustomTagEnd gets the "custom_tag_end" callback function.
277// Called for the end tag of each custom element that is
278//
279// handled by the buildable (see @custom_tag_start).
280func (x *BuildableIface) GetCustomTagEnd() func(Buildable, *Builder, *gobject.Object, string, uintptr) {
281 if x.xCustomTagEnd == 0 {
282 return nil
283 }
284 var rawCallback func(BuildableVarp uintptr, BuilderVarp uintptr, ChildVarp uintptr, TagnameVarp string, DataVarp uintptr)
285 purego.RegisterFunc(&rawCallback, x.xCustomTagEnd)
286 return func(BuildableVar Buildable, BuilderVar *Builder, ChildVar *gobject.Object, TagnameVar string, DataVar uintptr) {
287 rawCallback(BuildableVar.GoPointer(), BuilderVar.GoPointer(), ChildVar.GoPointer(), TagnameVar, DataVar)
288 }
289}
290
291// OverrideCustomFinished sets the "custom_finished" callback function.
292// Called for each custom tag handled by the buildable
293//
294// when the builder finishes parsing (see @custom_tag_start)
295func (x *BuildableIface) OverrideCustomFinished(cb func(Buildable, *Builder, *gobject.Object, string, uintptr)) {
296 if cb == nil {
297 x.xCustomFinished = 0
298 } else {
299 x.xCustomFinished = purego.NewCallback(func(BuildableVarp uintptr, BuilderVarp uintptr, ChildVarp uintptr, TagnameVarp string, DataVarp uintptr) {
300 cb(&BuildableBase{Ptr: BuildableVarp}, BuilderNewFromInternalPtr(BuilderVarp), gobject.ObjectNewFromInternalPtr(ChildVarp), TagnameVarp, DataVarp)
301 })
302 }
303}
304
305// GetCustomFinished gets the "custom_finished" callback function.
306// Called for each custom tag handled by the buildable
307//
308// when the builder finishes parsing (see @custom_tag_start)
309func (x *BuildableIface) GetCustomFinished() func(Buildable, *Builder, *gobject.Object, string, uintptr) {
310 if x.xCustomFinished == 0 {
311 return nil
312 }
313 var rawCallback func(BuildableVarp uintptr, BuilderVarp uintptr, ChildVarp uintptr, TagnameVarp string, DataVarp uintptr)
314 purego.RegisterFunc(&rawCallback, x.xCustomFinished)
315 return func(BuildableVar Buildable, BuilderVar *Builder, ChildVar *gobject.Object, TagnameVar string, DataVar uintptr) {
316 rawCallback(BuildableVar.GoPointer(), BuilderVar.GoPointer(), ChildVar.GoPointer(), TagnameVar, DataVar)
317 }
318}
319
320// OverrideParserFinished sets the "parser_finished" callback function.
321// Called when a builder finishes the parsing
322//
323// of a UI definition. It is normally not necessary to implement this,
324// unless you need to perform special cleanup actions. `GtkWindow` sets
325// the `GtkWidget:visible` property here.
326func (x *BuildableIface) OverrideParserFinished(cb func(Buildable, *Builder)) {
327 if cb == nil {
328 x.xParserFinished = 0
329 } else {
330 x.xParserFinished = purego.NewCallback(func(BuildableVarp uintptr, BuilderVarp uintptr) {
331 cb(&BuildableBase{Ptr: BuildableVarp}, BuilderNewFromInternalPtr(BuilderVarp))
332 })
333 }
334}
335
336// GetParserFinished gets the "parser_finished" callback function.
337// Called when a builder finishes the parsing
338//
339// of a UI definition. It is normally not necessary to implement this,
340// unless you need to perform special cleanup actions. `GtkWindow` sets
341// the `GtkWidget:visible` property here.
342func (x *BuildableIface) GetParserFinished() func(Buildable, *Builder) {
343 if x.xParserFinished == 0 {
344 return nil
345 }
346 var rawCallback func(BuildableVarp uintptr, BuilderVarp uintptr)
347 purego.RegisterFunc(&rawCallback, x.xParserFinished)
348 return func(BuildableVar Buildable, BuilderVar *Builder) {
349 rawCallback(BuildableVar.GoPointer(), BuilderVar.GoPointer())
350 }
351}
352
353// OverrideGetInternalChild sets the "get_internal_child" callback function.
354// Returns an internal child of a buildable.
355//
356// `GtkDialog` implements this to give access to its @vbox, making
357// it possible to add children to the vbox in a UI definition.
358// Implement this if the buildable has internal children that may
359// need to be accessed from a UI definition.
360func (x *BuildableIface) OverrideGetInternalChild(cb func(Buildable, *Builder, string) *gobject.Object) {
361 if cb == nil {
362 x.xGetInternalChild = 0
363 } else {
364 x.xGetInternalChild = purego.NewCallback(func(BuildableVarp uintptr, BuilderVarp uintptr, ChildnameVarp string) uintptr {
365 ret := cb(&BuildableBase{Ptr: BuildableVarp}, BuilderNewFromInternalPtr(BuilderVarp), ChildnameVarp)
366 if ret == nil {
367 return 0
368 }
369 return ret.GoPointer()
370 })
371 }
372}
373
374// GetGetInternalChild gets the "get_internal_child" callback function.
375// Returns an internal child of a buildable.
376//
377// `GtkDialog` implements this to give access to its @vbox, making
378// it possible to add children to the vbox in a UI definition.
379// Implement this if the buildable has internal children that may
380// need to be accessed from a UI definition.
381func (x *BuildableIface) GetGetInternalChild() func(Buildable, *Builder, string) *gobject.Object {
382 if x.xGetInternalChild == 0 {
383 return nil
384 }
385 var rawCallback func(BuildableVarp uintptr, BuilderVarp uintptr, ChildnameVarp string) uintptr
386 purego.RegisterFunc(&rawCallback, x.xGetInternalChild)
387 return func(BuildableVar Buildable, BuilderVar *Builder, ChildnameVar string) *gobject.Object {
388 rawRet := rawCallback(BuildableVar.GoPointer(), BuilderVar.GoPointer(), ChildnameVar)
389 if rawRet == 0 {
390 return nil
391 }
392 ret := &gobject.Object{}
393 ret.Ptr = rawRet
394 return ret
395 }
396}
397
398// Provides context for parsing GtkBuilder UI files.
399//
400// `GtkBuildableParseContext` is an opaque struct.
401type BuildableParseContext struct {
402 _ structs.HostLayout
403}
404
405func (x *BuildableParseContext) GoPointer() uintptr {
406 return uintptr(unsafe.Pointer(x))
407}
408
409var xBuildableParseContextGetElement func(uintptr) string
410
411// Retrieves the name of the currently open element.
412//
413// If called from the start_element or end_element handlers this will
414// give the element_name as passed to those functions. For the parent
415// elements, see gtk_buildable_parse_context_get_element_stack().
416func (x *BuildableParseContext) GetElement() string {
417
418 cret := xBuildableParseContextGetElement(x.GoPointer())
419 return cret
420}
421
422var xBuildableParseContextGetElementStack func(uintptr) []string
423
424// Retrieves the element stack from the internal state of the parser.
425//
426// The returned `GPtrArray` is an array of strings where the last item is
427// the currently open tag (as would be returned by
428// gtk_buildable_parse_context_get_element()) and the previous item is its
429// immediate parent.
430//
431// This function is intended to be used in the start_element and
432// end_element handlers where gtk_buildable_parse_context_get_element()
433// would merely return the name of the element that is being
434// processed.
435func (x *BuildableParseContext) GetElementStack() []string {
436
437 cret := xBuildableParseContextGetElementStack(x.GoPointer())
438 return cret
439}
440
441var xBuildableParseContextGetPosition func(uintptr, *int, *int)
442
443// Retrieves the current line number and the number of the character on
444// that line. Intended for use in error messages; there are no strict
445// semantics for what constitutes the "current" line number other than
446// "the best number we could come up with for error messages."
447func (x *BuildableParseContext) GetPosition(LineNumberVar *int, CharNumberVar *int) {
448
449 xBuildableParseContextGetPosition(x.GoPointer(), LineNumberVar, CharNumberVar)
450
451}
452
453var xBuildableParseContextPop func(uintptr) uintptr
454
455// Completes the process of a temporary sub-parser redirection.
456//
457// This function exists to collect the user_data allocated by a
458// matching call to gtk_buildable_parse_context_push(). It must be called
459// in the end_element handler corresponding to the start_element
460// handler during which gtk_buildable_parse_context_push() was called.
461// You must not call this function from the error callback -- the
462// @user_data is provided directly to the callback in that case.
463//
464// This function is not intended to be directly called by users
465// interested in invoking subparsers. Instead, it is intended to
466// be used by the subparsers themselves to implement a higher-level
467// interface.
468func (x *BuildableParseContext) Pop() uintptr {
469
470 cret := xBuildableParseContextPop(x.GoPointer())
471 return cret
472}
473
474var xBuildableParseContextPush func(uintptr, *BuildableParser, uintptr)
475
476// Temporarily redirects markup data to a sub-parser.
477//
478// This function may only be called from the start_element handler of
479// a `GtkBuildableParser`. It must be matched with a corresponding call to
480// gtk_buildable_parse_context_pop() in the matching end_element handler
481// (except in the case that the parser aborts due to an error).
482//
483// All tags, text and other data between the matching tags is
484// redirected to the subparser given by @parser. @user_data is used
485// as the user_data for that parser. @user_data is also passed to the
486// error callback in the event that an error occurs. This includes
487// errors that occur in subparsers of the subparser.
488//
489// The end tag matching the start tag for which this call was made is
490// handled by the previous parser (which is given its own user_data)
491// which is why gtk_buildable_parse_context_pop() is provided to allow "one
492// last access" to the @user_data provided to this function. In the
493// case of error, the @user_data provided here is passed directly to
494// the error callback of the subparser and gtk_buildable_parse_context_pop()
495// should not be called. In either case, if @user_data was allocated
496// then it ought to be freed from both of these locations.
497//
498// This function is not intended to be directly called by users
499// interested in invoking subparsers. Instead, it is intended to be
500// used by the subparsers themselves to implement a higher-level
501// interface.
502//
503// For an example of how to use this, see g_markup_parse_context_push() which
504// has the same kind of API.
505func (x *BuildableParseContext) Push(ParserVar *BuildableParser, UserDataVar uintptr) {
506
507 xBuildableParseContextPush(x.GoPointer(), ParserVar, UserDataVar)
508
509}
510
511// A sub-parser for `GtkBuildable` implementations.
512type BuildableParser struct {
513 _ structs.HostLayout
514
515 xStartElement uintptr
516
517 xEndElement uintptr
518
519 xText uintptr
520
521 xError uintptr
522
523 Padding [4]uintptr
524}
525
526func (x *BuildableParser) GoPointer() uintptr {
527 return uintptr(unsafe.Pointer(x))
528}
529
530// OverrideStartElement sets the "start_element" callback function.
531// function called for open elements
532func (x *BuildableParser) OverrideStartElement(cb func(*BuildableParseContext, string, string, string, uintptr)) {
533 if cb == nil {
534 x.xStartElement = 0
535 } else {
536 x.xStartElement = purego.NewCallback(func(ContextVarp *BuildableParseContext, ElementNameVarp string, AttributeNamesVarp string, AttributeValuesVarp string, UserDataVarp uintptr) {
537 cb(ContextVarp, ElementNameVarp, AttributeNamesVarp, AttributeValuesVarp, UserDataVarp)
538 })
539 }
540}
541
542// GetStartElement gets the "start_element" callback function.
543// function called for open elements
544func (x *BuildableParser) GetStartElement() func(*BuildableParseContext, string, string, string, uintptr) {
545 if x.xStartElement == 0 {
546 return nil
547 }
548 var rawCallback func(ContextVarp *BuildableParseContext, ElementNameVarp string, AttributeNamesVarp string, AttributeValuesVarp string, UserDataVarp uintptr)
549 purego.RegisterFunc(&rawCallback, x.xStartElement)
550 return func(ContextVar *BuildableParseContext, ElementNameVar string, AttributeNamesVar string, AttributeValuesVar string, UserDataVar uintptr) {
551 rawCallback(ContextVar, ElementNameVar, AttributeNamesVar, AttributeValuesVar, UserDataVar)
552 }
553}
554
555// OverrideEndElement sets the "end_element" callback function.
556// function called for close elements
557func (x *BuildableParser) OverrideEndElement(cb func(*BuildableParseContext, string, uintptr)) {
558 if cb == nil {
559 x.xEndElement = 0
560 } else {
561 x.xEndElement = purego.NewCallback(func(ContextVarp *BuildableParseContext, ElementNameVarp string, UserDataVarp uintptr) {
562 cb(ContextVarp, ElementNameVarp, UserDataVarp)
563 })
564 }
565}
566
567// GetEndElement gets the "end_element" callback function.
568// function called for close elements
569func (x *BuildableParser) GetEndElement() func(*BuildableParseContext, string, uintptr) {
570 if x.xEndElement == 0 {
571 return nil
572 }
573 var rawCallback func(ContextVarp *BuildableParseContext, ElementNameVarp string, UserDataVarp uintptr)
574 purego.RegisterFunc(&rawCallback, x.xEndElement)
575 return func(ContextVar *BuildableParseContext, ElementNameVar string, UserDataVar uintptr) {
576 rawCallback(ContextVar, ElementNameVar, UserDataVar)
577 }
578}
579
580// OverrideText sets the "text" callback function.
581// function called for character data
582func (x *BuildableParser) OverrideText(cb func(*BuildableParseContext, string, uint, uintptr)) {
583 if cb == nil {
584 x.xText = 0
585 } else {
586 x.xText = purego.NewCallback(func(ContextVarp *BuildableParseContext, TextVarp string, TextLenVarp uint, UserDataVarp uintptr) {
587 cb(ContextVarp, TextVarp, TextLenVarp, UserDataVarp)
588 })
589 }
590}
591
592// GetText gets the "text" callback function.
593// function called for character data
594func (x *BuildableParser) GetText() func(*BuildableParseContext, string, uint, uintptr) {
595 if x.xText == 0 {
596 return nil
597 }
598 var rawCallback func(ContextVarp *BuildableParseContext, TextVarp string, TextLenVarp uint, UserDataVarp uintptr)
599 purego.RegisterFunc(&rawCallback, x.xText)
600 return func(ContextVar *BuildableParseContext, TextVar string, TextLenVar uint, UserDataVar uintptr) {
601 rawCallback(ContextVar, TextVar, TextLenVar, UserDataVar)
602 }
603}
604
605// OverrideError sets the "error" callback function.
606// function called on error
607func (x *BuildableParser) OverrideError(cb func(*BuildableParseContext, *glib.Error, uintptr)) {
608 if cb == nil {
609 x.xError = 0
610 } else {
611 x.xError = purego.NewCallback(func(ContextVarp *BuildableParseContext, ErrorVarp *glib.Error, UserDataVarp uintptr) {
612 cb(ContextVarp, ErrorVarp, UserDataVarp)
613 })
614 }
615}
616
617// GetError gets the "error" callback function.
618// function called on error
619func (x *BuildableParser) GetError() func(*BuildableParseContext, *glib.Error, uintptr) {
620 if x.xError == 0 {
621 return nil
622 }
623 var rawCallback func(ContextVarp *BuildableParseContext, ErrorVarp *glib.Error, UserDataVarp uintptr)
624 purego.RegisterFunc(&rawCallback, x.xError)
625 return func(ContextVar *BuildableParseContext, ErrorVar *glib.Error, UserDataVar uintptr) {
626 rawCallback(ContextVar, ErrorVar, UserDataVar)
627 }
628}
629
630// Allows objects to extend and customize deserialization from ui files.
631//
632// The `GtkBuildable` interface includes methods for setting names and
633// properties of objects, parsing custom tags and constructing child objects.
634//
635// It is implemented by all widgets and many of the non-widget objects that are
636// provided by GTK. The main user of this interface is [class@Gtk.Builder].
637// There should be very little need for applications to call any of these
638// functions directly.
639//
640// An object only needs to implement this interface if it needs to extend the
641// `GtkBuilder` XML format or run any extra routines at deserialization time.
642type Buildable interface {
643 GoPointer() uintptr
644 SetGoPointer(uintptr)
645 GetBuildableId() string
646}
647
648var xBuildableGLibType func() types.GType
649
650func BuildableGLibType() types.GType {
651 return xBuildableGLibType()
652}
653
654type BuildableBase struct {
655 Ptr uintptr
656}
657
658func (x *BuildableBase) GoPointer() uintptr {
659 if x == nil {
660 return 0
661 }
662 return x.Ptr
663}
664
665func (x *BuildableBase) SetGoPointer(ptr uintptr) {
666 x.Ptr = ptr
667}
668
669// Gets the ID of the @buildable object.
670//
671// `GtkBuilder` sets the name based on the ID attribute
672// of the `<object>` tag used to construct the @buildable.
673func (x *BuildableBase) GetBuildableId() string {
674
675 cret := XGtkBuildableGetBuildableId(x.GoPointer())
676 return cret
677}
678
679var XGtkBuildableGetBuildableId func(uintptr) string
680
681func init() {
682 core.SetPackageName("GTK", "gtk4")
683 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
684 var libs []uintptr
685 for _, libPath := range core.GetPaths("GTK") {
686 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
687 if err != nil {
688 panic(err)
689 }
690 libs = append(libs, lib)
691 }
692
693 core.PuregoSafeRegister(&xBuildableParseContextGetElement, libs, "gtk_buildable_parse_context_get_element")
694 core.PuregoSafeRegister(&xBuildableParseContextGetElementStack, libs, "gtk_buildable_parse_context_get_element_stack")
695 core.PuregoSafeRegister(&xBuildableParseContextGetPosition, libs, "gtk_buildable_parse_context_get_position")
696 core.PuregoSafeRegister(&xBuildableParseContextPop, libs, "gtk_buildable_parse_context_pop")
697 core.PuregoSafeRegister(&xBuildableParseContextPush, libs, "gtk_buildable_parse_context_push")
698
699 core.PuregoSafeRegister(&xBuildableGLibType, libs, "gtk_buildable_get_type")
700
701 core.PuregoSafeRegister(&XGtkBuildableGetBuildableId, libs, "gtk_buildable_get_buildable_id")
702
703}