1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/glib"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16// The type of function that is passed to
17// gtk_print_run_page_setup_dialog_async().
18//
19// This function will be called when the page setup dialog
20// is dismissed, and also serves as destroy notify for @data.
21type PageSetupDoneFunc func(uintptr, uintptr)
22
23type PrintOperationClass struct {
24 _ structs.HostLayout
25
26 ParentClass gobject.ObjectClass
27
28 xDone uintptr
29
30 xBeginPrint uintptr
31
32 xPaginate uintptr
33
34 xRequestPageSetup uintptr
35
36 xDrawPage uintptr
37
38 xEndPrint uintptr
39
40 xStatusChanged uintptr
41
42 xCreateCustomWidget uintptr
43
44 xCustomWidgetApply uintptr
45
46 xPreview uintptr
47
48 xUpdateCustomWidget uintptr
49
50 Padding [8]uintptr
51}
52
53func (x *PrintOperationClass) GoPointer() uintptr {
54 return uintptr(unsafe.Pointer(x))
55}
56
57// OverrideDone sets the "done" callback function.
58// Signal emitted when the print operation run has finished
59//
60// doing everything required for printing.
61func (x *PrintOperationClass) OverrideDone(cb func(*PrintOperation, PrintOperationResult)) {
62 if cb == nil {
63 x.xDone = 0
64 } else {
65 x.xDone = purego.NewCallback(func(OperationVarp uintptr, ResultVarp PrintOperationResult) {
66 cb(PrintOperationNewFromInternalPtr(OperationVarp), ResultVarp)
67 })
68 }
69}
70
71// GetDone gets the "done" callback function.
72// Signal emitted when the print operation run has finished
73//
74// doing everything required for printing.
75func (x *PrintOperationClass) GetDone() func(*PrintOperation, PrintOperationResult) {
76 if x.xDone == 0 {
77 return nil
78 }
79 var rawCallback func(OperationVarp uintptr, ResultVarp PrintOperationResult)
80 purego.RegisterFunc(&rawCallback, x.xDone)
81 return func(OperationVar *PrintOperation, ResultVar PrintOperationResult) {
82 rawCallback(OperationVar.GoPointer(), ResultVar)
83 }
84}
85
86// OverrideBeginPrint sets the "begin_print" callback function.
87// Signal emitted after the user has finished changing
88//
89// print settings in the dialog, before the actual rendering starts.
90func (x *PrintOperationClass) OverrideBeginPrint(cb func(*PrintOperation, *PrintContext)) {
91 if cb == nil {
92 x.xBeginPrint = 0
93 } else {
94 x.xBeginPrint = purego.NewCallback(func(OperationVarp uintptr, ContextVarp uintptr) {
95 cb(PrintOperationNewFromInternalPtr(OperationVarp), PrintContextNewFromInternalPtr(ContextVarp))
96 })
97 }
98}
99
100// GetBeginPrint gets the "begin_print" callback function.
101// Signal emitted after the user has finished changing
102//
103// print settings in the dialog, before the actual rendering starts.
104func (x *PrintOperationClass) GetBeginPrint() func(*PrintOperation, *PrintContext) {
105 if x.xBeginPrint == 0 {
106 return nil
107 }
108 var rawCallback func(OperationVarp uintptr, ContextVarp uintptr)
109 purego.RegisterFunc(&rawCallback, x.xBeginPrint)
110 return func(OperationVar *PrintOperation, ContextVar *PrintContext) {
111 rawCallback(OperationVar.GoPointer(), ContextVar.GoPointer())
112 }
113}
114
115// OverridePaginate sets the "paginate" callback function.
116// Signal emitted after the “begin-print” signal, but
117//
118// before the actual rendering starts.
119func (x *PrintOperationClass) OverridePaginate(cb func(*PrintOperation, *PrintContext) bool) {
120 if cb == nil {
121 x.xPaginate = 0
122 } else {
123 x.xPaginate = purego.NewCallback(func(OperationVarp uintptr, ContextVarp uintptr) bool {
124 return cb(PrintOperationNewFromInternalPtr(OperationVarp), PrintContextNewFromInternalPtr(ContextVarp))
125 })
126 }
127}
128
129// GetPaginate gets the "paginate" callback function.
130// Signal emitted after the “begin-print” signal, but
131//
132// before the actual rendering starts.
133func (x *PrintOperationClass) GetPaginate() func(*PrintOperation, *PrintContext) bool {
134 if x.xPaginate == 0 {
135 return nil
136 }
137 var rawCallback func(OperationVarp uintptr, ContextVarp uintptr) bool
138 purego.RegisterFunc(&rawCallback, x.xPaginate)
139 return func(OperationVar *PrintOperation, ContextVar *PrintContext) bool {
140 return rawCallback(OperationVar.GoPointer(), ContextVar.GoPointer())
141 }
142}
143
144// OverrideRequestPageSetup sets the "request_page_setup" callback function.
145// Emitted once for every page that is printed,
146//
147// to give the application a chance to modify the page setup.
148func (x *PrintOperationClass) OverrideRequestPageSetup(cb func(*PrintOperation, *PrintContext, int, *PageSetup)) {
149 if cb == nil {
150 x.xRequestPageSetup = 0
151 } else {
152 x.xRequestPageSetup = purego.NewCallback(func(OperationVarp uintptr, ContextVarp uintptr, PageNrVarp int, SetupVarp uintptr) {
153 cb(PrintOperationNewFromInternalPtr(OperationVarp), PrintContextNewFromInternalPtr(ContextVarp), PageNrVarp, PageSetupNewFromInternalPtr(SetupVarp))
154 })
155 }
156}
157
158// GetRequestPageSetup gets the "request_page_setup" callback function.
159// Emitted once for every page that is printed,
160//
161// to give the application a chance to modify the page setup.
162func (x *PrintOperationClass) GetRequestPageSetup() func(*PrintOperation, *PrintContext, int, *PageSetup) {
163 if x.xRequestPageSetup == 0 {
164 return nil
165 }
166 var rawCallback func(OperationVarp uintptr, ContextVarp uintptr, PageNrVarp int, SetupVarp uintptr)
167 purego.RegisterFunc(&rawCallback, x.xRequestPageSetup)
168 return func(OperationVar *PrintOperation, ContextVar *PrintContext, PageNrVar int, SetupVar *PageSetup) {
169 rawCallback(OperationVar.GoPointer(), ContextVar.GoPointer(), PageNrVar, SetupVar.GoPointer())
170 }
171}
172
173// OverrideDrawPage sets the "draw_page" callback function.
174// Signal emitted for every page that is printed.
175func (x *PrintOperationClass) OverrideDrawPage(cb func(*PrintOperation, *PrintContext, int)) {
176 if cb == nil {
177 x.xDrawPage = 0
178 } else {
179 x.xDrawPage = purego.NewCallback(func(OperationVarp uintptr, ContextVarp uintptr, PageNrVarp int) {
180 cb(PrintOperationNewFromInternalPtr(OperationVarp), PrintContextNewFromInternalPtr(ContextVarp), PageNrVarp)
181 })
182 }
183}
184
185// GetDrawPage gets the "draw_page" callback function.
186// Signal emitted for every page that is printed.
187func (x *PrintOperationClass) GetDrawPage() func(*PrintOperation, *PrintContext, int) {
188 if x.xDrawPage == 0 {
189 return nil
190 }
191 var rawCallback func(OperationVarp uintptr, ContextVarp uintptr, PageNrVarp int)
192 purego.RegisterFunc(&rawCallback, x.xDrawPage)
193 return func(OperationVar *PrintOperation, ContextVar *PrintContext, PageNrVar int) {
194 rawCallback(OperationVar.GoPointer(), ContextVar.GoPointer(), PageNrVar)
195 }
196}
197
198// OverrideEndPrint sets the "end_print" callback function.
199// Signal emitted after all pages have been rendered.
200func (x *PrintOperationClass) OverrideEndPrint(cb func(*PrintOperation, *PrintContext)) {
201 if cb == nil {
202 x.xEndPrint = 0
203 } else {
204 x.xEndPrint = purego.NewCallback(func(OperationVarp uintptr, ContextVarp uintptr) {
205 cb(PrintOperationNewFromInternalPtr(OperationVarp), PrintContextNewFromInternalPtr(ContextVarp))
206 })
207 }
208}
209
210// GetEndPrint gets the "end_print" callback function.
211// Signal emitted after all pages have been rendered.
212func (x *PrintOperationClass) GetEndPrint() func(*PrintOperation, *PrintContext) {
213 if x.xEndPrint == 0 {
214 return nil
215 }
216 var rawCallback func(OperationVarp uintptr, ContextVarp uintptr)
217 purego.RegisterFunc(&rawCallback, x.xEndPrint)
218 return func(OperationVar *PrintOperation, ContextVar *PrintContext) {
219 rawCallback(OperationVar.GoPointer(), ContextVar.GoPointer())
220 }
221}
222
223// OverrideStatusChanged sets the "status_changed" callback function.
224// Emitted at between the various phases of the print
225//
226// operation.
227func (x *PrintOperationClass) OverrideStatusChanged(cb func(*PrintOperation)) {
228 if cb == nil {
229 x.xStatusChanged = 0
230 } else {
231 x.xStatusChanged = purego.NewCallback(func(OperationVarp uintptr) {
232 cb(PrintOperationNewFromInternalPtr(OperationVarp))
233 })
234 }
235}
236
237// GetStatusChanged gets the "status_changed" callback function.
238// Emitted at between the various phases of the print
239//
240// operation.
241func (x *PrintOperationClass) GetStatusChanged() func(*PrintOperation) {
242 if x.xStatusChanged == 0 {
243 return nil
244 }
245 var rawCallback func(OperationVarp uintptr)
246 purego.RegisterFunc(&rawCallback, x.xStatusChanged)
247 return func(OperationVar *PrintOperation) {
248 rawCallback(OperationVar.GoPointer())
249 }
250}
251
252// OverrideCreateCustomWidget sets the "create_custom_widget" callback function.
253// Signal emitted when displaying the print dialog.
254func (x *PrintOperationClass) OverrideCreateCustomWidget(cb func(*PrintOperation) *Widget) {
255 if cb == nil {
256 x.xCreateCustomWidget = 0
257 } else {
258 x.xCreateCustomWidget = purego.NewCallback(func(OperationVarp uintptr) uintptr {
259 ret := cb(PrintOperationNewFromInternalPtr(OperationVarp))
260 if ret == nil {
261 return 0
262 }
263 return ret.GoPointer()
264 })
265 }
266}
267
268// GetCreateCustomWidget gets the "create_custom_widget" callback function.
269// Signal emitted when displaying the print dialog.
270func (x *PrintOperationClass) GetCreateCustomWidget() func(*PrintOperation) *Widget {
271 if x.xCreateCustomWidget == 0 {
272 return nil
273 }
274 var rawCallback func(OperationVarp uintptr) uintptr
275 purego.RegisterFunc(&rawCallback, x.xCreateCustomWidget)
276 return func(OperationVar *PrintOperation) *Widget {
277 rawRet := rawCallback(OperationVar.GoPointer())
278 if rawRet == 0 {
279 return nil
280 }
281 ret := &Widget{}
282 ret.Ptr = rawRet
283 return ret
284 }
285}
286
287// OverrideCustomWidgetApply sets the "custom_widget_apply" callback function.
288// Signal emitted right before “begin-print” if
289//
290// you added a custom widget in the “create-custom-widget” handler.
291func (x *PrintOperationClass) OverrideCustomWidgetApply(cb func(*PrintOperation, *Widget)) {
292 if cb == nil {
293 x.xCustomWidgetApply = 0
294 } else {
295 x.xCustomWidgetApply = purego.NewCallback(func(OperationVarp uintptr, WidgetVarp uintptr) {
296 cb(PrintOperationNewFromInternalPtr(OperationVarp), WidgetNewFromInternalPtr(WidgetVarp))
297 })
298 }
299}
300
301// GetCustomWidgetApply gets the "custom_widget_apply" callback function.
302// Signal emitted right before “begin-print” if
303//
304// you added a custom widget in the “create-custom-widget” handler.
305func (x *PrintOperationClass) GetCustomWidgetApply() func(*PrintOperation, *Widget) {
306 if x.xCustomWidgetApply == 0 {
307 return nil
308 }
309 var rawCallback func(OperationVarp uintptr, WidgetVarp uintptr)
310 purego.RegisterFunc(&rawCallback, x.xCustomWidgetApply)
311 return func(OperationVar *PrintOperation, WidgetVar *Widget) {
312 rawCallback(OperationVar.GoPointer(), WidgetVar.GoPointer())
313 }
314}
315
316// OverridePreview sets the "preview" callback function.
317// Signal emitted when a preview is requested from the
318//
319// native dialog.
320func (x *PrintOperationClass) OverridePreview(cb func(*PrintOperation, PrintOperationPreview, *PrintContext, *Window) bool) {
321 if cb == nil {
322 x.xPreview = 0
323 } else {
324 x.xPreview = purego.NewCallback(func(OperationVarp uintptr, PreviewVarp uintptr, ContextVarp uintptr, ParentVarp uintptr) bool {
325 return cb(PrintOperationNewFromInternalPtr(OperationVarp), &PrintOperationPreviewBase{Ptr: PreviewVarp}, PrintContextNewFromInternalPtr(ContextVarp), WindowNewFromInternalPtr(ParentVarp))
326 })
327 }
328}
329
330// GetPreview gets the "preview" callback function.
331// Signal emitted when a preview is requested from the
332//
333// native dialog.
334func (x *PrintOperationClass) GetPreview() func(*PrintOperation, PrintOperationPreview, *PrintContext, *Window) bool {
335 if x.xPreview == 0 {
336 return nil
337 }
338 var rawCallback func(OperationVarp uintptr, PreviewVarp uintptr, ContextVarp uintptr, ParentVarp uintptr) bool
339 purego.RegisterFunc(&rawCallback, x.xPreview)
340 return func(OperationVar *PrintOperation, PreviewVar PrintOperationPreview, ContextVar *PrintContext, ParentVar *Window) bool {
341 return rawCallback(OperationVar.GoPointer(), PreviewVar.GoPointer(), ContextVar.GoPointer(), ParentVar.GoPointer())
342 }
343}
344
345// OverrideUpdateCustomWidget sets the "update_custom_widget" callback function.
346// Emitted after change of selected printer.
347func (x *PrintOperationClass) OverrideUpdateCustomWidget(cb func(*PrintOperation, *Widget, *PageSetup, *PrintSettings)) {
348 if cb == nil {
349 x.xUpdateCustomWidget = 0
350 } else {
351 x.xUpdateCustomWidget = purego.NewCallback(func(OperationVarp uintptr, WidgetVarp uintptr, SetupVarp uintptr, SettingsVarp uintptr) {
352 cb(PrintOperationNewFromInternalPtr(OperationVarp), WidgetNewFromInternalPtr(WidgetVarp), PageSetupNewFromInternalPtr(SetupVarp), PrintSettingsNewFromInternalPtr(SettingsVarp))
353 })
354 }
355}
356
357// GetUpdateCustomWidget gets the "update_custom_widget" callback function.
358// Emitted after change of selected printer.
359func (x *PrintOperationClass) GetUpdateCustomWidget() func(*PrintOperation, *Widget, *PageSetup, *PrintSettings) {
360 if x.xUpdateCustomWidget == 0 {
361 return nil
362 }
363 var rawCallback func(OperationVarp uintptr, WidgetVarp uintptr, SetupVarp uintptr, SettingsVarp uintptr)
364 purego.RegisterFunc(&rawCallback, x.xUpdateCustomWidget)
365 return func(OperationVar *PrintOperation, WidgetVar *Widget, SetupVar *PageSetup, SettingsVar *PrintSettings) {
366 rawCallback(OperationVar.GoPointer(), WidgetVar.GoPointer(), SetupVar.GoPointer(), SettingsVar.GoPointer())
367 }
368}
369
370type PrintOperationPrivate struct {
371 _ structs.HostLayout
372}
373
374func (x *PrintOperationPrivate) GoPointer() uintptr {
375 return uintptr(unsafe.Pointer(x))
376}
377
378// Error codes that identify various errors that can occur while
379// using the GTK printing support.
380type PrintError int
381
382var xPrintErrorGLibType func() types.GType
383
384func PrintErrorGLibType() types.GType {
385 return xPrintErrorGLibType()
386}
387
388const (
389
390 // An unspecified error occurred.
391 PrintErrorGeneralValue PrintError = 0
392 // An internal error occurred.
393 PrintErrorInternalErrorValue PrintError = 1
394 // A memory allocation failed.
395 PrintErrorNomemValue PrintError = 2
396 // An error occurred while loading a page setup
397 // or paper size from a key file.
398 PrintErrorInvalidFileValue PrintError = 3
399)
400
401// Determines what action the print operation should perform.
402//
403// A parameter of this typs is passed to [method@Gtk.PrintOperation.run].
404type PrintOperationAction int
405
406var xPrintOperationActionGLibType func() types.GType
407
408func PrintOperationActionGLibType() types.GType {
409 return xPrintOperationActionGLibType()
410}
411
412const (
413
414 // Show the print dialog.
415 PrintOperationActionPrintDialogValue PrintOperationAction = 0
416 // Start to print without showing
417 // the print dialog, based on the current print settings, if possible.
418 // Depending on the platform, a print dialog might appear anyway.
419 PrintOperationActionPrintValue PrintOperationAction = 1
420 // Show the print preview.
421 PrintOperationActionPreviewValue PrintOperationAction = 2
422 // Export to a file. This requires
423 // the export-filename property to be set.
424 PrintOperationActionExportValue PrintOperationAction = 3
425)
426
427// The result of a print operation.
428//
429// A value of this type is returned by [method@Gtk.PrintOperation.run].
430type PrintOperationResult int
431
432var xPrintOperationResultGLibType func() types.GType
433
434func PrintOperationResultGLibType() types.GType {
435 return xPrintOperationResultGLibType()
436}
437
438const (
439
440 // An error has occurred.
441 PrintOperationResultErrorValue PrintOperationResult = 0
442 // The print settings should be stored.
443 PrintOperationResultApplyValue PrintOperationResult = 1
444 // The print operation has been canceled,
445 // the print settings should not be stored.
446 PrintOperationResultCancelValue PrintOperationResult = 2
447 // The print operation is not complete
448 // yet. This value will only be returned when running asynchronously.
449 PrintOperationResultInProgressValue PrintOperationResult = 3
450)
451
452// The status gives a rough indication of the completion of a running
453// print operation.
454type PrintStatus int
455
456var xPrintStatusGLibType func() types.GType
457
458func PrintStatusGLibType() types.GType {
459 return xPrintStatusGLibType()
460}
461
462const (
463
464 // The printing has not started yet; this
465 // status is set initially, and while the print dialog is shown.
466 PrintStatusInitialValue PrintStatus = 0
467 // This status is set while the begin-print
468 // signal is emitted and during pagination.
469 PrintStatusPreparingValue PrintStatus = 1
470 // This status is set while the
471 // pages are being rendered.
472 PrintStatusGeneratingDataValue PrintStatus = 2
473 // The print job is being sent off to the
474 // printer.
475 PrintStatusSendingDataValue PrintStatus = 3
476 // The print job has been sent to the printer,
477 // but is not printed for some reason, e.g. the printer may be stopped.
478 PrintStatusPendingValue PrintStatus = 4
479 // Some problem has occurred during
480 // printing, e.g. a paper jam.
481 PrintStatusPendingIssueValue PrintStatus = 5
482 // The printer is processing the print job.
483 PrintStatusPrintingValue PrintStatus = 6
484 // The printing has been completed successfully.
485 PrintStatusFinishedValue PrintStatus = 7
486 // The printing has been aborted.
487 PrintStatusFinishedAbortedValue PrintStatus = 8
488)
489
490var xPrintErrorQuark func() glib.Quark
491
492// Registers an error quark for `GtkPrintOperation` if necessary.
493func PrintErrorQuark() glib.Quark {
494
495 cret := xPrintErrorQuark()
496 return cret
497}
498
499var xPrintRunPageSetupDialog func(uintptr, uintptr, uintptr) uintptr
500
501// Runs a page setup dialog, letting the user modify the values from @page_setup.
502//
503// If the user cancels the dialog, the returned `GtkPageSetup` is identical
504// to the passed in @page_setup, otherwise it contains the modifications
505// done in the dialog.
506//
507// Note that this function may use a recursive mainloop to show the page
508// setup dialog. See [func@Gtk.print_run_page_setup_dialog_async] if this is
509// a problem.
510func PrintRunPageSetupDialog(ParentVar *Window, PageSetupVar *PageSetup, SettingsVar *PrintSettings) *PageSetup {
511 var cls *PageSetup
512
513 cret := xPrintRunPageSetupDialog(ParentVar.GoPointer(), PageSetupVar.GoPointer(), SettingsVar.GoPointer())
514
515 if cret == 0 {
516 return nil
517 }
518 cls = &PageSetup{}
519 cls.Ptr = cret
520 return cls
521}
522
523var xPrintRunPageSetupDialogAsync func(uintptr, uintptr, uintptr, uintptr, uintptr)
524
525// Runs a page setup dialog, letting the user modify the values from @page_setup.
526//
527// In contrast to [func@Gtk.print_run_page_setup_dialog], this function returns
528// after showing the page setup dialog on platforms that support this, and calls
529// @done_cb from a signal handler for the ::response signal of the dialog.
530func PrintRunPageSetupDialogAsync(ParentVar *Window, PageSetupVar *PageSetup, SettingsVar *PrintSettings, DoneCbVar *PageSetupDoneFunc, DataVar uintptr) {
531
532 var DoneCbVarRef uintptr
533 if DoneCbVar != nil {
534 DoneCbVarPtr := uintptr(unsafe.Pointer(DoneCbVar))
535 if cbRefPtr, ok := glib.GetCallback(DoneCbVarPtr); ok {
536 DoneCbVarRef = cbRefPtr
537 } else {
538 fcb := func(arg0 uintptr, arg1 uintptr) {
539 cbFn := *DoneCbVar
540 cbFn(arg0, arg1)
541 }
542 DoneCbVarRef = purego.NewCallback(fcb)
543 glib.SaveCallbackWithClosure(DoneCbVarPtr, DoneCbVarRef, DoneCbVar)
544 }
545 }
546
547 xPrintRunPageSetupDialogAsync(ParentVar.GoPointer(), PageSetupVar.GoPointer(), SettingsVar.GoPointer(), DoneCbVarRef, DataVar)
548
549}
550
551// High-level, portable printing API.
552//
553// It looks a bit different than other GTK dialogs such as the
554// `GtkFileChooser`, since some platforms don’t expose enough
555// infrastructure to implement a good print dialog. On such
556// platforms, `GtkPrintOperation` uses the native print dialog.
557// On platforms which do not provide a native print dialog, GTK
558// uses its own, see [class@Gtk.PrintUnixDialog].
559//
560// The typical way to use the high-level printing API is to create
561// a `GtkPrintOperation` object with [ctor@Gtk.PrintOperation.new]
562// when the user selects to print. Then you set some properties on it,
563// e.g. the page size, any [class@Gtk.PrintSettings] from previous print
564// operations, the number of pages, the current page, etc.
565//
566// Then you start the print operation by calling [method@Gtk.PrintOperation.run].
567// It will then show a dialog, let the user select a printer and options.
568// When the user finished the dialog, various signals will be emitted on
569// the `GtkPrintOperation`, the main one being
570// [signal@Gtk.PrintOperation::draw-page], which you are supposed to handle
571// and render the page on the provided [class@Gtk.PrintContext] using Cairo.
572//
573// # The high-level printing API
574//
575// ```c
576// static GtkPrintSettings *settings = NULL;
577//
578// static void
579// do_print (void)
580//
581// {
582// GtkPrintOperation *print;
583// GtkPrintOperationResult res;
584//
585// print = gtk_print_operation_new ();
586//
587// if (settings != NULL)
588// gtk_print_operation_set_print_settings (print, settings);
589//
590// g_signal_connect (print, "begin_print", G_CALLBACK (begin_print), NULL);
591// g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
592//
593// res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
594// GTK_WINDOW (main_window), NULL);
595//
596// if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
597// {
598// if (settings != NULL)
599// g_object_unref (settings);
600// settings = g_object_ref (gtk_print_operation_get_print_settings (print));
601// }
602//
603// g_object_unref (print);
604// }
605//
606// ```
607//
608// By default `GtkPrintOperation` uses an external application to do
609// print preview. To implement a custom print preview, an application
610// must connect to the preview signal. The functions
611// [method@Gtk.PrintOperationPreview.render_page],
612// [method@Gtk.PrintOperationPreview.end_preview] and
613// [method@Gtk.PrintOperationPreview.is_selected]
614// are useful when implementing a print preview.
615type PrintOperation struct {
616 gobject.Object
617}
618
619var xPrintOperationGLibType func() types.GType
620
621func PrintOperationGLibType() types.GType {
622 return xPrintOperationGLibType()
623}
624
625func PrintOperationNewFromInternalPtr(ptr uintptr) *PrintOperation {
626 cls := &PrintOperation{}
627 cls.Ptr = ptr
628 return cls
629}
630
631var xNewPrintOperation func() uintptr
632
633// Creates a new `GtkPrintOperation`.
634func NewPrintOperation() *PrintOperation {
635 var cls *PrintOperation
636
637 cret := xNewPrintOperation()
638
639 if cret == 0 {
640 return nil
641 }
642 cls = &PrintOperation{}
643 cls.Ptr = cret
644 return cls
645}
646
647var xPrintOperationCancel func(uintptr)
648
649// Cancels a running print operation.
650//
651// This function may be called from a [signal@Gtk.PrintOperation::begin-print],
652// [signal@Gtk.PrintOperation::paginate] or [signal@Gtk.PrintOperation::draw-page]
653// signal handler to stop the currently running print operation.
654func (x *PrintOperation) Cancel() {
655
656 xPrintOperationCancel(x.GoPointer())
657
658}
659
660var xPrintOperationDrawPageFinish func(uintptr)
661
662// Signal that drawing of particular page is complete.
663//
664// It is called after completion of page drawing (e.g. drawing
665// in another thread). If [method@Gtk.PrintOperation.set_defer_drawing]
666// was called before, then this function has to be called by application.
667// Otherwise it is called by GTK itself.
668func (x *PrintOperation) DrawPageFinish() {
669
670 xPrintOperationDrawPageFinish(x.GoPointer())
671
672}
673
674var xPrintOperationGetDefaultPageSetup func(uintptr) uintptr
675
676// Returns the default page setup.
677func (x *PrintOperation) GetDefaultPageSetup() *PageSetup {
678 var cls *PageSetup
679
680 cret := xPrintOperationGetDefaultPageSetup(x.GoPointer())
681
682 if cret == 0 {
683 return nil
684 }
685 gobject.IncreaseRef(cret)
686 cls = &PageSetup{}
687 cls.Ptr = cret
688 return cls
689}
690
691var xPrintOperationGetEmbedPageSetup func(uintptr) bool
692
693// Gets whether page setup selection combos are embedded
694func (x *PrintOperation) GetEmbedPageSetup() bool {
695
696 cret := xPrintOperationGetEmbedPageSetup(x.GoPointer())
697 return cret
698}
699
700var xPrintOperationGetError func(uintptr)
701
702// Call this when the result of a print operation is
703// %GTK_PRINT_OPERATION_RESULT_ERROR.
704//
705// It can be called either after [method@Gtk.PrintOperation.run]
706// returns, or in the [signal@Gtk.PrintOperation::done] signal
707// handler.
708//
709// The returned `GError` will contain more details on what went wrong.
710func (x *PrintOperation) GetError() error {
711 var cerr *glib.Error
712
713 xPrintOperationGetError(x.GoPointer())
714 if cerr == nil {
715 return nil
716 }
717 return cerr
718
719}
720
721var xPrintOperationGetHasSelection func(uintptr) bool
722
723// Gets whether there is a selection.
724func (x *PrintOperation) GetHasSelection() bool {
725
726 cret := xPrintOperationGetHasSelection(x.GoPointer())
727 return cret
728}
729
730var xPrintOperationGetNPagesToPrint func(uintptr) int
731
732// Returns the number of pages that will be printed.
733//
734// Note that this value is set during print preparation phase
735// (%GTK_PRINT_STATUS_PREPARING), so this function should never be
736// called before the data generation phase (%GTK_PRINT_STATUS_GENERATING_DATA).
737// You can connect to the [signal@Gtk.PrintOperation::status-changed]
738// signal and call gtk_print_operation_get_n_pages_to_print() when
739// print status is %GTK_PRINT_STATUS_GENERATING_DATA.
740//
741// This is typically used to track the progress of print operation.
742func (x *PrintOperation) GetNPagesToPrint() int {
743
744 cret := xPrintOperationGetNPagesToPrint(x.GoPointer())
745 return cret
746}
747
748var xPrintOperationGetPrintSettings func(uintptr) uintptr
749
750// Returns the current print settings.
751//
752// Note that the return value is %NULL until either
753// [method@Gtk.PrintOperation.set_print_settings] or
754// [method@Gtk.PrintOperation.run] have been called.
755func (x *PrintOperation) GetPrintSettings() *PrintSettings {
756 var cls *PrintSettings
757
758 cret := xPrintOperationGetPrintSettings(x.GoPointer())
759
760 if cret == 0 {
761 return nil
762 }
763 gobject.IncreaseRef(cret)
764 cls = &PrintSettings{}
765 cls.Ptr = cret
766 return cls
767}
768
769var xPrintOperationGetStatus func(uintptr) PrintStatus
770
771// Returns the status of the print operation.
772//
773// Also see [method@Gtk.PrintOperation.get_status_string].
774func (x *PrintOperation) GetStatus() PrintStatus {
775
776 cret := xPrintOperationGetStatus(x.GoPointer())
777 return cret
778}
779
780var xPrintOperationGetStatusString func(uintptr) string
781
782// Returns a string representation of the status of the
783// print operation.
784//
785// The string is translated and suitable for displaying
786// the print status e.g. in a `GtkStatusbar`.
787//
788// Use [method@Gtk.PrintOperation.get_status] to obtain
789// a status value that is suitable for programmatic use.
790func (x *PrintOperation) GetStatusString() string {
791
792 cret := xPrintOperationGetStatusString(x.GoPointer())
793 return cret
794}
795
796var xPrintOperationGetSupportSelection func(uintptr) bool
797
798// Gets whether the application supports print of selection
799func (x *PrintOperation) GetSupportSelection() bool {
800
801 cret := xPrintOperationGetSupportSelection(x.GoPointer())
802 return cret
803}
804
805var xPrintOperationIsFinished func(uintptr) bool
806
807// A convenience function to find out if the print operation
808// is finished.
809//
810// a print operation is finished if its status is either
811// %GTK_PRINT_STATUS_FINISHED or %GTK_PRINT_STATUS_FINISHED_ABORTED.
812//
813// Note: when you enable print status tracking the print operation
814// can be in a non-finished state even after done has been called, as
815// the operation status then tracks the print job status on the printer.
816func (x *PrintOperation) IsFinished() bool {
817
818 cret := xPrintOperationIsFinished(x.GoPointer())
819 return cret
820}
821
822var xPrintOperationRun func(uintptr, PrintOperationAction, uintptr, **glib.Error) PrintOperationResult
823
824// Runs the print operation.
825//
826// Normally that this function does not return until the rendering
827// of all pages is complete. You can connect to the
828// [signal@Gtk.PrintOperation::status-changed] signal on @op to obtain
829// some information about the progress of the print operation.
830//
831// Furthermore, it may use a recursive mainloop to show the print dialog.
832//
833// If you set the [Gtk.PrintOperation:allow-async] property, the operation
834// will run asynchronously if this is supported on the platform. The
835// [signal@Gtk.PrintOperation::done] signal will be emitted with the result
836// of the operation when the it is done (i.e. when the dialog is canceled,
837// or when the print succeeds or fails).
838//
839// ```c
840// if (settings != NULL)
841//
842// gtk_print_operation_set_print_settings (print, settings);
843//
844// if (page_setup != NULL)
845//
846// gtk_print_operation_set_default_page_setup (print, page_setup);
847//
848// g_signal_connect (print, "begin-print",
849//
850// G_CALLBACK (begin_print), &data);
851//
852// g_signal_connect (print, "draw-page",
853//
854// G_CALLBACK (draw_page), &data);
855//
856// res = gtk_print_operation_run (print,
857//
858// GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
859// parent,
860// &error);
861//
862// if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
863//
864// {
865// error_dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
866// GTK_DIALOG_DESTROY_WITH_PARENT,
867// GTK_MESSAGE_ERROR,
868// GTK_BUTTONS_CLOSE,
869// "Error printing file:\n%s",
870// error->message);
871// g_signal_connect (error_dialog, "response",
872// G_CALLBACK (gtk_window_destroy), NULL);
873// gtk_window_present (GTK_WINDOW (error_dialog));
874// g_error_free (error);
875// }
876//
877// else if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
878//
879// {
880// if (settings != NULL)
881//
882// g_object_unref (settings);
883//
884// settings = g_object_ref (gtk_print_operation_get_print_settings (print));
885// }
886//
887// ```
888//
889// Note that gtk_print_operation_run() can only be called once on a
890// given `GtkPrintOperation`.
891func (x *PrintOperation) Run(ActionVar PrintOperationAction, ParentVar *Window) (PrintOperationResult, error) {
892 var cerr *glib.Error
893
894 cret := xPrintOperationRun(x.GoPointer(), ActionVar, ParentVar.GoPointer(), &cerr)
895 if cerr == nil {
896 return cret, nil
897 }
898 return cret, cerr
899
900}
901
902var xPrintOperationSetAllowAsync func(uintptr, bool)
903
904// Sets whether gtk_print_operation_run() may return
905// before the print operation is completed.
906//
907// Note that some platforms may not allow asynchronous
908// operation.
909func (x *PrintOperation) SetAllowAsync(AllowAsyncVar bool) {
910
911 xPrintOperationSetAllowAsync(x.GoPointer(), AllowAsyncVar)
912
913}
914
915var xPrintOperationSetCurrentPage func(uintptr, int)
916
917// Sets the current page.
918//
919// If this is called before [method@Gtk.PrintOperation.run],
920// the user will be able to select to print only the current page.
921//
922// Note that this only makes sense for pre-paginated documents.
923func (x *PrintOperation) SetCurrentPage(CurrentPageVar int) {
924
925 xPrintOperationSetCurrentPage(x.GoPointer(), CurrentPageVar)
926
927}
928
929var xPrintOperationSetCustomTabLabel func(uintptr, uintptr)
930
931// Sets the label for the tab holding custom widgets.
932func (x *PrintOperation) SetCustomTabLabel(LabelVar *string) {
933
934 LabelVarPtr := core.GStrdupNullable(LabelVar)
935 defer core.GFreeNullable(LabelVarPtr)
936
937 xPrintOperationSetCustomTabLabel(x.GoPointer(), LabelVarPtr)
938
939}
940
941var xPrintOperationSetDefaultPageSetup func(uintptr, uintptr)
942
943// Makes @default_page_setup the default page setup for @op.
944//
945// This page setup will be used by [method@Gtk.PrintOperation.run],
946// but it can be overridden on a per-page basis by connecting
947// to the [signal@Gtk.PrintOperation::request-page-setup] signal.
948func (x *PrintOperation) SetDefaultPageSetup(DefaultPageSetupVar *PageSetup) {
949
950 xPrintOperationSetDefaultPageSetup(x.GoPointer(), DefaultPageSetupVar.GoPointer())
951
952}
953
954var xPrintOperationSetDeferDrawing func(uintptr)
955
956// Sets up the `GtkPrintOperation` to wait for calling of
957// [method@Gtk.PrintOperation.draw_page_finish from application.
958//
959// This can be used for drawing page in another thread.
960//
961// This function must be called in the callback of the
962// [signal@Gtk.PrintOperation::draw-page] signal.
963func (x *PrintOperation) SetDeferDrawing() {
964
965 xPrintOperationSetDeferDrawing(x.GoPointer())
966
967}
968
969var xPrintOperationSetEmbedPageSetup func(uintptr, bool)
970
971// Embed page size combo box and orientation combo box into page setup page.
972//
973// Selected page setup is stored as default page setup in `GtkPrintOperation`.
974func (x *PrintOperation) SetEmbedPageSetup(EmbedVar bool) {
975
976 xPrintOperationSetEmbedPageSetup(x.GoPointer(), EmbedVar)
977
978}
979
980var xPrintOperationSetExportFilename func(uintptr, string)
981
982// Sets up the `GtkPrintOperation` to generate a file instead
983// of showing the print dialog.
984//
985// The intended use of this function is for implementing
986// “Export to PDF” actions. Currently, PDF is the only supported
987// format.
988//
989// “Print to PDF” support is independent of this and is done
990// by letting the user pick the “Print to PDF” item from the list
991// of printers in the print dialog.
992func (x *PrintOperation) SetExportFilename(FilenameVar string) {
993
994 xPrintOperationSetExportFilename(x.GoPointer(), FilenameVar)
995
996}
997
998var xPrintOperationSetHasSelection func(uintptr, bool)
999
1000// Sets whether there is a selection to print.
1001//
1002// Application has to set number of pages to which the selection
1003// will draw by [method@Gtk.PrintOperation.set_n_pages] in a handler
1004// for the [signal@Gtk.PrintOperation::begin-print] signal.
1005func (x *PrintOperation) SetHasSelection(HasSelectionVar bool) {
1006
1007 xPrintOperationSetHasSelection(x.GoPointer(), HasSelectionVar)
1008
1009}
1010
1011var xPrintOperationSetJobName func(uintptr, string)
1012
1013// Sets the name of the print job.
1014//
1015// The name is used to identify the job (e.g. in monitoring
1016// applications like eggcups).
1017//
1018// If you don’t set a job name, GTK picks a default one by
1019// numbering successive print jobs.
1020func (x *PrintOperation) SetJobName(JobNameVar string) {
1021
1022 xPrintOperationSetJobName(x.GoPointer(), JobNameVar)
1023
1024}
1025
1026var xPrintOperationSetNPages func(uintptr, int)
1027
1028// Sets the number of pages in the document.
1029//
1030// This must be set to a positive number before the rendering
1031// starts. It may be set in a [signal@Gtk.PrintOperation::begin-print]
1032// signal handler.
1033//
1034// Note that the page numbers passed to the
1035// [signal@Gtk.PrintOperation::request-page-setup]
1036// and [signal@Gtk.PrintOperation::draw-page] signals are 0-based, i.e.
1037// if the user chooses to print all pages, the last ::draw-page signal
1038// will be for page @n_pages - 1.
1039func (x *PrintOperation) SetNPages(NPagesVar int) {
1040
1041 xPrintOperationSetNPages(x.GoPointer(), NPagesVar)
1042
1043}
1044
1045var xPrintOperationSetPrintSettings func(uintptr, uintptr)
1046
1047// Sets the print settings for @op.
1048//
1049// This is typically used to re-establish print settings
1050// from a previous print operation, see [method@Gtk.PrintOperation.run].
1051func (x *PrintOperation) SetPrintSettings(PrintSettingsVar *PrintSettings) {
1052
1053 xPrintOperationSetPrintSettings(x.GoPointer(), PrintSettingsVar.GoPointer())
1054
1055}
1056
1057var xPrintOperationSetShowProgress func(uintptr, bool)
1058
1059// If @show_progress is %TRUE, the print operation will show
1060// a progress dialog during the print operation.
1061func (x *PrintOperation) SetShowProgress(ShowProgressVar bool) {
1062
1063 xPrintOperationSetShowProgress(x.GoPointer(), ShowProgressVar)
1064
1065}
1066
1067var xPrintOperationSetSupportSelection func(uintptr, bool)
1068
1069// Sets whether selection is supported by `GtkPrintOperation`.
1070func (x *PrintOperation) SetSupportSelection(SupportSelectionVar bool) {
1071
1072 xPrintOperationSetSupportSelection(x.GoPointer(), SupportSelectionVar)
1073
1074}
1075
1076var xPrintOperationSetTrackPrintStatus func(uintptr, bool)
1077
1078// If track_status is %TRUE, the print operation will try to continue
1079// report on the status of the print job in the printer queues and printer.
1080//
1081// This can allow your application to show things like “out of paper”
1082// issues, and when the print job actually reaches the printer.
1083//
1084// This function is often implemented using some form of polling,
1085// so it should not be enabled unless needed.
1086func (x *PrintOperation) SetTrackPrintStatus(TrackStatusVar bool) {
1087
1088 xPrintOperationSetTrackPrintStatus(x.GoPointer(), TrackStatusVar)
1089
1090}
1091
1092var xPrintOperationSetUnit func(uintptr, Unit)
1093
1094// Sets up the transformation for the cairo context obtained from
1095// `GtkPrintContext` in such a way that distances are measured in
1096// units of @unit.
1097func (x *PrintOperation) SetUnit(UnitVar Unit) {
1098
1099 xPrintOperationSetUnit(x.GoPointer(), UnitVar)
1100
1101}
1102
1103var xPrintOperationSetUseFullPage func(uintptr, bool)
1104
1105// If @full_page is %TRUE, the transformation for the cairo context
1106// obtained from `GtkPrintContext` puts the origin at the top left
1107// corner of the page.
1108//
1109// This may not be the top left corner of the sheet, depending on page
1110// orientation and the number of pages per sheet). Otherwise, the origin
1111// is at the top left corner of the imageable area (i.e. inside the margins).
1112func (x *PrintOperation) SetUseFullPage(FullPageVar bool) {
1113
1114 xPrintOperationSetUseFullPage(x.GoPointer(), FullPageVar)
1115
1116}
1117
1118func (c *PrintOperation) GoPointer() uintptr {
1119 if c == nil {
1120 return 0
1121 }
1122 return c.Ptr
1123}
1124
1125func (c *PrintOperation) SetGoPointer(ptr uintptr) {
1126 c.Ptr = ptr
1127}
1128
1129// SetPropertyAllowAsync sets the "allow-async" property.
1130// Determines whether the print operation may run asynchronously or not.
1131//
1132// Some systems don't support asynchronous printing, but those that do
1133// will return %GTK_PRINT_OPERATION_RESULT_IN_PROGRESS as the status, and
1134// emit the [signal@Gtk.PrintOperation::done] signal when the operation
1135// is actually done.
1136//
1137// The Windows port does not support asynchronous operation at all (this
1138// is unlikely to change). On other platforms, all actions except for
1139// %GTK_PRINT_OPERATION_ACTION_EXPORT support asynchronous operation.
1140func (x *PrintOperation) SetPropertyAllowAsync(value bool) {
1141 var v gobject.Value
1142 v.Init(gobject.TypeBooleanVal)
1143 v.SetBoolean(value)
1144 x.SetProperty("allow-async", &v)
1145}
1146
1147// GetPropertyAllowAsync gets the "allow-async" property.
1148// Determines whether the print operation may run asynchronously or not.
1149//
1150// Some systems don't support asynchronous printing, but those that do
1151// will return %GTK_PRINT_OPERATION_RESULT_IN_PROGRESS as the status, and
1152// emit the [signal@Gtk.PrintOperation::done] signal when the operation
1153// is actually done.
1154//
1155// The Windows port does not support asynchronous operation at all (this
1156// is unlikely to change). On other platforms, all actions except for
1157// %GTK_PRINT_OPERATION_ACTION_EXPORT support asynchronous operation.
1158func (x *PrintOperation) GetPropertyAllowAsync() bool {
1159 var v gobject.Value
1160 x.GetProperty("allow-async", &v)
1161 return v.GetBoolean()
1162}
1163
1164// SetPropertyCurrentPage sets the "current-page" property.
1165// The current page in the document.
1166//
1167// If this is set before [method@Gtk.PrintOperation.run],
1168// the user will be able to select to print only the current page.
1169//
1170// Note that this only makes sense for pre-paginated documents.
1171func (x *PrintOperation) SetPropertyCurrentPage(value int) {
1172 var v gobject.Value
1173 v.Init(gobject.TypeIntVal)
1174 v.SetInt(value)
1175 x.SetProperty("current-page", &v)
1176}
1177
1178// GetPropertyCurrentPage gets the "current-page" property.
1179// The current page in the document.
1180//
1181// If this is set before [method@Gtk.PrintOperation.run],
1182// the user will be able to select to print only the current page.
1183//
1184// Note that this only makes sense for pre-paginated documents.
1185func (x *PrintOperation) GetPropertyCurrentPage() int {
1186 var v gobject.Value
1187 x.GetProperty("current-page", &v)
1188 return v.GetInt()
1189}
1190
1191// SetPropertyCustomTabLabel sets the "custom-tab-label" property.
1192// Used as the label of the tab containing custom widgets.
1193//
1194// Note that this property may be ignored on some platforms.
1195//
1196// If this is %NULL, GTK uses a default label.
1197func (x *PrintOperation) SetPropertyCustomTabLabel(value string) {
1198 var v gobject.Value
1199 v.Init(gobject.TypeStringVal)
1200 v.SetString(&value)
1201 x.SetProperty("custom-tab-label", &v)
1202}
1203
1204// GetPropertyCustomTabLabel gets the "custom-tab-label" property.
1205// Used as the label of the tab containing custom widgets.
1206//
1207// Note that this property may be ignored on some platforms.
1208//
1209// If this is %NULL, GTK uses a default label.
1210func (x *PrintOperation) GetPropertyCustomTabLabel() string {
1211 var v gobject.Value
1212 x.GetProperty("custom-tab-label", &v)
1213 return v.GetString()
1214}
1215
1216// SetPropertyEmbedPageSetup sets the "embed-page-setup" property.
1217// If %TRUE, page size combo box and orientation combo box
1218// are embedded into page setup page.
1219func (x *PrintOperation) SetPropertyEmbedPageSetup(value bool) {
1220 var v gobject.Value
1221 v.Init(gobject.TypeBooleanVal)
1222 v.SetBoolean(value)
1223 x.SetProperty("embed-page-setup", &v)
1224}
1225
1226// GetPropertyEmbedPageSetup gets the "embed-page-setup" property.
1227// If %TRUE, page size combo box and orientation combo box
1228// are embedded into page setup page.
1229func (x *PrintOperation) GetPropertyEmbedPageSetup() bool {
1230 var v gobject.Value
1231 x.GetProperty("embed-page-setup", &v)
1232 return v.GetBoolean()
1233}
1234
1235// SetPropertyExportFilename sets the "export-filename" property.
1236// The name of a file to generate instead of showing the print dialog.
1237//
1238// Currently, PDF is the only supported format.
1239//
1240// The intended use of this property is for implementing
1241// “Export to PDF” actions.
1242//
1243// “Print to PDF” support is independent of this and is done
1244// by letting the user pick the “Print to PDF” item from the
1245// list of printers in the print dialog.
1246func (x *PrintOperation) SetPropertyExportFilename(value string) {
1247 var v gobject.Value
1248 v.Init(gobject.TypeStringVal)
1249 v.SetString(&value)
1250 x.SetProperty("export-filename", &v)
1251}
1252
1253// GetPropertyExportFilename gets the "export-filename" property.
1254// The name of a file to generate instead of showing the print dialog.
1255//
1256// Currently, PDF is the only supported format.
1257//
1258// The intended use of this property is for implementing
1259// “Export to PDF” actions.
1260//
1261// “Print to PDF” support is independent of this and is done
1262// by letting the user pick the “Print to PDF” item from the
1263// list of printers in the print dialog.
1264func (x *PrintOperation) GetPropertyExportFilename() string {
1265 var v gobject.Value
1266 x.GetProperty("export-filename", &v)
1267 return v.GetString()
1268}
1269
1270// SetPropertyHasSelection sets the "has-selection" property.
1271// Determines whether there is a selection in your application.
1272//
1273// This can allow your application to print the selection.
1274// This is typically used to make a "Selection" button sensitive.
1275func (x *PrintOperation) SetPropertyHasSelection(value bool) {
1276 var v gobject.Value
1277 v.Init(gobject.TypeBooleanVal)
1278 v.SetBoolean(value)
1279 x.SetProperty("has-selection", &v)
1280}
1281
1282// GetPropertyHasSelection gets the "has-selection" property.
1283// Determines whether there is a selection in your application.
1284//
1285// This can allow your application to print the selection.
1286// This is typically used to make a "Selection" button sensitive.
1287func (x *PrintOperation) GetPropertyHasSelection() bool {
1288 var v gobject.Value
1289 x.GetProperty("has-selection", &v)
1290 return v.GetBoolean()
1291}
1292
1293// SetPropertyJobName sets the "job-name" property.
1294// A string used to identify the job (e.g. in monitoring
1295// applications like eggcups).
1296//
1297// If you don't set a job name, GTK picks a default one
1298// by numbering successive print jobs.
1299func (x *PrintOperation) SetPropertyJobName(value string) {
1300 var v gobject.Value
1301 v.Init(gobject.TypeStringVal)
1302 v.SetString(&value)
1303 x.SetProperty("job-name", &v)
1304}
1305
1306// GetPropertyJobName gets the "job-name" property.
1307// A string used to identify the job (e.g. in monitoring
1308// applications like eggcups).
1309//
1310// If you don't set a job name, GTK picks a default one
1311// by numbering successive print jobs.
1312func (x *PrintOperation) GetPropertyJobName() string {
1313 var v gobject.Value
1314 x.GetProperty("job-name", &v)
1315 return v.GetString()
1316}
1317
1318// SetPropertyNPages sets the "n-pages" property.
1319// The number of pages in the document.
1320//
1321// This must be set to a positive number before the rendering
1322// starts. It may be set in a [signal@Gtk.PrintOperation::begin-print]
1323// signal handler.
1324//
1325// Note that the page numbers passed to the
1326// [signal@Gtk.PrintOperation::request-page-setup] and
1327// [signal@Gtk.PrintOperation::draw-page] signals are 0-based, i.e.
1328// if the user chooses to print all pages, the last ::draw-page signal
1329// will be for page @n_pages - 1.
1330func (x *PrintOperation) SetPropertyNPages(value int) {
1331 var v gobject.Value
1332 v.Init(gobject.TypeIntVal)
1333 v.SetInt(value)
1334 x.SetProperty("n-pages", &v)
1335}
1336
1337// GetPropertyNPages gets the "n-pages" property.
1338// The number of pages in the document.
1339//
1340// This must be set to a positive number before the rendering
1341// starts. It may be set in a [signal@Gtk.PrintOperation::begin-print]
1342// signal handler.
1343//
1344// Note that the page numbers passed to the
1345// [signal@Gtk.PrintOperation::request-page-setup] and
1346// [signal@Gtk.PrintOperation::draw-page] signals are 0-based, i.e.
1347// if the user chooses to print all pages, the last ::draw-page signal
1348// will be for page @n_pages - 1.
1349func (x *PrintOperation) GetPropertyNPages() int {
1350 var v gobject.Value
1351 x.GetProperty("n-pages", &v)
1352 return v.GetInt()
1353}
1354
1355// GetPropertyNPagesToPrint gets the "n-pages-to-print" property.
1356// The number of pages that will be printed.
1357//
1358// Note that this value is set during print preparation phase
1359// (%GTK_PRINT_STATUS_PREPARING), so this value should never be
1360// get before the data generation phase (%GTK_PRINT_STATUS_GENERATING_DATA).
1361// You can connect to the [signal@Gtk.PrintOperation::status-changed] signal
1362// and call [method@Gtk.PrintOperation.get_n_pages_to_print] when
1363// print status is %GTK_PRINT_STATUS_GENERATING_DATA.
1364//
1365// This is typically used to track the progress of print operation.
1366func (x *PrintOperation) GetPropertyNPagesToPrint() int {
1367 var v gobject.Value
1368 x.GetProperty("n-pages-to-print", &v)
1369 return v.GetInt()
1370}
1371
1372// SetPropertyShowProgress sets the "show-progress" property.
1373// Determines whether to show a progress dialog during the
1374// print operation.
1375func (x *PrintOperation) SetPropertyShowProgress(value bool) {
1376 var v gobject.Value
1377 v.Init(gobject.TypeBooleanVal)
1378 v.SetBoolean(value)
1379 x.SetProperty("show-progress", &v)
1380}
1381
1382// GetPropertyShowProgress gets the "show-progress" property.
1383// Determines whether to show a progress dialog during the
1384// print operation.
1385func (x *PrintOperation) GetPropertyShowProgress() bool {
1386 var v gobject.Value
1387 x.GetProperty("show-progress", &v)
1388 return v.GetBoolean()
1389}
1390
1391// GetPropertyStatusString gets the "status-string" property.
1392// A string representation of the status of the print operation.
1393//
1394// The string is translated and suitable for displaying the print
1395// status e.g. in a `GtkStatusbar`.
1396//
1397// See the [property@Gtk.PrintOperation:status] property for a status
1398// value that is suitable for programmatic use.
1399func (x *PrintOperation) GetPropertyStatusString() string {
1400 var v gobject.Value
1401 x.GetProperty("status-string", &v)
1402 return v.GetString()
1403}
1404
1405// SetPropertySupportSelection sets the "support-selection" property.
1406// If %TRUE, the print operation will support print of selection.
1407//
1408// This allows the print dialog to show a "Selection" button.
1409func (x *PrintOperation) SetPropertySupportSelection(value bool) {
1410 var v gobject.Value
1411 v.Init(gobject.TypeBooleanVal)
1412 v.SetBoolean(value)
1413 x.SetProperty("support-selection", &v)
1414}
1415
1416// GetPropertySupportSelection gets the "support-selection" property.
1417// If %TRUE, the print operation will support print of selection.
1418//
1419// This allows the print dialog to show a "Selection" button.
1420func (x *PrintOperation) GetPropertySupportSelection() bool {
1421 var v gobject.Value
1422 x.GetProperty("support-selection", &v)
1423 return v.GetBoolean()
1424}
1425
1426// SetPropertyTrackPrintStatus sets the "track-print-status" property.
1427// If %TRUE, the print operation will try to continue report on
1428// the status of the print job in the printer queues and printer.
1429//
1430// This can allow your application to show things like “out of paper”
1431// issues, and when the print job actually reaches the printer.
1432// However, this is often implemented using polling, and should
1433// not be enabled unless needed.
1434func (x *PrintOperation) SetPropertyTrackPrintStatus(value bool) {
1435 var v gobject.Value
1436 v.Init(gobject.TypeBooleanVal)
1437 v.SetBoolean(value)
1438 x.SetProperty("track-print-status", &v)
1439}
1440
1441// GetPropertyTrackPrintStatus gets the "track-print-status" property.
1442// If %TRUE, the print operation will try to continue report on
1443// the status of the print job in the printer queues and printer.
1444//
1445// This can allow your application to show things like “out of paper”
1446// issues, and when the print job actually reaches the printer.
1447// However, this is often implemented using polling, and should
1448// not be enabled unless needed.
1449func (x *PrintOperation) GetPropertyTrackPrintStatus() bool {
1450 var v gobject.Value
1451 x.GetProperty("track-print-status", &v)
1452 return v.GetBoolean()
1453}
1454
1455// SetPropertyUseFullPage sets the "use-full-page" property.
1456// If %TRUE, the transformation for the cairo context obtained
1457// from `GtkPrintContext` puts the origin at the top left corner
1458// of the page.
1459//
1460// This may not be the top left corner of the sheet, depending on
1461// page orientation and the number of pages per sheet. Otherwise,
1462// the origin is at the top left corner of the imageable area (i.e.
1463// inside the margins).
1464func (x *PrintOperation) SetPropertyUseFullPage(value bool) {
1465 var v gobject.Value
1466 v.Init(gobject.TypeBooleanVal)
1467 v.SetBoolean(value)
1468 x.SetProperty("use-full-page", &v)
1469}
1470
1471// GetPropertyUseFullPage gets the "use-full-page" property.
1472// If %TRUE, the transformation for the cairo context obtained
1473// from `GtkPrintContext` puts the origin at the top left corner
1474// of the page.
1475//
1476// This may not be the top left corner of the sheet, depending on
1477// page orientation and the number of pages per sheet. Otherwise,
1478// the origin is at the top left corner of the imageable area (i.e.
1479// inside the margins).
1480func (x *PrintOperation) GetPropertyUseFullPage() bool {
1481 var v gobject.Value
1482 x.GetProperty("use-full-page", &v)
1483 return v.GetBoolean()
1484}
1485
1486// Emitted after the user has finished changing print settings
1487// in the dialog, before the actual rendering starts.
1488//
1489// A typical use for ::begin-print is to use the parameters from the
1490// [class@Gtk.PrintContext] and paginate the document accordingly,
1491// and then set the number of pages with
1492// [method@Gtk.PrintOperation.set_n_pages].
1493func (x *PrintOperation) ConnectBeginPrint(cb *func(PrintOperation, uintptr)) uint {
1494 cbPtr := uintptr(unsafe.Pointer(cb))
1495 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
1496 handlerID := gobject.SignalConnect(x.GoPointer(), "begin-print", cbRefPtr)
1497 glib.SaveHandlerMapping(handlerID, cbPtr)
1498 return handlerID
1499 }
1500
1501 fcb := func(clsPtr uintptr, ContextVarp uintptr) {
1502 fa := PrintOperation{}
1503 fa.Ptr = clsPtr
1504 cbFn := *cb
1505
1506 cbFn(fa, ContextVarp)
1507
1508 }
1509 cbRefPtr := purego.NewCallback(fcb)
1510 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
1511 handlerID := gobject.SignalConnect(x.GoPointer(), "begin-print", cbRefPtr)
1512 glib.SaveHandlerMapping(handlerID, cbPtr)
1513 return handlerID
1514}
1515
1516// Emitted when displaying the print dialog.
1517//
1518// If you return a widget in a handler for this signal it will be
1519// added to a custom tab in the print dialog. You typically return a
1520// container widget with multiple widgets in it.
1521//
1522// The print dialog owns the returned widget, and its lifetime is not
1523// controlled by the application. However, the widget is guaranteed
1524// to stay around until the [signal@Gtk.PrintOperation::custom-widget-apply]
1525// signal is emitted on the operation. Then you can read out any
1526// information you need from the widgets.
1527func (x *PrintOperation) ConnectCreateCustomWidget(cb *func(PrintOperation) gobject.Object) uint {
1528 cbPtr := uintptr(unsafe.Pointer(cb))
1529 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
1530 handlerID := gobject.SignalConnect(x.GoPointer(), "create-custom-widget", cbRefPtr)
1531 glib.SaveHandlerMapping(handlerID, cbPtr)
1532 return handlerID
1533 }
1534
1535 fcb := func(clsPtr uintptr) uintptr {
1536 fa := PrintOperation{}
1537 fa.Ptr = clsPtr
1538 cbFn := *cb
1539
1540 CreateCustomWidgetCls := cbFn(fa)
1541 return CreateCustomWidgetCls.Ptr
1542
1543 }
1544 cbRefPtr := purego.NewCallback(fcb)
1545 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
1546 handlerID := gobject.SignalConnect(x.GoPointer(), "create-custom-widget", cbRefPtr)
1547 glib.SaveHandlerMapping(handlerID, cbPtr)
1548 return handlerID
1549}
1550
1551// Emitted right before ::begin-print if you added
1552// a custom widget in the ::create-custom-widget handler.
1553//
1554// When you get this signal you should read the information from the
1555// custom widgets, as the widgets are not guaranteed to be around at a
1556// later time.
1557func (x *PrintOperation) ConnectCustomWidgetApply(cb *func(PrintOperation, uintptr)) uint {
1558 cbPtr := uintptr(unsafe.Pointer(cb))
1559 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
1560 handlerID := gobject.SignalConnect(x.GoPointer(), "custom-widget-apply", cbRefPtr)
1561 glib.SaveHandlerMapping(handlerID, cbPtr)
1562 return handlerID
1563 }
1564
1565 fcb := func(clsPtr uintptr, WidgetVarp uintptr) {
1566 fa := PrintOperation{}
1567 fa.Ptr = clsPtr
1568 cbFn := *cb
1569
1570 cbFn(fa, WidgetVarp)
1571
1572 }
1573 cbRefPtr := purego.NewCallback(fcb)
1574 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
1575 handlerID := gobject.SignalConnect(x.GoPointer(), "custom-widget-apply", cbRefPtr)
1576 glib.SaveHandlerMapping(handlerID, cbPtr)
1577 return handlerID
1578}
1579
1580// Emitted when the print operation run has finished doing
1581// everything required for printing.
1582//
1583// @result gives you information about what happened during the run.
1584// If @result is %GTK_PRINT_OPERATION_RESULT_ERROR then you can call
1585// [method@Gtk.PrintOperation.get_error] for more information.
1586//
1587// If you enabled print status tracking then
1588// [method@Gtk.PrintOperation.is_finished] may still return %FALSE
1589// after the ::done signal was emitted.
1590func (x *PrintOperation) ConnectDone(cb *func(PrintOperation, PrintOperationResult)) uint {
1591 cbPtr := uintptr(unsafe.Pointer(cb))
1592 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
1593 handlerID := gobject.SignalConnect(x.GoPointer(), "done", cbRefPtr)
1594 glib.SaveHandlerMapping(handlerID, cbPtr)
1595 return handlerID
1596 }
1597
1598 fcb := func(clsPtr uintptr, ResultVarp PrintOperationResult) {
1599 fa := PrintOperation{}
1600 fa.Ptr = clsPtr
1601 cbFn := *cb
1602
1603 cbFn(fa, ResultVarp)
1604
1605 }
1606 cbRefPtr := purego.NewCallback(fcb)
1607 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
1608 handlerID := gobject.SignalConnect(x.GoPointer(), "done", cbRefPtr)
1609 glib.SaveHandlerMapping(handlerID, cbPtr)
1610 return handlerID
1611}
1612
1613// Emitted for every page that is printed.
1614//
1615// The signal handler must render the @page_nr's page onto the cairo
1616// context obtained from @context using
1617// [method@Gtk.PrintContext.get_cairo_context].
1618//
1619// ```c
1620// static void
1621// draw_page (GtkPrintOperation *operation,
1622//
1623// GtkPrintContext *context,
1624// int page_nr,
1625// gpointer user_data)
1626//
1627// {
1628// cairo_t *cr;
1629// PangoLayout *layout;
1630// double width, text_height;
1631// int layout_height;
1632// PangoFontDescription *desc;
1633//
1634// cr = gtk_print_context_get_cairo_context (context);
1635// width = gtk_print_context_get_width (context);
1636//
1637// cairo_rectangle (cr, 0, 0, width, HEADER_HEIGHT);
1638//
1639// cairo_set_source_rgb (cr, 0.8, 0.8, 0.8);
1640// cairo_fill (cr);
1641//
1642// layout = gtk_print_context_create_pango_layout (context);
1643//
1644// desc = pango_font_description_from_string ("sans 14");
1645// pango_layout_set_font_description (layout, desc);
1646// pango_font_description_free (desc);
1647//
1648// pango_layout_set_text (layout, "some text", -1);
1649// pango_layout_set_width (layout, width * PANGO_SCALE);
1650// pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
1651//
1652// pango_layout_get_size (layout, NULL, &layout_height);
1653// text_height = (double)layout_height / PANGO_SCALE;
1654//
1655// cairo_move_to (cr, width / 2, (HEADER_HEIGHT - text_height) / 2);
1656// pango_cairo_show_layout (cr, layout);
1657//
1658// g_object_unref (layout);
1659// }
1660//
1661// ```
1662//
1663// Use [method@Gtk.PrintOperation.set_use_full_page] and
1664// [method@Gtk.PrintOperation.set_unit] before starting the print
1665// operation to set up the transformation of the cairo context
1666// according to your needs.
1667func (x *PrintOperation) ConnectDrawPage(cb *func(PrintOperation, uintptr, int)) uint {
1668 cbPtr := uintptr(unsafe.Pointer(cb))
1669 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
1670 handlerID := gobject.SignalConnect(x.GoPointer(), "draw-page", cbRefPtr)
1671 glib.SaveHandlerMapping(handlerID, cbPtr)
1672 return handlerID
1673 }
1674
1675 fcb := func(clsPtr uintptr, ContextVarp uintptr, PageNrVarp int) {
1676 fa := PrintOperation{}
1677 fa.Ptr = clsPtr
1678 cbFn := *cb
1679
1680 cbFn(fa, ContextVarp, PageNrVarp)
1681
1682 }
1683 cbRefPtr := purego.NewCallback(fcb)
1684 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
1685 handlerID := gobject.SignalConnect(x.GoPointer(), "draw-page", cbRefPtr)
1686 glib.SaveHandlerMapping(handlerID, cbPtr)
1687 return handlerID
1688}
1689
1690// Emitted after all pages have been rendered.
1691//
1692// A handler for this signal can clean up any resources that have
1693// been allocated in the [signal@Gtk.PrintOperation::begin-print] handler.
1694func (x *PrintOperation) ConnectEndPrint(cb *func(PrintOperation, uintptr)) uint {
1695 cbPtr := uintptr(unsafe.Pointer(cb))
1696 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
1697 handlerID := gobject.SignalConnect(x.GoPointer(), "end-print", cbRefPtr)
1698 glib.SaveHandlerMapping(handlerID, cbPtr)
1699 return handlerID
1700 }
1701
1702 fcb := func(clsPtr uintptr, ContextVarp uintptr) {
1703 fa := PrintOperation{}
1704 fa.Ptr = clsPtr
1705 cbFn := *cb
1706
1707 cbFn(fa, ContextVarp)
1708
1709 }
1710 cbRefPtr := purego.NewCallback(fcb)
1711 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
1712 handlerID := gobject.SignalConnect(x.GoPointer(), "end-print", cbRefPtr)
1713 glib.SaveHandlerMapping(handlerID, cbPtr)
1714 return handlerID
1715}
1716
1717// Emitted after the ::begin-print signal, but before the actual rendering
1718// starts.
1719//
1720// It keeps getting emitted until a connected signal handler returns %TRUE.
1721//
1722// The ::paginate signal is intended to be used for paginating a document
1723// in small chunks, to avoid blocking the user interface for a long
1724// time. The signal handler should update the number of pages using
1725// [method@Gtk.PrintOperation.set_n_pages], and return %TRUE if the document
1726// has been completely paginated.
1727//
1728// If you don't need to do pagination in chunks, you can simply do
1729// it all in the ::begin-print handler, and set the number of pages
1730// from there.
1731func (x *PrintOperation) ConnectPaginate(cb *func(PrintOperation, uintptr) bool) uint {
1732 cbPtr := uintptr(unsafe.Pointer(cb))
1733 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
1734 handlerID := gobject.SignalConnect(x.GoPointer(), "paginate", cbRefPtr)
1735 glib.SaveHandlerMapping(handlerID, cbPtr)
1736 return handlerID
1737 }
1738
1739 fcb := func(clsPtr uintptr, ContextVarp uintptr) bool {
1740 fa := PrintOperation{}
1741 fa.Ptr = clsPtr
1742 cbFn := *cb
1743
1744 return cbFn(fa, ContextVarp)
1745
1746 }
1747 cbRefPtr := purego.NewCallback(fcb)
1748 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
1749 handlerID := gobject.SignalConnect(x.GoPointer(), "paginate", cbRefPtr)
1750 glib.SaveHandlerMapping(handlerID, cbPtr)
1751 return handlerID
1752}
1753
1754// Gets emitted when a preview is requested from the native dialog.
1755//
1756// The default handler for this signal uses an external viewer
1757// application to preview.
1758//
1759// To implement a custom print preview, an application must return
1760// %TRUE from its handler for this signal. In order to use the
1761// provided @context for the preview implementation, it must be
1762// given a suitable cairo context with
1763// [method@Gtk.PrintContext.set_cairo_context].
1764//
1765// The custom preview implementation can use
1766// [method@Gtk.PrintOperationPreview.is_selected] and
1767// [method@Gtk.PrintOperationPreview.render_page] to find pages which
1768// are selected for print and render them. The preview must be
1769// finished by calling [method@Gtk.PrintOperationPreview.end_preview]
1770// (typically in response to the user clicking a close button).
1771func (x *PrintOperation) ConnectPreview(cb *func(PrintOperation, uintptr, uintptr, uintptr) bool) uint {
1772 cbPtr := uintptr(unsafe.Pointer(cb))
1773 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
1774 handlerID := gobject.SignalConnect(x.GoPointer(), "preview", cbRefPtr)
1775 glib.SaveHandlerMapping(handlerID, cbPtr)
1776 return handlerID
1777 }
1778
1779 fcb := func(clsPtr uintptr, PreviewVarp uintptr, ContextVarp uintptr, ParentVarp uintptr) bool {
1780 fa := PrintOperation{}
1781 fa.Ptr = clsPtr
1782 cbFn := *cb
1783
1784 return cbFn(fa, PreviewVarp, ContextVarp, ParentVarp)
1785
1786 }
1787 cbRefPtr := purego.NewCallback(fcb)
1788 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
1789 handlerID := gobject.SignalConnect(x.GoPointer(), "preview", cbRefPtr)
1790 glib.SaveHandlerMapping(handlerID, cbPtr)
1791 return handlerID
1792}
1793
1794// Emitted once for every page that is printed.
1795//
1796// This gives the application a chance to modify the page setup.
1797// Any changes done to @setup will be in force only for printing
1798// this page.
1799func (x *PrintOperation) ConnectRequestPageSetup(cb *func(PrintOperation, uintptr, int, uintptr)) uint {
1800 cbPtr := uintptr(unsafe.Pointer(cb))
1801 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
1802 handlerID := gobject.SignalConnect(x.GoPointer(), "request-page-setup", cbRefPtr)
1803 glib.SaveHandlerMapping(handlerID, cbPtr)
1804 return handlerID
1805 }
1806
1807 fcb := func(clsPtr uintptr, ContextVarp uintptr, PageNrVarp int, SetupVarp uintptr) {
1808 fa := PrintOperation{}
1809 fa.Ptr = clsPtr
1810 cbFn := *cb
1811
1812 cbFn(fa, ContextVarp, PageNrVarp, SetupVarp)
1813
1814 }
1815 cbRefPtr := purego.NewCallback(fcb)
1816 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
1817 handlerID := gobject.SignalConnect(x.GoPointer(), "request-page-setup", cbRefPtr)
1818 glib.SaveHandlerMapping(handlerID, cbPtr)
1819 return handlerID
1820}
1821
1822// Emitted at between the various phases of the print operation.
1823//
1824// See [enum@Gtk.PrintStatus] for the phases that are being discriminated.
1825// Use [method@Gtk.PrintOperation.get_status] to find out the current
1826// status.
1827func (x *PrintOperation) ConnectStatusChanged(cb *func(PrintOperation)) uint {
1828 cbPtr := uintptr(unsafe.Pointer(cb))
1829 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
1830 handlerID := gobject.SignalConnect(x.GoPointer(), "status-changed", cbRefPtr)
1831 glib.SaveHandlerMapping(handlerID, cbPtr)
1832 return handlerID
1833 }
1834
1835 fcb := func(clsPtr uintptr) {
1836 fa := PrintOperation{}
1837 fa.Ptr = clsPtr
1838 cbFn := *cb
1839
1840 cbFn(fa)
1841
1842 }
1843 cbRefPtr := purego.NewCallback(fcb)
1844 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
1845 handlerID := gobject.SignalConnect(x.GoPointer(), "status-changed", cbRefPtr)
1846 glib.SaveHandlerMapping(handlerID, cbPtr)
1847 return handlerID
1848}
1849
1850// Emitted after change of selected printer.
1851//
1852// The actual page setup and print settings are passed to the custom
1853// widget, which can actualize itself according to this change.
1854func (x *PrintOperation) ConnectUpdateCustomWidget(cb *func(PrintOperation, uintptr, uintptr, uintptr)) uint {
1855 cbPtr := uintptr(unsafe.Pointer(cb))
1856 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
1857 handlerID := gobject.SignalConnect(x.GoPointer(), "update-custom-widget", cbRefPtr)
1858 glib.SaveHandlerMapping(handlerID, cbPtr)
1859 return handlerID
1860 }
1861
1862 fcb := func(clsPtr uintptr, WidgetVarp uintptr, SetupVarp uintptr, SettingsVarp uintptr) {
1863 fa := PrintOperation{}
1864 fa.Ptr = clsPtr
1865 cbFn := *cb
1866
1867 cbFn(fa, WidgetVarp, SetupVarp, SettingsVarp)
1868
1869 }
1870 cbRefPtr := purego.NewCallback(fcb)
1871 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
1872 handlerID := gobject.SignalConnect(x.GoPointer(), "update-custom-widget", cbRefPtr)
1873 glib.SaveHandlerMapping(handlerID, cbPtr)
1874 return handlerID
1875}
1876
1877// Ends a preview.
1878//
1879// This function must be called to finish a custom print preview.
1880func (x *PrintOperation) EndPreview() {
1881
1882 XGtkPrintOperationPreviewEndPreview(x.GoPointer())
1883
1884}
1885
1886// Returns whether the given page is included in the set of pages that
1887// have been selected for printing.
1888func (x *PrintOperation) IsSelected(PageNrVar int) bool {
1889
1890 cret := XGtkPrintOperationPreviewIsSelected(x.GoPointer(), PageNrVar)
1891 return cret
1892}
1893
1894// Renders a page to the preview.
1895//
1896// This is using the print context that was passed to the
1897// [signal@Gtk.PrintOperation::preview] handler together
1898// with @preview.
1899//
1900// A custom print preview should use this function to render
1901// the currently selected page.
1902//
1903// Note that this function requires a suitable cairo context to
1904// be associated with the print context.
1905func (x *PrintOperation) RenderPage(PageNrVar int) {
1906
1907 XGtkPrintOperationPreviewRenderPage(x.GoPointer(), PageNrVar)
1908
1909}
1910
1911func init() {
1912 core.SetPackageName("GTK", "gtk4")
1913 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
1914 var libs []uintptr
1915 for _, libPath := range core.GetPaths("GTK") {
1916 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
1917 if err != nil {
1918 panic(err)
1919 }
1920 libs = append(libs, lib)
1921 }
1922
1923 core.PuregoSafeRegister(&xPrintErrorGLibType, libs, "gtk_print_error_get_type")
1924
1925 core.PuregoSafeRegister(&xPrintOperationActionGLibType, libs, "gtk_print_operation_action_get_type")
1926
1927 core.PuregoSafeRegister(&xPrintOperationResultGLibType, libs, "gtk_print_operation_result_get_type")
1928
1929 core.PuregoSafeRegister(&xPrintStatusGLibType, libs, "gtk_print_status_get_type")
1930
1931 core.PuregoSafeRegister(&xPrintErrorQuark, libs, "gtk_print_error_quark")
1932 core.PuregoSafeRegister(&xPrintRunPageSetupDialog, libs, "gtk_print_run_page_setup_dialog")
1933 core.PuregoSafeRegister(&xPrintRunPageSetupDialogAsync, libs, "gtk_print_run_page_setup_dialog_async")
1934
1935 core.PuregoSafeRegister(&xPrintOperationGLibType, libs, "gtk_print_operation_get_type")
1936
1937 core.PuregoSafeRegister(&xNewPrintOperation, libs, "gtk_print_operation_new")
1938
1939 core.PuregoSafeRegister(&xPrintOperationCancel, libs, "gtk_print_operation_cancel")
1940 core.PuregoSafeRegister(&xPrintOperationDrawPageFinish, libs, "gtk_print_operation_draw_page_finish")
1941 core.PuregoSafeRegister(&xPrintOperationGetDefaultPageSetup, libs, "gtk_print_operation_get_default_page_setup")
1942 core.PuregoSafeRegister(&xPrintOperationGetEmbedPageSetup, libs, "gtk_print_operation_get_embed_page_setup")
1943 core.PuregoSafeRegister(&xPrintOperationGetError, libs, "gtk_print_operation_get_error")
1944 core.PuregoSafeRegister(&xPrintOperationGetHasSelection, libs, "gtk_print_operation_get_has_selection")
1945 core.PuregoSafeRegister(&xPrintOperationGetNPagesToPrint, libs, "gtk_print_operation_get_n_pages_to_print")
1946 core.PuregoSafeRegister(&xPrintOperationGetPrintSettings, libs, "gtk_print_operation_get_print_settings")
1947 core.PuregoSafeRegister(&xPrintOperationGetStatus, libs, "gtk_print_operation_get_status")
1948 core.PuregoSafeRegister(&xPrintOperationGetStatusString, libs, "gtk_print_operation_get_status_string")
1949 core.PuregoSafeRegister(&xPrintOperationGetSupportSelection, libs, "gtk_print_operation_get_support_selection")
1950 core.PuregoSafeRegister(&xPrintOperationIsFinished, libs, "gtk_print_operation_is_finished")
1951 core.PuregoSafeRegister(&xPrintOperationRun, libs, "gtk_print_operation_run")
1952 core.PuregoSafeRegister(&xPrintOperationSetAllowAsync, libs, "gtk_print_operation_set_allow_async")
1953 core.PuregoSafeRegister(&xPrintOperationSetCurrentPage, libs, "gtk_print_operation_set_current_page")
1954 core.PuregoSafeRegister(&xPrintOperationSetCustomTabLabel, libs, "gtk_print_operation_set_custom_tab_label")
1955 core.PuregoSafeRegister(&xPrintOperationSetDefaultPageSetup, libs, "gtk_print_operation_set_default_page_setup")
1956 core.PuregoSafeRegister(&xPrintOperationSetDeferDrawing, libs, "gtk_print_operation_set_defer_drawing")
1957 core.PuregoSafeRegister(&xPrintOperationSetEmbedPageSetup, libs, "gtk_print_operation_set_embed_page_setup")
1958 core.PuregoSafeRegister(&xPrintOperationSetExportFilename, libs, "gtk_print_operation_set_export_filename")
1959 core.PuregoSafeRegister(&xPrintOperationSetHasSelection, libs, "gtk_print_operation_set_has_selection")
1960 core.PuregoSafeRegister(&xPrintOperationSetJobName, libs, "gtk_print_operation_set_job_name")
1961 core.PuregoSafeRegister(&xPrintOperationSetNPages, libs, "gtk_print_operation_set_n_pages")
1962 core.PuregoSafeRegister(&xPrintOperationSetPrintSettings, libs, "gtk_print_operation_set_print_settings")
1963 core.PuregoSafeRegister(&xPrintOperationSetShowProgress, libs, "gtk_print_operation_set_show_progress")
1964 core.PuregoSafeRegister(&xPrintOperationSetSupportSelection, libs, "gtk_print_operation_set_support_selection")
1965 core.PuregoSafeRegister(&xPrintOperationSetTrackPrintStatus, libs, "gtk_print_operation_set_track_print_status")
1966 core.PuregoSafeRegister(&xPrintOperationSetUnit, libs, "gtk_print_operation_set_unit")
1967 core.PuregoSafeRegister(&xPrintOperationSetUseFullPage, libs, "gtk_print_operation_set_use_full_page")
1968
1969}