GtkPaperSize — Support for named paper sizes
GtkPaperSize | |
enum | GtkUnit |
#define | GTK_UNIT_PIXEL |
#define | GTK_PAPER_NAME_A3 |
#define | GTK_PAPER_NAME_A4 |
#define | GTK_PAPER_NAME_A5 |
#define | GTK_PAPER_NAME_B5 |
#define | GTK_PAPER_NAME_LETTER |
#define | GTK_PAPER_NAME_EXECUTIVE |
#define | GTK_PAPER_NAME_LEGAL |
GBoxed ╰── GtkPaperSize
#include <gtk/gtk.h>
GtkPaperSize handles paper sizes. It uses the standard called PWG 5101.1-2002 PWG: Standard for Media Standardized Names to name the paper sizes (and to get the data for the page sizes). In addition to standard paper sizes, GtkPaperSize allows to construct custom paper sizes with arbitrary dimensions.
The GtkPaperSize object stores not only the dimensions (width and height) of a paper size and its name, it also provides default print margins.
GtkPaperSize *
gtk_paper_size_new (const char *name
);
Creates a new GtkPaperSize object by parsing a PWG 5101.1-2002 paper name.
If name
is NULL
, the default paper size is returned, see gtk_paper_size_get_default()
.
name | a paper size name, or | [allow-none] |
a new GtkPaperSize, use gtk_paper_size_free()
to free it
GtkPaperSize * gtk_paper_size_new_from_ppd (const char *ppd_name
,const char *ppd_display_name
,double width
,double height
);
Creates a new GtkPaperSize object by using PPD information.
If ppd_name
is not a recognized PPD paper name, ppd_display_name
, width
and height
are used to construct a custom GtkPaperSize object.
ppd_name | a PPD paper name | |
ppd_display_name | the corresponding human-readable name | |
width | the paper width, in points | |
height | the paper height in points |
a new GtkPaperSize, use gtk_paper_size_free()
to free it
GtkPaperSize * gtk_paper_size_new_from_ipp (const char *ipp_name
,double width
,double height
);
Creates a new GtkPaperSize object by using IPP information.
If ipp_name
is not a recognized paper name, width
and height
are used to construct a custom GtkPaperSize object.
ipp_name | an IPP paper name | |
width | the paper width, in points | |
height | the paper height in points |
a new GtkPaperSize, use gtk_paper_size_free()
to free it
GtkPaperSize * gtk_paper_size_new_custom (const char *name
,const char *display_name
,double width
,double height
,GtkUnit unit
);
Creates a new GtkPaperSize object with the given parameters.
name | the paper name | |
display_name | the human-readable name | |
width | the paper width, in units of | |
height | the paper height, in units of | |
unit | the unit for |
a new GtkPaperSize object, use gtk_paper_size_free()
to free it
GtkPaperSize *
gtk_paper_size_copy (GtkPaperSize *other
);
Copies an existing GtkPaperSize.
other |
a copy of other
void
gtk_paper_size_free (GtkPaperSize *size
);
Free the given GtkPaperSize object.
size |
gboolean gtk_paper_size_is_equal (GtkPaperSize *size1
,GtkPaperSize *size2
);
Compares two GtkPaperSize objects.
size1 | a GtkPaperSize object | |
size2 | another GtkPaperSize object |
TRUE
, if size1
and size2
represent the same paper size
GList * gtk_paper_size_get_paper_sizes (gboolean include_custom);
Creates a list of known paper sizes.
include_custom | whether to include custom paper sizes as defined in the page setup dialog |
a newly allocated list of newly allocated GtkPaperSize objects.
[element-type GtkPaperSize][transfer full]
const char *
gtk_paper_size_get_name (GtkPaperSize *size
);
Gets the name of the GtkPaperSize.
size | a GtkPaperSize object |
the name of size
const char *
gtk_paper_size_get_display_name (GtkPaperSize *size
);
Gets the human-readable name of the GtkPaperSize.
size | a GtkPaperSize object |
the human-readable name of size
const char *
gtk_paper_size_get_ppd_name (GtkPaperSize *size
);
Gets the PPD name of the GtkPaperSize, which may be NULL
.
size | a GtkPaperSize object |
the PPD name of size
double gtk_paper_size_get_width (GtkPaperSize *size
,GtkUnit unit
);
Gets the paper width of the GtkPaperSize, in units of unit
.
size | a GtkPaperSize object | |
unit | the unit for the return value, not |
the paper width
double gtk_paper_size_get_height (GtkPaperSize *size
,GtkUnit unit
);
Gets the paper height of the GtkPaperSize, in units of unit
.
size | a GtkPaperSize object | |
unit | the unit for the return value, not |
the paper height
gboolean
gtk_paper_size_is_ipp (GtkPaperSize *size
);
Returns TRUE
if size
is an IPP standard paper size.
size | a GtkPaperSize object |
whether size
is not an IPP custom paper size.
gboolean
gtk_paper_size_is_custom (GtkPaperSize *size
);
Returns TRUE
if size
is not a standard paper size.
size | a GtkPaperSize object |
whether size
is a custom paper size.
void gtk_paper_size_set_size (GtkPaperSize *size
,double width
,double height
,GtkUnit unit
);
Changes the dimensions of a size
to width
x height
.
size | a custom GtkPaperSize object | |
width | the new width in units of | |
height | the new height in units of | |
unit | the unit for |
double gtk_paper_size_get_default_top_margin (GtkPaperSize *size
,GtkUnit unit
);
Gets the default top margin for the GtkPaperSize.
size | a GtkPaperSize object | |
unit | the unit for the return value, not |
the default top margin
double gtk_paper_size_get_default_bottom_margin (GtkPaperSize *size
,GtkUnit unit
);
Gets the default bottom margin for the GtkPaperSize.
size | a GtkPaperSize object | |
unit | the unit for the return value, not |
the default bottom margin
double gtk_paper_size_get_default_left_margin (GtkPaperSize *size
,GtkUnit unit
);
Gets the default left margin for the GtkPaperSize.
size | a GtkPaperSize object | |
unit | the unit for the return value, not |
the default left margin
double gtk_paper_size_get_default_right_margin (GtkPaperSize *size
,GtkUnit unit
);
Gets the default right margin for the GtkPaperSize.
size | a GtkPaperSize object | |
unit | the unit for the return value, not |
the default right margin
const char * gtk_paper_size_get_default (void);
Returns the name of the default paper size, which depends on the current locale.
the name of the default paper size. The string is owned by GTK and should not be modified.
GtkPaperSize * gtk_paper_size_new_from_key_file (GKeyFile *key_file
,const char *group_name
,GError **error
);
Reads a paper size from the group group_name
in the key file key_file
.
key_file | the GKeyFile to retrieve the papersize from | |
group_name | the name of the group in the key file to read, or | [nullable] |
error | return location for an error, or | [allow-none] |
a new GtkPaperSize object with the restored paper size, or NULL
if an error occurred
GtkPaperSize *
gtk_paper_size_new_from_gvariant (GVariant *variant
);
Deserialize a paper size from an a{sv} variant in the format produced by gtk_paper_size_to_gvariant()
.
variant | an a{sv} GVariant |
void gtk_paper_size_to_key_file (GtkPaperSize *size
,GKeyFile *key_file
,const char *group_name
);
This function adds the paper size from size
to key_file
.
size | ||
key_file | the GKeyFile to save the paper size to | |
group_name | the group to add the settings to in |
GVariant *
gtk_paper_size_to_gvariant (GtkPaperSize *paper_size
);
Serialize a paper size to an a{sv} variant.
paper_size |
a new, floating, GVariant.
[transfer none]
typedef struct _GtkPaperSize GtkPaperSize;
See also gtk_print_settings_set_paper_width()
.
GTK_UNIT_NONE | No units. | |
GTK_UNIT_POINTS | Dimensions in points. | |
GTK_UNIT_INCH | Dimensions in inches. | |
GTK_UNIT_MM | Dimensions in millimeters |
#define GTK_UNIT_PIXEL GTK_UNIT_NONE
#define GTK_PAPER_NAME_A3 "iso_a3"
Name for the A3 paper size.
#define GTK_PAPER_NAME_A4 "iso_a4"
Name for the A4 paper size.
#define GTK_PAPER_NAME_A5 "iso_a5"
Name for the A5 paper size.
#define GTK_PAPER_NAME_B5 "iso_b5"
Name for the B5 paper size.
#define GTK_PAPER_NAME_LETTER "na_letter"
Name for the Letter paper size.
#define GTK_PAPER_NAME_EXECUTIVE "na_executive"
Name for the Executive paper size.
#define GTK_PAPER_NAME_LEGAL "na_legal"
Name for the Legal paper size.
© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/GtkPaperSize.html