v0.2.1 c0399be

gtkprintdialog.go RawHistoryFolder

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/gio"
12	"github.com/bnema/puregotk/v4/glib"
13	"github.com/bnema/puregotk/v4/gobject"
14	"github.com/bnema/puregotk/v4/gobject/types"
15)
16
17type PrintDialogClass struct {
18	_ structs.HostLayout
19
20	ParentClass gobject.ObjectClass
21}
22
23func (x *PrintDialogClass) GoPointer() uintptr {
24	return uintptr(unsafe.Pointer(x))
25}
26
27// An auxiliary object for printing that allows decoupling the setup from the printing.
28//
29// A print setup is obtained by calling [method@Gtk.PrintDialog.setup],
30// and can later be passed to print functions such as [method@Gtk.PrintDialog.print].
31//
32// Print setups can be reused for multiple print calls.
33//
34// Applications may wish to store the page_setup and print_settings from the print setup
35// and copy them to the PrintDialog if they want to keep using them.
36type PrintSetup struct {
37	_ structs.HostLayout
38}
39
40var xPrintSetupGLibType func() types.GType
41
42func PrintSetupGLibType() types.GType {
43	return xPrintSetupGLibType()
44}
45
46func (x *PrintSetup) GoPointer() uintptr {
47	return uintptr(unsafe.Pointer(x))
48}
49
50var xPrintSetupGetPageSetup func(uintptr) uintptr
51
52// Returns the page setup of @setup.
53//
54// It may be different from the `GtkPrintDialog`'s page setup
55// if the user changed it during the setup process.
56func (x *PrintSetup) GetPageSetup() *PageSetup {
57	var cls *PageSetup
58
59	cret := xPrintSetupGetPageSetup(x.GoPointer())
60
61	if cret == 0 {
62		return nil
63	}
64	gobject.IncreaseRef(cret)
65	cls = &PageSetup{}
66	cls.Ptr = cret
67	return cls
68}
69
70var xPrintSetupGetPrintSettings func(uintptr) uintptr
71
72// Returns the print settings of @setup.
73//
74// They may be different from the `GtkPrintDialog`'s settings
75// if the user changed them during the setup process.
76func (x *PrintSetup) GetPrintSettings() *PrintSettings {
77	var cls *PrintSettings
78
79	cret := xPrintSetupGetPrintSettings(x.GoPointer())
80
81	if cret == 0 {
82		return nil
83	}
84	gobject.IncreaseRef(cret)
85	cls = &PrintSettings{}
86	cls.Ptr = cret
87	return cls
88}
89
90var xPrintSetupRef func(uintptr) *PrintSetup
91
92// Increase the reference count of @setup.
93func (x *PrintSetup) Ref() *PrintSetup {
94
95	cret := xPrintSetupRef(x.GoPointer())
96	return cret
97}
98
99var xPrintSetupUnref func(uintptr)
100
101// Decrease the reference count of @setup.
102//
103// If the reference count reaches zero,
104// the object is freed.
105func (x *PrintSetup) Unref() {
106
107	xPrintSetupUnref(x.GoPointer())
108
109}
110
111// Asynchronous API to present a print dialog to the user.
112//
113// `GtkPrintDialog` collects the arguments that are needed to present
114//
115//	the dialog, such as a title for the dialog and whether it should
116//	be modal.
117//
118// The dialog is shown with the [method@Gtk.PrintDialog.setup] function.
119//
120// The actual printing can be done with [method@Gtk.PrintDialog.print] or
121// [method@Gtk.PrintDialog.print_file]. These APIs follows the GIO async pattern,
122// and the results can be obtained by calling the corresponding finish methods.
123type PrintDialog struct {
124	gobject.Object
125}
126
127var xPrintDialogGLibType func() types.GType
128
129func PrintDialogGLibType() types.GType {
130	return xPrintDialogGLibType()
131}
132
133func PrintDialogNewFromInternalPtr(ptr uintptr) *PrintDialog {
134	cls := &PrintDialog{}
135	cls.Ptr = ptr
136	return cls
137}
138
139var xNewPrintDialog func() uintptr
140
141// Creates a new `GtkPrintDialog` object.
142func NewPrintDialog() *PrintDialog {
143	var cls *PrintDialog
144
145	cret := xNewPrintDialog()
146
147	if cret == 0 {
148		return nil
149	}
150	cls = &PrintDialog{}
151	cls.Ptr = cret
152	return cls
153}
154
155var xPrintDialogGetAcceptLabel func(uintptr) string
156
157// Returns the label that will be shown on the
158// accept button of the print dialog.
159func (x *PrintDialog) GetAcceptLabel() string {
160
161	cret := xPrintDialogGetAcceptLabel(x.GoPointer())
162	return cret
163}
164
165var xPrintDialogGetModal func(uintptr) bool
166
167// Returns whether the print dialog blocks
168// interaction with the parent window while
169// it is presented.
170func (x *PrintDialog) GetModal() bool {
171
172	cret := xPrintDialogGetModal(x.GoPointer())
173	return cret
174}
175
176var xPrintDialogGetPageSetup func(uintptr) uintptr
177
178// Returns the page setup.
179func (x *PrintDialog) GetPageSetup() *PageSetup {
180	var cls *PageSetup
181
182	cret := xPrintDialogGetPageSetup(x.GoPointer())
183
184	if cret == 0 {
185		return nil
186	}
187	gobject.IncreaseRef(cret)
188	cls = &PageSetup{}
189	cls.Ptr = cret
190	return cls
191}
192
193var xPrintDialogGetPrintSettings func(uintptr) uintptr
194
195// Returns the print settings for the print dialog.
196func (x *PrintDialog) GetPrintSettings() *PrintSettings {
197	var cls *PrintSettings
198
199	cret := xPrintDialogGetPrintSettings(x.GoPointer())
200
201	if cret == 0 {
202		return nil
203	}
204	gobject.IncreaseRef(cret)
205	cls = &PrintSettings{}
206	cls.Ptr = cret
207	return cls
208}
209
210var xPrintDialogGetTitle func(uintptr) string
211
212// Returns the title that will be shown on the
213// print dialog.
214func (x *PrintDialog) GetTitle() string {
215
216	cret := xPrintDialogGetTitle(x.GoPointer())
217	return cret
218}
219
220var xPrintDialogPrint func(uintptr, uintptr, *PrintSetup, uintptr, uintptr, uintptr)
221
222// This function prints content from a stream.
223//
224// If you pass `NULL` as @setup, then this method will present a print dialog.
225// Otherwise, it will attempt to print directly, without user interaction.
226//
227// The @callback will be called when the printing is done.
228func (x *PrintDialog) Print(ParentVar *Window, SetupVar *PrintSetup, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
229
230	var CallbackVarRef uintptr
231	if CallbackVar != nil {
232		CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
233		if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
234			CallbackVarRef = cbRefPtr
235		} else {
236			fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
237				cbFn := *CallbackVar
238				cbFn(arg0, arg1, arg2)
239			}
240			CallbackVarRef = purego.NewCallback(fcb)
241			glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
242		}
243	}
244
245	xPrintDialogPrint(x.GoPointer(), ParentVar.GoPointer(), SetupVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
246
247}
248
249var xPrintDialogPrintFile func(uintptr, uintptr, *PrintSetup, uintptr, uintptr, uintptr, uintptr)
250
251// This function prints a file.
252//
253// If you pass `NULL` as @setup, then this method will present a print dialog.
254// Otherwise, it will attempt to print directly, without user interaction.
255func (x *PrintDialog) PrintFile(ParentVar *Window, SetupVar *PrintSetup, FileVar gio.File, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
256
257	var CallbackVarRef uintptr
258	if CallbackVar != nil {
259		CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
260		if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
261			CallbackVarRef = cbRefPtr
262		} else {
263			fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
264				cbFn := *CallbackVar
265				cbFn(arg0, arg1, arg2)
266			}
267			CallbackVarRef = purego.NewCallback(fcb)
268			glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
269		}
270	}
271
272	xPrintDialogPrintFile(x.GoPointer(), ParentVar.GoPointer(), SetupVar, FileVar.GoPointer(), CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
273
274}
275
276var xPrintDialogPrintFileFinish func(uintptr, uintptr, **glib.Error) bool
277
278// Finishes the [method@Gtk.PrintDialog.print_file] call and
279// returns the results.
280//
281// Note that this function returns a [error@Gtk.DialogError.DISMISSED]
282// error if the user cancels the dialog.
283func (x *PrintDialog) PrintFileFinish(ResultVar gio.AsyncResult) (bool, error) {
284	var cerr *glib.Error
285
286	cret := xPrintDialogPrintFileFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
287	if cerr == nil {
288		return cret, nil
289	}
290	return cret, cerr
291
292}
293
294var xPrintDialogPrintFinish func(uintptr, uintptr, **glib.Error) uintptr
295
296// Finishes the [method@Gtk.PrintDialog.print] call and
297// returns the results.
298//
299// If the call was successful, the content to be printed should be
300// written to the returned output stream. Otherwise, `NULL` is returned.
301//
302// The overall results of the print operation will be returned in the
303// [method@Gio.OutputStream.close] call, so if you are interested in the
304// results, you need to explicitly close the output stream (it will be
305// closed automatically if you just unref it). Be aware that the close
306// call may not be instant as it operation will for the printer to finish
307// printing.
308//
309// Note that this function returns a [error@Gtk.DialogError.DISMISSED]
310// error if the user cancels the dialog.
311func (x *PrintDialog) PrintFinish(ResultVar gio.AsyncResult) (*gio.OutputStream, error) {
312	var cls *gio.OutputStream
313	var cerr *glib.Error
314
315	cret := xPrintDialogPrintFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
316
317	if cret == 0 {
318		return nil, cerr
319	}
320	cls = &gio.OutputStream{}
321	cls.Ptr = cret
322	if cerr == nil {
323		return cls, nil
324	}
325	return cls, cerr
326
327}
328
329var xPrintDialogSetAcceptLabel func(uintptr, string)
330
331// Sets the label that will be shown on the
332// accept button of the print dialog shown for
333// [method@Gtk.PrintDialog.setup].
334func (x *PrintDialog) SetAcceptLabel(AcceptLabelVar string) {
335
336	xPrintDialogSetAcceptLabel(x.GoPointer(), AcceptLabelVar)
337
338}
339
340var xPrintDialogSetModal func(uintptr, bool)
341
342// Sets whether the print dialog blocks
343// interaction with the parent window while
344// it is presented.
345func (x *PrintDialog) SetModal(ModalVar bool) {
346
347	xPrintDialogSetModal(x.GoPointer(), ModalVar)
348
349}
350
351var xPrintDialogSetPageSetup func(uintptr, uintptr)
352
353// Set the page setup for the print dialog.
354func (x *PrintDialog) SetPageSetup(PageSetupVar *PageSetup) {
355
356	xPrintDialogSetPageSetup(x.GoPointer(), PageSetupVar.GoPointer())
357
358}
359
360var xPrintDialogSetPrintSettings func(uintptr, uintptr)
361
362// Sets the print settings for the print dialog.
363func (x *PrintDialog) SetPrintSettings(PrintSettingsVar *PrintSettings) {
364
365	xPrintDialogSetPrintSettings(x.GoPointer(), PrintSettingsVar.GoPointer())
366
367}
368
369var xPrintDialogSetTitle func(uintptr, string)
370
371// Sets the title that will be shown on the print dialog.
372func (x *PrintDialog) SetTitle(TitleVar string) {
373
374	xPrintDialogSetTitle(x.GoPointer(), TitleVar)
375
376}
377
378var xPrintDialogSetup func(uintptr, uintptr, uintptr, uintptr, uintptr)
379
380// This function presents a print dialog to let the user select a printer,
381// and set up print settings and page setup.
382//
383// The @callback will be called when the dialog is dismissed.
384// The obtained [struct@Gtk.PrintSetup] can then be passed
385// to [method@Gtk.PrintDialog.print] or [method@Gtk.PrintDialog.print_file].
386//
387// One possible use for this method is to have the user select a printer,
388// then show a page setup UI in the application (e.g. to arrange images
389// on a page), then call [method@Gtk.PrintDialog.print] on @self
390// to do the printing without further user interaction.
391func (x *PrintDialog) Setup(ParentVar *Window, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
392
393	var CallbackVarRef uintptr
394	if CallbackVar != nil {
395		CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
396		if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
397			CallbackVarRef = cbRefPtr
398		} else {
399			fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
400				cbFn := *CallbackVar
401				cbFn(arg0, arg1, arg2)
402			}
403			CallbackVarRef = purego.NewCallback(fcb)
404			glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
405		}
406	}
407
408	xPrintDialogSetup(x.GoPointer(), ParentVar.GoPointer(), CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
409
410}
411
412var xPrintDialogSetupFinish func(uintptr, uintptr, **glib.Error) *PrintSetup
413
414// Finishes the [method@Gtk.PrintDialog.setup] call.
415//
416// If the call was successful, it returns a [struct@Gtk.PrintSetup]
417// which contains the print settings and page setup information that
418// will be used to print.
419//
420// Note that this function returns a [error@Gtk.DialogError.DISMISSED]
421// error if the user cancels the dialog.
422func (x *PrintDialog) SetupFinish(ResultVar gio.AsyncResult) (*PrintSetup, error) {
423	var cerr *glib.Error
424
425	cret := xPrintDialogSetupFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
426	if cerr == nil {
427		return cret, nil
428	}
429	return cret, cerr
430
431}
432
433func (c *PrintDialog) GoPointer() uintptr {
434	if c == nil {
435		return 0
436	}
437	return c.Ptr
438}
439
440func (c *PrintDialog) SetGoPointer(ptr uintptr) {
441	c.Ptr = ptr
442}
443
444// SetPropertyAcceptLabel sets the "accept-label" property.
445// A label that may be shown on the accept button of a print dialog
446// that is presented by [method@Gtk.PrintDialog.setup].
447func (x *PrintDialog) SetPropertyAcceptLabel(value string) {
448	var v gobject.Value
449	v.Init(gobject.TypeStringVal)
450	v.SetString(&value)
451	x.SetProperty("accept-label", &v)
452}
453
454// GetPropertyAcceptLabel gets the "accept-label" property.
455// A label that may be shown on the accept button of a print dialog
456// that is presented by [method@Gtk.PrintDialog.setup].
457func (x *PrintDialog) GetPropertyAcceptLabel() string {
458	var v gobject.Value
459	x.GetProperty("accept-label", &v)
460	return v.GetString()
461}
462
463// SetPropertyModal sets the "modal" property.
464// Whether the print dialog is modal.
465func (x *PrintDialog) SetPropertyModal(value bool) {
466	var v gobject.Value
467	v.Init(gobject.TypeBooleanVal)
468	v.SetBoolean(value)
469	x.SetProperty("modal", &v)
470}
471
472// GetPropertyModal gets the "modal" property.
473// Whether the print dialog is modal.
474func (x *PrintDialog) GetPropertyModal() bool {
475	var v gobject.Value
476	x.GetProperty("modal", &v)
477	return v.GetBoolean()
478}
479
480// SetPropertyTitle sets the "title" property.
481// A title that may be shown on the print dialog that is
482// presented by [method@Gtk.PrintDialog.setup].
483func (x *PrintDialog) SetPropertyTitle(value string) {
484	var v gobject.Value
485	v.Init(gobject.TypeStringVal)
486	v.SetString(&value)
487	x.SetProperty("title", &v)
488}
489
490// GetPropertyTitle gets the "title" property.
491// A title that may be shown on the print dialog that is
492// presented by [method@Gtk.PrintDialog.setup].
493func (x *PrintDialog) GetPropertyTitle() string {
494	var v gobject.Value
495	x.GetProperty("title", &v)
496	return v.GetString()
497}
498
499func init() {
500	core.SetPackageName("GTK", "gtk4")
501	core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
502	var libs []uintptr
503	for _, libPath := range core.GetPaths("GTK") {
504		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
505		if err != nil {
506			panic(err)
507		}
508		libs = append(libs, lib)
509	}
510
511	core.PuregoSafeRegister(&xPrintSetupGLibType, libs, "gtk_print_setup_get_type")
512
513	core.PuregoSafeRegister(&xPrintSetupGetPageSetup, libs, "gtk_print_setup_get_page_setup")
514	core.PuregoSafeRegister(&xPrintSetupGetPrintSettings, libs, "gtk_print_setup_get_print_settings")
515	core.PuregoSafeRegister(&xPrintSetupRef, libs, "gtk_print_setup_ref")
516	core.PuregoSafeRegister(&xPrintSetupUnref, libs, "gtk_print_setup_unref")
517
518	core.PuregoSafeRegister(&xPrintDialogGLibType, libs, "gtk_print_dialog_get_type")
519
520	core.PuregoSafeRegister(&xNewPrintDialog, libs, "gtk_print_dialog_new")
521
522	core.PuregoSafeRegister(&xPrintDialogGetAcceptLabel, libs, "gtk_print_dialog_get_accept_label")
523	core.PuregoSafeRegister(&xPrintDialogGetModal, libs, "gtk_print_dialog_get_modal")
524	core.PuregoSafeRegister(&xPrintDialogGetPageSetup, libs, "gtk_print_dialog_get_page_setup")
525	core.PuregoSafeRegister(&xPrintDialogGetPrintSettings, libs, "gtk_print_dialog_get_print_settings")
526	core.PuregoSafeRegister(&xPrintDialogGetTitle, libs, "gtk_print_dialog_get_title")
527	core.PuregoSafeRegister(&xPrintDialogPrint, libs, "gtk_print_dialog_print")
528	core.PuregoSafeRegister(&xPrintDialogPrintFile, libs, "gtk_print_dialog_print_file")
529	core.PuregoSafeRegister(&xPrintDialogPrintFileFinish, libs, "gtk_print_dialog_print_file_finish")
530	core.PuregoSafeRegister(&xPrintDialogPrintFinish, libs, "gtk_print_dialog_print_finish")
531	core.PuregoSafeRegister(&xPrintDialogSetAcceptLabel, libs, "gtk_print_dialog_set_accept_label")
532	core.PuregoSafeRegister(&xPrintDialogSetModal, libs, "gtk_print_dialog_set_modal")
533	core.PuregoSafeRegister(&xPrintDialogSetPageSetup, libs, "gtk_print_dialog_set_page_setup")
534	core.PuregoSafeRegister(&xPrintDialogSetPrintSettings, libs, "gtk_print_dialog_set_print_settings")
535	core.PuregoSafeRegister(&xPrintDialogSetTitle, libs, "gtk_print_dialog_set_title")
536	core.PuregoSafeRegister(&xPrintDialogSetup, libs, "gtk_print_dialog_setup")
537	core.PuregoSafeRegister(&xPrintDialogSetupFinish, libs, "gtk_print_dialog_setup_finish")
538
539}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close