// 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/gio" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) type PrintDialogClass struct { _ structs.HostLayout ParentClass gobject.ObjectClass } func (x *PrintDialogClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // An auxiliary object for printing that allows decoupling the setup from the printing. // // A print setup is obtained by calling [method@Gtk.PrintDialog.setup], // and can later be passed to print functions such as [method@Gtk.PrintDialog.print]. // // Print setups can be reused for multiple print calls. // // Applications may wish to store the page_setup and print_settings from the print setup // and copy them to the PrintDialog if they want to keep using them. type PrintSetup struct { _ structs.HostLayout } var xPrintSetupGLibType func() types.GType func PrintSetupGLibType() types.GType { return xPrintSetupGLibType() } func (x *PrintSetup) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } var xPrintSetupGetPageSetup func(uintptr) uintptr // Returns the page setup of @setup. // // It may be different from the `GtkPrintDialog`'s page setup // if the user changed it during the setup process. func (x *PrintSetup) GetPageSetup() *PageSetup { var cls *PageSetup cret := xPrintSetupGetPageSetup(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &PageSetup{} cls.Ptr = cret return cls } var xPrintSetupGetPrintSettings func(uintptr) uintptr // Returns the print settings of @setup. // // They may be different from the `GtkPrintDialog`'s settings // if the user changed them during the setup process. func (x *PrintSetup) GetPrintSettings() *PrintSettings { var cls *PrintSettings cret := xPrintSetupGetPrintSettings(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &PrintSettings{} cls.Ptr = cret return cls } var xPrintSetupRef func(uintptr) *PrintSetup // Increase the reference count of @setup. func (x *PrintSetup) Ref() *PrintSetup { cret := xPrintSetupRef(x.GoPointer()) return cret } var xPrintSetupUnref func(uintptr) // Decrease the reference count of @setup. // // If the reference count reaches zero, // the object is freed. func (x *PrintSetup) Unref() { xPrintSetupUnref(x.GoPointer()) } // Asynchronous API to present a print dialog to the user. // // `GtkPrintDialog` collects the arguments that are needed to present // // the dialog, such as a title for the dialog and whether it should // be modal. // // The dialog is shown with the [method@Gtk.PrintDialog.setup] function. // // The actual printing can be done with [method@Gtk.PrintDialog.print] or // [method@Gtk.PrintDialog.print_file]. These APIs follows the GIO async pattern, // and the results can be obtained by calling the corresponding finish methods. type PrintDialog struct { gobject.Object } var xPrintDialogGLibType func() types.GType func PrintDialogGLibType() types.GType { return xPrintDialogGLibType() } func PrintDialogNewFromInternalPtr(ptr uintptr) *PrintDialog { cls := &PrintDialog{} cls.Ptr = ptr return cls } var xNewPrintDialog func() uintptr // Creates a new `GtkPrintDialog` object. func NewPrintDialog() *PrintDialog { var cls *PrintDialog cret := xNewPrintDialog() if cret == 0 { return nil } cls = &PrintDialog{} cls.Ptr = cret return cls } var xPrintDialogGetAcceptLabel func(uintptr) string // Returns the label that will be shown on the // accept button of the print dialog. func (x *PrintDialog) GetAcceptLabel() string { cret := xPrintDialogGetAcceptLabel(x.GoPointer()) return cret } var xPrintDialogGetModal func(uintptr) bool // Returns whether the print dialog blocks // interaction with the parent window while // it is presented. func (x *PrintDialog) GetModal() bool { cret := xPrintDialogGetModal(x.GoPointer()) return cret } var xPrintDialogGetPageSetup func(uintptr) uintptr // Returns the page setup. func (x *PrintDialog) GetPageSetup() *PageSetup { var cls *PageSetup cret := xPrintDialogGetPageSetup(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &PageSetup{} cls.Ptr = cret return cls } var xPrintDialogGetPrintSettings func(uintptr) uintptr // Returns the print settings for the print dialog. func (x *PrintDialog) GetPrintSettings() *PrintSettings { var cls *PrintSettings cret := xPrintDialogGetPrintSettings(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &PrintSettings{} cls.Ptr = cret return cls } var xPrintDialogGetTitle func(uintptr) string // Returns the title that will be shown on the // print dialog. func (x *PrintDialog) GetTitle() string { cret := xPrintDialogGetTitle(x.GoPointer()) return cret } var xPrintDialogPrint func(uintptr, uintptr, *PrintSetup, uintptr, uintptr, uintptr) // This function prints content from a stream. // // If you pass `NULL` as @setup, then this method will present a print dialog. // Otherwise, it will attempt to print directly, without user interaction. // // The @callback will be called when the printing is done. func (x *PrintDialog) Print(ParentVar *Window, SetupVar *PrintSetup, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { var CallbackVarRef uintptr if CallbackVar != nil { CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar)) if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok { CallbackVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) { cbFn := *CallbackVar cbFn(arg0, arg1, arg2) } CallbackVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar) } } xPrintDialogPrint(x.GoPointer(), ParentVar.GoPointer(), SetupVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar) } var xPrintDialogPrintFile func(uintptr, uintptr, *PrintSetup, uintptr, uintptr, uintptr, uintptr) // This function prints a file. // // If you pass `NULL` as @setup, then this method will present a print dialog. // Otherwise, it will attempt to print directly, without user interaction. func (x *PrintDialog) PrintFile(ParentVar *Window, SetupVar *PrintSetup, FileVar gio.File, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { var CallbackVarRef uintptr if CallbackVar != nil { CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar)) if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok { CallbackVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) { cbFn := *CallbackVar cbFn(arg0, arg1, arg2) } CallbackVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar) } } xPrintDialogPrintFile(x.GoPointer(), ParentVar.GoPointer(), SetupVar, FileVar.GoPointer(), CancellableVar.GoPointer(), CallbackVarRef, UserDataVar) } var xPrintDialogPrintFileFinish func(uintptr, uintptr, **glib.Error) bool // Finishes the [method@Gtk.PrintDialog.print_file] call and // returns the results. // // Note that this function returns a [error@Gtk.DialogError.DISMISSED] // error if the user cancels the dialog. func (x *PrintDialog) PrintFileFinish(ResultVar gio.AsyncResult) (bool, error) { var cerr *glib.Error cret := xPrintDialogPrintFileFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr) if cerr == nil { return cret, nil } return cret, cerr } var xPrintDialogPrintFinish func(uintptr, uintptr, **glib.Error) uintptr // Finishes the [method@Gtk.PrintDialog.print] call and // returns the results. // // If the call was successful, the content to be printed should be // written to the returned output stream. Otherwise, `NULL` is returned. // // The overall results of the print operation will be returned in the // [method@Gio.OutputStream.close] call, so if you are interested in the // results, you need to explicitly close the output stream (it will be // closed automatically if you just unref it). Be aware that the close // call may not be instant as it operation will for the printer to finish // printing. // // Note that this function returns a [error@Gtk.DialogError.DISMISSED] // error if the user cancels the dialog. func (x *PrintDialog) PrintFinish(ResultVar gio.AsyncResult) (*gio.OutputStream, error) { var cls *gio.OutputStream var cerr *glib.Error cret := xPrintDialogPrintFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr) if cret == 0 { return nil, cerr } cls = &gio.OutputStream{} cls.Ptr = cret if cerr == nil { return cls, nil } return cls, cerr } var xPrintDialogSetAcceptLabel func(uintptr, string) // Sets the label that will be shown on the // accept button of the print dialog shown for // [method@Gtk.PrintDialog.setup]. func (x *PrintDialog) SetAcceptLabel(AcceptLabelVar string) { xPrintDialogSetAcceptLabel(x.GoPointer(), AcceptLabelVar) } var xPrintDialogSetModal func(uintptr, bool) // Sets whether the print dialog blocks // interaction with the parent window while // it is presented. func (x *PrintDialog) SetModal(ModalVar bool) { xPrintDialogSetModal(x.GoPointer(), ModalVar) } var xPrintDialogSetPageSetup func(uintptr, uintptr) // Set the page setup for the print dialog. func (x *PrintDialog) SetPageSetup(PageSetupVar *PageSetup) { xPrintDialogSetPageSetup(x.GoPointer(), PageSetupVar.GoPointer()) } var xPrintDialogSetPrintSettings func(uintptr, uintptr) // Sets the print settings for the print dialog. func (x *PrintDialog) SetPrintSettings(PrintSettingsVar *PrintSettings) { xPrintDialogSetPrintSettings(x.GoPointer(), PrintSettingsVar.GoPointer()) } var xPrintDialogSetTitle func(uintptr, string) // Sets the title that will be shown on the print dialog. func (x *PrintDialog) SetTitle(TitleVar string) { xPrintDialogSetTitle(x.GoPointer(), TitleVar) } var xPrintDialogSetup func(uintptr, uintptr, uintptr, uintptr, uintptr) // This function presents a print dialog to let the user select a printer, // and set up print settings and page setup. // // The @callback will be called when the dialog is dismissed. // The obtained [struct@Gtk.PrintSetup] can then be passed // to [method@Gtk.PrintDialog.print] or [method@Gtk.PrintDialog.print_file]. // // One possible use for this method is to have the user select a printer, // then show a page setup UI in the application (e.g. to arrange images // on a page), then call [method@Gtk.PrintDialog.print] on @self // to do the printing without further user interaction. func (x *PrintDialog) Setup(ParentVar *Window, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) { var CallbackVarRef uintptr if CallbackVar != nil { CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar)) if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok { CallbackVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) { cbFn := *CallbackVar cbFn(arg0, arg1, arg2) } CallbackVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar) } } xPrintDialogSetup(x.GoPointer(), ParentVar.GoPointer(), CancellableVar.GoPointer(), CallbackVarRef, UserDataVar) } var xPrintDialogSetupFinish func(uintptr, uintptr, **glib.Error) *PrintSetup // Finishes the [method@Gtk.PrintDialog.setup] call. // // If the call was successful, it returns a [struct@Gtk.PrintSetup] // which contains the print settings and page setup information that // will be used to print. // // Note that this function returns a [error@Gtk.DialogError.DISMISSED] // error if the user cancels the dialog. func (x *PrintDialog) SetupFinish(ResultVar gio.AsyncResult) (*PrintSetup, error) { var cerr *glib.Error cret := xPrintDialogSetupFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr) if cerr == nil { return cret, nil } return cret, cerr } func (c *PrintDialog) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *PrintDialog) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // SetPropertyAcceptLabel sets the "accept-label" property. // A label that may be shown on the accept button of a print dialog // that is presented by [method@Gtk.PrintDialog.setup]. func (x *PrintDialog) SetPropertyAcceptLabel(value string) { var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) x.SetProperty("accept-label", &v) } // GetPropertyAcceptLabel gets the "accept-label" property. // A label that may be shown on the accept button of a print dialog // that is presented by [method@Gtk.PrintDialog.setup]. func (x *PrintDialog) GetPropertyAcceptLabel() string { var v gobject.Value x.GetProperty("accept-label", &v) return v.GetString() } // SetPropertyModal sets the "modal" property. // Whether the print dialog is modal. func (x *PrintDialog) 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 print dialog is modal. func (x *PrintDialog) GetPropertyModal() bool { var v gobject.Value x.GetProperty("modal", &v) return v.GetBoolean() } // SetPropertyTitle sets the "title" property. // A title that may be shown on the print dialog that is // presented by [method@Gtk.PrintDialog.setup]. func (x *PrintDialog) SetPropertyTitle(value string) { var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) x.SetProperty("title", &v) } // GetPropertyTitle gets the "title" property. // A title that may be shown on the print dialog that is // presented by [method@Gtk.PrintDialog.setup]. func (x *PrintDialog) GetPropertyTitle() string { var v gobject.Value x.GetProperty("title", &v) return v.GetString() } 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(&xPrintSetupGLibType, libs, "gtk_print_setup_get_type") core.PuregoSafeRegister(&xPrintSetupGetPageSetup, libs, "gtk_print_setup_get_page_setup") core.PuregoSafeRegister(&xPrintSetupGetPrintSettings, libs, "gtk_print_setup_get_print_settings") core.PuregoSafeRegister(&xPrintSetupRef, libs, "gtk_print_setup_ref") core.PuregoSafeRegister(&xPrintSetupUnref, libs, "gtk_print_setup_unref") core.PuregoSafeRegister(&xPrintDialogGLibType, libs, "gtk_print_dialog_get_type") core.PuregoSafeRegister(&xNewPrintDialog, libs, "gtk_print_dialog_new") core.PuregoSafeRegister(&xPrintDialogGetAcceptLabel, libs, "gtk_print_dialog_get_accept_label") core.PuregoSafeRegister(&xPrintDialogGetModal, libs, "gtk_print_dialog_get_modal") core.PuregoSafeRegister(&xPrintDialogGetPageSetup, libs, "gtk_print_dialog_get_page_setup") core.PuregoSafeRegister(&xPrintDialogGetPrintSettings, libs, "gtk_print_dialog_get_print_settings") core.PuregoSafeRegister(&xPrintDialogGetTitle, libs, "gtk_print_dialog_get_title") core.PuregoSafeRegister(&xPrintDialogPrint, libs, "gtk_print_dialog_print") core.PuregoSafeRegister(&xPrintDialogPrintFile, libs, "gtk_print_dialog_print_file") core.PuregoSafeRegister(&xPrintDialogPrintFileFinish, libs, "gtk_print_dialog_print_file_finish") core.PuregoSafeRegister(&xPrintDialogPrintFinish, libs, "gtk_print_dialog_print_finish") core.PuregoSafeRegister(&xPrintDialogSetAcceptLabel, libs, "gtk_print_dialog_set_accept_label") core.PuregoSafeRegister(&xPrintDialogSetModal, libs, "gtk_print_dialog_set_modal") core.PuregoSafeRegister(&xPrintDialogSetPageSetup, libs, "gtk_print_dialog_set_page_setup") core.PuregoSafeRegister(&xPrintDialogSetPrintSettings, libs, "gtk_print_dialog_set_print_settings") core.PuregoSafeRegister(&xPrintDialogSetTitle, libs, "gtk_print_dialog_set_title") core.PuregoSafeRegister(&xPrintDialogSetup, libs, "gtk_print_dialog_setup") core.PuregoSafeRegister(&xPrintDialogSetupFinish, libs, "gtk_print_dialog_setup_finish") }