// 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/gdk" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) type RootInterface struct { _ structs.HostLayout } func (x *RootInterface) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // An interface for widgets that can act as the root of a widget hierarchy. // // The root widget takes care of providing the connection to the windowing // system and manages layout, drawing and event delivery for its widget // hierarchy. // // The obvious example of a `GtkRoot` is `GtkWindow`. // // To get the display to which a `GtkRoot` belongs, use // [method@Gtk.Root.get_display]. // // `GtkRoot` also maintains the location of keyboard focus inside its widget // hierarchy, with [method@Gtk.Root.set_focus] and [method@Gtk.Root.get_focus]. type Root interface { GoPointer() uintptr SetGoPointer(uintptr) GetDisplay() *gdk.Display GetFocus() *Widget SetFocus(FocusVar *Widget) } var xRootGLibType func() types.GType func RootGLibType() types.GType { return xRootGLibType() } type RootBase struct { Ptr uintptr } func (x *RootBase) GoPointer() uintptr { if x == nil { return 0 } return x.Ptr } func (x *RootBase) SetGoPointer(ptr uintptr) { x.Ptr = ptr } // Returns the display that this `GtkRoot` is on. func (x *RootBase) GetDisplay() *gdk.Display { var cls *gdk.Display cret := XGtkRootGetDisplay(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &gdk.Display{} cls.Ptr = cret return cls } // Retrieves the current focused widget within the root. // // Note that this is the widget that would have the focus // if the root is active; if the root is not focused then // `gtk_widget_has_focus (widget)` will be %FALSE for the // widget. func (x *RootBase) GetFocus() *Widget { var cls *Widget cret := XGtkRootGetFocus(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &Widget{} cls.Ptr = cret return cls } // If @focus is not the current focus widget, and is focusable, sets // it as the focus widget for the root. // // If @focus is %NULL, unsets the focus widget for the root. // // To set the focus to a particular widget in the root, it is usually // more convenient to use [method@Gtk.Widget.grab_focus] instead of // this function. func (x *RootBase) SetFocus(FocusVar *Widget) { XGtkRootSetFocus(x.GoPointer(), FocusVar.GoPointer()) } var XGtkRootGetDisplay func(uintptr) uintptr var XGtkRootGetFocus func(uintptr) uintptr var XGtkRootSetFocus func(uintptr, uintptr) 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(&xRootGLibType, libs, "gtk_root_get_type") core.PuregoSafeRegister(&XGtkRootGetDisplay, libs, "gtk_root_get_display") core.PuregoSafeRegister(&XGtkRootGetFocus, libs, "gtk_root_get_focus") core.PuregoSafeRegister(&XGtkRootSetFocus, libs, "gtk_root_set_focus") }