// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT package glib import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" ) // Specifies the type of the function passed to g_completion_new(). It // should return the string corresponding to the given target item. // This is used when you use data structures as #GCompletion items. type CompletionFunc func(uintptr) string // Specifies the type of the function passed to // g_completion_set_compare(). This is used when you use strings as // #GCompletion items. type CompletionStrncmpFunc func(string, string, uint) int // `GCompletion` provides support for automatic completion of a string // using any group of target strings. It is typically used for file // name completion as is common in many UNIX shells. // // A `GCompletion` is created using [func@GLib.Completion.new]. Target items are // added and removed with [method@GLib.Completion.add_items], // [method@GLib.Completion.remove_items] and // [method@GLib.Completion.clear_items]. A completion attempt is requested with // [method@GLib.Completion.complete] or [method@GLib.Completion.complete_utf8]. // When no longer needed, the `GCompletion` is freed with // [method@GLib.Completion.free]. // // Items in the completion can be simple strings (e.g. filenames), or // pointers to arbitrary data structures. If data structures are used // you must provide a [type@GLib.CompletionFunc] in [func@GLib.Completion.new], // which retrieves the item’s string from the data structure. You can change // the way in which strings are compared by setting a different // [type@GLib.CompletionStrncmpFunc] in [method@GLib.Completion.set_compare]. // // `GCompletion` has been marked as deprecated, since this API is rarely // used and not very actively maintained. type Completion struct { _ structs.HostLayout Items *List Func CompletionFunc Prefix uintptr Cache *List StrncmpFunc CompletionStrncmpFunc } func (x *Completion) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } var xCompletionAddItems func(uintptr, *List) // Adds items to the #GCompletion. func (x *Completion) AddItems(ItemsVar *List) { xCompletionAddItems(x.GoPointer(), ItemsVar) } var xCompletionClearItems func(uintptr) // Removes all items from the #GCompletion. The items are not freed, so if the // memory was dynamically allocated, it should be freed after calling this // function. func (x *Completion) ClearItems() { xCompletionClearItems(x.GoPointer()) } var xCompletionComplete func(uintptr, string, string) *List // Attempts to complete the string @prefix using the #GCompletion // target items. func (x *Completion) Complete(PrefixVar string, NewPrefixVar string) *List { cret := xCompletionComplete(x.GoPointer(), PrefixVar, NewPrefixVar) return cret } var xCompletionCompleteUtf8 func(uintptr, string, string) *List // Attempts to complete the string @prefix using the #GCompletion target items. // In contrast to g_completion_complete(), this function returns the largest common // prefix that is a valid UTF-8 string, omitting a possible common partial // character. // // You should use this function instead of g_completion_complete() if your // items are UTF-8 strings. func (x *Completion) CompleteUtf8(PrefixVar string, NewPrefixVar string) *List { cret := xCompletionCompleteUtf8(x.GoPointer(), PrefixVar, NewPrefixVar) return cret } var xCompletionFree func(uintptr) // Frees all memory used by the #GCompletion. The items are not freed, so if // the memory was dynamically allocated, it should be freed after calling this // function. func (x *Completion) Free() { xCompletionFree(x.GoPointer()) } var xCompletionRemoveItems func(uintptr, *List) // Removes items from a #GCompletion. The items are not freed, so if the memory // was dynamically allocated, free @items with g_list_free_full() after calling // this function. func (x *Completion) RemoveItems(ItemsVar *List) { xCompletionRemoveItems(x.GoPointer(), ItemsVar) } var xCompletionSetCompare func(uintptr, uintptr) // Sets the function to use for string comparisons. The default string // comparison function is strncmp(). func (x *Completion) SetCompare(StrncmpFuncVar *CompletionStrncmpFunc) { var StrncmpFuncVarRef uintptr if StrncmpFuncVar != nil { StrncmpFuncVarPtr := uintptr(unsafe.Pointer(StrncmpFuncVar)) if cbRefPtr, ok := GetCallback(StrncmpFuncVarPtr); ok { StrncmpFuncVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uint) int { cbFn := *StrncmpFuncVar return cbFn(core.GoString(arg0), core.GoString(arg1), arg2) } StrncmpFuncVarRef = purego.NewCallback(fcb) SaveCallbackWithClosure(StrncmpFuncVarPtr, StrncmpFuncVarRef, StrncmpFuncVar) } } xCompletionSetCompare(x.GoPointer(), StrncmpFuncVarRef) } func init() { core.SetPackageName("GLIB", "glib-2.0") core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"}) var libs []uintptr for _, libPath := range core.GetPaths("GLIB") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xCompletionAddItems, libs, "g_completion_add_items") core.PuregoSafeRegister(&xCompletionClearItems, libs, "g_completion_clear_items") core.PuregoSafeRegister(&xCompletionComplete, libs, "g_completion_complete") core.PuregoSafeRegister(&xCompletionCompleteUtf8, libs, "g_completion_complete_utf8") core.PuregoSafeRegister(&xCompletionFree, libs, "g_completion_free") core.PuregoSafeRegister(&xCompletionRemoveItems, libs, "g_completion_remove_items") core.PuregoSafeRegister(&xCompletionSetCompare, libs, "g_completion_set_compare") }