CtkPageSetup: CTK+ 3 Reference Manual

## CtkPageSetup CtkPageSetup — Stores page setup information |

## Functions

CtkPageSetup * | ctk_page_setup_new ()
CtkPageSetup * | ctk_page_setup_copy ()
CtkPageOrientation | ctk_page_setup_get_orientation ()
void | ctk_page_setup_set_orientation ()
CtkPaperSize * | ctk_page_setup_get_paper_size ()
void | ctk_page_setup_set_paper_size ()
gdouble | ctk_page_setup_get_top_margin ()
void | ctk_page_setup_set_top_margin ()
gdouble | ctk_page_setup_get_bottom_margin ()
void | ctk_page_setup_set_bottom_margin ()
gdouble | ctk_page_setup_get_left_margin ()
void | ctk_page_setup_set_left_margin ()
gdouble | ctk_page_setup_get_right_margin ()
void | ctk_page_setup_set_right_margin ()
void | ctk_page_setup_set_paper_size_and_default_margins ()
gdouble | ctk_page_setup_get_paper_width ()
gdouble | ctk_page_setup_get_paper_height ()
gdouble | ctk_page_setup_get_page_width ()
gdouble | ctk_page_setup_get_page_height ()
CtkPageSetup * | ctk_page_setup_new_from_file ()
CtkPageSetup * | ctk_page_setup_new_from_key_file ()
CtkPageSetup * | ctk_page_setup_new_from_gvariant ()
gboolean | ctk_page_setup_load_file ()
gboolean | ctk_page_setup_load_key_file ()
gboolean | ctk_page_setup_to_file ()
void | ctk_page_setup_to_key_file ()
GVariant * | ctk_page_setup_to_gvariant ()

## Types and Values

| CtkPageSetup

## Object Hierarchy

        GObject
        ╰── CtkPageSetup

## Includes

    #include <ctk/ctk.h>

## Description

A CtkPageSetup 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 CtkPrintOperation when printing. The benefit of splitting this out of the CtkPrintSettings 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 CtkPageSetup use `ctk_page_setup_new()` to get the defaults, or use `ctk_print_run_page_setup_dialog()` to show the page setup dialog and receive the resulting page setup.

#### A page setup dialog

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    static CtkPrintSettings *settings = NULL;
    static CtkPageSetup *page_setup = NULL;

    static void
    do_page_setup (void)
    {
      CtkPageSetup *new_page_setup;

      if (settings == NULL)
        settings = ctk_print_settings_new ();

      new_page_setup = ctk_print_run_page_setup_dialog (CTK_WINDOW (main_window),
                                                        page_setup, settings);

      if (page_setup)
        g_object_unref (page_setup);

      page_setup = new_page_setup;
    }

Printing support was added in CTK+ 2.10.

## Functions

### ctk_page_setup_new ()

    CtkPageSetup *
    ctk_page_setup_new (void);

Creates a new CtkPageSetup.

#### Returns

a new CtkPageSetup.

Since: 2.10

### ctk_page_setup_copy ()

    CtkPageSetup *
    ctk_page_setup_copy (CtkPageSetup *other);

Copies a CtkPageSetup.

#### Parameters

other | the CtkPageSetup to copy |

#### Returns

a copy of `other` .

[transfer full]

Since: 2.10

### ctk_page_setup_get_orientation ()

    CtkPageOrientation
    ctk_page_setup_get_orientation (CtkPageSetup *setup);

Gets the page orientation of the CtkPageSetup.

#### Parameters

setup | a CtkPageSetup |

#### Returns

the page orientation

Since: 2.10

### ctk_page_setup_set_orientation ()

    void
    ctk_page_setup_set_orientation (CtkPageSetup *setup,
                                    CtkPageOrientation orientation);

Sets the page orientation of the CtkPageSetup.

#### Parameters

setup | a CtkPageSetup |
orientation | a CtkPageOrientation value |

Since: 2.10

### ctk_page_setup_get_paper_size ()

    CtkPaperSize *
    ctk_page_setup_get_paper_size (CtkPageSetup *setup);

Gets the paper size of the CtkPageSetup.

#### Parameters

setup | a CtkPageSetup |

#### Returns

the paper size.

[transfer none]

Since: 2.10

