v0.2.1 c0399be

gtkprinter.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/glib"
12	"github.com/bnema/puregotk/v4/gobject"
13	"github.com/bnema/puregotk/v4/gobject/types"
14)
15
16// The type of function passed to gtk_enumerate_printers().
17//
18// Note that you need to ref @printer, if you want to keep
19// a reference to it after the function has returned.
20type PrinterFunc func(uintptr, uintptr) bool
21
22// A print backend.
23type PrintBackend struct {
24	_ structs.HostLayout
25}
26
27func (x *PrintBackend) GoPointer() uintptr {
28	return uintptr(unsafe.Pointer(x))
29}
30
31// Specifies which features the print dialog should offer.
32//
33// If neither %GTK_PRINT_CAPABILITY_GENERATE_PDF nor
34// %GTK_PRINT_CAPABILITY_GENERATE_PS is specified, GTK assumes that all
35// formats are supported.
36type PrintCapabilities int
37
38var xPrintCapabilitiesGLibType func() types.GType
39
40func PrintCapabilitiesGLibType() types.GType {
41	return xPrintCapabilitiesGLibType()
42}
43
44const (
45
46	// Print dialog will offer printing even/odd pages.
47	PrintCapabilityPageSetValue PrintCapabilities = 1
48	// Print dialog will allow to print multiple copies.
49	PrintCapabilityCopiesValue PrintCapabilities = 2
50	// Print dialog will allow to collate multiple copies.
51	PrintCapabilityCollateValue PrintCapabilities = 4
52	// Print dialog will allow to print pages in reverse order.
53	PrintCapabilityReverseValue PrintCapabilities = 8
54	// Print dialog will allow to scale the output.
55	PrintCapabilityScaleValue PrintCapabilities = 16
56	// The program will send the document to
57	//   the printer in PDF format
58	PrintCapabilityGeneratePdfValue PrintCapabilities = 32
59	// The program will send the document to
60	//   the printer in Postscript format
61	PrintCapabilityGeneratePsValue PrintCapabilities = 64
62	// Print dialog will offer a preview
63	PrintCapabilityPreviewValue PrintCapabilities = 128
64	// Print dialog will offer printing multiple
65	//   pages per sheet
66	PrintCapabilityNumberUpValue PrintCapabilities = 256
67	// Print dialog will allow to rearrange
68	//   pages when printing multiple pages per sheet
69	PrintCapabilityNumberUpLayoutValue PrintCapabilities = 512
70)
71
72var xEnumeratePrinters func(uintptr, uintptr, uintptr, bool)
73
74// Calls a function for all printers that are known to GTK.
75//
76// If @func returns true, the enumeration is stopped.
77func EnumeratePrinters(FuncVar *PrinterFunc, DataVar uintptr, DestroyVar *glib.DestroyNotify, WaitVar bool) {
78
79	var FuncVarRef uintptr
80	if FuncVar != nil {
81		FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
82		if cbRefPtr, ok := glib.GetCallback(FuncVarPtr); ok {
83			FuncVarRef = cbRefPtr
84		} else {
85			fcb := func(arg0 uintptr, arg1 uintptr) bool {
86				cbFn := *FuncVar
87				return cbFn(arg0, arg1)
88			}
89			FuncVarRef = purego.NewCallback(fcb)
90			glib.SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
91		}
92	}
93
94	var DestroyVarRef uintptr
95	if DestroyVar != nil {
96		DestroyVarPtr := uintptr(unsafe.Pointer(DestroyVar))
97		if cbRefPtr, ok := glib.GetCallback(DestroyVarPtr); ok {
98			DestroyVarRef = cbRefPtr
99		} else {
100			fcb := func(arg0 uintptr) {
101				cbFn := *DestroyVar
102				cbFn(arg0)
103			}
104			DestroyVarRef = purego.NewCallback(fcb)
105			glib.SaveCallbackWithClosure(DestroyVarPtr, DestroyVarRef, DestroyVar)
106		}
107	}
108
109	xEnumeratePrinters(FuncVarRef, DataVar, DestroyVarRef, WaitVar)
110
111}
112
113// Represents a printer.
114//
115// You only need to deal directly with printers if you use the
116// non-portable [class@Gtk.PrintUnixDialog] API.
117//
118// A `GtkPrinter` allows to get status information about the printer,
119// such as its description, its location, the number of queued jobs,
120// etc. Most importantly, a `GtkPrinter` object can be used to create
121// a [class@Gtk.PrintJob] object, which lets you print to the printer.
122type Printer struct {
123	gobject.Object
124}
125
126var xPrinterGLibType func() types.GType
127
128func PrinterGLibType() types.GType {
129	return xPrinterGLibType()
130}
131
132func PrinterNewFromInternalPtr(ptr uintptr) *Printer {
133	cls := &Printer{}
134	cls.Ptr = ptr
135	return cls
136}
137
138var xNewPrinter func(string, *PrintBackend, bool) uintptr
139
140// Creates a new `GtkPrinter`.
141func NewPrinter(NameVar string, BackendVar *PrintBackend, VirtualVar bool) *Printer {
142	var cls *Printer
143
144	cret := xNewPrinter(NameVar, BackendVar, VirtualVar)
145
146	if cret == 0 {
147		return nil
148	}
149	cls = &Printer{}
150	cls.Ptr = cret
151	return cls
152}
153
154var xPrinterAcceptsPdf func(uintptr) bool
155
156// Returns whether the printer accepts input in
157// PDF format.
158func (x *Printer) AcceptsPdf() bool {
159
160	cret := xPrinterAcceptsPdf(x.GoPointer())
161	return cret
162}
163
164var xPrinterAcceptsPs func(uintptr) bool
165
166// Returns whether the printer accepts input in
167// PostScript format.
168func (x *Printer) AcceptsPs() bool {
169
170	cret := xPrinterAcceptsPs(x.GoPointer())
171	return cret
172}
173
174var xPrinterCompare func(uintptr, uintptr) int
175
176// Compares two printers.
177func (x *Printer) Compare(BVar *Printer) int {
178
179	cret := xPrinterCompare(x.GoPointer(), BVar.GoPointer())
180	return cret
181}
182
183var xPrinterGetBackend func(uintptr) *PrintBackend
184
185// Returns the backend of the printer.
186func (x *Printer) GetBackend() *PrintBackend {
187
188	cret := xPrinterGetBackend(x.GoPointer())
189	return cret
190}
191
192var xPrinterGetCapabilities func(uintptr) PrintCapabilities
193
194// Returns the printer’s capabilities.
195//
196// This is useful when you’re using `GtkPrintUnixDialog`’s
197// manual-capabilities setting and need to know which settings
198// the printer can handle and which you must handle yourself.
199//
200// This will return 0 unless the printer’s details are
201// available, see [method@Gtk.Printer.has_details] and
202// [method@Gtk.Printer.request_details].
203func (x *Printer) GetCapabilities() PrintCapabilities {
204
205	cret := xPrinterGetCapabilities(x.GoPointer())
206	return cret
207}
208
209var xPrinterGetDefaultPageSize func(uintptr) uintptr
210
211// Returns default page size of @printer.
212func (x *Printer) GetDefaultPageSize() *PageSetup {
213	var cls *PageSetup
214
215	cret := xPrinterGetDefaultPageSize(x.GoPointer())
216
217	if cret == 0 {
218		return nil
219	}
220	cls = &PageSetup{}
221	cls.Ptr = cret
222	return cls
223}
224
225var xPrinterGetDescription func(uintptr) string
226
227// Gets the description of the printer.
228func (x *Printer) GetDescription() string {
229
230	cret := xPrinterGetDescription(x.GoPointer())
231	return cret
232}
233
234var xPrinterGetHardMargins func(uintptr, *float64, *float64, *float64, *float64) bool
235
236// Retrieve the hard margins of @printer.
237//
238// These are the margins that define the area at the borders
239// of the paper that the printer cannot print to.
240//
241// Note: This will not succeed unless the printer’s details are
242// available, see [method@Gtk.Printer.has_details] and
243// [method@Gtk.Printer.request_details].
244func (x *Printer) GetHardMargins(TopVar *float64, BottomVar *float64, LeftVar *float64, RightVar *float64) bool {
245
246	cret := xPrinterGetHardMargins(x.GoPointer(), TopVar, BottomVar, LeftVar, RightVar)
247	return cret
248}
249
250var xPrinterGetHardMarginsForPaperSize func(uintptr, *PaperSize, *float64, *float64, *float64, *float64) bool
251
252// Retrieve the hard margins of @printer for @paper_size.
253//
254// These are the margins that define the area at the borders
255// of the paper that the printer cannot print to.
256//
257// Note: This will not succeed unless the printer’s details are
258// available, see [method@Gtk.Printer.has_details] and
259// [method@Gtk.Printer.request_details].
260func (x *Printer) GetHardMarginsForPaperSize(PaperSizeVar *PaperSize, TopVar *float64, BottomVar *float64, LeftVar *float64, RightVar *float64) bool {
261
262	cret := xPrinterGetHardMarginsForPaperSize(x.GoPointer(), PaperSizeVar, TopVar, BottomVar, LeftVar, RightVar)
263	return cret
264}
265
266var xPrinterGetIconName func(uintptr) string
267
268// Gets the name of the icon to use for the printer.
269func (x *Printer) GetIconName() string {
270
271	cret := xPrinterGetIconName(x.GoPointer())
272	return cret
273}
274
275var xPrinterGetJobCount func(uintptr) int
276
277// Gets the number of jobs currently queued on the printer.
278func (x *Printer) GetJobCount() int {
279
280	cret := xPrinterGetJobCount(x.GoPointer())
281	return cret
282}
283
284var xPrinterGetLocation func(uintptr) string
285
286// Returns a description of the location of the printer.
287func (x *Printer) GetLocation() string {
288
289	cret := xPrinterGetLocation(x.GoPointer())
290	return cret
291}
292
293var xPrinterGetName func(uintptr) string
294
295// Returns the name of the printer.
296func (x *Printer) GetName() string {
297
298	cret := xPrinterGetName(x.GoPointer())
299	return cret
300}
301
302var xPrinterGetStateMessage func(uintptr) string
303
304// Returns the state message describing the current state
305// of the printer.
306func (x *Printer) GetStateMessage() string {
307
308	cret := xPrinterGetStateMessage(x.GoPointer())
309	return cret
310}
311
312var xPrinterHasDetails func(uintptr) bool
313
314// Returns whether the printer details are available.
315func (x *Printer) HasDetails() bool {
316
317	cret := xPrinterHasDetails(x.GoPointer())
318	return cret
319}
320
321var xPrinterIsAcceptingJobs func(uintptr) bool
322
323// Returns whether the printer is accepting jobs
324func (x *Printer) IsAcceptingJobs() bool {
325
326	cret := xPrinterIsAcceptingJobs(x.GoPointer())
327	return cret
328}
329
330var xPrinterIsActive func(uintptr) bool
331
332// Returns whether the printer is currently active (i.e.
333// accepts new jobs).
334func (x *Printer) IsActive() bool {
335
336	cret := xPrinterIsActive(x.GoPointer())
337	return cret
338}
339
340var xPrinterIsDefault func(uintptr) bool
341
342// Returns whether the printer is the default printer.
343func (x *Printer) IsDefault() bool {
344
345	cret := xPrinterIsDefault(x.GoPointer())
346	return cret
347}
348
349var xPrinterIsPaused func(uintptr) bool
350
351// Returns whether the printer is currently paused.
352//
353// A paused printer still accepts jobs, but it is not
354// printing them.
355func (x *Printer) IsPaused() bool {
356
357	cret := xPrinterIsPaused(x.GoPointer())
358	return cret
359}
360
361var xPrinterIsVirtual func(uintptr) bool
362
363// Returns whether the printer is virtual (i.e. does not
364// represent actual printer hardware, but something like
365// a CUPS class).
366func (x *Printer) IsVirtual() bool {
367
368	cret := xPrinterIsVirtual(x.GoPointer())
369	return cret
370}
371
372var xPrinterListPapers func(uintptr) *glib.List
373
374// Lists all the paper sizes @printer supports.
375//
376// This will return and empty list unless the printer’s details
377// are available, see [method@Gtk.Printer.has_details] and
378// [method@Gtk.Printer.request_details].
379func (x *Printer) ListPapers() *glib.List {
380
381	cret := xPrinterListPapers(x.GoPointer())
382	return cret
383}
384
385var xPrinterRequestDetails func(uintptr)
386
387// Requests the printer details.
388//
389// When the details are available, the
390// [signal@Gtk.Printer::details-acquired] signal
391// will be emitted on @printer.
392func (x *Printer) RequestDetails() {
393
394	xPrinterRequestDetails(x.GoPointer())
395
396}
397
398func (c *Printer) GoPointer() uintptr {
399	if c == nil {
400		return 0
401	}
402	return c.Ptr
403}
404
405func (c *Printer) SetGoPointer(ptr uintptr) {
406	c.Ptr = ptr
407}
408
409// GetPropertyAcceptingJobs gets the "accepting-jobs" property.
410// %TRUE if the printer is accepting jobs.
411func (x *Printer) GetPropertyAcceptingJobs() bool {
412	var v gobject.Value
413	x.GetProperty("accepting-jobs", &v)
414	return v.GetBoolean()
415}
416
417// SetPropertyAcceptsPdf sets the "accepts-pdf" property.
418// %TRUE if this printer can accept PDF.
419func (x *Printer) SetPropertyAcceptsPdf(value bool) {
420	var v gobject.Value
421	v.Init(gobject.TypeBooleanVal)
422	v.SetBoolean(value)
423	x.SetProperty("accepts-pdf", &v)
424}
425
426// GetPropertyAcceptsPdf gets the "accepts-pdf" property.
427// %TRUE if this printer can accept PDF.
428func (x *Printer) GetPropertyAcceptsPdf() bool {
429	var v gobject.Value
430	x.GetProperty("accepts-pdf", &v)
431	return v.GetBoolean()
432}
433
434// SetPropertyAcceptsPs sets the "accepts-ps" property.
435// %TRUE if this printer can accept PostScript.
436func (x *Printer) SetPropertyAcceptsPs(value bool) {
437	var v gobject.Value
438	v.Init(gobject.TypeBooleanVal)
439	v.SetBoolean(value)
440	x.SetProperty("accepts-ps", &v)
441}
442
443// GetPropertyAcceptsPs gets the "accepts-ps" property.
444// %TRUE if this printer can accept PostScript.
445func (x *Printer) GetPropertyAcceptsPs() bool {
446	var v gobject.Value
447	x.GetProperty("accepts-ps", &v)
448	return v.GetBoolean()
449}
450
451// GetPropertyIconName gets the "icon-name" property.
452// Icon name to use for the printer.
453func (x *Printer) GetPropertyIconName() string {
454	var v gobject.Value
455	x.GetProperty("icon-name", &v)
456	return v.GetString()
457}
458
459// SetPropertyIsVirtual sets the "is-virtual" property.
460// %FALSE if this represents a real hardware device.
461func (x *Printer) SetPropertyIsVirtual(value bool) {
462	var v gobject.Value
463	v.Init(gobject.TypeBooleanVal)
464	v.SetBoolean(value)
465	x.SetProperty("is-virtual", &v)
466}
467
468// GetPropertyIsVirtual gets the "is-virtual" property.
469// %FALSE if this represents a real hardware device.
470func (x *Printer) GetPropertyIsVirtual() bool {
471	var v gobject.Value
472	x.GetProperty("is-virtual", &v)
473	return v.GetBoolean()
474}
475
476// GetPropertyJobCount gets the "job-count" property.
477// Number of jobs queued in the printer.
478func (x *Printer) GetPropertyJobCount() int {
479	var v gobject.Value
480	x.GetProperty("job-count", &v)
481	return v.GetInt()
482}
483
484// GetPropertyLocation gets the "location" property.
485// Information about the location of the printer.
486func (x *Printer) GetPropertyLocation() string {
487	var v gobject.Value
488	x.GetProperty("location", &v)
489	return v.GetString()
490}
491
492// SetPropertyName sets the "name" property.
493// The name of the printer.
494func (x *Printer) SetPropertyName(value string) {
495	var v gobject.Value
496	v.Init(gobject.TypeStringVal)
497	v.SetString(&value)
498	x.SetProperty("name", &v)
499}
500
501// GetPropertyName gets the "name" property.
502// The name of the printer.
503func (x *Printer) GetPropertyName() string {
504	var v gobject.Value
505	x.GetProperty("name", &v)
506	return v.GetString()
507}
508
509// GetPropertyPaused gets the "paused" property.
510// %TRUE if this printer is paused.
511//
512// A paused printer still accepts jobs, but it does
513// not print them.
514func (x *Printer) GetPropertyPaused() bool {
515	var v gobject.Value
516	x.GetProperty("paused", &v)
517	return v.GetBoolean()
518}
519
520// GetPropertyStateMessage gets the "state-message" property.
521// String giving the current status of the printer.
522func (x *Printer) GetPropertyStateMessage() string {
523	var v gobject.Value
524	x.GetProperty("state-message", &v)
525	return v.GetString()
526}
527
528// Emitted in response to a request for detailed information
529// about a printer from the print backend.
530//
531// The @success parameter indicates if the information was
532// actually obtained.
533func (x *Printer) ConnectDetailsAcquired(cb *func(Printer, bool)) uint {
534	cbPtr := uintptr(unsafe.Pointer(cb))
535	if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
536		handlerID := gobject.SignalConnect(x.GoPointer(), "details-acquired", cbRefPtr)
537		glib.SaveHandlerMapping(handlerID, cbPtr)
538		return handlerID
539	}
540
541	fcb := func(clsPtr uintptr, SuccessVarp bool) {
542		fa := Printer{}
543		fa.Ptr = clsPtr
544		cbFn := *cb
545
546		cbFn(fa, SuccessVarp)
547
548	}
549	cbRefPtr := purego.NewCallback(fcb)
550	glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
551	handlerID := gobject.SignalConnect(x.GoPointer(), "details-acquired", cbRefPtr)
552	glib.SaveHandlerMapping(handlerID, cbPtr)
553	return handlerID
554}
555
556func init() {
557	core.SetPackageName("GTK", "gtk4")
558	core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
559	var libs []uintptr
560	for _, libPath := range core.GetPaths("GTK") {
561		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
562		if err != nil {
563			panic(err)
564		}
565		libs = append(libs, lib)
566	}
567
568	core.PuregoSafeRegister(&xPrintCapabilitiesGLibType, libs, "gtk_print_capabilities_get_type")
569
570	core.PuregoSafeRegister(&xEnumeratePrinters, libs, "gtk_enumerate_printers")
571
572	core.PuregoSafeRegister(&xPrinterGLibType, libs, "gtk_printer_get_type")
573
574	core.PuregoSafeRegister(&xNewPrinter, libs, "gtk_printer_new")
575
576	core.PuregoSafeRegister(&xPrinterAcceptsPdf, libs, "gtk_printer_accepts_pdf")
577	core.PuregoSafeRegister(&xPrinterAcceptsPs, libs, "gtk_printer_accepts_ps")
578	core.PuregoSafeRegister(&xPrinterCompare, libs, "gtk_printer_compare")
579	core.PuregoSafeRegister(&xPrinterGetBackend, libs, "gtk_printer_get_backend")
580	core.PuregoSafeRegister(&xPrinterGetCapabilities, libs, "gtk_printer_get_capabilities")
581	core.PuregoSafeRegister(&xPrinterGetDefaultPageSize, libs, "gtk_printer_get_default_page_size")
582	core.PuregoSafeRegister(&xPrinterGetDescription, libs, "gtk_printer_get_description")
583	core.PuregoSafeRegister(&xPrinterGetHardMargins, libs, "gtk_printer_get_hard_margins")
584	core.PuregoSafeRegister(&xPrinterGetHardMarginsForPaperSize, libs, "gtk_printer_get_hard_margins_for_paper_size")
585	core.PuregoSafeRegister(&xPrinterGetIconName, libs, "gtk_printer_get_icon_name")
586	core.PuregoSafeRegister(&xPrinterGetJobCount, libs, "gtk_printer_get_job_count")
587	core.PuregoSafeRegister(&xPrinterGetLocation, libs, "gtk_printer_get_location")
588	core.PuregoSafeRegister(&xPrinterGetName, libs, "gtk_printer_get_name")
589	core.PuregoSafeRegister(&xPrinterGetStateMessage, libs, "gtk_printer_get_state_message")
590	core.PuregoSafeRegister(&xPrinterHasDetails, libs, "gtk_printer_has_details")
591	core.PuregoSafeRegister(&xPrinterIsAcceptingJobs, libs, "gtk_printer_is_accepting_jobs")
592	core.PuregoSafeRegister(&xPrinterIsActive, libs, "gtk_printer_is_active")
593	core.PuregoSafeRegister(&xPrinterIsDefault, libs, "gtk_printer_is_default")
594	core.PuregoSafeRegister(&xPrinterIsPaused, libs, "gtk_printer_is_paused")
595	core.PuregoSafeRegister(&xPrinterIsVirtual, libs, "gtk_printer_is_virtual")
596	core.PuregoSafeRegister(&xPrinterListPapers, libs, "gtk_printer_list_papers")
597	core.PuregoSafeRegister(&xPrinterRequestDetails, libs, "gtk_printer_request_details")
598
599}

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