CtkPaperSize

CtkPaperSize — Support for named paper sizes

Functions

Types and Values

Object Hierarchy

    GBoxed
    ╰── CtkPaperSize

Includes

#include <ctk/ctk.h>

Description

CtkPaperSize 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, CtkPaperSize allows to construct custom paper sizes with arbitrary dimensions.

The CtkPaperSize object stores not only the dimensions (width and height) of a paper size and its name, it also provides default print margins.

Printing support has been added in CTK+ 2.10.

Functions

ctk_paper_size_new ()

CtkPaperSize *
ctk_paper_size_new (const gchar *name);

Creates a new CtkPaperSize object by parsing a PWG 5101.1-2002 paper name.

If name is NULL, the default paper size is returned, see ctk_paper_size_get_default().

Parameters

name

a paper size name, or NULL.

[allow-none]

Returns

a new CtkPaperSize, use ctk_paper_size_free() to free it

Since: 2.10


ctk_paper_size_new_from_ppd ()

CtkPaperSize *
ctk_paper_size_new_from_ppd (const gchar *ppd_name,
                             const gchar *ppd_display_name,
                             gdouble width,
                             gdouble height);

Creates a new CtkPaperSize 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 CtkPaperSize object.

Parameters

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

 

Returns

a new CtkPaperSize, use ctk_paper_size_free() to free it

Since: 2.10


ctk_paper_size_new_from_ipp ()

CtkPaperSize *
ctk_paper_size_new_from_ipp (const gchar *ipp_name,
                             gdouble width,
                             gdouble height);

Creates a new CtkPaperSize object by using IPP information.

If ipp_name is not a recognized paper name, width and height are used to construct a custom CtkPaperSize object.

Parameters

ipp_name

an IPP paper name

 

width

the paper width, in points

 

height

the paper height in points

 

Returns

a new CtkPaperSize, use ctk_paper_size_free() to free it

Since: 3.16


ctk_paper_size_new_custom ()

CtkPaperSize *
ctk_paper_size_new_custom (const gchar *name,
                           const gchar *display_name,
                           gdouble width,
                           gdouble height,
                           CtkUnit unit);

Creates a new CtkPaperSize object with the given parameters.

Parameters

name

the paper name

 

display_name

the human-readable name

 

width

the paper width, in units of unit

 

height

the paper height, in units of unit

 

unit

the unit for width and height . not CTK_UNIT_NONE.

 

Returns

a new CtkPaperSize object, use ctk_paper_size_free() to free it

Since: 2.10


ctk_paper_size_copy ()

CtkPaperSize *
ctk_paper_size_copy (CtkPaperSize *other);

Copies an existing CtkPaperSize.

Parameters

other

a CtkPaperSize

 

Returns

a copy of other

Since: 2.10


ctk_paper_size_free ()

void
ctk_paper_size_free (CtkPaperSize *size);

Free the given CtkPaperSize object.

Parameters

size

a CtkPaperSize

 

Since: 2.10


ctk_paper_size_is_equal ()

gboolean
ctk_paper_size_is_equal (CtkPaperSize *size1,
                         CtkPaperSize *size2);

Compares two CtkPaperSize objects.

Parameters

size1

a CtkPaperSize object

 

size2

another CtkPaperSize object

 

Returns

TRUE, if size1 and size2 represent the same paper size

Since: 2.10


ctk_paper_size_get_paper_sizes ()

GList *
ctk_paper_size_get_paper_sizes (gboolean include_custom);

Creates a list of known paper sizes.

Parameters

include_custom

whether to include custom paper sizes as defined in the page setup dialog

 

Returns

a newly allocated list of newly allocated CtkPaperSize objects.

[element-type CtkPaperSize][transfer full]

Since: 2.12


ctk_paper_size_get_name ()

const gchar *
ctk_paper_size_get_name (CtkPaperSize *size);

Gets the name of the CtkPaperSize.

Parameters

size

a CtkPaperSize object

 

Returns

the name of size

Since: 2.10


ctk_paper_size_get_display_name ()

const gchar *
ctk_paper_size_get_display_name (CtkPaperSize *size);

Gets the human-readable name of the CtkPaperSize.

Parameters

size

a CtkPaperSize object

 

Returns

the human-readable name of size

Since: 2.10


ctk_paper_size_get_ppd_name ()

const gchar *
ctk_paper_size_get_ppd_name (CtkPaperSize *size);

Gets the PPD name of the CtkPaperSize, which may be NULL.

Parameters

size

a CtkPaperSize object

 

Returns

the PPD name of size

Since: 2.10


ctk_paper_size_get_width ()

gdouble
ctk_paper_size_get_width (CtkPaperSize *size,
                          CtkUnit unit);

Gets the paper width of the CtkPaperSize, in units of unit .

Parameters

size

a CtkPaperSize object

 

unit

the unit for the return value, not CTK_UNIT_NONE

 

Returns

the paper width

Since: 2.10


ctk_paper_size_get_height ()

gdouble
ctk_paper_size_get_height (CtkPaperSize *size,
                           CtkUnit unit);

Gets the paper height of the CtkPaperSize, in units of unit .

Parameters

size

a CtkPaperSize object

 

unit

the unit for the return value, not CTK_UNIT_NONE

 

Returns

the paper height

Since: 2.10


ctk_paper_size_is_ipp ()

gboolean
ctk_paper_size_is_ipp (CtkPaperSize *size);

Returns TRUE if size is an IPP standard paper size.

Parameters

size

a CtkPaperSize object

 

Returns

whether size is not an IPP custom paper size.


ctk_paper_size_is_custom ()