### ctk_page_setup_set_paper_size ()

    void
    ctk_page_setup_set_paper_size (CtkPageSetup *setup,
                                   CtkPaperSize *size);

Sets the paper size of the CtkPageSetup without changing the margins. See `ctk_page_setup_set_paper_size_and_default_margins()`.

#### Parameters

setup | a CtkPageSetup |
size | a CtkPaperSize |

Since: 2.10

### ctk_page_setup_get_top_margin ()

    gdouble
    ctk_page_setup_get_top_margin (CtkPageSetup *setup,
                                   CtkUnit unit);

Gets the top margin in units of `unit` .

#### Parameters

setup | a CtkPageSetup |
unit | the unit for the return value |

#### Returns

the top margin

Since: 2.10

### ctk_page_setup_set_top_margin ()

    void
    ctk_page_setup_set_top_margin (CtkPageSetup *setup,
                                   gdouble margin,
                                   CtkUnit unit);

Sets the top margin of the CtkPageSetup.

#### Parameters

setup | a CtkPageSetup |
margin | the new top margin in units of `unit` |
unit | the units for `margin` |

Since: 2.10

### ctk_page_setup_get_bottom_margin ()

    gdouble
    ctk_page_setup_get_bottom_margin (CtkPageSetup *setup,
                                      CtkUnit unit);

Gets the bottom margin in units of `unit` .

#### Parameters

setup | a CtkPageSetup |
unit | the unit for the return value |

#### Returns

the bottom margin

Since: 2.10

### ctk_page_setup_set_bottom_margin ()

    void
    ctk_page_setup_set_bottom_margin (CtkPageSetup *setup,
                                      gdouble margin,
                                      CtkUnit unit);

Sets the bottom margin of the CtkPageSetup.

#### Parameters

setup | a CtkPageSetup |
margin | the new bottom margin in units of `unit` |
unit | the units for `margin` |

Since: 2.10

### ctk_page_setup_get_left_margin ()

    gdouble
    ctk_page_setup_get_left_margin (CtkPageSetup *setup,
                                    CtkUnit unit);

Gets the left margin in units of `unit` .

#### Parameters

setup | a CtkPageSetup |
unit | the unit for the return value |

#### Returns

the left margin

Since: 2.10

### ctk_page_setup_set_left_margin ()

    void
    ctk_page_setup_set_left_margin (CtkPageSetup *setup,
                                    gdouble margin,
                                    CtkUnit unit);

Sets the left margin of the CtkPageSetup.

#### Parameters

setup | a CtkPageSetup |
margin | the new left margin in units of `unit` |
unit | the units for `margin` |

Since: 2.10

### ctk_page_setup_get_right_margin ()

    gdouble
    ctk_page_setup_get_right_margin (CtkPageSetup *setup,
                                     CtkUnit unit);

Gets the right margin in units of `unit` .

#### Parameters

setup | a CtkPageSetup |
unit | the unit for the return value |

#### Returns

the right margin

Since: 2.10

### ctk_page_setup_set_right_margin ()

    void
    ctk_page_setup_set_right_margin (CtkPageSetup *setup,
                                     gdouble margin,
                                     CtkUnit unit);

Sets the right margin of the CtkPageSetup.

#### Parameters

setup | a CtkPageSetup |
margin | the new right margin in units of `unit` |
unit | the units for `margin` |

Since: 2.10

### ctk_page_setup_set_paper_size_and_default_margins ()

    void
    ctk_page_setup_set_paper_size_and_default_margins
                                   (CtkPageSetup *setup,
                                    CtkPaperSize *size);

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

#### Parameters

setup | a CtkPageSetup |
size | a CtkPaperSize |

Since: 2.10

### ctk_page_setup_get_paper_width ()

    gdouble
    ctk_page_setup_get_paper_width (CtkPageSetup *setup,
                                    CtkUnit unit);

Returns the paper width in units of `unit` .

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

#### Parameters

setup | a CtkPageSetup |
unit | the unit for the return value |

#### Returns

the paper width.

Since: 2.10

### ctk_page_setup_get_paper_height ()

    gdouble
    ctk_page_setup_get_paper_height (CtkPageSetup *setup,
                                     CtkUnit unit);

Returns the paper height in units of `unit` .

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

#### Parameters

setup | a CtkPageSetup |
unit | the unit for the return value |

#### Returns

