Class PaperSize

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class PaperSize extends ProxyInstance

GtkPaperSize handles paper sizes.

It uses the standard called PWG 5101.1-2002 PWG: Standard for Media Standardized Names to name the paper sizes (and to get the data for the page sizes). In addition to standard paper sizes, GtkPaperSize allows to construct custom paper sizes with arbitrary dimensions.

The GtkPaperSize object stores not only the dimensions (width and height) of a paper size and its name, it also provides default print margins.

  • Constructor Details

    • PaperSize

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

      public PaperSize(@Nullable String name)

      Creates a new GtkPaperSize object by parsing a PWG 5101.1-2002 paper name.

      If name is null, the default paper size is returned, see getDefault().

      Parameters:
      name - a paper size name
  • Method Details

    • getType

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

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

      public static PaperSize custom(String name, String displayName, double width, double height, Unit unit)
      Creates a new GtkPaperSize object with the given parameters.
      Parameters:
      name - the paper name
      displayName - the human-readable name
      width - the paper width, in units of unit
      height - the paper height, in units of unit
      unit - the unit for width and height. not Unit.NONE.
      Returns:
      a new GtkPaperSize object, use free() to free it
    • fromGvariant

      public static PaperSize fromGvariant(Variant variant)

      Deserialize a paper size from a GVariant.

      The `GVariant must be in the format produced by toGvariant().

      Parameters:
      variant - an a{sv} GVariant
      Returns:
      a new GtkPaperSize object
    • fromIpp

      public static PaperSize fromIpp(String ippName, double width, double height)

      Creates a new GtkPaperSize object by using IPP information.

      If ippName is not a recognized paper name, width and height are used to construct a custom GtkPaperSize object.

      Parameters:
      ippName - an IPP paper name
      width - the paper width, in points
      height - the paper height in points
      Returns:
      a new GtkPaperSize, use free() to free it
    • fromKeyFile

      public static PaperSize fromKeyFile(KeyFile keyFile, @Nullable String groupName) throws GErrorException
      Reads a paper size from the group groupName in the key file keyFile.
      Parameters:
      keyFile - the GKeyFile to retrieve the papersize from
      groupName - the name of the group in the key file to read, or null to read the first group
      Returns:
      a new GtkPaperSize object with the restored paper size
      Throws:
      GErrorException - see GError
    • fromPpd

      public static PaperSize fromPpd(String ppdName, String ppdDisplayName, double width, double height)

      Creates a new GtkPaperSize object by using PPD information.

      If ppdName is not a recognized PPD paper name, ppdDisplayName, width and height are used to construct a custom GtkPaperSize object.

      Parameters:
      ppdName - a PPD paper name
      ppdDisplayName - the corresponding human-readable name
      width - the paper width, in points
      height - the paper height in points
      Returns:
      a new GtkPaperSize, use free() to free it
    • getDefault

      public static String getDefault()
      Returns the name of the default paper size, which depends on the current locale.
      Returns:
      the name of the default paper size. The string is owned by GTK and should not be modified.
    • getPaperSizes

      public static List<PaperSize> getPaperSizes(boolean includeCustom)
      Creates a list of known paper sizes.
      Parameters:
      includeCustom - whether to include custom paper sizes as defined in the page setup dialog
      Returns:
      a newly allocated list of newly allocated GtkPaperSize objects
    • copy

      public PaperSize copy()
      Copies an existing GtkPaperSize.
      Returns:
      a copy of this PaperSize
    • free

      public void free()
      Free the given GtkPaperSize object.
    • getDefaultBottomMargin

      public double getDefaultBottomMargin(Unit unit)
      Gets the default bottom margin for the GtkPaperSize.
      Parameters:
      unit - the unit for the return value, not Unit.NONE
      Returns:
      the default bottom margin
    • getDefaultLeftMargin

      public double getDefaultLeftMargin(Unit unit)
      Gets the default left margin for the GtkPaperSize.
      Parameters:
      unit - the unit for the return value, not Unit.NONE
      Returns:
      the default left margin
    • getDefaultRightMargin

      public double getDefaultRightMargin(Unit unit)
      Gets the default right margin for the GtkPaperSize.
      Parameters:
      unit - the unit for the return value, not Unit.NONE
      Returns:
      the default right margin
    • getDefaultTopMargin

      public double getDefaultTopMargin(Unit unit)
      Gets the default top margin for the GtkPaperSize.
      Parameters:
      unit - the unit for the return value, not Unit.NONE
      Returns:
      the default top margin
    • getDisplayName

      public String getDisplayName()
      Gets the human-readable name of the GtkPaperSize.
      Returns:
      the human-readable name of this PaperSize
    • getHeight

      public double getHeight(Unit unit)
      Gets the paper height of the GtkPaperSize, in units of unit.
      Parameters:
      unit - the unit for the return value, not Unit.NONE
      Returns:
      the paper height
    • getName

      public String getName()
      Gets the name of the GtkPaperSize.
      Returns:
      the name of this PaperSize
    • getPpdName

      public String getPpdName()
      Gets the PPD name of the GtkPaperSize, which may be null.
      Returns:
      the PPD name of this PaperSize
    • getWidth

      public double getWidth(Unit unit)
      Gets the paper width of the GtkPaperSize, in units of unit.
      Parameters:
      unit - the unit for the return value, not Unit.NONE
      Returns:
      the paper width
    • isCustom

      public boolean isCustom()
      Returns true if this PaperSize is not a standard paper size.
      Returns:
      whether this PaperSize is a custom paper size.
    • isEqual

      public boolean isEqual(PaperSize size2)
      Compares two GtkPaperSize objects.
      Parameters:
      size2 - another GtkPaperSize object
      Returns:
      true, if this PaperSize and size2 represent the same paper size
    • isIpp

      public boolean isIpp()
      Returns true if this PaperSize is an IPP standard paper size.
      Returns:
      whether this PaperSize is not an IPP custom paper size.
    • setSize

      public void setSize(double width, double height, Unit unit)
      Changes the dimensions of a this PaperSize to width x height.
      Parameters:
      width - the new width in units of unit
      height - the new height in units of unit
      unit - the unit for width and height
    • toGvariant

      public Variant toGvariant()
      Serialize a paper size to an a{sv} variant.
      Returns:
      a new, floating, GVariant
    • toKeyFile

      public void toKeyFile(KeyFile keyFile, String groupName)
      This function adds the paper size from this PaperSize to keyFile.
      Parameters:
      keyFile - the GKeyFile to save the paper size to
      groupName - the group to add the settings to in keyFile