// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gtk import ( "structs" "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" ) type EntryBufferClass struct { _ structs.HostLayout ParentClass gobject.ObjectClass xInsertedText uintptr xDeletedText uintptr xGetText uintptr xGetLength uintptr xInsertText uintptr xDeleteText uintptr xGtkReserved1 uintptr xGtkReserved2 uintptr xGtkReserved3 uintptr xGtkReserved4 uintptr xGtkReserved5 uintptr xGtkReserved6 uintptr xGtkReserved7 uintptr xGtkReserved8 uintptr } func (x *EntryBufferClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverrideInsertedText sets the "inserted_text" callback function. func (x *EntryBufferClass) OverrideInsertedText(cb func(*EntryBuffer, uint, string, uint)) { if cb == nil { x.xInsertedText = 0 } else { x.xInsertedText = purego.NewCallback(func(BufferVarp uintptr, PositionVarp uint, CharsVarp string, NCharsVarp uint) { cb(EntryBufferNewFromInternalPtr(BufferVarp), PositionVarp, CharsVarp, NCharsVarp) }) } } // GetInsertedText gets the "inserted_text" callback function. func (x *EntryBufferClass) GetInsertedText() func(*EntryBuffer, uint, string, uint) { if x.xInsertedText == 0 { return nil } var rawCallback func(BufferVarp uintptr, PositionVarp uint, CharsVarp string, NCharsVarp uint) purego.RegisterFunc(&rawCallback, x.xInsertedText) return func(BufferVar *EntryBuffer, PositionVar uint, CharsVar string, NCharsVar uint) { rawCallback(BufferVar.GoPointer(), PositionVar, CharsVar, NCharsVar) } } // OverrideDeletedText sets the "deleted_text" callback function. func (x *EntryBufferClass) OverrideDeletedText(cb func(*EntryBuffer, uint, uint)) { if cb == nil { x.xDeletedText = 0 } else { x.xDeletedText = purego.NewCallback(func(BufferVarp uintptr, PositionVarp uint, NCharsVarp uint) { cb(EntryBufferNewFromInternalPtr(BufferVarp), PositionVarp, NCharsVarp) }) } } // GetDeletedText gets the "deleted_text" callback function. func (x *EntryBufferClass) GetDeletedText() func(*EntryBuffer, uint, uint) { if x.xDeletedText == 0 { return nil } var rawCallback func(BufferVarp uintptr, PositionVarp uint, NCharsVarp uint) purego.RegisterFunc(&rawCallback, x.xDeletedText) return func(BufferVar *EntryBuffer, PositionVar uint, NCharsVar uint) { rawCallback(BufferVar.GoPointer(), PositionVar, NCharsVar) } } // OverrideGetText sets the "get_text" callback function. func (x *EntryBufferClass) OverrideGetText(cb func(*EntryBuffer, uint) string) { if cb == nil { x.xGetText = 0 } else { x.xGetText = purego.NewCallback(func(BufferVarp uintptr, NBytesVarp uint) string { return cb(EntryBufferNewFromInternalPtr(BufferVarp), NBytesVarp) }) } } // GetGetText gets the "get_text" callback function. func (x *EntryBufferClass) GetGetText() func(*EntryBuffer, uint) string { if x.xGetText == 0 { return nil } var rawCallback func(BufferVarp uintptr, NBytesVarp uint) string purego.RegisterFunc(&rawCallback, x.xGetText) return func(BufferVar *EntryBuffer, NBytesVar uint) string { return rawCallback(BufferVar.GoPointer(), NBytesVar) } } // OverrideGetLength sets the "get_length" callback function. func (x *EntryBufferClass) OverrideGetLength(cb func(*EntryBuffer) uint) { if cb == nil { x.xGetLength = 0 } else { x.xGetLength = purego.NewCallback(func(BufferVarp uintptr) uint { return cb(EntryBufferNewFromInternalPtr(BufferVarp)) }) } } // GetGetLength gets the "get_length" callback function. func (x *EntryBufferClass) GetGetLength() func(*EntryBuffer) uint { if x.xGetLength == 0 { return nil } var rawCallback func(BufferVarp uintptr) uint purego.RegisterFunc(&rawCallback, x.xGetLength) return func(BufferVar *EntryBuffer) uint { return rawCallback(BufferVar.GoPointer()) } } // OverrideInsertText sets the "insert_text" callback function. func (x *EntryBufferClass) OverrideInsertText(cb func(*EntryBuffer, uint, string, uint) uint) { if cb == nil { x.xInsertText = 0 } else { x.xInsertText = purego.NewCallback(func(BufferVarp uintptr, PositionVarp uint, CharsVarp string, NCharsVarp uint) uint { return cb(EntryBufferNewFromInternalPtr(BufferVarp), PositionVarp, CharsVarp, NCharsVarp) }) } } // GetInsertText gets the "insert_text" callback function. func (x *EntryBufferClass) GetInsertText() func(*EntryBuffer, uint, string, uint) uint { if x.xInsertText == 0 { return nil } var rawCallback func(BufferVarp uintptr, PositionVarp uint, CharsVarp string, NCharsVarp uint) uint purego.RegisterFunc(&rawCallback, x.xInsertText) return func(BufferVar *EntryBuffer, PositionVar uint, CharsVar string, NCharsVar uint) uint { return rawCallback(BufferVar.GoPointer(), PositionVar, CharsVar, NCharsVar) } } // OverrideDeleteText sets the "delete_text" callback function. func (x *EntryBufferClass) OverrideDeleteText(cb func(*EntryBuffer, uint, uint) uint) { if cb == nil { x.xDeleteText = 0 } else { x.xDeleteText = purego.NewCallback(func(BufferVarp uintptr, PositionVarp uint, NCharsVarp uint) uint { return cb(EntryBufferNewFromInternalPtr(BufferVarp), PositionVarp, NCharsVarp) }) } } // GetDeleteText gets the "delete_text" callback function. func (x *EntryBufferClass) GetDeleteText() func(*EntryBuffer, uint, uint) uint { if x.xDeleteText == 0 { return nil } var rawCallback func(BufferVarp uintptr, PositionVarp uint, NCharsVarp uint) uint purego.RegisterFunc(&rawCallback, x.xDeleteText) return func(BufferVar *EntryBuffer, PositionVar uint, NCharsVar uint) uint { return rawCallback(BufferVar.GoPointer(), PositionVar, NCharsVar) } } // OverrideGtkReserved1 sets the "_gtk_reserved1" callback function. func (x *EntryBufferClass) OverrideGtkReserved1(cb func()) { if cb == nil { x.xGtkReserved1 = 0 } else { x.xGtkReserved1 = purego.NewCallback(func() { cb() }) } } // GetGtkReserved1 gets the "_gtk_reserved1" callback function. func (x *EntryBufferClass) GetGtkReserved1() func() { if x.xGtkReserved1 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGtkReserved1) return func() { rawCallback() } } // OverrideGtkReserved2 sets the "_gtk_reserved2" callback function. func (x *EntryBufferClass) OverrideGtkReserved2(cb func()) { if cb == nil { x.xGtkReserved2 = 0 } else { x.xGtkReserved2 = purego.NewCallback(func() { cb() }) } } // GetGtkReserved2 gets the "_gtk_reserved2" callback function. func (x *EntryBufferClass) GetGtkReserved2() func() { if x.xGtkReserved2 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGtkReserved2) return func() { rawCallback() } } // OverrideGtkReserved3 sets the "_gtk_reserved3" callback function. func (x *EntryBufferClass) OverrideGtkReserved3(cb func()) { if cb == nil { x.xGtkReserved3 = 0 } else { x.xGtkReserved3 = purego.NewCallback(func() { cb() }) } } // GetGtkReserved3 gets the "_gtk_reserved3" callback function. func (x *EntryBufferClass) GetGtkReserved3() func() { if x.xGtkReserved3 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGtkReserved3) return func() { rawCallback() } } // OverrideGtkReserved4 sets the "_gtk_reserved4" callback function. func (x *EntryBufferClass) OverrideGtkReserved4(cb func()) { if cb == nil { x.xGtkReserved4 = 0 } else { x.xGtkReserved4 = purego.NewCallback(func() { cb() }) } } // GetGtkReserved4 gets the "_gtk_reserved4" callback function. func (x *EntryBufferClass) GetGtkReserved4() func() { if x.xGtkReserved4 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGtkReserved4) return func() { rawCallback() } } // OverrideGtkReserved5 sets the "_gtk_reserved5" callback function. func (x *EntryBufferClass) OverrideGtkReserved5(cb func()) { if cb == nil { x.xGtkReserved5 = 0 } else { x.xGtkReserved5 = purego.NewCallback(func() { cb() }) } } // GetGtkReserved5 gets the "_gtk_reserved5" callback function. func (x *EntryBufferClass) GetGtkReserved5() func() { if x.xGtkReserved5 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGtkReserved5) return func() { rawCallback() } } // OverrideGtkReserved6 sets the "_gtk_reserved6" callback function. func (x *EntryBufferClass) OverrideGtkReserved6(cb func()) { if cb == nil { x.xGtkReserved6 = 0 } else { x.xGtkReserved6 = purego.NewCallback(func() { cb() }) } } // GetGtkReserved6 gets the "_gtk_reserved6" callback function. func (x *EntryBufferClass) GetGtkReserved6() func() { if x.xGtkReserved6 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGtkReserved6) return func() { rawCallback() } } // OverrideGtkReserved7 sets the "_gtk_reserved7" callback function. func (x *EntryBufferClass) OverrideGtkReserved7(cb func()) { if cb == nil { x.xGtkReserved7 = 0 } else { x.xGtkReserved7 = purego.NewCallback(func() { cb() }) } } // GetGtkReserved7 gets the "_gtk_reserved7" callback function. func (x *EntryBufferClass) GetGtkReserved7() func() { if x.xGtkReserved7 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGtkReserved7) return func() { rawCallback() } } // OverrideGtkReserved8 sets the "_gtk_reserved8" callback function. func (x *EntryBufferClass) OverrideGtkReserved8(cb func()) { if cb == nil { x.xGtkReserved8 = 0 } else { x.xGtkReserved8 = purego.NewCallback(func() { cb() }) } } // GetGtkReserved8 gets the "_gtk_reserved8" callback function. func (x *EntryBufferClass) GetGtkReserved8() func() { if x.xGtkReserved8 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGtkReserved8) return func() { rawCallback() } } // Holds the text that is displayed in a single-line text entry widget. // // A single `GtkEntryBuffer` object can be shared by multiple widgets // which will then share the same text content, but not the cursor // position, visibility attributes, icon etc. // // `GtkEntryBuffer` may be derived from. Such a derived class might allow // text to be stored in an alternate location, such as non-pageable memory, // useful in the case of important passwords. Or a derived class could // integrate with an application’s concept of undo/redo. type EntryBuffer struct { gobject.Object } var xEntryBufferGLibType func() types.GType func EntryBufferGLibType() types.GType { return xEntryBufferGLibType() } func EntryBufferNewFromInternalPtr(ptr uintptr) *EntryBuffer { cls := &EntryBuffer{} cls.Ptr = ptr return cls } var xNewEntryBuffer func(uintptr, int) uintptr // Create a new `GtkEntryBuffer` object. // // Optionally, specify initial text to set in the buffer. func NewEntryBuffer(InitialCharsVar *string, NInitialCharsVar int) *EntryBuffer { var cls *EntryBuffer InitialCharsVarPtr := core.GStrdupNullable(InitialCharsVar) defer core.GFreeNullable(InitialCharsVarPtr) cret := xNewEntryBuffer(InitialCharsVarPtr, NInitialCharsVar) if cret == 0 { return nil } cls = &EntryBuffer{} cls.Ptr = cret return cls } var xEntryBufferDeleteText func(uintptr, uint, int) uint // Deletes a sequence of characters from the buffer. // // @n_chars characters are deleted starting at @position. // If @n_chars is negative, then all characters until the // end of the text are deleted. // // If @position or @n_chars are out of bounds, then they // are coerced to sane values. // // Note that the positions are specified in characters, // not bytes. func (x *EntryBuffer) DeleteText(PositionVar uint, NCharsVar int) uint { cret := xEntryBufferDeleteText(x.GoPointer(), PositionVar, NCharsVar) return cret } var xEntryBufferEmitDeletedText func(uintptr, uint, uint) // Used when subclassing `GtkEntryBuffer`. func (x *EntryBuffer) EmitDeletedText(PositionVar uint, NCharsVar uint) { xEntryBufferEmitDeletedText(x.GoPointer(), PositionVar, NCharsVar) } var xEntryBufferEmitInsertedText func(uintptr, uint, string, uint) // Used when subclassing `GtkEntryBuffer`. func (x *EntryBuffer) EmitInsertedText(PositionVar uint, CharsVar string, NCharsVar uint) { xEntryBufferEmitInsertedText(x.GoPointer(), PositionVar, CharsVar, NCharsVar) } var xEntryBufferGetBytes func(uintptr) uint // Retrieves the length in bytes of the buffer. // // See [method@Gtk.EntryBuffer.get_length]. func (x *EntryBuffer) GetBytes() uint { cret := xEntryBufferGetBytes(x.GoPointer()) return cret } var xEntryBufferGetLength func(uintptr) uint // Retrieves the length in characters of the buffer. func (x *EntryBuffer) GetLength() uint { cret := xEntryBufferGetLength(x.GoPointer()) return cret } var xEntryBufferGetMaxLength func(uintptr) int // Retrieves the maximum allowed length of the text in @buffer. func (x *EntryBuffer) GetMaxLength() int { cret := xEntryBufferGetMaxLength(x.GoPointer()) return cret } var xEntryBufferGetText func(uintptr) string // Retrieves the contents of the buffer. // // The memory pointer returned by this call will not change // unless this object emits a signal, or is finalized. func (x *EntryBuffer) GetText() string { cret := xEntryBufferGetText(x.GoPointer()) return cret } var xEntryBufferInsertText func(uintptr, uint, string, int) uint // Inserts @n_chars characters of @chars into the contents of the // buffer, at position @position. // // If @n_chars is negative, then characters from chars will be inserted // until a null-terminator is found. If @position or @n_chars are out of // bounds, or the maximum buffer text length is exceeded, then they are // coerced to sane values. // // Note that the position and length are in characters, not in bytes. func (x *EntryBuffer) InsertText(PositionVar uint, CharsVar string, NCharsVar int) uint { cret := xEntryBufferInsertText(x.GoPointer(), PositionVar, CharsVar, NCharsVar) return cret } var xEntryBufferSetMaxLength func(uintptr, int) // Sets the maximum allowed length of the contents of the buffer. // // If the current contents are longer than the given length, then // they will be truncated to fit. func (x *EntryBuffer) SetMaxLength(MaxLengthVar int) { xEntryBufferSetMaxLength(x.GoPointer(), MaxLengthVar) } var xEntryBufferSetText func(uintptr, string, int) // Sets the text in the buffer. // // This is roughly equivalent to calling // [method@Gtk.EntryBuffer.delete_text] and // [method@Gtk.EntryBuffer.insert_text]. // // Note that @n_chars is in characters, not in bytes. func (x *EntryBuffer) SetText(CharsVar string, NCharsVar int) { xEntryBufferSetText(x.GoPointer(), CharsVar, NCharsVar) } func (c *EntryBuffer) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *EntryBuffer) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // GetPropertyLength gets the "length" property. // The length (in characters) of the text in buffer. func (x *EntryBuffer) GetPropertyLength() uint { var v gobject.Value x.GetProperty("length", &v) return v.GetUint() } // SetPropertyMaxLength sets the "max-length" property. // The maximum length (in characters) of the text in the buffer. func (x *EntryBuffer) SetPropertyMaxLength(value int) { var v gobject.Value v.Init(gobject.TypeIntVal) v.SetInt(value) x.SetProperty("max-length", &v) } // GetPropertyMaxLength gets the "max-length" property. // The maximum length (in characters) of the text in the buffer. func (x *EntryBuffer) GetPropertyMaxLength() int { var v gobject.Value x.GetProperty("max-length", &v) return v.GetInt() } // SetPropertyText sets the "text" property. // The contents of the buffer. func (x *EntryBuffer) SetPropertyText(value string) { var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) x.SetProperty("text", &v) } // GetPropertyText gets the "text" property. // The contents of the buffer. func (x *EntryBuffer) GetPropertyText() string { var v gobject.Value x.GetProperty("text", &v) return v.GetString() } // The text is altered in the default handler for this signal. // // If you want access to the text after the text has been modified, // use %G_CONNECT_AFTER. func (x *EntryBuffer) ConnectDeletedText(cb *func(EntryBuffer, uint, uint)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "deleted-text", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr, PositionVarp uint, NCharsVarp uint) { fa := EntryBuffer{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa, PositionVarp, NCharsVarp) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "deleted-text", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } // This signal is emitted after text is inserted into the buffer. func (x *EntryBuffer) ConnectInsertedText(cb *func(EntryBuffer, uint, string, uint)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "inserted-text", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr, PositionVarp uint, CharsVarp uintptr, NCharsVarp uint) { fa := EntryBuffer{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa, PositionVarp, core.GoString(CharsVarp), NCharsVarp) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "inserted-text", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } 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(&xEntryBufferGLibType, libs, "gtk_entry_buffer_get_type") core.PuregoSafeRegister(&xNewEntryBuffer, libs, "gtk_entry_buffer_new") core.PuregoSafeRegister(&xEntryBufferDeleteText, libs, "gtk_entry_buffer_delete_text") core.PuregoSafeRegister(&xEntryBufferEmitDeletedText, libs, "gtk_entry_buffer_emit_deleted_text") core.PuregoSafeRegister(&xEntryBufferEmitInsertedText, libs, "gtk_entry_buffer_emit_inserted_text") core.PuregoSafeRegister(&xEntryBufferGetBytes, libs, "gtk_entry_buffer_get_bytes") core.PuregoSafeRegister(&xEntryBufferGetLength, libs, "gtk_entry_buffer_get_length") core.PuregoSafeRegister(&xEntryBufferGetMaxLength, libs, "gtk_entry_buffer_get_max_length") core.PuregoSafeRegister(&xEntryBufferGetText, libs, "gtk_entry_buffer_get_text") core.PuregoSafeRegister(&xEntryBufferInsertText, libs, "gtk_entry_buffer_insert_text") core.PuregoSafeRegister(&xEntryBufferSetMaxLength, libs, "gtk_entry_buffer_set_max_length") core.PuregoSafeRegister(&xEntryBufferSetText, libs, "gtk_entry_buffer_set_text") }