// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gtk import ( "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) // A function used with gtk_text_tag_table_foreach(), // to iterate over every `GtkTextTag` inside a `GtkTextTagTable`. type TextTagTableForeach func(uintptr, uintptr) // Collects the tags in a `GtkTextBuffer`. // // You may wish to begin by reading the // [text widget conceptual overview](section-text-widget.html), // which gives an overview of all the objects and data types // related to the text widget and how they work together. // // # GtkTextTagTables as GtkBuildable // // The `GtkTextTagTable` implementation of the `GtkBuildable` interface // supports adding tags by specifying “tag” as the “type” attribute // of a `<child>` element. // // An example of a UI definition fragment specifying tags: // ```xml // <object class="GtkTextTagTable"> // // <child type="tag"> // <object class="GtkTextTag"/> // </child> // // </object> // ``` type TextTagTable struct { gobject.Object } var xTextTagTableGLibType func() types.GType func TextTagTableGLibType() types.GType { return xTextTagTableGLibType() } func TextTagTableNewFromInternalPtr(ptr uintptr) *TextTagTable { cls := &TextTagTable{} cls.Ptr = ptr return cls } var xNewTextTagTable func() uintptr // Creates a new `GtkTextTagTable`. // // The table contains no tags by default. func NewTextTagTable() *TextTagTable { var cls *TextTagTable cret := xNewTextTagTable() if cret == 0 { return nil } cls = &TextTagTable{} cls.Ptr = cret return cls } var xTextTagTableAdd func(uintptr, uintptr) bool // Add a tag to the table. // // The tag is assigned the highest priority in the table. // // @tag must not be in a tag table already, and may not have // the same name as an already-added tag. func (x *TextTagTable) Add(TagVar *TextTag) bool { cret := xTextTagTableAdd(x.GoPointer(), TagVar.GoPointer()) return cret } var xTextTagTableForeach func(uintptr, uintptr, uintptr) // Calls @func on each tag in @table, with user data @data. // // Note that the table may not be modified while iterating // over it (you can’t add/remove tags). func (x *TextTagTable) Foreach(FuncVar *TextTagTableForeach, DataVar uintptr) { var FuncVarRef uintptr if FuncVar != nil { FuncVarPtr := uintptr(unsafe.Pointer(FuncVar)) if cbRefPtr, ok := glib.GetCallback(FuncVarPtr); ok { FuncVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr) { cbFn := *FuncVar cbFn(arg0, arg1) } FuncVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar) } } xTextTagTableForeach(x.GoPointer(), FuncVarRef, DataVar) } var xTextTagTableGetSize func(uintptr) int // Returns the size of the table (number of tags) func (x *TextTagTable) GetSize() int { cret := xTextTagTableGetSize(x.GoPointer()) return cret } var xTextTagTableLookup func(uintptr, string) uintptr // Look up a named tag. func (x *TextTagTable) Lookup(NameVar string) *TextTag { var cls *TextTag cret := xTextTagTableLookup(x.GoPointer(), NameVar) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &TextTag{} cls.Ptr = cret return cls } var xTextTagTableRemove func(uintptr, uintptr) // Remove a tag from the table. // // If a `GtkTextBuffer` has @table as its tag table, the tag is // removed from the buffer. The table’s reference to the tag is // removed, so the tag will end up destroyed if you don’t have // a reference to it. func (x *TextTagTable) Remove(TagVar *TextTag) { xTextTagTableRemove(x.GoPointer(), TagVar.GoPointer()) } func (c *TextTagTable) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *TextTagTable) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // Emitted every time a new tag is added in the `GtkTextTagTable`. func (x *TextTagTable) ConnectTagAdded(cb *func(TextTagTable, uintptr)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "tag-added", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr, TagVarp uintptr) { fa := TextTagTable{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa, TagVarp) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "tag-added", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } // Emitted every time a tag in the `GtkTextTagTable` changes. func (x *TextTagTable) ConnectTagChanged(cb *func(TextTagTable, uintptr, bool)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "tag-changed", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr, TagVarp uintptr, SizeChangedVarp bool) { fa := TextTagTable{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa, TagVarp, SizeChangedVarp) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "tag-changed", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } // Emitted every time a tag is removed from the `GtkTextTagTable`. // // The @tag is still valid by the time the signal is emitted, but // it is not associated with a tag table any more. func (x *TextTagTable) ConnectTagRemoved(cb *func(TextTagTable, uintptr)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "tag-removed", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr, TagVarp uintptr) { fa := TextTagTable{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa, TagVarp) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "tag-removed", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } // Gets the ID of the @buildable object. // // `GtkBuilder` sets the name based on the ID attribute // of the `<object>` tag used to construct the @buildable. func (x *TextTagTable) GetBuildableId() string { cret := XGtkBuildableGetBuildableId(x.GoPointer()) return cret } func init() { core.SetPackageName("GTK", "gtk4") core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"}) var libs []uintptr for _, libPath := range core.GetPaths("GTK") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xTextTagTableGLibType, libs, "gtk_text_tag_table_get_type") core.PuregoSafeRegister(&xNewTextTagTable, libs, "gtk_text_tag_table_new") core.PuregoSafeRegister(&xTextTagTableAdd, libs, "gtk_text_tag_table_add") core.PuregoSafeRegister(&xTextTagTableForeach, libs, "gtk_text_tag_table_foreach") core.PuregoSafeRegister(&xTextTagTableGetSize, libs, "gtk_text_tag_table_get_size") core.PuregoSafeRegister(&xTextTagTableLookup, libs, "gtk_text_tag_table_lookup") core.PuregoSafeRegister(&xTextTagTableRemove, libs, "gtk_text_tag_table_remove") }