Class PrintSettings
- All Implemented Interfaces:
Proxy
GtkPrintSettings
object represents the settings of a print dialog in
a system-independent way.
The main use for this object is that once you’ve printed you can get a settings object that represents the settings the user chose, and the next time you print you can pass that object in so that the user doesn’t have to re-set all his settings.
Its also possible to enumerate the settings so that you can easily save the settings for the next time your app runs, or even store them in a document. The predefined keys try to use shared values as much as possible so that moving such a document between systems still works.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
PrintSettings.Builder<B extends PrintSettings.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionCreates a newGtkPrintSettings
object.PrintSettings
(MemorySegment address) Create a PrintSettings proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected PrintSettings
asParent()
Returns this instance as if it were its parent type.static PrintSettings.Builder
<? extends PrintSettings.Builder> builder()
APrintSettings.Builder
object constructs aPrintSettings
with the specified properties.copy()
Copies aGtkPrintSettings
object.void
foreach
(PrintSettingsFunc func) Callsfunc
for each key-value pair of this PrintSettings.static PrintSettings
Reads the print settings fromfileName
.static PrintSettings
fromGvariant
(Variant variant) Deserialize print settings from an a{sv} variant.static PrintSettings
fromKeyFile
(KeyFile keyFile, @Nullable String groupName) Reads the print settings from the groupgroupName
inkeyFile
.boolean
Returns the boolean represented by the value that is associated withkey
.boolean
Gets the value ofGTK_PRINT_SETTINGS_COLLATE
.Gets the value ofGTK_PRINT_SETTINGS_DEFAULT_SOURCE
.Gets the value ofGTK_PRINT_SETTINGS_DITHER
.double
Returns the double value associated withkey
, or 0.double
getDoubleWithDefault
(String key, double def) Returns the floating point number represented by the value that is associated withkey
, ordefaultVal
if the value does not represent a floating point number.Gets the value ofGTK_PRINT_SETTINGS_DUPLEX
.Gets the value ofGTK_PRINT_SETTINGS_FINISHINGS
.int
Returns the integer value ofkey
, or 0.int
getIntWithDefault
(String key, int def) Returns the value ofkey
, interpreted as an integer, or the default value.double
Returns the value associated withkey
, interpreted as a length.Gets the value ofGTK_PRINT_SETTINGS_MEDIA_TYPE
.int
Gets the value ofGTK_PRINT_SETTINGS_N_COPIES
.int
Gets the value ofGTK_PRINT_SETTINGS_NUMBER_UP
.Gets the value ofGTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT
.Get the value ofGTK_PRINT_SETTINGS_ORIENTATION
, converted to aGtkPageOrientation
.Gets the value ofGTK_PRINT_SETTINGS_OUTPUT_BIN
.Gets the value ofGTK_PRINT_SETTINGS_PAGE_RANGES
.Gets the value ofGTK_PRINT_SETTINGS_PAGE_SET
.double
getPaperHeight
(Unit unit) Gets the value ofGTK_PRINT_SETTINGS_PAPER_HEIGHT
, converted tounit
.Gets the value ofGTK_PRINT_SETTINGS_PAPER_FORMAT
, converted to aGtkPaperSize
.double
getPaperWidth
(Unit unit) Gets the value ofGTK_PRINT_SETTINGS_PAPER_WIDTH
, converted tounit
.Convenience function to obtain the value ofGTK_PRINT_SETTINGS_PRINTER
.double
Gets the value ofGTK_PRINT_SETTINGS_PRINTER_LPI
.Gets the value ofGTK_PRINT_SETTINGS_PRINT_PAGES
.Gets the value ofGTK_PRINT_SETTINGS_QUALITY
.int
Gets the value ofGTK_PRINT_SETTINGS_RESOLUTION
.int
Gets the value ofGTK_PRINT_SETTINGS_RESOLUTION_X
.int
Gets the value ofGTK_PRINT_SETTINGS_RESOLUTION_Y
.boolean
Gets the value ofGTK_PRINT_SETTINGS_REVERSE
.double
getScale()
Gets the value ofGTK_PRINT_SETTINGS_SCALE
.Looks up the string value associated withkey
.static Type
getType()
Get the GType of the PrintSettings classboolean
Gets the value ofGTK_PRINT_SETTINGS_USE_COLOR
.boolean
Returnstrue
, if a value is associated withkey
.boolean
Reads the print settings fromfileName
.boolean
loadKeyFile
(KeyFile keyFile, @Nullable String groupName) Reads the print settings from the groupgroupName
inkeyFile
.void
Associatesvalue
withkey
.void
Setskey
to a boolean value.void
setCollate
(boolean collate) Sets the value ofGTK_PRINT_SETTINGS_COLLATE
.void
setDefaultSource
(String defaultSource) Sets the value ofGTK_PRINT_SETTINGS_DEFAULT_SOURCE
.void
Sets the value ofGTK_PRINT_SETTINGS_DITHER
.void
Setskey
to a double value.void
setDuplex
(PrintDuplex duplex) Sets the value ofGTK_PRINT_SETTINGS_DUPLEX
.void
setFinishings
(String finishings) Sets the value ofGTK_PRINT_SETTINGS_FINISHINGS
.void
Setskey
to an integer value.void
Associates a length in units ofunit
withkey
.void
setMediaType
(String mediaType) Sets the value ofGTK_PRINT_SETTINGS_MEDIA_TYPE
.void
setNCopies
(int numCopies) Sets the value ofGTK_PRINT_SETTINGS_N_COPIES
.void
setNumberUp
(int numberUp) Sets the value ofGTK_PRINT_SETTINGS_NUMBER_UP
.void
setNumberUpLayout
(NumberUpLayout numberUpLayout) Sets the value ofGTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT
.void
setOrientation
(PageOrientation orientation) Sets the value ofGTK_PRINT_SETTINGS_ORIENTATION
.void
setOutputBin
(String outputBin) Sets the value ofGTK_PRINT_SETTINGS_OUTPUT_BIN
.void
setPageRanges
(PageRange[] pageRanges) Sets the value ofGTK_PRINT_SETTINGS_PAGE_RANGES
.void
setPageSet
(PageSet pageSet) Sets the value ofGTK_PRINT_SETTINGS_PAGE_SET
.void
setPaperHeight
(double height, Unit unit) Sets the value ofGTK_PRINT_SETTINGS_PAPER_HEIGHT
.void
setPaperSize
(PaperSize paperSize) Sets the value ofGTK_PRINT_SETTINGS_PAPER_FORMAT
,GTK_PRINT_SETTINGS_PAPER_WIDTH
andGTK_PRINT_SETTINGS_PAPER_HEIGHT
.void
setPaperWidth
(double width, Unit unit) Sets the value ofGTK_PRINT_SETTINGS_PAPER_WIDTH
.void
setPrinter
(String printer) Convenience function to setGTK_PRINT_SETTINGS_PRINTER
toprinter
.void
setPrinterLpi
(double lpi) Sets the value ofGTK_PRINT_SETTINGS_PRINTER_LPI
.void
setPrintPages
(PrintPages pages) Sets the value ofGTK_PRINT_SETTINGS_PRINT_PAGES
.void
setQuality
(PrintQuality quality) Sets the value ofGTK_PRINT_SETTINGS_QUALITY
.void
setResolution
(int resolution) Sets the values ofGTK_PRINT_SETTINGS_RESOLUTION
,GTK_PRINT_SETTINGS_RESOLUTION_X
andGTK_PRINT_SETTINGS_RESOLUTION_Y
.void
setResolutionXy
(int resolutionX, int resolutionY) Sets the values ofGTK_PRINT_SETTINGS_RESOLUTION
,GTK_PRINT_SETTINGS_RESOLUTION_X
andGTK_PRINT_SETTINGS_RESOLUTION_Y
.void
setReverse
(boolean reverse) Sets the value ofGTK_PRINT_SETTINGS_REVERSE
.void
setScale
(double scale) Sets the value ofGTK_PRINT_SETTINGS_SCALE
.void
setUseColor
(boolean useColor) Sets the value ofGTK_PRINT_SETTINGS_USE_COLOR
.boolean
This function saves the print settings from this PrintSettings tofileName
.Serialize print settings to an a{sv} variant.void
This function adds the print settings from this PrintSettings tokeyFile
.void
Removes any value associated withkey
.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
-
PrintSettings
Create a PrintSettings proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
PrintSettings
public PrintSettings()Creates a newGtkPrintSettings
object.
-
-
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. -
fromFile
Reads the print settings fromfileName
.Returns a new
GtkPrintSettings
object with the restored settings, ornull
if an error occurred. If the file could not be loaded then error is set to either aGFileError
orGKeyFileError
.- Parameters:
fileName
- the filename to read the settings from- Returns:
- the restored
GtkPrintSettings
- Throws:
GErrorException
- seeGError
-
fromGvariant
Deserialize print settings from an a{sv} variant.The variant must be in the format produced by
toGvariant()
.- Parameters:
variant
- an a{sv}GVariant
- Returns:
- a new
GtkPrintSettings
object
-
fromKeyFile
public static PrintSettings fromKeyFile(KeyFile keyFile, @Nullable @Nullable String groupName) throws GErrorException Reads the print settings from the groupgroupName
inkeyFile
.Returns a new
GtkPrintSettings
object with the restored settings, ornull
if an error occurred. If the file could not be loaded then error is set to eitherGFileError
orGKeyFileError
.- Parameters:
keyFile
- theGKeyFile
to retrieve the settings fromgroupName
- the name of the group to use, ornull
to use the default “Print Settings”- Returns:
- the restored
GtkPrintSettings
- Throws:
GErrorException
- seeGError
-
copy
Copies aGtkPrintSettings
object.- Returns:
- a newly allocated copy of this PrintSettings
-
foreach
Callsfunc
for each key-value pair of this PrintSettings.- Parameters:
func
- the function to call
-
getString
-
getBool
Returns the boolean represented by the value that is associated withkey
.The string “true” represents
true
, any other stringfalse
.- Parameters:
key
- a key- Returns:
true
, ifkey
maps to a true value.
-
getCollate
public boolean getCollate()Gets the value ofGTK_PRINT_SETTINGS_COLLATE
.- Returns:
- whether to collate the printed pages
-
getDefaultSource
Gets the value ofGTK_PRINT_SETTINGS_DEFAULT_SOURCE
.- Returns:
- the default source
-
getDither
Gets the value ofGTK_PRINT_SETTINGS_DITHER
.- Returns:
- the dithering that is used
-
getDouble
Returns the double value associated withkey
, or 0.- Parameters:
key
- a key- Returns:
- the double value of
key
-
getDoubleWithDefault
Returns the floating point number represented by the value that is associated withkey
, ordefaultVal
if the value does not represent a floating point number.Floating point numbers are parsed with g_ascii_strtod().
- Parameters:
key
- a keydef
- the default value- Returns:
- the floating point number associated with
key
-
getDuplex
Gets the value ofGTK_PRINT_SETTINGS_DUPLEX
.- Returns:
- whether to print the output in duplex.
-
getFinishings
Gets the value ofGTK_PRINT_SETTINGS_FINISHINGS
.- Returns:
- the finishings
-
getInt
Returns the integer value ofkey
, or 0.- Parameters:
key
- a key- Returns:
- the integer value of
key
-
getIntWithDefault
Returns the value ofkey
, interpreted as an integer, or the default value.- Parameters:
key
- a keydef
- the default value- Returns:
- the integer value of
key
-
getLength
-
getMediaType
Gets the value ofGTK_PRINT_SETTINGS_MEDIA_TYPE
.The set of media types is defined in PWG 5101.1-2002 PWG.
- Returns:
- the media type
-
getNCopies
public int getNCopies()Gets the value ofGTK_PRINT_SETTINGS_N_COPIES
.- Returns:
- the number of copies to print
-
getNumberUp
public int getNumberUp()Gets the value ofGTK_PRINT_SETTINGS_NUMBER_UP
.- Returns:
- the number of pages per sheet
-
getNumberUpLayout
Gets the value ofGTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT
.- Returns:
- layout of page in number-up mode
-
getOrientation
Get the value ofGTK_PRINT_SETTINGS_ORIENTATION
, converted to aGtkPageOrientation
.- Returns:
- the orientation
-
getOutputBin
Gets the value ofGTK_PRINT_SETTINGS_OUTPUT_BIN
.- Returns:
- the output bin
-
getPageRanges
Gets the value ofGTK_PRINT_SETTINGS_PAGE_RANGES
.- Returns:
- an array
of
GtkPageRange
s. Use g_free() to free the array when it is no longer needed.
-
getPageSet
Gets the value ofGTK_PRINT_SETTINGS_PAGE_SET
.- Returns:
- the set of pages to print
-
getPaperHeight
Gets the value ofGTK_PRINT_SETTINGS_PAPER_HEIGHT
, converted tounit
.- Parameters:
unit
- the unit for the return value- Returns:
- the paper height, in units of
unit
-
getPaperSize
Gets the value ofGTK_PRINT_SETTINGS_PAPER_FORMAT
, converted to aGtkPaperSize
.- Returns:
- the paper size
-
getPaperWidth
Gets the value ofGTK_PRINT_SETTINGS_PAPER_WIDTH
, converted tounit
.- Parameters:
unit
- the unit for the return value- Returns:
- the paper width, in units of
unit
-
getPrintPages
Gets the value ofGTK_PRINT_SETTINGS_PRINT_PAGES
.- Returns:
- which pages to print
-
getPrinter
Convenience function to obtain the value ofGTK_PRINT_SETTINGS_PRINTER
.- Returns:
- the printer name
-
getPrinterLpi
public double getPrinterLpi()Gets the value ofGTK_PRINT_SETTINGS_PRINTER_LPI
.- Returns:
- the resolution in lpi (lines per inch)
-
getQuality
Gets the value ofGTK_PRINT_SETTINGS_QUALITY
.- Returns:
- the print quality
-
getResolution
public int getResolution()Gets the value ofGTK_PRINT_SETTINGS_RESOLUTION
.- Returns:
- the resolution in dpi
-
getResolutionX
public int getResolutionX()Gets the value ofGTK_PRINT_SETTINGS_RESOLUTION_X
.- Returns:
- the horizontal resolution in dpi
-
getResolutionY
public int getResolutionY()Gets the value ofGTK_PRINT_SETTINGS_RESOLUTION_Y
.- Returns:
- the vertical resolution in dpi
-
getReverse
public boolean getReverse()Gets the value ofGTK_PRINT_SETTINGS_REVERSE
.- Returns:
- whether to reverse the order of the printed pages
-
getScale
public double getScale()Gets the value ofGTK_PRINT_SETTINGS_SCALE
.- Returns:
- the scale in percent
-
getUseColor
public boolean getUseColor()Gets the value ofGTK_PRINT_SETTINGS_USE_COLOR
.- Returns:
- whether to use color
-
hasKey
Returnstrue
, if a value is associated withkey
.- Parameters:
key
- a key- Returns:
true
, ifkey
has a value
-
loadFile
Reads the print settings fromfileName
.If the file could not be loaded then error is set to either a
GFileError
orGKeyFileError
.- Parameters:
fileName
- the filename to read the settings from- Returns:
true
on success- Throws:
GErrorException
- seeGError
-
loadKeyFile
public boolean loadKeyFile(KeyFile keyFile, @Nullable @Nullable String groupName) throws GErrorException Reads the print settings from the groupgroupName
inkeyFile
.If the file could not be loaded then error is set to either a
GFileError
orGKeyFileError
.- Parameters:
keyFile
- theGKeyFile
to retrieve the settings fromgroupName
- the name of the group to use, ornull
to use the default “Print Settings”- Returns:
true
on success- Throws:
GErrorException
- seeGError
-
set
-
setBool
Setskey
to a boolean value.- Parameters:
key
- a keyvalue
- a boolean
-
setCollate
public void setCollate(boolean collate) Sets the value ofGTK_PRINT_SETTINGS_COLLATE
.- Parameters:
collate
- whether to collate the output
-
setDefaultSource
Sets the value ofGTK_PRINT_SETTINGS_DEFAULT_SOURCE
.- Parameters:
defaultSource
- the default source
-
setDither
Sets the value ofGTK_PRINT_SETTINGS_DITHER
.- Parameters:
dither
- the dithering that is used
-
setDouble
Setskey
to a double value.- Parameters:
key
- a keyvalue
- a double value
-
setDuplex
Sets the value ofGTK_PRINT_SETTINGS_DUPLEX
.- Parameters:
duplex
- aGtkPrintDuplex
value
-
setFinishings
Sets the value ofGTK_PRINT_SETTINGS_FINISHINGS
.- Parameters:
finishings
- the finishings
-
setInt
Setskey
to an integer value.- Parameters:
key
- a keyvalue
- an integer
-
setLength
-
setMediaType
Sets the value ofGTK_PRINT_SETTINGS_MEDIA_TYPE
.The set of media types is defined in PWG 5101.1-2002 PWG.
- Parameters:
mediaType
- the media type
-
setNCopies
public void setNCopies(int numCopies) Sets the value ofGTK_PRINT_SETTINGS_N_COPIES
.- Parameters:
numCopies
- the number of copies
-
setNumberUp
public void setNumberUp(int numberUp) Sets the value ofGTK_PRINT_SETTINGS_NUMBER_UP
.- Parameters:
numberUp
- the number of pages per sheet
-
setNumberUpLayout
Sets the value ofGTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT
.- Parameters:
numberUpLayout
- aGtkNumberUpLayout
value
-
setOrientation
Sets the value ofGTK_PRINT_SETTINGS_ORIENTATION
.- Parameters:
orientation
- a page orientation
-
setOutputBin
Sets the value ofGTK_PRINT_SETTINGS_OUTPUT_BIN
.- Parameters:
outputBin
- the output bin
-
setPageRanges
Sets the value ofGTK_PRINT_SETTINGS_PAGE_RANGES
.- Parameters:
pageRanges
- an array ofGtkPageRange
s
-
setPageSet
Sets the value ofGTK_PRINT_SETTINGS_PAGE_SET
.- Parameters:
pageSet
- aGtkPageSet
value
-
setPaperHeight
Sets the value ofGTK_PRINT_SETTINGS_PAPER_HEIGHT
.- Parameters:
height
- the paper heightunit
- the units ofheight
-
setPaperSize
Sets the value ofGTK_PRINT_SETTINGS_PAPER_FORMAT
,GTK_PRINT_SETTINGS_PAPER_WIDTH
andGTK_PRINT_SETTINGS_PAPER_HEIGHT
.- Parameters:
paperSize
- a paper size
-
setPaperWidth
Sets the value ofGTK_PRINT_SETTINGS_PAPER_WIDTH
.- Parameters:
width
- the paper widthunit
- the units ofwidth
-
setPrintPages
Sets the value ofGTK_PRINT_SETTINGS_PRINT_PAGES
.- Parameters:
pages
- aGtkPrintPages
value
-
setPrinter
Convenience function to setGTK_PRINT_SETTINGS_PRINTER
toprinter
.- Parameters:
printer
- the printer name
-
setPrinterLpi
public void setPrinterLpi(double lpi) Sets the value ofGTK_PRINT_SETTINGS_PRINTER_LPI
.- Parameters:
lpi
- the resolution in lpi (lines per inch)
-
setQuality
Sets the value ofGTK_PRINT_SETTINGS_QUALITY
.- Parameters:
quality
- aGtkPrintQuality
value
-
setResolution
public void setResolution(int resolution) Sets the values ofGTK_PRINT_SETTINGS_RESOLUTION
,GTK_PRINT_SETTINGS_RESOLUTION_X
andGTK_PRINT_SETTINGS_RESOLUTION_Y
.- Parameters:
resolution
- the resolution in dpi
-
setResolutionXy
public void setResolutionXy(int resolutionX, int resolutionY) Sets the values ofGTK_PRINT_SETTINGS_RESOLUTION
,GTK_PRINT_SETTINGS_RESOLUTION_X
andGTK_PRINT_SETTINGS_RESOLUTION_Y
.- Parameters:
resolutionX
- the horizontal resolution in dpiresolutionY
- the vertical resolution in dpi
-
setReverse
public void setReverse(boolean reverse) Sets the value ofGTK_PRINT_SETTINGS_REVERSE
.- Parameters:
reverse
- whether to reverse the output
-
setScale
public void setScale(double scale) Sets the value ofGTK_PRINT_SETTINGS_SCALE
.- Parameters:
scale
- the scale in percent
-
setUseColor
public void setUseColor(boolean useColor) Sets the value ofGTK_PRINT_SETTINGS_USE_COLOR
.- Parameters:
useColor
- whether to use color
-
toFile
This function saves the print settings from this PrintSettings tofileName
.If the file could not be written then error is set to either a
GFileError
orGKeyFileError
.- Parameters:
fileName
- the file to save to- Returns:
true
on success- Throws:
GErrorException
- seeGError
-
toGvariant
Serialize print settings to an a{sv} variant.- Returns:
- a new, floating,
GVariant
-
toKeyFile
This function adds the print settings from this PrintSettings tokeyFile
.- Parameters:
keyFile
- theGKeyFile
to save the print settings togroupName
- the group to add the settings to inkeyFile
, ornull
to use the default “Print Settings”
-
unset
Removes any value associated withkey
.This has the same effect as setting the value to
null
.- Parameters:
key
- a key
-
builder
APrintSettings.Builder
object constructs aPrintSettings
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withPrintSettings.Builder.build()
.
-