Struct gtk4::PageSetup

source ·
#[repr(transparent)]
pub struct PageSetup { /* private fields */ }
Expand description

A 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 PrintOperation when printing. The benefit of splitting this out of the 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 PageSetup use new() to get the defaults, or use print_run_page_setup_dialog() to show the page setup dialog and receive the resulting page setup.

A page setup dialog

⚠️ 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;
}

Implements

glib::ObjectExt

Implementations

Creates a new PageSetup.

Returns

a new PageSetup.

Reads the page setup from the file @file_name.

Returns a new PageSetup object with the restored page setup, or None if an error occurred. See to_file().

file_name

the filename to read the page setup from

Returns

the restored PageSetup

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

The variant must be in the format produced by to_gvariant().

variant

an a{sv} GVariant

Returns

a new PageSetup object

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

Returns a new PageSetup object with the restored page setup, or None if an error occurred.

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 PageSetup

Gets the bottom margin in units of @unit.

unit

the unit for the return value

Returns

the bottom margin

Gets the left margin in units of @unit.

unit

the unit for the return value

Returns

the left margin

Gets the page orientation of the PageSetup.

Returns

the page orientation

Returns the page height in units of @unit.

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

unit

the unit for the return value

Returns

the page height.

Returns the page width in units of @unit.

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

unit

the unit for the return value

Returns

the page width.

Returns the paper height in units of @unit.

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

unit

the unit for the return value

Returns

the paper height.

Gets the paper size of the PageSetup.

Returns

the paper size

Returns the paper width in units of @unit.

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

unit

the unit for the return value

Returns

the paper width.

Gets the right margin in units of @unit.

unit

the unit for the return value

Returns

the right margin

Gets the top margin in units of @unit.

unit

the unit for the return value

Returns

the top margin

Reads the page setup from the file @file_name.

See to_file().

file_name

the filename to read the page setup from

Returns

true on success

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

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

Sets the bottom margin of the PageSetup.

margin

the new bottom margin in units of @unit

unit

the units for @margin

Sets the left margin of the PageSetup.

margin

the new left margin in units of @unit

unit

the units for @margin

Sets the page orientation of the PageSetup.

orientation

a PageOrientation value

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

See set_paper_size_and_default_margins().

size

a PaperSize

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

size

a PaperSize

Sets the right margin of the PageSetup.

margin

the new right margin in units of @unit

unit

the units for @margin

Sets the top margin of the PageSetup.

margin

the new top margin in units of @unit

unit

the units for @margin

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

file_name

the file to save to

Returns

true on success

Serialize page setup to an a{sv} variant.

Returns

a new, floating, GVariant

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

key_file

the GKeyFile to save the page setup to

group_name

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

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Upcasts an object to a superclass or interface T. Read more
Upcasts an object to a reference of its superclass or interface T. Read more
Tries to downcast to a subclass or interface implementor T. Read more
Tries to downcast to a reference of its subclass or interface implementor T. Read more
Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more
Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more
Casts to T unconditionally. Read more
Casts to &T unconditionally. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Returns true if the object is an instance of (can be cast to) T.
Returns the type of the object.
Returns the ObjectClass of the object. Read more
Returns the class of the object.
Returns the class of the object in the given type T. Read more
Returns the interface T of the object. Read more
Sets the property property_name of the object to value value. Read more
Sets the property property_name of the object to value value. Read more
Sets multiple properties of the object at once. Read more
Sets multiple properties of the object at once. Read more
Gets the property property_name of the object and cast it to the type V. Read more
Gets the property property_name of the object. Read more
Check if the object has a property property_name of the given type_. Read more
Get the type of the property property_name of this object. Read more
Get the ParamSpec of the property property_name of this object.
Return all ParamSpec of the properties of this object.
Freeze all property notifications until the return guard object is dropped. Read more
Set arbitrary data on this object with the given key. Read more
Return previously set arbitrary data of this object with the given key. Read more
Retrieve previously set arbitrary data of this object with the given key. Read more
Set arbitrary data on this object with the given key. Read more
Return previously set arbitrary data of this object with the given key. Read more
Retrieve previously set arbitrary data of this object with the given key. Read more
Block a given signal handler. Read more
Unblock a given signal handler.
Stop emission of the currently emitted signal.
Stop emission of the currently emitted signal by the (possibly detailed) signal name.
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect to the signal signal_name on this object. Read more
Connect to the signal signal_id on this object. Read more
Connect a closure to the signal signal_name on this object. Read more
Connect a closure to the signal signal_id on this object. Read more
Limits the lifetime of closure to the lifetime of the object. When the object’s reference count drops to zero, the closure will be invalidated. An invalidated closure will ignore any calls to invoke_with_values, or invoke when using Rust closures. Read more
Emit signal by signal id. Read more
Same as Self::emit but takes Value for the arguments.
Emit signal by its name. Read more
Emit signal by its name. Read more
Emit signal by its name with details. Read more
Emit signal by its name with details. Read more
Emit signal by signal id with details. Read more
Emit signal by signal id with details. Read more
Disconnect a previously connected signal handler.
Connect to the notify signal of the object. Read more
Connect to the notify signal of the object. Read more
Connect to the notify signal of the object. Read more
Notify that the given property has changed its value. Read more
Notify that the given property has changed its value. Read more
Downgrade this object to a weak reference.
Add a callback to be notified when the Object is disposed.
Add a callback to be notified when the Object is disposed. Read more
Bind property source_property on this object to the target_property on the target object. Read more
Returns the strong reference count of this object.
Runs the dispose mechanism of the object. Read more
Ensures that the type has been registered with the type system.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.