Class PrintSettings
- All Implemented Interfaces:
Proxy
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
Nested ClassesModifier and TypeClassDescriptionstatic classPrintSettings.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
ConstructorsConstructorDescriptionCreates a new PrintSettings.PrintSettings(MemorySegment address) Create a PrintSettings proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected PrintSettingsasParent()Returns this instance as if it were its parent type.static PrintSettings.Builder<? extends PrintSettings.Builder> builder()APrintSettings.Builderobject constructs aPrintSettingswith the specified properties.copy()Copies aGtkPrintSettingsobject.voidforeach(@Nullable PrintSettingsFunc func) Callsfuncfor each key-value pair ofsettings.static PrintSettingsReads the print settings fromfileName.static PrintSettingsfromGvariant(Variant variant) Deserialize print settings from an a{sv} variant.static PrintSettingsfromKeyFile(KeyFile keyFile, @Nullable String groupName) Reads the print settings from the groupgroupNameinkeyFile.booleanReturns the boolean represented by the value that is associated withkey.booleanGets the value ofGTK_PRINT_SETTINGS_COLLATE.@Nullable StringGets the value ofGTK_PRINT_SETTINGS_DEFAULT_SOURCE.@Nullable StringGets the value ofGTK_PRINT_SETTINGS_DITHER.doubleReturns the double value associated withkey,or 0.doublegetDoubleWithDefault(String key, double def) Returns the floating point number represented by the value that is associated withkey,ordefaultValif the value does not represent a floating point number.Gets the value ofGTK_PRINT_SETTINGS_DUPLEX.@Nullable StringGets the value ofGTK_PRINT_SETTINGS_FINISHINGS.intReturns the integer value ofkey,or 0.intgetIntWithDefault(String key, int def) Returns the value ofkey,interpreted as an integer, or the default value.doubleReturns the value associated withkey,interpreted as a length.@Nullable StringGets the value ofGTK_PRINT_SETTINGS_MEDIA_TYPE.intGets the value ofGTK_PRINT_SETTINGS_N_COPIES.intGets 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.@Nullable StringGets the value ofGTK_PRINT_SETTINGS_OUTPUT_BIN.Gets the value ofGTK_PRINT_SETTINGS_PAGE_RANGES.Gets the value ofGTK_PRINT_SETTINGS_PAGE_SET.doublegetPaperHeight(Unit unit) Gets the value ofGTK_PRINT_SETTINGS_PAPER_HEIGHT, converted tounit.@Nullable PaperSizeGets the value ofGTK_PRINT_SETTINGS_PAPER_FORMAT, converted to aGtkPaperSize.doublegetPaperWidth(Unit unit) Gets the value ofGTK_PRINT_SETTINGS_PAPER_WIDTH, converted tounit.@Nullable StringConvenience function to obtain the value ofGTK_PRINT_SETTINGS_PRINTER.doubleGets the value ofGTK_PRINT_SETTINGS_PRINTER_LPI.Gets the value ofGTK_PRINT_SETTINGS_PRINT_PAGES.Gets the value ofGTK_PRINT_SETTINGS_QUALITY.intGets the value ofGTK_PRINT_SETTINGS_RESOLUTION.intGets the value ofGTK_PRINT_SETTINGS_RESOLUTION_X.intGets the value ofGTK_PRINT_SETTINGS_RESOLUTION_Y.booleanGets the value ofGTK_PRINT_SETTINGS_REVERSE.doublegetScale()Gets the value ofGTK_PRINT_SETTINGS_SCALE.@Nullable StringLooks up the string value associated withkey.static @Nullable TypegetType()Get the GType of the PrintSettings classbooleanGets the value ofGTK_PRINT_SETTINGS_USE_COLOR.booleanReturnstrue, if a value is associated withkey.booleanReads the print settings fromfileName.booleanloadKeyFile(KeyFile keyFile, @Nullable String groupName) Reads the print settings from the groupgroupNameinkeyFile.voidAssociatesvaluewithkey.voidSetskeyto a boolean value.voidsetCollate(boolean collate) Sets the value ofGTK_PRINT_SETTINGS_COLLATE.voidsetDefaultSource(String defaultSource) Sets the value ofGTK_PRINT_SETTINGS_DEFAULT_SOURCE.voidSets the value ofGTK_PRINT_SETTINGS_DITHER.voidSetskeyto a double value.voidsetDuplex(PrintDuplex duplex) Sets the value ofGTK_PRINT_SETTINGS_DUPLEX.voidsetFinishings(String finishings) Sets the value ofGTK_PRINT_SETTINGS_FINISHINGS.voidSetskeyto an integer value.voidAssociates a length in units ofunitwithkey.voidsetMediaType(String mediaType) Sets the value ofGTK_PRINT_SETTINGS_MEDIA_TYPE.voidsetNCopies(int numCopies) Sets the value ofGTK_PRINT_SETTINGS_N_COPIES.voidsetNumberUp(int numberUp) Sets the value ofGTK_PRINT_SETTINGS_NUMBER_UP.voidsetNumberUpLayout(NumberUpLayout numberUpLayout) Sets the value ofGTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT.voidsetOrientation(PageOrientation orientation) Sets the value ofGTK_PRINT_SETTINGS_ORIENTATION.voidsetOutputBin(String outputBin) Sets the value ofGTK_PRINT_SETTINGS_OUTPUT_BIN.voidsetPageRanges(@Nullable PageRange @Nullable [] pageRanges) Sets the value ofGTK_PRINT_SETTINGS_PAGE_RANGES.voidsetPageSet(PageSet pageSet) Sets the value ofGTK_PRINT_SETTINGS_PAGE_SET.voidsetPaperHeight(double height, Unit unit) Sets the value ofGTK_PRINT_SETTINGS_PAPER_HEIGHT.voidsetPaperSize(PaperSize paperSize) Sets the value ofGTK_PRINT_SETTINGS_PAPER_FORMAT,GTK_PRINT_SETTINGS_PAPER_WIDTHandGTK_PRINT_SETTINGS_PAPER_HEIGHT.voidsetPaperWidth(double width, Unit unit) Sets the value ofGTK_PRINT_SETTINGS_PAPER_WIDTH.voidsetPrinter(String printer) Convenience function to setGTK_PRINT_SETTINGS_PRINTERtoprinter.voidsetPrinterLpi(double lpi) Sets the value ofGTK_PRINT_SETTINGS_PRINTER_LPI.voidsetPrintPages(PrintPages pages) Sets the value ofGTK_PRINT_SETTINGS_PRINT_PAGES.voidsetQuality(PrintQuality quality) Sets the value ofGTK_PRINT_SETTINGS_QUALITY.voidsetResolution(int resolution) Sets the values ofGTK_PRINT_SETTINGS_RESOLUTION,GTK_PRINT_SETTINGS_RESOLUTION_XandGTK_PRINT_SETTINGS_RESOLUTION_Y.voidsetResolutionXy(int resolutionX, int resolutionY) Sets the values ofGTK_PRINT_SETTINGS_RESOLUTION,GTK_PRINT_SETTINGS_RESOLUTION_XandGTK_PRINT_SETTINGS_RESOLUTION_Y.voidsetReverse(boolean reverse) Sets the value ofGTK_PRINT_SETTINGS_REVERSE.voidsetScale(double scale) Sets the value ofGTK_PRINT_SETTINGS_SCALE.voidsetUseColor(boolean useColor) Sets the value ofGTK_PRINT_SETTINGS_USE_COLOR.booleanThis function saves the print settings from this PrintSettings tofileName.Serialize print settings to an a{sv} variant.voidThis function adds the print settings from this PrintSettings tokeyFile.voidRemoves 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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.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 new PrintSettings.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, 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
GtkPrintSettingsobject with the restored settings, ornullif an error occurred. If the file could not be loaded then error is set to either aGFileErrororGKeyFileError.- 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
GtkPrintSettingsobject
-
fromKeyFile
public static PrintSettings fromKeyFile(KeyFile keyFile, @Nullable String groupName) throws GErrorException Reads the print settings from the groupgroupNameinkeyFile.Returns a new
GtkPrintSettingsobject with the restored settings, ornullif an error occurred. If the file could not be loaded then error is set to eitherGFileErrororGKeyFileError.- Parameters:
keyFile- theGKeyFileto retrieve the settings fromgroupName- the name of the group to use, ornullto use the default “Print Settings”- Returns:
- the restored
GtkPrintSettings - Throws:
GErrorException- seeGError
-
copy
Copies aGtkPrintSettingsobject.- Returns:
- a newly allocated copy of this PrintSettings
-
foreach
Callsfuncfor each key-value pair ofsettings.- 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, ifkeymaps 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,ordefaultValif 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
GtkPageRanges. 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, ifkeyhas a value
-
loadFile
Reads the print settings fromfileName.If the file could not be loaded then error is set to either a
GFileErrororGKeyFileError.- Parameters:
fileName- the filename to read the settings from- Returns:
trueon success- Throws:
GErrorException- seeGError
-
loadKeyFile
Reads the print settings from the groupgroupNameinkeyFile.If the file could not be loaded then error is set to either a
GFileErrororGKeyFileError.- Parameters:
keyFile- theGKeyFileto retrieve the settings fromgroupName- the name of the group to use, ornullto use the default “Print Settings”- Returns:
trueon success- Throws:
GErrorException- seeGError
-
set
-
setBool
Setskeyto 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
Setskeyto a double value.- Parameters:
key- a keyvalue- a double value
-
setDuplex
Sets the value ofGTK_PRINT_SETTINGS_DUPLEX.- Parameters:
duplex- aGtkPrintDuplexvalue
-
setFinishings
Sets the value ofGTK_PRINT_SETTINGS_FINISHINGS.- Parameters:
finishings- the finishings
-
setInt
Setskeyto 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- aGtkNumberUpLayoutvalue
-
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 ofGtkPageRanges
-
setPageSet
Sets the value ofGTK_PRINT_SETTINGS_PAGE_SET.- Parameters:
pageSet- aGtkPageSetvalue
-
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_WIDTHandGTK_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- aGtkPrintPagesvalue
-
setPrinter
Convenience function to setGTK_PRINT_SETTINGS_PRINTERtoprinter.- 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- aGtkPrintQualityvalue
-
setResolution
public void setResolution(int resolution) Sets the values ofGTK_PRINT_SETTINGS_RESOLUTION,GTK_PRINT_SETTINGS_RESOLUTION_XandGTK_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_XandGTK_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
GFileErrororGKeyFileError.- Parameters:
fileName- the file to save to- Returns:
trueon 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- theGKeyFileto save the print settings togroupName- the group to add the settings to inkeyFile,ornullto 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.Builderobject constructs aPrintSettingswith the specified properties. Use the variousset...()methods to set properties, and finish construction withPrintSettings.Builder.build().- Returns:
- the builder object
-