| Top |
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.
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.
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.
CtkPageSetup *
ctk_page_setup_new (void);
Creates a new CtkPageSetup.
Since: 2.10
CtkPageSetup *
ctk_page_setup_copy (CtkPageSetup *other);
Copies a CtkPageSetup.
Since: 2.10
CtkPageOrientation
ctk_page_setup_get_orientation (CtkPageSetup *setup);
Gets the page orientation of the CtkPageSetup.
Since: 2.10
void ctk_page_setup_set_orientation (CtkPageSetup *setup,CtkPageOrientation orientation);
Sets the page orientation of the CtkPageSetup.
Since: 2.10
CtkPaperSize *
ctk_page_setup_get_paper_size (CtkPageSetup *setup);
Gets the paper size of the CtkPageSetup.
Since: 2.10
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().
Since: 2.10
gdouble ctk_page_setup_get_top_margin (CtkPageSetup *setup,CtkUnit unit);
Gets the top margin in units of unit
.
Since: 2.10
void ctk_page_setup_set_top_margin (CtkPageSetup *setup,gdouble margin,CtkUnit unit);
Sets the top margin of the CtkPageSetup.
Since: 2.10
gdouble ctk_page_setup_get_bottom_margin (CtkPageSetup *setup,CtkUnit unit);
Gets the bottom margin in units of unit
.
Since: 2.10
void ctk_page_setup_set_bottom_margin (CtkPageSetup *setup,gdouble margin,CtkUnit unit);
Sets the bottom margin of the CtkPageSetup.
Since: 2.10
gdouble ctk_page_setup_get_left_margin (CtkPageSetup *setup,CtkUnit unit);
Gets the left margin in units of unit
.
Since: 2.10
void ctk_page_setup_set_left_margin (CtkPageSetup *setup,gdouble margin,CtkUnit unit);
Sets the left margin of the CtkPageSetup.
Since: 2.10
gdouble ctk_page_setup_get_right_margin (CtkPageSetup *setup,CtkUnit unit);
Gets the right margin in units of unit
.
Since: 2.10
void ctk_page_setup_set_right_margin (CtkPageSetup *setup,gdouble margin,CtkUnit unit);
Sets the right margin of the CtkPageSetup.
Since: 2.10
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.
Since: 2.10
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().
Since: 2.10
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().
Since: 2.10
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().
Since: 2.10
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().
Since: 2.10
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().
file_name |
the filename to read the page setup from. |
[type filename] |
error |
return location for an error, or |
[allow-none] |
Since: 2.12
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.
key_file |
the GKeyFile to retrieve the page_setup from |
|
group_name |
the name of the group in the key_file to read, or |
[allow-none] |
error |
return location for an error, or |
[allow-none] |
Since: 2.12
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().
Since: 3.22
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().
setup |
||
file_name |
the filename to read the page setup from. |
[type filename] |
error |
return location for an error, or |
[allow-none] |
Since: 2.14
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
.
setup |
||
key_file |
the GKeyFile to retrieve the page_setup from |
|
group_name |
the name of the group in the key_file to read, or |
[allow-none] |
error |
return location for an error, or |
[allow-none] |
Since: 2.14
gboolean ctk_page_setup_to_file (CtkPageSetup *setup,const char *file_name,GError **error);
This function saves the information from setup
to file_name
.
setup |
||
file_name |
the file to save to. |
[type filename] |
error |
return location for errors, or |
[allow-none] |
Since: 2.12
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
.
setup |
||
key_file |
the GKeyFile to save the page setup to |
|
group_name |
the group to add the settings to in |
[nullable] |
Since: 2.12
GVariant *
ctk_page_setup_to_gvariant (CtkPageSetup *setup);
Serialize page setup to an a{sv} variant.
Return: (transfer none): a new, floating, GVariant
Since: 3.22