class Gtk::PageSetup

Overview

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

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::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 Gtk::PrintSettings *settings = NULL;
static Gtk::PageSetup *page_setup = NULL;

static void
do_page_setup (void)
{
  Gtk::PageSetup *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

==(other : self) ==, 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) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, 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) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil 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, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : 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 Gtk::PageSetup.


[View source]
def self.new_from_file(file_name : String) : self #

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


[View source]
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.


[View source]
def self.new_from_key_file(key_file : GLib::KeyFile, group_name : String | Nil) : self #

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.


[View source]

Class Method Detail

def self.g_type : UInt64 #

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


[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


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

Gets the bottom margin in units of unit.


[View source]
def copy : Gtk::PageSetup #

Copies a Gtk::PageSetup.


[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


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

Gets the left margin in units of unit.


[View source]
def load_file(file_name : String) : Bool #

Reads the page setup from the file file_name.

See Gtk::PageSetup#to_file.


[View source]
def load_key_file(key_file : GLib::KeyFile, group_name : String | Nil) : Bool #

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


[View source]
def orientation : Gtk::PageOrientation #

Gets the page orientation of the Gtk::PageSetup.


[View source]
def orientation=(orientation : Gtk::PageOrientation) : Nil #

Sets the page orientation of the Gtk::PageSetup.


[View source]
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.


[View source]
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.


[View source]
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.


[View source]
def paper_size : Gtk::PaperSize #

Gets the paper size of the Gtk::PageSetup.


[View source]
def paper_size=(size : Gtk::PaperSize) : Nil #

Sets the paper size of the Gtk::PageSetup without changing the margins.

See Gtk::PageSetup#paper_size_and_default_margins=.


[View source]
def paper_size_and_default_margins=(size : Gtk::PaperSize) : Nil #

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


[View source]
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.


[View source]
def right_margin(unit : Gtk::Unit) : Float64 #

Gets the right margin in units of unit.


[View source]
def set_bottom_margin(margin : Float64, unit : Gtk::Unit) : Nil #

Sets the bottom margin of the Gtk::PageSetup.


[View source]
def set_left_margin(margin : Float64, unit : Gtk::Unit) : Nil #

Sets the left margin of the Gtk::PageSetup.


[View source]
def set_right_margin(margin : Float64, unit : Gtk::Unit) : Nil #

Sets the right margin of the Gtk::PageSetup.


[View source]
def set_top_margin(margin : Float64, unit : Gtk::Unit) : Nil #

Sets the top margin of the Gtk::PageSetup.


[View source]
def to_file(file_name : String) : Bool #

This function saves the information from setup to file_name.


[View source]
def to_gvariant : GLib::Variant #

Serialize page setup to an a{sv} variant.


[View source]
def to_key_file(key_file : GLib::KeyFile, group_name : String | Nil) : Nil #

This function adds the page setup from setup to key_file.


[View source]
def top_margin(unit : Gtk::Unit) : Float64 #

Gets the top margin in units of unit.


[View source]