gboolean
ctk_paper_size_is_custom (CtkPaperSize *size);

Returns TRUE if size is not a standard paper size.

Parameters

size

a CtkPaperSize object

 

Returns

whether size is a custom paper size.


ctk_paper_size_set_size ()

void
ctk_paper_size_set_size (CtkPaperSize *size,
                         gdouble width,
                         gdouble height,
                         CtkUnit unit);

Changes the dimensions of a size to width x height .

Parameters

size

a custom CtkPaperSize object

 

width

the new width in units of unit

 

height

the new height in units of unit

 

unit

the unit for width and height

 

Since: 2.10


ctk_paper_size_get_default_top_margin ()

gdouble
ctk_paper_size_get_default_top_margin (CtkPaperSize *size,
                                       CtkUnit unit);

Gets the default top margin for the CtkPaperSize.

Parameters

size

a CtkPaperSize object

 

unit

the unit for the return value, not CTK_UNIT_NONE

 

Returns

the default top margin

Since: 2.10


ctk_paper_size_get_default_bottom_margin ()

gdouble
ctk_paper_size_get_default_bottom_margin
                               (CtkPaperSize *size,
                                CtkUnit unit);

Gets the default bottom margin for the CtkPaperSize.

Parameters

size

a CtkPaperSize object

 

unit

the unit for the return value, not CTK_UNIT_NONE

 

Returns

the default bottom margin

Since: 2.10


ctk_paper_size_get_default_left_margin ()

gdouble
ctk_paper_size_get_default_left_margin
                               (CtkPaperSize *size,
                                CtkUnit unit);

Gets the default left margin for the CtkPaperSize.

Parameters

size

a CtkPaperSize object

 

unit

the unit for the return value, not CTK_UNIT_NONE

 

Returns

the default left margin

Since: 2.10


ctk_paper_size_get_default_right_margin ()

gdouble
ctk_paper_size_get_default_right_margin
                               (CtkPaperSize *size,
                                CtkUnit unit);

Gets the default right margin for the CtkPaperSize.

Parameters

size

a CtkPaperSize object

 

unit

the unit for the return value, not CTK_UNIT_NONE

 

Returns

the default right margin

Since: 2.10


ctk_paper_size_get_default ()

const gchar *
ctk_paper_size_get_default (void);

Returns the name of the default paper size, which depends on the current locale.

Returns

the name of the default paper size. The string is owned by CTK+ and should not be modified.

Since: 2.10


ctk_paper_size_new_from_key_file ()

CtkPaperSize *
ctk_paper_size_new_from_key_file (GKeyFile *key_file,
                                  const gchar *group_name,
                                  GError **error);

Reads a paper size from the group group_name in the key file key_file .

Parameters

key_file

the GKeyFile to retrieve the papersize from

 

group_name

the name of the group in the key file to read, or NULL to read the first group.

[nullable]

error

return location for an error, or NULL.

[allow-none]

Returns

a new CtkPaperSize object with the restored paper size, or NULL if an error occurred

Since: 2.12


ctk_paper_size_new_from_gvariant ()

CtkPaperSize *
ctk_paper_size_new_from_gvariant (GVariant *variant);

Deserialize a paper size from an a{sv} variant in the format produced by ctk_paper_size_to_gvariant().

Parameters

variant

an a{sv} GVariant

 

Returns

a new CtkPaperSize object.

[transfer full]

Since: 3.22


ctk_paper_size_to_key_file ()

void
ctk_paper_size_to_key_file (CtkPaperSize *size,
                            GKeyFile *key_file,
                            const gchar *group_name);

This function adds the paper size from size to key_file .

Parameters

size

a CtkPaperSize

 

key_file

the GKeyFile to save the paper size to

 

group_name

the group to add the settings to in key_file

 

Since: 2.12


ctk_paper_size_to_gvariant ()

GVariant *
ctk_paper_size_to_gvariant (CtkPaperSize *paper_size);

Serialize a paper size to an a{sv} variant.

Parameters

paper_size

a CtkPaperSize

 

Returns

a new, floating, GVariant.

[transfer none]

Since: 3.22

Types and Values

CtkPaperSize

typedef struct _CtkPaperSize CtkPaperSize;

enum CtkUnit

See also ctk_print_settings_set_paper_width().

Members

CTK_UNIT_NONE

No units.

 

CTK_UNIT_POINTS

Dimensions in points.

 

CTK_UNIT_INCH

Dimensions in inches.

 

CTK_UNIT_MM

Dimensions in millimeters

 

CTK_UNIT_PIXEL

#define CTK_UNIT_PIXEL CTK_UNIT_NONE

CTK_PAPER_NAME_A3

#define CTK_PAPER_NAME_A3 "iso_a3"

Name for the A3 paper size.


CTK_PAPER_NAME_A4

#define CTK_PAPER_NAME_A4 "iso_a4"

Name for the A4 paper size.


CTK_PAPER_NAME_A5

#define CTK_PAPER_NAME_A5 "iso_a5"

Name for the A5 paper size.


CTK_PAPER_NAME_B5

#define CTK_PAPER_NAME_B5 "iso_b5"

Name for the B5 paper size.


CTK_PAPER_NAME_LETTER

#define CTK_PAPER_NAME_LETTER "na_letter"

Name for the Letter paper size.


CTK_PAPER_NAME_EXECUTIVE

#define CTK_PAPER_NAME_EXECUTIVE "na_executive"

Name for the Executive paper size.


CTK_PAPER_NAME_LEGAL

#define CTK_PAPER_NAME_LEGAL "na_legal"

Name for the Legal paper size.

See Also

CtkPageSetup