Class Printer

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Printer extends GObject

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.

  • Constructor Details

    • Printer

      public Printer(MemorySegment address)
      Create a Printer instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Printer

      public Printer(String name, PrintBackend backend, boolean virtual)
      Creates a new GtkPrinter.
      Parameters:
      name - the name of the printer
      backend - a GtkPrintBackend
      virtual - whether the printer is virtual
    • Printer

      public Printer()
      Create a new Printer.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Printer class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected Printer asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its 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

      public int compare(Printer b)
      Compares two printers.
      Parameters:
      b - another GtkPrinter
      Returns:
      0 if the printer match, a negative value if this Printer < b, or a positive value if this Printer > b
    • getBackend

      public PrintBackend getBackend()
      Returns the backend of the printer.
      Returns:
      the backend of this Printer
    • getCapabilities

      public Set<PrintCapabilities> 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() and requestDetails().

      Returns:
      the printer’s capabilities
    • getDefaultPageSize

      public PageSetup getDefaultPageSize()
      Returns default page size of printer.
      Returns:
      a newly allocated GtkPageSetup with default page size of the printer.
    • getDescription

      public String 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 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() and requestDetails().

      Parameters:
      top - a location to store the top margin in
      bottom - a location to store the bottom margin in
      left - a location to store the left margin in
      right - 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 for paperSize.

      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() and requestDetails().

      Parameters:
      paperSize - a GtkPaperSize
      top - a location to store the top margin in
      bottom - a location to store the bottom margin in
      left - a location to store the left margin in
      right - a location to store the right margin in
      Returns:
      true iff the hard margins were retrieved
    • getIconName

      public String 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

      public String getLocation()
      Returns a description of the location of the printer.
      Returns:
      the location of this Printer
    • getName

      public String getName()
      Returns the name of the printer.
      Returns:
      the name of this Printer
    • getStateMessage

      public String 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

      public List<PageSetup> listPapers()

      Lists all the paper sizes this Printer supports.

      This will return and empty list unless the printer’s details are available, see hasDetails() and requestDetails().

      Returns:
      a newly allocated list of newly allocated GtkPageSetups.
    • requestDetails

      public void requestDetails()

      Requests the printer details.

      When the details are available, the Gtk.Printer::details-acquired signal will be emitted on printer.

    • onDetailsAcquired

      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. See onDetailsAcquired(Printer.DetailsAcquiredCallback).
    • builder

      public static Printer.Builder<? extends Printer.Builder> builder()
      A Printer.Builder object constructs a Printer with the specified properties. Use the various set...() methods to set properties, and finish construction with Printer.Builder.build().
      Returns:
      the builder object