Class Printer
- All Implemented Interfaces:
Proxy
GtkPrinter
object represents a printer.
You only need to deal directly with printers if you use the
non-portable PrintUnixDialog
API.
A GtkPrinter
allows to get status information about the printer,
such as its description, its location, the number of queued jobs,
etc. Most importantly, a GtkPrinter
object can be used to create
a PrintJob
object, which lets you print to the printer.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Printer.Builder<B extends Printer.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theDetailsAcquiredCallback
callback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionPrinter
(MemorySegment address) Create a Printer proxy instance for the provided memory address.Printer
(String name, PrintBackend backend, boolean virtual) Creates a newGtkPrinter
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether the printer accepts input in PDF format.boolean
Returns whether the printer accepts input in PostScript format.protected Printer
asParent()
Returns this instance as if it were its parent type.static Printer.Builder
<? extends Printer.Builder> builder()
APrinter.Builder
object constructs aPrinter
with the specified properties.int
Compares two printers.void
emitDetailsAcquired
(boolean success) Emits the "details-acquired" signal.Returns the backend of the printer.Returns the printer’s capabilities.Returns default page size of this Printer.Gets the description of the printer.boolean
Retrieve the hard margins of this Printer.boolean
getHardMarginsForPaperSize
(PaperSize paperSize, Out<Double> top, Out<Double> bottom, Out<Double> left, Out<Double> right) Retrieve the hard margins of this Printer forpaperSize
.Gets the name of the icon to use for the printer.int
Gets the number of jobs currently queued on the printer.Returns a description of the location of the printer.getName()
Returns the name of the printer.Returns the state message describing the current state of the printer.static Type
getType()
Get the GType of the Printer classboolean
Returns whether the printer details are available.boolean
Returns whether the printer is accepting jobsboolean
isActive()
Returns whether the printer is currently active (i.e.boolean
Returns whether the printer is the default printer.boolean
isPaused()
Returns whether the printer is currently paused.boolean
Returns whether the printer is virtual (i.e.Lists all the paper sizes this Printer supports.Emitted in response to a request for detailed information about a printer from the print backend.void
Requests the printer details.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Printer
Create a Printer proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Printer
public Printer(String name, PrintBackend backend, boolean virtual) throws UnsupportedPlatformException Creates a newGtkPrinter
.- Parameters:
name
- the name of the printerbackend
- aGtkPrintBackend
virtual
- whether the printer is virtual- Throws:
UnsupportedPlatformException
- when run on a platform other than linux or macos
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
acceptsPdf
public boolean acceptsPdf()Returns whether the printer accepts input in PDF format.- Returns:
true
if this Printer accepts PDF
-
acceptsPs
public boolean acceptsPs()Returns whether the printer accepts input in PostScript format.- Returns:
true
if this Printer accepts PostScript
-
compare
Compares two printers.- Parameters:
b
- anotherGtkPrinter
- Returns:
- 0 if the printer match, a negative value if this Printer <
b
, or a positive value if this Printer >b
-
getBackend
Returns the backend of the printer.- Returns:
- the backend of this Printer
-
getCapabilities
Returns the printer’s capabilities.This is useful when you’re using
GtkPrintUnixDialog
’s manual-capabilities setting and need to know which settings the printer can handle and which you must handle yourself.This will return 0 unless the printer’s details are available, see
hasDetails()
andrequestDetails()
.- Returns:
- the printer’s capabilities
-
getDefaultPageSize
Returns default page size of this Printer.- Returns:
- a newly allocated
GtkPageSetup
with default page size of the printer.
-
getDescription
Gets the description of the printer.- Returns:
- the description of this Printer
-
getHardMargins
public boolean getHardMargins(Out<Double> top, Out<Double> bottom, Out<Double> left, Out<Double> right) Retrieve the hard margins of this Printer.These are the margins that define the area at the borders of the paper that the printer cannot print to.
Note: This will not succeed unless the printer’s details are available, see
hasDetails()
andrequestDetails()
.- Parameters:
top
- a location to store the top margin inbottom
- a location to store the bottom margin inleft
- a location to store the left margin inright
- a location to store the right margin in- Returns:
true
iff the hard margins were retrieved
-
getHardMarginsForPaperSize
public boolean getHardMarginsForPaperSize(PaperSize paperSize, Out<Double> top, Out<Double> bottom, Out<Double> left, Out<Double> right) Retrieve the hard margins of this Printer forpaperSize
.These are the margins that define the area at the borders of the paper that the printer cannot print to.
Note: This will not succeed unless the printer’s details are available, see
hasDetails()
andrequestDetails()
.- Parameters:
paperSize
- aGtkPaperSize
top
- a location to store the top margin inbottom
- a location to store the bottom margin inleft
- a location to store the left margin inright
- a location to store the right margin in- Returns:
true
iff the hard margins were retrieved
-
getIconName
Gets the name of the icon to use for the printer.- Returns:
- the icon name for this Printer
-
getJobCount
public int getJobCount()Gets the number of jobs currently queued on the printer.- Returns:
- the number of jobs on this Printer
-
getLocation
Returns a description of the location of the printer.- Returns:
- the location of this Printer
-
getName
-
getStateMessage
Returns the state message describing the current state of the printer.- Returns:
- the state message of this Printer
-
hasDetails
public boolean hasDetails()Returns whether the printer details are available.- Returns:
true
if this Printer details are available
-
isAcceptingJobs
public boolean isAcceptingJobs()Returns whether the printer is accepting jobs- Returns:
true
if this Printer is accepting jobs
-
isActive
public boolean isActive()Returns whether the printer is currently active (i.e. accepts new jobs).- Returns:
true
if this Printer is active
-
isDefault
public boolean isDefault()Returns whether the printer is the default printer.- Returns:
true
if this Printer is the default
-
isPaused
public boolean isPaused()Returns whether the printer is currently paused.A paused printer still accepts jobs, but it is not printing them.
- Returns:
true
if this Printer is paused
-
isVirtual
public boolean isVirtual()Returns whether the printer is virtual (i.e. does not represent actual printer hardware, but something like a CUPS class).- Returns:
true
if this Printer is virtual
-
listPapers
Lists all the paper sizes this Printer supports.This will return and empty list unless the printer’s details are available, see
hasDetails()
andrequestDetails()
.- Returns:
- a newly
allocated list of newly allocated
GtkPageSetup
s.
-
requestDetails
public void requestDetails()Requests the printer details.When the details are available, the
Gtk.Printer::details-acquired
signal will be emitted on this Printer. -
onDetailsAcquired
public SignalConnection<Printer.DetailsAcquiredCallback> onDetailsAcquired(Printer.DetailsAcquiredCallback handler) Emitted in response to a request for detailed information about a printer from the print backend.The
success
parameter indicates if the information was actually obtained.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDetailsAcquired
public void emitDetailsAcquired(boolean success) Emits the "details-acquired" signal. SeeonDetailsAcquired(org.gnome.gtk.Printer.DetailsAcquiredCallback)
. -
builder
APrinter.Builder
object constructs aPrinter
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withPrinter.Builder.build()
.
-