the paper height.

Since: 2.10

### ctk_page_setup_get_page_width ()

    gdouble
    ctk_page_setup_get_page_width (CtkPageSetup *setup,
                                   CtkUnit unit);

Returns the page width in units of `unit` .

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

#### Parameters

setup | a CtkPageSetup |
unit | the unit for the return value |

#### Returns

the page width.

Since: 2.10

### ctk_page_setup_get_page_height ()

    gdouble
    ctk_page_setup_get_page_height (CtkPageSetup *setup,
                                    CtkUnit unit);

Returns the page height in units of `unit` .

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

#### Parameters

setup | a CtkPageSetup |
unit | the unit for the return value |

#### Returns

the page height.

Since: 2.10

### ctk_page_setup_new_from_file ()

    CtkPageSetup *
    ctk_page_setup_new_from_file (const gchar *file_name,
                                  GError **error);

Reads the page setup from the file `file_name` . Returns a new CtkPageSetup object with the restored page setup, or `NULL` if an error occurred. See `ctk_page_setup_to_file()`.

#### Parameters

file_name | the filename to read the page setup from. | [type filename]
error | return location for an error, or `NULL`. | [allow-none]

#### Returns

the restored CtkPageSetup

Since: 2.12

### ctk_page_setup_new_from_key_file ()

    CtkPageSetup *
    ctk_page_setup_new_from_key_file (GKeyFile *key_file,
                                      const gchar *group_name,
                                      GError **error);

Reads the page setup from the group `group_name` in the key file `key_file` . Returns a new CtkPageSetup 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, or `NULL` to use the default name “Page Setup”. | [allow-none]
error | return location for an error, or `NULL`. | [allow-none]

#### Returns

the restored CtkPageSetup

Since: 2.12

### ctk_page_setup_new_from_gvariant ()

    CtkPageSetup *
    ctk_page_setup_new_from_gvariant (GVariant *variant);

Desrialize a page setup from an a{sv} variant in the format produced by `ctk_page_setup_to_gvariant()`.

#### Parameters

variant | an a{sv} GVariant |

#### Returns

a new CtkPageSetup object.

[transfer full]

Since: 3.22

### ctk_page_setup_load_file ()

    gboolean
    ctk_page_setup_load_file (CtkPageSetup *setup,
                              const char *file_name,
                              GError **error);

Reads the page setup from the file `file_name` . See `ctk_page_setup_to_file()`.

#### Parameters

setup | a CtkPageSetup |
file_name | the filename to read the page setup from. | [type filename]
error | return location for an error, or `NULL`. | [allow-none]

#### Returns

`TRUE` on success

Since: 2.14

### ctk_page_setup_load_key_file ()

    gboolean
    ctk_page_setup_load_key_file (CtkPageSetup *setup,
                                  GKeyFile *key_file,
                                  const gchar *group_name,
                                  GError **error);

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

#### Parameters

setup | a CtkPageSetup |
key_file | the GKeyFile to retrieve the page_setup from |
group_name | the name of the group in the key_file to read, or `NULL` to use the default name “Page Setup”. | [allow-none]
error | return location for an error, or `NULL`. | [allow-none]

#### Returns

`TRUE` on success

Since: 2.14

### ctk_page_setup_to_file ()

    gboolean
    ctk_page_setup_to_file (CtkPageSetup *setup,
                            const char *file_name,
                            GError **error);

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

#### Parameters

setup | a CtkPageSetup |
file_name | the file to save to. | [type filename]
error | return location for errors, or `NULL`. | [allow-none]

#### Returns

`TRUE` on success

Since: 2.12

### ctk_page_setup_to_key_file ()

    void
    ctk_page_setup_to_key_file (CtkPageSetup *setup,
                                GKeyFile *key_file,
                                const gchar *group_name);

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

#### Parameters

setup | a CtkPageSetup |
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”. | [nullable]

Since: 2.12

### ctk_page_setup_to_gvariant ()

    GVariant *
    ctk_page_setup_to_gvariant (CtkPageSetup *setup);

Serialize page setup to an a{sv} variant.

Return: (transfer none): a new, floating, GVariant

#### Parameters

setup | a CtkPageSetup |

Since: 3.22

## Types and Values

### CtkPageSetup

    typedef struct _CtkPageSetup CtkPageSetup;