class Gtk::PageSetup

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 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 Gtk::PageSetup.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

WARNING ⚠️ The following code is in 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;
}

Defined in:

lib/gi-crystal/src/auto/gtk-4.0/page_setup.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class GObject::Object

bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void)? data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void)? qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void)?) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void)? steal_data, steal_qdata(quark : UInt32) : Pointer(Void)? steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, cast?(obj : GObject::Object) : self? cast?, new(pointer, transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

compat_control(what : UInt64, data : Pointer(Void)?) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Constructor Detail

def self.new : self #

Creates a new GtkPageSetup.


def self.new_from_file(file_name : String) : self #

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 Gtk::PageSetup#to_file.


def self.new_from_gvariant(variant : _) : self #

Desrialize a page setup from an a{sv} variant.

The variant must be in the format produced by Gtk::PageSetup#to_gvariant.


def self.new_from_key_file(key_file : GLib::KeyFile, group_name : String?) : self #

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.


Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


Instance Method Detail

def bottom_margin(unit : Gtk::Unit) : Float64 #

Gets the bottom margin in units of @unit.


def copy : Gtk::PageSetup #

Copies a GtkPageSetup.


def left_margin(unit : Gtk::Unit) : Float64 #

Gets the left margin in units of @unit.


def load_file(file_name : String) : Bool #

Reads the page setup from the file @file_name.

See Gtk::PageSetup#to_file.


def load_key_file(key_file : GLib::KeyFile, group_name : String?) : Bool #

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


def orientation : Gtk::PageOrientation #

Gets the page orientation of the GtkPageSetup.


def orientation=(orientation : Gtk::PageOrientation) : Nil #

Sets the page orientation of the GtkPageSetup.


def page_height(unit : Gtk::Unit) : Float64 #

Returns the page height in units of @unit.

Note that this function takes orientation and margins into consideration. See Gtk::PageSetup#paper_height.


def page_width(unit : Gtk::Unit) : Float64 #

Returns the page width in units of @unit.

Note that this function takes orientation and margins into consideration. See Gtk::PageSetup#paper_width.


def paper_height(unit : Gtk::Unit) : Float64 #

Returns the paper height in units of @unit.

Note that this function takes orientation, but not margins into consideration. See Gtk::PageSetup#page_height.


def paper_size : Gtk::PaperSize #

Gets the paper size of the GtkPageSetup.


def paper_size=(size : Gtk::PaperSize) : Nil #

Sets the paper size of the GtkPageSetup without changing the margins.

See Gtk::PageSetup#paper_size_and_default_margins=.


def paper_size_and_default_margins=(size : Gtk::PaperSize) : Nil #

Sets the paper size of the GtkPageSetup and modifies the margins according to the new paper size.


def paper_width(unit : Gtk::Unit) : Float64 #

Returns the paper width in units of @unit.

Note that this function takes orientation, but not margins into consideration. See Gtk::PageSetup#page_width.


def right_margin(unit : Gtk::Unit) : Float64 #

Gets the right margin in units of @unit.


def set_bottom_margin(margin : Float64, unit : Gtk::Unit) : Nil #

Sets the bottom margin of the GtkPageSetup.


def set_left_margin(margin : Float64, unit : Gtk::Unit) : Nil #

Sets the left margin of the GtkPageSetup.


def set_right_margin(margin : Float64, unit : Gtk::Unit) : Nil #

Sets the right margin of the GtkPageSetup.


def set_top_margin(margin : Float64, unit : Gtk::Unit) : Nil #

Sets the top margin of the GtkPageSetup.


def to_file(file_name : String) : Bool #

This function saves the information from @setup to @file_name.


def to_gvariant : GLib::Variant #

Serialize page setup to an a{sv} variant.


def to_key_file(key_file : GLib::KeyFile, group_name : String?) : Nil #

This function adds the page setup from @setup to @key_file.


def top_margin(unit : Gtk::Unit) : Float64 #

Gets the top margin in units of @unit.