Package ch.bailu.gtk.gtk
Class PageSetup
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gtk.PageSetup
- All Implemented Interfaces:
PointerInterface
A `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 [ctor@Gtk.PageSetup.new] to get the defaults,
or use [func@Gtk.print_run_page_setup_dialog] to show the page setup dialog
and receive the resulting page setup.
## A page setup dialog
```c
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;
}
```
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 [ctor@Gtk.PageSetup.new] to get the defaults,
or use [func@Gtk.print_run_page_setup_dialog] to show the page setup dialog
and receive the resulting page setup.
## A page setup dialog
```c
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
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify -
Field Summary
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()Copies a `GtkPageSetup`.doublegetBottomMargin(int unit) Gets the bottom margin in units of @unit.static ClassHandlerstatic intdoublegetLeftMargin(int unit) Gets the left margin in units of @unit.intGets the page orientation of the `GtkPageSetup`.doublegetPageHeight(int unit) Returns the page height in units of @unit.doublegetPageWidth(int unit) Returns the page width in units of @unit.doublegetPaperHeight(int unit) Returns the paper height in units of @unit.Gets the paper size of the `GtkPageSetup`.doublegetPaperWidth(int unit) Returns the paper width in units of @unit.static longstatic TypeSystem.TypeSizedoublegetRightMargin(int unit) Gets the right margin in units of @unit.doublegetTopMargin(int unit) Gets the top margin in units of @unit.static longstatic TypeSystem.TypeSizebooleanReads the page setup from the file @file_name.booleanReads the page setup from the file @file_name.booleanloadKeyFile(KeyFile key_file, Str group_name) Reads the page setup from the group @group_name in the key file
@key_file.booleanloadKeyFile(KeyFile key_file, String group_name) Reads the page setup from the group @group_name in the key file
@key_file.static PageSetupnewFromFilePageSetup(Str file_name) Reads the page setup from the file @file_name.static PageSetupnewFromFilePageSetup(String file_name) Reads the page setup from the file @file_name.static PageSetupnewFromGvariantPageSetup(Variant variant) Desrialize a page setup from an a{sv} variant.static PageSetupnewFromKeyFilePageSetup(KeyFile key_file, Str group_name) Reads the page setup from the group @group_name in the key file
@key_file.static PageSetupnewFromKeyFilePageSetup(KeyFile key_file, String group_name) Reads the page setup from the group @group_name in the key file
@key_file.voidsetBottomMargin(double margin, int unit) Sets the bottom margin of the `GtkPageSetup`.voidsetLeftMargin(double margin, int unit) Sets the left margin of the `GtkPageSetup`.voidsetOrientation(int orientation) Sets the page orientation of the `GtkPageSetup`.voidsetPaperSize(PaperSize size) Sets the paper size of the `GtkPageSetup` without
changing the margins.voidSets the paper size of the `GtkPageSetup` and modifies
the margins according to the new paper size.voidsetRightMargin(double margin, int unit) Sets the right margin of the `GtkPageSetup`.voidsetTopMargin(double margin, int unit) Sets the top margin of the `GtkPageSetup`.booleanThis function saves the information from @setup to @file_name.booleanThis function saves the information from @setup to @file_name.Serialize page setup to an a{sv} variant.voidThis function adds the page setup from @setup to @key_file.voidThis function adds the page setup from @setup to @key_file.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnrefMethods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacksMethods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNullMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
PageSetup
-
PageSetup
public PageSetup()Creates a new `GtkPageSetup`.
-
-
Method Details
-
getClassHandler
-
newFromFilePageSetup
Reads the page setup from the file @file_name.
Returns a new `GtkPageSetup` object with the restored
page setup, or %NULL if an error occurred.
See [method@Gtk.PageSetup.to_file].- Parameters:
file_name- the filename to read the page setup from- Returns:
- the restored `GtkPageSetup`
- Throws:
AllocationError
-
newFromFilePageSetup
Reads the page setup from the file @file_name.
Returns a new `GtkPageSetup` object with the restored
page setup, or %NULL if an error occurred.
See [method@Gtk.PageSetup.to_file].- Parameters:
file_name- the filename to read the page setup from- Returns:
- the restored `GtkPageSetup`
- Throws:
AllocationError
-
newFromGvariantPageSetup
Desrialize a page setup from an a{sv} variant.
The variant must be in the format produced by
[method@Gtk.PageSetup.to_gvariant].- Parameters:
variant- an a{sv} `GVariant`- Returns:
- a new `GtkPageSetup` object
-
newFromKeyFilePageSetup
public static PageSetup newFromKeyFilePageSetup(@Nonnull KeyFile key_file, @Nullable Str group_name) throws AllocationError Reads the page setup from the group @group_name in the key file
@key_file.
Returns a new `GtkPageSetup` object with the restored
page setup, or %NULL if an error occurred.- Parameters:
key_file- the `GKeyFile` to retrieve the page_setup fromgroup_name- the name of the group in the key_file to read to use the default name “Page Setup”- Returns:
- the restored `GtkPageSetup`
- Throws:
AllocationError
-
newFromKeyFilePageSetup
public static PageSetup newFromKeyFilePageSetup(@Nonnull KeyFile key_file, String group_name) throws AllocationError Reads the page setup from the group @group_name in the key file
@key_file.
Returns a new `GtkPageSetup` object with the restored
page setup, or %NULL if an error occurred.- Parameters:
key_file- the `GKeyFile` to retrieve the page_setup fromgroup_name- the name of the group in the key_file to read to use the default name “Page Setup”- Returns:
- the restored `GtkPageSetup`
- Throws:
AllocationError
-
copy
Copies a `GtkPageSetup`.- Returns:
- a copy of @other
-
getBottomMargin
public double getBottomMargin(int unit) Gets the bottom margin in units of @unit.- Parameters:
unit- the unit for the return value- Returns:
- the bottom margin
-
getLeftMargin
public double getLeftMargin(int unit) Gets the left margin in units of @unit.- Parameters:
unit- the unit for the return value- Returns:
- the left margin
-
getOrientation
public int getOrientation()Gets the page orientation of the `GtkPageSetup`.- Returns:
- the page orientation
-
getPageHeight
public double getPageHeight(int unit) Returns the page height in units of @unit.
Note that this function takes orientation
and margins into consideration.
See [method@Gtk.PageSetup.get_paper_height].- Parameters:
unit- the unit for the return value- Returns:
- the page height.
-
getPageWidth
public double getPageWidth(int unit) Returns the page width in units of @unit.
Note that this function takes orientation
and margins into consideration.
See [method@Gtk.PageSetup.get_paper_width].- Parameters:
unit- the unit for the return value- Returns:
- the page width.
-
getPaperHeight
public double getPaperHeight(int unit) Returns the paper height in units of @unit.
Note that this function takes orientation,
but not margins into consideration.
See [method@Gtk.PageSetup.get_page_height].- Parameters:
unit- the unit for the return value- Returns:
- the paper height.
-
getPaperSize
Gets the paper size of the `GtkPageSetup`.- Returns:
- the paper size
-
getPaperWidth
public double getPaperWidth(int unit) Returns the paper width in units of @unit.
Note that this function takes orientation,
but not margins into consideration.
See [method@Gtk.PageSetup.get_page_width].- Parameters:
unit- the unit for the return value- Returns:
- the paper width.
-
getRightMargin
public double getRightMargin(int unit) Gets the right margin in units of @unit.- Parameters:
unit- the unit for the return value- Returns:
- the right margin
-
getTopMargin
public double getTopMargin(int unit) Gets the top margin in units of @unit.- Parameters:
unit- the unit for the return value- Returns:
- the top margin
-
loadFile
Reads the page setup from the file @file_name.
See [method@Gtk.PageSetup.to_file].- Parameters:
file_name- the filename to read the page setup from- Returns:
- %TRUE on success
- Throws:
AllocationError
-
loadFile
Reads the page setup from the file @file_name.
See [method@Gtk.PageSetup.to_file].- Parameters:
file_name- the filename to read the page setup from- Returns:
- %TRUE on success
- Throws:
AllocationError
-
loadKeyFile
public boolean loadKeyFile(@Nonnull KeyFile key_file, @Nullable Str group_name) throws AllocationError Reads the page setup from the group @group_name in the key file
@key_file.- Parameters:
key_file- the `GKeyFile` to retrieve the page_setup fromgroup_name- the name of the group in the key_file to read to use the default name “Page Setup”- Returns:
- %TRUE on success
- Throws:
AllocationError
-
loadKeyFile
Reads the page setup from the group @group_name in the key file
@key_file.- Parameters:
key_file- the `GKeyFile` to retrieve the page_setup fromgroup_name- the name of the group in the key_file to read to use the default name “Page Setup”- Returns:
- %TRUE on success
- Throws:
AllocationError
-
setBottomMargin
public void setBottomMargin(double margin, int unit) Sets the bottom margin of the `GtkPageSetup`.- Parameters:
margin- the new bottom margin in units of @unitunit- the units for @margin
-
setLeftMargin
public void setLeftMargin(double margin, int unit) Sets the left margin of the `GtkPageSetup`.- Parameters:
margin- the new left margin in units of @unitunit- the units for @margin
-
setOrientation
public void setOrientation(int orientation) Sets the page orientation of the `GtkPageSetup`.- Parameters:
orientation- a `GtkPageOrientation` value
-
setPaperSize
Sets the paper size of the `GtkPageSetup` without
changing the margins.
See [method@Gtk.PageSetup.set_paper_size_and_default_margins].- Parameters:
size- a `GtkPaperSize`
-
setPaperSizeAndDefaultMargins
Sets the paper size of the `GtkPageSetup` and modifies
the margins according to the new paper size.- Parameters:
size- a `GtkPaperSize`
-
setRightMargin
public void setRightMargin(double margin, int unit) Sets the right margin of the `GtkPageSetup`.- Parameters:
margin- the new right margin in units of @unitunit- the units for @margin
-
setTopMargin
public void setTopMargin(double margin, int unit) Sets the top margin of the `GtkPageSetup`.- Parameters:
margin- the new top margin in units of @unitunit- the units for @margin
-
toFile
This function saves the information from @setup to @file_name.- Parameters:
file_name- the file to save to- Returns:
- %TRUE on success
- Throws:
AllocationError
-
toFile
This function saves the information from @setup to @file_name.- Parameters:
file_name- the file to save to- Returns:
- %TRUE on success
- Throws:
AllocationError
-
toGvariant
Serialize page setup to an a{sv} variant.- Returns:
- a new, floating, `GVariant`
-
toKeyFile
This function adds the page setup from @setup to @key_file.- Parameters:
key_file- the `GKeyFile` to save the page setup togroup_name- the group to add the settings to in @key_file, or %NULL to use the default name “Page Setup”
-
toKeyFile
This function adds the page setup from @setup to @key_file.- Parameters:
key_file- the `GKeyFile` to save the page setup togroup_name- the group to add the settings to in @key_file, or %NULL to use the default name “Page Setup”
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-