// 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" ) // Class structure for `GtkNativeDialog`. type NativeDialogClass struct { _ structs.HostLayout ParentClass gobject.ObjectClass xResponse uintptr xShow uintptr xHide uintptr xGtkReserved1 uintptr xGtkReserved2 uintptr xGtkReserved3 uintptr xGtkReserved4 uintptr } func (x *NativeDialogClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverrideResponse sets the "response" callback function. // class handler for the `GtkNativeDialog::response` signal func (x *NativeDialogClass) OverrideResponse(cb func(*NativeDialog, int)) { if cb == nil { x.xResponse = 0 } else { x.xResponse = purego.NewCallback(func(SelfVarp uintptr, ResponseIdVarp int) { cb(NativeDialogNewFromInternalPtr(SelfVarp), ResponseIdVarp) }) } } // GetResponse gets the "response" callback function. // class handler for the `GtkNativeDialog::response` signal func (x *NativeDialogClass) GetResponse() func(*NativeDialog, int) { if x.xResponse == 0 { return nil } var rawCallback func(SelfVarp uintptr, ResponseIdVarp int) purego.RegisterFunc(&rawCallback, x.xResponse) return func(SelfVar *NativeDialog, ResponseIdVar int) { rawCallback(SelfVar.GoPointer(), ResponseIdVar) } } // OverrideShow sets the "show" callback function. func (x *NativeDialogClass) OverrideShow(cb func(*NativeDialog)) { if cb == nil { x.xShow = 0 } else { x.xShow = purego.NewCallback(func(SelfVarp uintptr) { cb(NativeDialogNewFromInternalPtr(SelfVarp)) }) } } // GetShow gets the "show" callback function. func (x *NativeDialogClass) GetShow() func(*NativeDialog) { if x.xShow == 0 { return nil } var rawCallback func(SelfVarp uintptr) purego.RegisterFunc(&rawCallback, x.xShow) return func(SelfVar *NativeDialog) { rawCallback(SelfVar.GoPointer()) } } // OverrideHide sets the "hide" callback function. func (x *NativeDialogClass) OverrideHide(cb func(*NativeDialog)) { if cb == nil { x.xHide = 0 } else { x.xHide = purego.NewCallback(func(SelfVarp uintptr) { cb(NativeDialogNewFromInternalPtr(SelfVarp)) }) } } // GetHide gets the "hide" callback function. func (x *NativeDialogClass) GetHide() func(*NativeDialog) { if x.xHide == 0 { return nil } var rawCallback func(SelfVarp uintptr) purego.RegisterFunc(&rawCallback, x.xHide) return func(SelfVar *NativeDialog) { rawCallback(SelfVar.GoPointer()) } } // OverrideGtkReserved1 sets the "_gtk_reserved1" callback function. func (x *NativeDialogClass) 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 *NativeDialogClass) 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 *NativeDialogClass) 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 *NativeDialogClass) 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 *NativeDialogClass) 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 *NativeDialogClass) 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 *NativeDialogClass) 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 *NativeDialogClass) GetGtkReserved4() func() { if x.xGtkReserved4 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGtkReserved4) return func() { rawCallback() } } // Base class for platform dialogs that don't use `GtkDialog`. // // Native dialogs are used in order to integrate better with a platform, // by looking the same as other native applications and supporting // platform specific features. // // The [class@Gtk.Dialog] functions cannot be used on such objects, // but we need a similar API in order to drive them. The `GtkNativeDialog` // object is an API that allows you to do this. It allows you to set // various common properties on the dialog, as well as show and hide // it and get a [signal@Gtk.NativeDialog::response] signal when the user // finished with the dialog. // // Note that unlike `GtkDialog`, `GtkNativeDialog` objects are not // toplevel widgets, and GTK does not keep them alive. It is your // responsibility to keep a reference until you are done with the // object. type NativeDialog struct { gobject.Object } var xNativeDialogGLibType func() types.GType func NativeDialogGLibType() types.GType { return xNativeDialogGLibType() } func NativeDialogNewFromInternalPtr(ptr uintptr) *NativeDialog { cls := &NativeDialog{} cls.Ptr = ptr return cls } var xNativeDialogDestroy func(uintptr) // Destroys a dialog. // // When a dialog is destroyed, it will break any references it holds // to other objects. // // If it is visible it will be hidden and any underlying window system // resources will be destroyed. // // Note that this does not release any reference to the object (as opposed // to destroying a `GtkWindow`) because there is no reference from the // windowing system to the `GtkNativeDialog`. func (x *NativeDialog) Destroy() { xNativeDialogDestroy(x.GoPointer()) } var xNativeDialogGetModal func(uintptr) bool // Returns whether the dialog is modal. func (x *NativeDialog) GetModal() bool { cret := xNativeDialogGetModal(x.GoPointer()) return cret } var xNativeDialogGetTitle func(uintptr) string // Gets the title of the `GtkNativeDialog`. func (x *NativeDialog) GetTitle() string { cret := xNativeDialogGetTitle(x.GoPointer()) return cret } var xNativeDialogGetTransientFor func(uintptr) uintptr // Fetches the transient parent for this window. func (x *NativeDialog) GetTransientFor() *Window { var cls *Window cret := xNativeDialogGetTransientFor(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &Window{} cls.Ptr = cret return cls } var xNativeDialogGetVisible func(uintptr) bool // Determines whether the dialog is visible. func (x *NativeDialog) GetVisible() bool { cret := xNativeDialogGetVisible(x.GoPointer()) return cret } var xNativeDialogHide func(uintptr) // Hides the dialog if it is visible, aborting any interaction. // // Once this is called the [signal@Gtk.NativeDialog::response] signal // will *not* be emitted until after the next call to // [method@Gtk.NativeDialog.show]. // // If the dialog is not visible this does nothing. func (x *NativeDialog) Hide() { xNativeDialogHide(x.GoPointer()) } var xNativeDialogSetModal func(uintptr, bool) // Sets a dialog modal or non-modal. // // Modal dialogs prevent interaction with other windows in the same // application. To keep modal dialogs on top of main application // windows, use [method@Gtk.NativeDialog.set_transient_for] to make // the dialog transient for the parent; most window managers will // then disallow lowering the dialog below the parent. func (x *NativeDialog) SetModal(ModalVar bool) { xNativeDialogSetModal(x.GoPointer(), ModalVar) } var xNativeDialogSetTitle func(uintptr, string) // Sets the title of the `GtkNativeDialog.` func (x *NativeDialog) SetTitle(TitleVar string) { xNativeDialogSetTitle(x.GoPointer(), TitleVar) } var xNativeDialogSetTransientFor func(uintptr, uintptr) // Dialog windows should be set transient for the main application // window they were spawned from. // // This allows window managers to e.g. keep the dialog on top of the // main window, or center the dialog over the main window. // // Passing %NULL for @parent unsets the current transient window. func (x *NativeDialog) SetTransientFor(ParentVar *Window) { xNativeDialogSetTransientFor(x.GoPointer(), ParentVar.GoPointer()) } var xNativeDialogShow func(uintptr) // Shows the dialog on the display. // // When the user accepts the state of the dialog the dialog will // be automatically hidden and the [signal@Gtk.NativeDialog::response] // signal will be emitted. // // Multiple calls while the dialog is visible will be ignored. func (x *NativeDialog) Show() { xNativeDialogShow(x.GoPointer()) } func (c *NativeDialog) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *NativeDialog) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // SetPropertyModal sets the "modal" property. // Whether the window should be modal with respect to its transient parent. func (x *NativeDialog) SetPropertyModal(value bool) { var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) x.SetProperty("modal", &v) } // GetPropertyModal gets the "modal" property. // Whether the window should be modal with respect to its transient parent. func (x *NativeDialog) GetPropertyModal() bool { var v gobject.Value x.GetProperty("modal", &v) return v.GetBoolean() } // SetPropertyTitle sets the "title" property. // The title of the dialog window func (x *NativeDialog) SetPropertyTitle(value string) { var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) x.SetProperty("title", &v) } // GetPropertyTitle gets the "title" property. // The title of the dialog window func (x *NativeDialog) GetPropertyTitle() string { var v gobject.Value x.GetProperty("title", &v) return v.GetString() } // SetPropertyVisible sets the "visible" property. // Whether the window is currently visible. func (x *NativeDialog) SetPropertyVisible(value bool) { var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) x.SetProperty("visible", &v) } // GetPropertyVisible gets the "visible" property. // Whether the window is currently visible. func (x *NativeDialog) GetPropertyVisible() bool { var v gobject.Value x.GetProperty("visible", &v) return v.GetBoolean() } // Emitted when the user responds to the dialog. // // When this is called the dialog has been hidden. // // If you call [method@Gtk.NativeDialog.hide] before the user // responds to the dialog this signal will not be emitted. func (x *NativeDialog) ConnectResponse(cb *func(NativeDialog, int)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "response", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr, ResponseIdVarp int) { fa := NativeDialog{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa, ResponseIdVarp) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "response", 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(&xNativeDialogGLibType, libs, "gtk_native_dialog_get_type") core.PuregoSafeRegister(&xNativeDialogDestroy, libs, "gtk_native_dialog_destroy") core.PuregoSafeRegister(&xNativeDialogGetModal, libs, "gtk_native_dialog_get_modal") core.PuregoSafeRegister(&xNativeDialogGetTitle, libs, "gtk_native_dialog_get_title") core.PuregoSafeRegister(&xNativeDialogGetTransientFor, libs, "gtk_native_dialog_get_transient_for") core.PuregoSafeRegister(&xNativeDialogGetVisible, libs, "gtk_native_dialog_get_visible") core.PuregoSafeRegister(&xNativeDialogHide, libs, "gtk_native_dialog_hide") core.PuregoSafeRegister(&xNativeDialogSetModal, libs, "gtk_native_dialog_set_modal") core.PuregoSafeRegister(&xNativeDialogSetTitle, libs, "gtk_native_dialog_set_title") core.PuregoSafeRegister(&xNativeDialogSetTransientFor, libs, "gtk_native_dialog_set_transient_for") core.PuregoSafeRegister(&xNativeDialogShow, libs, "gtk_native_dialog_show") }