Class PageSetup
- All Implemented Interfaces:
Proxy
GtkPageSetup
object stores the page size, orientation and margins.
The idea is that you can get one of these from the page setup dialog
and then pass it to the GtkPrintOperation
when printing.
The benefit of splitting this out of the GtkPrintSettings
is that
these affect the actual layout of the page, and thus need to be set
long before user prints.
Margins
The margins specified in this object are the “print margins”, i.e. the
parts of the page that the printer cannot print on. These are different
from the layout margins that a word processor uses; they are typically
used to determine the minimal size for the layout margins.
To obtain a GtkPageSetup
use PageSetup()
to get the defaults,
or use Gtk.printRunPageSetupDialog(org.gnome.gtk.Window, org.gnome.gtk.PageSetup, org.gnome.gtk.PrintSettings)
to show the page setup dialog
and receive the resulting page setup.
A page setup dialog
static GtkPrintSettings *settings = NULL;
static GtkPageSetup *page_setup = NULL;
static void
do_page_setup (void)
{
GtkPageSetup *new_page_setup;
if (settings == NULL)
settings = gtk_print_settings_new ();
new_page_setup = gtk_print_run_page_setup_dialog (GTK_WINDOW (main_window),
page_setup, settings);
if (page_setup)
g_object_unref (page_setup);
page_setup = new_page_setup;
}
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
PageSetup.Builder<B extends PageSetup.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 newGtkPageSetup
.PageSetup
(MemorySegment address) Create a PageSetup proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected PageSetup
asParent()
Returns this instance as if it were its parent type.static PageSetup.Builder
<? extends PageSetup.Builder> builder()
APageSetup.Builder
object constructs aPageSetup
with the specified properties.copy()
Copies aGtkPageSetup
.static PageSetup
Reads the page setup from the filefileName
.static PageSetup
fromGvariant
(Variant variant) Desrialize a page setup from an a{sv} variant.static PageSetup
fromKeyFile
(KeyFile keyFile, @Nullable String groupName) Reads the page setup from the groupgroupName
in the key filekeyFile
.double
getBottomMargin
(Unit unit) Gets the bottom margin in units ofunit
.double
getLeftMargin
(Unit unit) Gets the left margin in units ofunit
.Gets the page orientation of theGtkPageSetup
.double
getPageHeight
(Unit unit) Returns the page height in units ofunit
.double
getPageWidth
(Unit unit) Returns the page width in units ofunit
.double
getPaperHeight
(Unit unit) Returns the paper height in units ofunit
.Gets the paper size of theGtkPageSetup
.double
getPaperWidth
(Unit unit) Returns the paper width in units ofunit
.double
getRightMargin
(Unit unit) Gets the right margin in units ofunit
.double
getTopMargin
(Unit unit) Gets the top margin in units ofunit
.static Type
getType()
Get the GType of the PageSetup classboolean
Reads the page setup from the filefileName
.boolean
loadKeyFile
(KeyFile keyFile, @Nullable String groupName) Reads the page setup from the groupgroupName
in the key filekeyFile
.void
setBottomMargin
(double margin, Unit unit) Sets the bottom margin of theGtkPageSetup
.void
setLeftMargin
(double margin, Unit unit) Sets the left margin of theGtkPageSetup
.void
setOrientation
(PageOrientation orientation) Sets the page orientation of theGtkPageSetup
.void
setPaperSize
(PaperSize size) Sets the paper size of theGtkPageSetup
without changing the margins.void
Sets the paper size of theGtkPageSetup
and modifies the margins according to the new paper size.void
setRightMargin
(double margin, Unit unit) Sets the right margin of theGtkPageSetup
.void
setTopMargin
(double margin, Unit unit) Sets the top margin of theGtkPageSetup
.boolean
This function saves the information from this PageSetup tofileName
.Serialize page setup to an a{sv} variant.void
This function adds the page setup from this PageSetup tokeyFile
.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
-
PageSetup
Create a PageSetup proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
PageSetup
public PageSetup()Creates a newGtkPageSetup
.
-
-
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 page setup from the filefileName
.Returns a new
GtkPageSetup
object with the restored page setup, ornull
if an error occurred. SeetoFile(java.lang.String)
.- Parameters:
fileName
- the filename to read the page setup from- Returns:
- the restored
GtkPageSetup
- Throws:
GErrorException
- seeGError
-
fromGvariant
Desrialize a page setup from an a{sv} variant.The variant must be in the format produced by
toGvariant()
.- Parameters:
variant
- an a{sv}GVariant
- Returns:
- a new
GtkPageSetup
object
-
fromKeyFile
public static PageSetup fromKeyFile(KeyFile keyFile, @Nullable @Nullable String groupName) throws GErrorException Reads the page setup from the groupgroupName
in the key filekeyFile
.Returns a new
GtkPageSetup
object with the restored page setup, ornull
if an error occurred.- Parameters:
keyFile
- theGKeyFile
to retrieve the page_setup fromgroupName
- the name of the group in the key_file to read to use the default name “Page Setup”- Returns:
- the restored
GtkPageSetup
- Throws:
GErrorException
- seeGError
-
copy
-
getBottomMargin
Gets the bottom margin in units ofunit
.- Parameters:
unit
- the unit for the return value- Returns:
- the bottom margin
-
getLeftMargin
Gets the left margin in units ofunit
.- Parameters:
unit
- the unit for the return value- Returns:
- the left margin
-
getOrientation
Gets the page orientation of theGtkPageSetup
.- Returns:
- the page orientation
-
getPageHeight
Returns the page height in units ofunit
.Note that this function takes orientation and margins into consideration. See
getPaperHeight(org.gnome.gtk.Unit)
.- Parameters:
unit
- the unit for the return value- Returns:
- the page height.
-
getPageWidth
Returns the page width in units ofunit
.Note that this function takes orientation and margins into consideration. See
getPaperWidth(org.gnome.gtk.Unit)
.- Parameters:
unit
- the unit for the return value- Returns:
- the page width.
-
getPaperHeight
Returns the paper height in units ofunit
.Note that this function takes orientation, but not margins into consideration. See
getPageHeight(org.gnome.gtk.Unit)
.- Parameters:
unit
- the unit for the return value- Returns:
- the paper height.
-
getPaperSize
-
getPaperWidth
Returns the paper width in units ofunit
.Note that this function takes orientation, but not margins into consideration. See
getPageWidth(org.gnome.gtk.Unit)
.- Parameters:
unit
- the unit for the return value- Returns:
- the paper width.
-
getRightMargin
Gets the right margin in units ofunit
.- Parameters:
unit
- the unit for the return value- Returns:
- the right margin
-
getTopMargin
Gets the top margin in units ofunit
.- Parameters:
unit
- the unit for the return value- Returns:
- the top margin
-
loadFile
Reads the page setup from the filefileName
.- Parameters:
fileName
- the filename to read the page setup from- Returns:
true
on success- Throws:
GErrorException
- seeGError
-
loadKeyFile
public boolean loadKeyFile(KeyFile keyFile, @Nullable @Nullable String groupName) throws GErrorException Reads the page setup from the groupgroupName
in the key filekeyFile
.- Parameters:
keyFile
- theGKeyFile
to retrieve the page_setup fromgroupName
- the name of the group in the key_file to read to use the default name “Page Setup”- Returns:
true
on success- Throws:
GErrorException
- seeGError
-
setBottomMargin
Sets the bottom margin of theGtkPageSetup
.- Parameters:
margin
- the new bottom margin in units ofunit
unit
- the units formargin
-
setLeftMargin
Sets the left margin of theGtkPageSetup
.- Parameters:
margin
- the new left margin in units ofunit
unit
- the units formargin
-
setOrientation
Sets the page orientation of theGtkPageSetup
.- Parameters:
orientation
- aGtkPageOrientation
value
-
setPaperSize
Sets the paper size of theGtkPageSetup
without changing the margins.- Parameters:
size
- aGtkPaperSize
-
setPaperSizeAndDefaultMargins
Sets the paper size of theGtkPageSetup
and modifies the margins according to the new paper size.- Parameters:
size
- aGtkPaperSize
-
setRightMargin
Sets the right margin of theGtkPageSetup
.- Parameters:
margin
- the new right margin in units ofunit
unit
- the units formargin
-
setTopMargin
Sets the top margin of theGtkPageSetup
.- Parameters:
margin
- the new top margin in units ofunit
unit
- the units formargin
-
toFile
This function saves the information from this PageSetup tofileName
.- Parameters:
fileName
- the file to save to- Returns:
true
on success- Throws:
GErrorException
- seeGError
-
toGvariant
Serialize page setup to an a{sv} variant.- Returns:
- a new, floating,
GVariant
-
toKeyFile
This function adds the page setup from this PageSetup tokeyFile
.- Parameters:
keyFile
- theGKeyFile
to save the page setup togroupName
- the group to add the settings to inkeyFile
, ornull
to use the default name “Page Setup”
-
builder
APageSetup.Builder
object constructs aPageSetup
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withPageSetup.Builder.build()
.
-