Class PageSetup

All Implemented Interfaces:
PointerInterface

public class PageSetup extends Object
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;
}
```

https://docs.gtk.org/gtk4/class.PageSetup.html

  • Constructor Details

    • PageSetup

      public PageSetup(PointerContainer pointer)
    • PageSetup

      public PageSetup()
      Creates a new `GtkPageSetup`.
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • newFromFilePageSetup

      public static PageSetup newFromFilePageSetup(@Nonnull Str file_name) throws AllocationError
      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

      public static PageSetup newFromFilePageSetup(String file_name) throws AllocationError
      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

      public static PageSetup newFromGvariantPageSetup(@Nonnull Variant variant)
      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 from
      group_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 from
      group_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

      public PageSetup 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

      public PaperSize 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

      public boolean loadFile(@Nonnull Str file_name) throws AllocationError
      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

      public boolean loadFile(String file_name) throws AllocationError
      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 from
      group_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

      public boolean loadKeyFile(@Nonnull KeyFile key_file, String 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 from
      group_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 @unit
      unit - 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 @unit
      unit - the units for @margin
    • setOrientation

      public void setOrientation(int orientation)
      Sets the page orientation of the `GtkPageSetup`.
      Parameters:
      orientation - a `GtkPageOrientation` value
    • setPaperSize

      public void setPaperSize(@Nonnull PaperSize size)
      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

      public void setPaperSizeAndDefaultMargins(@Nonnull PaperSize size)
      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 @unit
      unit - 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 @unit
      unit - the units for @margin
    • toFile

      public boolean toFile(@Nonnull Str file_name) throws AllocationError
      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

      public boolean toFile(String file_name) throws AllocationError
      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

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

      public void toKeyFile(@Nonnull KeyFile key_file, @Nullable Str group_name)
      This function adds the page setup from @setup to @key_file.
      Parameters:
      key_file - the `GKeyFile` to save the page setup to
      group_name - the group to add the settings to in @key_file, or %NULL to use the default name “Page Setup”
    • toKeyFile

      public void toKeyFile(@Nonnull KeyFile key_file, String group_name)
      This function adds the page setup from @setup to @key_file.
      Parameters:
      key_file - the `GKeyFile` to save the page setup to
      group_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

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()