Class: Gtk::PageSetup

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Overview

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 Gtk::PrintOperation when printing. The benefit of splitting this out of the Gtk::PrintSettings is that these affect the actual layout of the page, and thus need to be set long before user prints.

## Margins ## #print-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 Gtk::PageSetup use gtk_page_setup_new() to get the defaults, or use gtk_print_run_page_setup_dialog() 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;
}

Printing support was added in GTK+ 2.10.

Instance Method Summary collapse

Instance Method Details

#copyGtk::PageSetup

Copies a Gtk::PageSetup.

Returns:

#get_bottom_margin(unit) ⇒ Float

Gets the bottom margin in units of unit.

Parameters:

  • unit (Gtk::Unit)

    the unit for the return value

Returns:

  • (Float)

    the bottom margin

#get_left_margin(unit) ⇒ Float

Gets the left margin in units of unit.

Parameters:

  • unit (Gtk::Unit)

    the unit for the return value

Returns:

  • (Float)

    the left margin

#get_page_height(unit) ⇒ Float

Returns the page height in units of unit.

Note that this function takes orientation and margins into consideration. See gtk_page_setup_get_paper_height().

Parameters:

  • unit (Gtk::Unit)

    the unit for the return value

Returns:

  • (Float)

    the page height.

#get_page_width(unit) ⇒ Float

Returns the page width in units of unit.

Note that this function takes orientation and margins into consideration. See gtk_page_setup_get_paper_width().

Parameters:

  • unit (Gtk::Unit)

    the unit for the return value

Returns:

  • (Float)

    the page width.

#get_paper_height(unit) ⇒ Float

Returns the paper height in units of unit.

Note that this function takes orientation, but not margins into consideration. See gtk_page_setup_get_page_height().

Parameters:

  • unit (Gtk::Unit)

    the unit for the return value

Returns:

  • (Float)

    the paper height.

#get_paper_width(unit) ⇒ Float

Returns the paper width in units of unit.

Note that this function takes orientation, but not margins into consideration. See gtk_page_setup_get_page_width().

Parameters:

  • unit (Gtk::Unit)

    the unit for the return value

Returns:

  • (Float)

    the paper width.

#get_right_margin(unit) ⇒ Float

Gets the right margin in units of unit.

Parameters:

  • unit (Gtk::Unit)

    the unit for the return value

Returns:

  • (Float)

    the right margin

#get_top_margin(unit) ⇒ Float

Gets the top margin in units of unit.

Parameters:

  • unit (Gtk::Unit)

    the unit for the return value

Returns:

  • (Float)

    the top margin

#load_file(file_name) ⇒ TrueClass

Reads the page setup from the file file_name. See gtk_page_setup_to_file().

Parameters:

  • file_name (Gtk::filename)

    the filename to read the page setup from

Returns:

  • (TrueClass)

    true on success

#load_key_file(key_file, group_name) ⇒ TrueClass

Reads the page setup from the group group_name in the key file key_file.

Parameters:

  • key_file (GLib::KeyFile)

    the GKey::File to retrieve the page_setup from

  • group_name (String)

    the name of the group in the key_file to read, or nil to use the default name “Page Setup”

Returns:

  • (TrueClass)

    true on success

#newGtk::PageSetup

Creates a new Gtk::PageSetup.

Returns:

#new_from_file(file_name) ⇒ Gtk::PageSetup

Reads the page setup from the file file_name. Returns a new Gtk::PageSetup object with the restored page setup, or nil if an error occurred. See gtk_page_setup_to_file().

Parameters:

  • file_name (Gtk::filename)

    the filename to read the page setup from

Returns:

#new_from_gvariant(variant) ⇒ Gtk::PageSetup

Desrialize a page setup from an asv variant in the format produced by gtk_page_setup_to_gvariant().

Parameters:

  • variant (GLib::Variant)

    an asv #GVariant

Returns:

#new_from_key_file(key_file, group_name) ⇒ Gtk::PageSetup

Reads the page setup from the group group_name in the key file key_file. Returns a new Gtk::PageSetup object with the restored page setup, or nil if an error occurred.

Parameters:

  • key_file (GLib::KeyFile)

    the GKey::File to retrieve the page_setup from

  • group_name (String)

    the name of the group in the key_file to read, or nil to use the default name “Page Setup”

Returns:

#orientationGtk::PageOrientation

Gets the page orientation of the Gtk::PageSetup.

Returns:

#orientation=(orientation) ⇒ nil

Sets the page orientation of the Gtk::PageSetup.

Parameters:

Returns:

  • (nil)

#paper_sizeGtk::PaperSize

Gets the paper size of the Gtk::PageSetup.

Returns:

  • (Gtk::PaperSize)

    the paper size

#paper_size=(size) ⇒ nil

Sets the paper size of the Gtk::PageSetup without changing the margins. See gtk_page_setup_set_paper_size_and_default_margins().

Parameters:

  • size (Gtk::PaperSize)

    a Gtk::PaperSize

Returns:

  • (nil)

#paper_size_and_default_margins=(size) ⇒ nil

Sets the paper size of the Gtk::PageSetup and modifies the margins according to the new paper size.

Parameters:

  • size (Gtk::PaperSize)

    a Gtk::PaperSize

Returns:

  • (nil)

#set_bottom_margin(margin, unit) ⇒ nil

Sets the bottom margin of the Gtk::PageSetup.

Parameters:

  • margin (Float)

    the new bottom margin in units of unit

  • unit (Gtk::Unit)

    the units for margin

Returns:

  • (nil)

#set_left_margin(margin, unit) ⇒ nil

Sets the left margin of the Gtk::PageSetup.

Parameters:

  • margin (Float)

    the new left margin in units of unit

  • unit (Gtk::Unit)

    the units for margin

Returns:

  • (nil)

#set_right_margin(margin, unit) ⇒ nil

Sets the right margin of the Gtk::PageSetup.

Parameters:

  • margin (Float)

    the new right margin in units of unit

  • unit (Gtk::Unit)

    the units for margin

Returns:

  • (nil)

#set_top_margin(margin, unit) ⇒ nil

Sets the top margin of the Gtk::PageSetup.

Parameters:

  • margin (Float)

    the new top margin in units of unit

  • unit (Gtk::Unit)

    the units for margin

Returns:

  • (nil)

#to_file(file_name) ⇒ TrueClass

This function saves the information from setup to file_name.

Parameters:

  • file_name (Gtk::filename)

    the file to save to

Returns:

  • (TrueClass)

    true on success

#to_gvariantGLib::Variant

Serialize page setup to an asv variant.

Returns:

  • (GLib::Variant)

    a new, floating, #GVariant

#to_key_file(key_file, group_name) ⇒ nil

This function adds the page setup from setup to key_file.

Parameters:

  • key_file (GLib::KeyFile)

    the GKey::File to save the page setup to

  • group_name (String)

    the group to add the settings to in key_file, or nil to use the default name “Page Setup”

Returns:

  • (nil)