// 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 FilterClass struct { _ structs.HostLayout ParentClass gobject.ObjectClass xMatch uintptr xGetStrictness uintptr xGtkReserved1 uintptr xGtkReserved2 uintptr xGtkReserved3 uintptr xGtkReserved4 uintptr xGtkReserved5 uintptr xGtkReserved6 uintptr xGtkReserved7 uintptr xGtkReserved8 uintptr } func (x *FilterClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverrideMatch sets the "match" callback function. func (x *FilterClass) OverrideMatch(cb func(*Filter, *gobject.Object) bool) { if cb == nil { x.xMatch = 0 } else { x.xMatch = purego.NewCallback(func(SelfVarp uintptr, ItemVarp uintptr) bool { return cb(FilterNewFromInternalPtr(SelfVarp), gobject.ObjectNewFromInternalPtr(ItemVarp)) }) } } // GetMatch gets the "match" callback function. func (x *FilterClass) GetMatch() func(*Filter, *gobject.Object) bool { if x.xMatch == 0 { return nil } var rawCallback func(SelfVarp uintptr, ItemVarp uintptr) bool purego.RegisterFunc(&rawCallback, x.xMatch) return func(SelfVar *Filter, ItemVar *gobject.Object) bool { return rawCallback(SelfVar.GoPointer(), ItemVar.GoPointer()) } } // OverrideGetStrictness sets the "get_strictness" callback function. func (x *FilterClass) OverrideGetStrictness(cb func(*Filter) FilterMatch) { if cb == nil { x.xGetStrictness = 0 } else { x.xGetStrictness = purego.NewCallback(func(SelfVarp uintptr) FilterMatch { return cb(FilterNewFromInternalPtr(SelfVarp)) }) } } // GetGetStrictness gets the "get_strictness" callback function. func (x *FilterClass) GetGetStrictness() func(*Filter) FilterMatch { if x.xGetStrictness == 0 { return nil } var rawCallback func(SelfVarp uintptr) FilterMatch purego.RegisterFunc(&rawCallback, x.xGetStrictness) return func(SelfVar *Filter) FilterMatch { return rawCallback(SelfVar.GoPointer()) } } // OverrideGtkReserved1 sets the "_gtk_reserved1" callback function. func (x *FilterClass) 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 *FilterClass) 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 *FilterClass) 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 *FilterClass) 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 *FilterClass) 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 *FilterClass) 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 *FilterClass) 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 *FilterClass) 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 *FilterClass) 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 *FilterClass) 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 *FilterClass) 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 *FilterClass) 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 *FilterClass) 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 *FilterClass) 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 *FilterClass) 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 *FilterClass) GetGtkReserved8() func() { if x.xGtkReserved8 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGtkReserved8) return func() { rawCallback() } } // Describes changes in a filter in more detail and allows objects // using the filter to optimize refiltering items. // // If you are writing an implementation and are not sure which // value to pass, `GTK_FILTER_CHANGE_DIFFERENT` is always a correct // choice. // // New values may be added in the future. type FilterChange int var xFilterChangeGLibType func() types.GType func FilterChangeGLibType() types.GType { return xFilterChangeGLibType() } const ( // The filter change cannot be // described with any of the other enumeration values FilterChangeDifferentValue FilterChange = 0 // The filter is less strict than // it was before: All items that it used to return true // still return true, others now may, too. FilterChangeLessStrictValue FilterChange = 1 // The filter is more strict than // it was before: All items that it used to return false // still return false, others now may, too. FilterChangeMoreStrictValue FilterChange = 2 // Similar to [enum@Gtk.FilterChange.DIFFERENT], // but signs that item watches should be recreated. This is used by // [class@Gtk.FilterListModel] to keep the list up-to-date when items // change. FilterChangeDifferentRewatchValue FilterChange = 3 // Similar to [enum@Gtk.FilterChange.LESS_STRICT], // but signs that item watches should be recreated. This is used by // [class@Gtk.FilterListModel] to keep the list up-to-date when items // change. FilterChangeLessStrictRewatchValue FilterChange = 4 // Similar to [enum@Gtk.FilterChange.MORE_STRICT], // but signs that item watches should be recreated. This is used by // [class@Gtk.FilterListModel] to keep the list up-to-date when items // change. FilterChangeMoreStrictRewatchValue FilterChange = 5 ) // Describes the known strictness of a filter. // // Note that for filters where the strictness is not known, // `GTK_FILTER_MATCH_SOME` is always an acceptable value, // even if a filter does match all or no items. type FilterMatch int var xFilterMatchGLibType func() types.GType func FilterMatchGLibType() types.GType { return xFilterMatchGLibType() } const ( // The filter matches some items, // [method@Gtk.Filter.match] may return true or false FilterMatchSomeValue FilterMatch = 0 // The filter does not match any item, // [method@Gtk.Filter.match] will always return false FilterMatchNoneValue FilterMatch = 1 // The filter matches all items, // [method@Gtk.Filter.match] will alays return true FilterMatchAllValue FilterMatch = 2 ) // Describes the filtering to be performed by a [class@Gtk.FilterListModel]. // // The model will use the filter to determine if it should include items // or not by calling [method@Gtk.Filter.match] for each item and only // keeping the ones that the function returns true for. // // Filters may change what items they match through their lifetime. In that // case, they will emit the [signal@Gtk.Filter::changed] signal to notify // that previous filter results are no longer valid and that items should // be checked again via [method@Gtk.Filter.match]. // // GTK provides various pre-made filter implementations for common filtering // operations. These filters often include properties that can be linked to // various widgets to easily allow searches. // // However, in particular for large lists or complex search methods, it is // also possible to subclass `GtkFilter` and provide one's own filter. type Filter struct { gobject.Object } var xFilterGLibType func() types.GType func FilterGLibType() types.GType { return xFilterGLibType() } func FilterNewFromInternalPtr(ptr uintptr) *Filter { cls := &Filter{} cls.Ptr = ptr return cls } var xFilterChanged func(uintptr, FilterChange) // Notifies all users of the filter that it has changed. // // This emits the [signal@Gtk.Filter::changed] signal. Users // of the filter should then check items again via // [method@Gtk.Filter.match]. // // Depending on the @change parameter, not all items need to // be changed, but only some. Refer to the [enum@Gtk.FilterChange] // documentation for details. // // This function is intended for implementers of `GtkFilter` // subclasses and should not be called from other functions. func (x *Filter) Changed(ChangeVar FilterChange) { xFilterChanged(x.GoPointer(), ChangeVar) } var xFilterGetStrictness func(uintptr) FilterMatch // Gets the known strictness of a filter. // // If the strictness is not known, [enum@Gtk.FilterMatch.some] is returned. // // This value may change after emission of the [signal@Gtk.Filter::changed] // signal. // // This function is meant purely for optimization purposes. Filters can // choose to omit implementing it, but `GtkFilterListModel` uses it. func (x *Filter) GetStrictness() FilterMatch { cret := xFilterGetStrictness(x.GoPointer()) return cret } var xFilterMatch func(uintptr, uintptr) bool // Checks if the given @item is matched by the filter or not. func (x *Filter) Match(ItemVar *gobject.Object) bool { cret := xFilterMatch(x.GoPointer(), ItemVar.GoPointer()) return cret } func (c *Filter) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *Filter) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // Emitted whenever the filter changed. // // Users of the filter should then check items again via // [method@Gtk.Filter.match]. // // `GtkFilterListModel` handles this signal automatically. // // Depending on the @change parameter, not all items need // to be checked, but only some. Refer to the [enum@Gtk.FilterChange] // documentation for details. func (x *Filter) ConnectChanged(cb *func(Filter, FilterChange)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "changed", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr, ChangeVarp FilterChange) { fa := Filter{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa, ChangeVarp) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "changed", 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(&xFilterChangeGLibType, libs, "gtk_filter_change_get_type") core.PuregoSafeRegister(&xFilterMatchGLibType, libs, "gtk_filter_match_get_type") core.PuregoSafeRegister(&xFilterGLibType, libs, "gtk_filter_get_type") core.PuregoSafeRegister(&xFilterChanged, libs, "gtk_filter_changed") core.PuregoSafeRegister(&xFilterGetStrictness, libs, "gtk_filter_get_strictness") core.PuregoSafeRegister(&xFilterMatch, libs, "gtk_filter_match") }