// 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/types" ) // A GtkTreeIterCompareFunc should return a negative integer, zero, or a positive // integer if @a sorts before @b, @a sorts with @b, or @a sorts after @b // respectively. // // If two iters compare as equal, their order in the sorted model // is undefined. In order to ensure that the `GtkTreeSortable` behaves as // expected, the GtkTreeIterCompareFunc must define a partial order on // the model, i.e. it must be reflexive, antisymmetric and transitive. // // For example, if @model is a product catalogue, then a compare function // for the “price” column could be one which returns // `price_of(@a) - price_of(@b)`. type TreeIterCompareFunc func(uintptr, *TreeIter, *TreeIter, uintptr) int type TreeSortableIface struct { _ structs.HostLayout GIface uintptr xSortColumnChanged uintptr xGetSortColumnId uintptr xSetSortColumnId uintptr xSetSortFunc uintptr xSetDefaultSortFunc uintptr xHasDefaultSortFunc uintptr } func (x *TreeSortableIface) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverrideSortColumnChanged sets the "sort_column_changed" callback function. // Signal emitted when the sort column or sort // // order of sortable is changed. func (x *TreeSortableIface) OverrideSortColumnChanged(cb func(TreeSortable)) { if cb == nil { x.xSortColumnChanged = 0 } else { x.xSortColumnChanged = purego.NewCallback(func(SortableVarp uintptr) { cb(&TreeSortableBase{Ptr: SortableVarp}) }) } } // GetSortColumnChanged gets the "sort_column_changed" callback function. // Signal emitted when the sort column or sort // // order of sortable is changed. func (x *TreeSortableIface) GetSortColumnChanged() func(TreeSortable) { if x.xSortColumnChanged == 0 { return nil } var rawCallback func(SortableVarp uintptr) purego.RegisterFunc(&rawCallback, x.xSortColumnChanged) return func(SortableVar TreeSortable) { rawCallback(SortableVar.GoPointer()) } } // OverrideGetSortColumnId sets the "get_sort_column_id" callback function. // Fills in sort_column_id and order with the // // current sort column and the order. func (x *TreeSortableIface) OverrideGetSortColumnId(cb func(TreeSortable, *int, *SortType) bool) { if cb == nil { x.xGetSortColumnId = 0 } else { x.xGetSortColumnId = purego.NewCallback(func(SortableVarp uintptr, SortColumnIdVarp *int, OrderVarp *SortType) bool { return cb(&TreeSortableBase{Ptr: SortableVarp}, SortColumnIdVarp, OrderVarp) }) } } // GetGetSortColumnId gets the "get_sort_column_id" callback function. // Fills in sort_column_id and order with the // // current sort column and the order. func (x *TreeSortableIface) GetGetSortColumnId() func(TreeSortable, *int, *SortType) bool { if x.xGetSortColumnId == 0 { return nil } var rawCallback func(SortableVarp uintptr, SortColumnIdVarp *int, OrderVarp *SortType) bool purego.RegisterFunc(&rawCallback, x.xGetSortColumnId) return func(SortableVar TreeSortable, SortColumnIdVar *int, OrderVar *SortType) bool { return rawCallback(SortableVar.GoPointer(), SortColumnIdVar, OrderVar) } } // OverrideSetSortColumnId sets the "set_sort_column_id" callback function. // Sets the current sort column to be // // sort_column_id. func (x *TreeSortableIface) OverrideSetSortColumnId(cb func(TreeSortable, int, SortType)) { if cb == nil { x.xSetSortColumnId = 0 } else { x.xSetSortColumnId = purego.NewCallback(func(SortableVarp uintptr, SortColumnIdVarp int, OrderVarp SortType) { cb(&TreeSortableBase{Ptr: SortableVarp}, SortColumnIdVarp, OrderVarp) }) } } // GetSetSortColumnId gets the "set_sort_column_id" callback function. // Sets the current sort column to be // // sort_column_id. func (x *TreeSortableIface) GetSetSortColumnId() func(TreeSortable, int, SortType) { if x.xSetSortColumnId == 0 { return nil } var rawCallback func(SortableVarp uintptr, SortColumnIdVarp int, OrderVarp SortType) purego.RegisterFunc(&rawCallback, x.xSetSortColumnId) return func(SortableVar TreeSortable, SortColumnIdVar int, OrderVar SortType) { rawCallback(SortableVar.GoPointer(), SortColumnIdVar, OrderVar) } } // OverrideSetSortFunc sets the "set_sort_func" callback function. // Sets the comparison function used when sorting to // // be sort_func. func (x *TreeSortableIface) OverrideSetSortFunc(cb func(TreeSortable, int, *TreeIterCompareFunc, uintptr, *glib.DestroyNotify)) { if cb == nil { x.xSetSortFunc = 0 } else { x.xSetSortFunc = purego.NewCallback(func(SortableVarp uintptr, SortColumnIdVarp int, SortFuncVarp uintptr, UserDataVarp uintptr, DestroyVarp uintptr) { cb(&TreeSortableBase{Ptr: SortableVarp}, SortColumnIdVarp, (*TreeIterCompareFunc)(unsafe.Pointer(SortFuncVarp)), UserDataVarp, (*glib.DestroyNotify)(unsafe.Pointer(DestroyVarp))) }) } } // GetSetSortFunc gets the "set_sort_func" callback function. // Sets the comparison function used when sorting to // // be sort_func. func (x *TreeSortableIface) GetSetSortFunc() func(TreeSortable, int, *TreeIterCompareFunc, uintptr, *glib.DestroyNotify) { if x.xSetSortFunc == 0 { return nil } var rawCallback func(SortableVarp uintptr, SortColumnIdVarp int, SortFuncVarp uintptr, UserDataVarp uintptr, DestroyVarp uintptr) purego.RegisterFunc(&rawCallback, x.xSetSortFunc) return func(SortableVar TreeSortable, SortColumnIdVar int, SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { rawCallback(SortableVar.GoPointer(), SortColumnIdVar, glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallbackNullable(DestroyVar)) } } // OverrideSetDefaultSortFunc sets the "set_default_sort_func" callback function. // Sets the default comparison function used // // when sorting to be sort_func. func (x *TreeSortableIface) OverrideSetDefaultSortFunc(cb func(TreeSortable, *TreeIterCompareFunc, uintptr, *glib.DestroyNotify)) { if cb == nil { x.xSetDefaultSortFunc = 0 } else { x.xSetDefaultSortFunc = purego.NewCallback(func(SortableVarp uintptr, SortFuncVarp uintptr, UserDataVarp uintptr, DestroyVarp uintptr) { cb(&TreeSortableBase{Ptr: SortableVarp}, (*TreeIterCompareFunc)(unsafe.Pointer(SortFuncVarp)), UserDataVarp, (*glib.DestroyNotify)(unsafe.Pointer(DestroyVarp))) }) } } // GetSetDefaultSortFunc gets the "set_default_sort_func" callback function. // Sets the default comparison function used // // when sorting to be sort_func. func (x *TreeSortableIface) GetSetDefaultSortFunc() func(TreeSortable, *TreeIterCompareFunc, uintptr, *glib.DestroyNotify) { if x.xSetDefaultSortFunc == 0 { return nil } var rawCallback func(SortableVarp uintptr, SortFuncVarp uintptr, UserDataVarp uintptr, DestroyVarp uintptr) purego.RegisterFunc(&rawCallback, x.xSetDefaultSortFunc) return func(SortableVar TreeSortable, SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { rawCallback(SortableVar.GoPointer(), glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallbackNullable(DestroyVar)) } } // OverrideHasDefaultSortFunc sets the "has_default_sort_func" callback function. // %TRUE if the model has a default sort // function. func (x *TreeSortableIface) OverrideHasDefaultSortFunc(cb func(TreeSortable) bool) { if cb == nil { x.xHasDefaultSortFunc = 0 } else { x.xHasDefaultSortFunc = purego.NewCallback(func(SortableVarp uintptr) bool { return cb(&TreeSortableBase{Ptr: SortableVarp}) }) } } // GetHasDefaultSortFunc gets the "has_default_sort_func" callback function. // %TRUE if the model has a default sort // function. func (x *TreeSortableIface) GetHasDefaultSortFunc() func(TreeSortable) bool { if x.xHasDefaultSortFunc == 0 { return nil } var rawCallback func(SortableVarp uintptr) bool purego.RegisterFunc(&rawCallback, x.xHasDefaultSortFunc) return func(SortableVar TreeSortable) bool { return rawCallback(SortableVar.GoPointer()) } } // The interface for sortable models used by GtkTreeView // // `GtkTreeSortable` is an interface to be implemented by tree models which // support sorting. The `GtkTreeView` uses the methods provided by this interface // to sort the model. type TreeSortable interface { GoPointer() uintptr SetGoPointer(uintptr) GetSortColumnId(SortColumnIdVar *int, OrderVar *SortType) bool HasDefaultSortFunc() bool SetDefaultSortFunc(SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) SetSortColumnId(SortColumnIdVar int, OrderVar SortType) SetSortFunc(SortColumnIdVar int, SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) SortColumnChanged() } var xTreeSortableGLibType func() types.GType func TreeSortableGLibType() types.GType { return xTreeSortableGLibType() } type TreeSortableBase struct { Ptr uintptr } func (x *TreeSortableBase) GoPointer() uintptr { if x == nil { return 0 } return x.Ptr } func (x *TreeSortableBase) SetGoPointer(ptr uintptr) { x.Ptr = ptr } // Fills in @sort_column_id and @order with the current sort column and the // order. It returns %TRUE unless the @sort_column_id is // %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID or // %GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID. func (x *TreeSortableBase) GetSortColumnId(SortColumnIdVar *int, OrderVar *SortType) bool { cret := XGtkTreeSortableGetSortColumnId(x.GoPointer(), SortColumnIdVar, OrderVar) return cret } // Returns %TRUE if the model has a default sort function. This is used // primarily by GtkTreeViewColumns in order to determine if a model can // go back to the default state, or not. func (x *TreeSortableBase) HasDefaultSortFunc() bool { cret := XGtkTreeSortableHasDefaultSortFunc(x.GoPointer()) return cret } // Sets the default comparison function used when sorting to be @sort_func. // If the current sort column id of @sortable is // %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the model will sort using // this function. // // If @sort_func is %NULL, then there will be no default comparison function. // This means that once the model has been sorted, it can’t go back to the // default state. In this case, when the current sort column id of @sortable // is %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will be unsorted. func (x *TreeSortableBase) SetDefaultSortFunc(SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { XGtkTreeSortableSetDefaultSortFunc(x.GoPointer(), glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallbackNullable(DestroyVar)) } // Sets the current sort column to be @sort_column_id. The @sortable will // resort itself to reflect this change, after emitting a // `GtkTreeSortable::sort-column-changed` signal. @sort_column_id may either be // a regular column id, or one of the following special values: // // - %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID: the default sort function // will be used, if it is set // // - %GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID: no sorting will occur func (x *TreeSortableBase) SetSortColumnId(SortColumnIdVar int, OrderVar SortType) { XGtkTreeSortableSetSortColumnId(x.GoPointer(), SortColumnIdVar, OrderVar) } // Sets the comparison function used when sorting to be @sort_func. If the // current sort column id of @sortable is the same as @sort_column_id, then // the model will sort using this function. func (x *TreeSortableBase) SetSortFunc(SortColumnIdVar int, SortFuncVar *TreeIterCompareFunc, UserDataVar uintptr, DestroyVar *glib.DestroyNotify) { XGtkTreeSortableSetSortFunc(x.GoPointer(), SortColumnIdVar, glib.NewCallback(SortFuncVar), UserDataVar, glib.NewCallbackNullable(DestroyVar)) } // Emits a `GtkTreeSortable::sort-column-changed` signal on @sortable. func (x *TreeSortableBase) SortColumnChanged() { XGtkTreeSortableSortColumnChanged(x.GoPointer()) } var XGtkTreeSortableGetSortColumnId func(uintptr, *int, *SortType) bool var XGtkTreeSortableHasDefaultSortFunc func(uintptr) bool var XGtkTreeSortableSetDefaultSortFunc func(uintptr, uintptr, uintptr, uintptr) var XGtkTreeSortableSetSortColumnId func(uintptr, int, SortType) var XGtkTreeSortableSetSortFunc func(uintptr, int, uintptr, uintptr, uintptr) var XGtkTreeSortableSortColumnChanged func(uintptr) const ( // Uses the default sort function in a [iface@Gtk.TreeSortable]. // // See also: [method@Gtk.TreeSortable.set_sort_column_id] TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID int = -1 // Disables sorting in a [iface@Gtk.TreeSortable]. // // See also: [method@Gtk.TreeSortable.set_sort_column_id] TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID int = -2 ) 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(&xTreeSortableGLibType, libs, "gtk_tree_sortable_get_type") core.PuregoSafeRegister(&XGtkTreeSortableGetSortColumnId, libs, "gtk_tree_sortable_get_sort_column_id") core.PuregoSafeRegister(&XGtkTreeSortableHasDefaultSortFunc, libs, "gtk_tree_sortable_has_default_sort_func") core.PuregoSafeRegister(&XGtkTreeSortableSetDefaultSortFunc, libs, "gtk_tree_sortable_set_default_sort_func") core.PuregoSafeRegister(&XGtkTreeSortableSetSortColumnId, libs, "gtk_tree_sortable_set_sort_column_id") core.PuregoSafeRegister(&XGtkTreeSortableSetSortFunc, libs, "gtk_tree_sortable_set_sort_func") core.PuregoSafeRegister(&XGtkTreeSortableSortColumnChanged, libs, "gtk_tree_sortable_sort_column_changed") }