GtkPaperSize

GtkPaperSize — Support for named paper sizes

Synopsis

#include <gtk/gtk.h>

                    GtkPaperSize;
enum                GtkUnit;
#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
GtkPaperSize *      gtk_paper_size_new                  (const gchar *name);
GtkPaperSize *      gtk_paper_size_new_from_ppd         (const gchar *ppd_name,
                                                         const gchar *ppd_display_name,
                                                         gdouble width,
                                                         gdouble height);
GtkPaperSize *      gtk_paper_size_new_custom           (const gchar *name,
                                                         const gchar *display_name,
                                                         gdouble width,
                                                         gdouble height,
                                                         GtkUnit unit);
GtkPaperSize *      gtk_paper_size_copy                 (GtkPaperSize *other);
void                gtk_paper_size_free                 (GtkPaperSize *size);
gboolean            gtk_paper_size_is_equal             (GtkPaperSize *size1,
                                                         GtkPaperSize *size2);
GList *             gtk_paper_size_get_paper_sizes      (gboolean include_custom);
const gchar *       gtk_paper_size_get_name             (GtkPaperSize *size);
const gchar *       gtk_paper_size_get_display_name     (GtkPaperSize *size);
const gchar *       gtk_paper_size_get_ppd_name         (GtkPaperSize *size);
gdouble             gtk_paper_size_get_width            (GtkPaperSize *size,
                                                         GtkUnit unit);
gdouble             gtk_paper_size_get_height           (GtkPaperSize *size,
                                                         GtkUnit unit);
gboolean            gtk_paper_size_is_custom            (GtkPaperSize *size);
void                gtk_paper_size_set_size             (GtkPaperSize *size,
                                                         gdouble width,
                                                         gdouble height,
                                                         GtkUnit unit);
gdouble             gtk_paper_size_get_default_top_margin
                                                        (GtkPaperSize *size,
                                                         GtkUnit unit);
gdouble             gtk_paper_size_get_default_bottom_margin
                                                        (GtkPaperSize *size,
                                                         GtkUnit unit);
gdouble             gtk_paper_size_get_default_left_margin
                                                        (GtkPaperSize *size,
                                                         GtkUnit unit);
gdouble             gtk_paper_size_get_default_right_margin
                                                        (GtkPaperSize *size,
                                                         GtkUnit unit);
const gchar *       gtk_paper_size_get_default          (void);

GtkPaperSize *      gtk_paper_size_new_from_key_file    (GKeyFile *key_file,
                                                         const gchar *group_name,
                                                         GError **error);
void                gtk_paper_size_to_key_file          (GtkPaperSize *size,
                                                         GKeyFile *key_file,
                                                         const gchar *group_name);

Object Hierarchy

  GBoxed
   +----GtkPaperSize

Description

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.

Printing support has been added in GTK+ 2.10.

Details

GtkPaperSize

typedef struct _GtkPaperSize GtkPaperSize;


enum GtkUnit

typedef enum
{
  GTK_UNIT_PIXEL,
  GTK_UNIT_POINTS,
  GTK_UNIT_INCH,
  GTK_UNIT_MM
} GtkUnit;


GTK_PAPER_NAME_A3

#define GTK_PAPER_NAME_A3 "iso_a3"

Name for the A4 paper size.


GTK_PAPER_NAME_A4

#define GTK_PAPER_NAME_A4 "iso_a4"

Name for the A4 paper size.


GTK_PAPER_NAME_A5

#define GTK_PAPER_NAME_A5 "iso_a5"

Name for the A5 paper size.


GTK_PAPER_NAME_B5

#define GTK_PAPER_NAME_B5 "iso_b5"

Name for the B5 paper size.


GTK_PAPER_NAME_LETTER

#define GTK_PAPER_NAME_LETTER "na_letter"

Name for the Letter paper size.


GTK_PAPER_NAME_EXECUTIVE

#define GTK_PAPER_NAME_EXECUTIVE "na_executive"

Name for the Executive paper size.


GTK_PAPER_NAME_LEGAL

#define GTK_PAPER_NAME_LEGAL "na_legal"

Name for the Legal paper size.


gtk_paper_size_new ()

GtkPaperSize *      gtk_paper_size_new                  (const gchar *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 NULL. [allow-none]

Returns :

a new GtkPaperSize, use gtk_paper_size_free() to free it

Since 2.10


gtk_paper_size_new_from_ppd ()

GtkPaperSize *      gtk_paper_size_new_from_ppd         (const gchar *ppd_name,
                                                         const gchar *ppd_display_name,
                                                         gdouble width,
                                                         gdouble 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

Returns :

a new GtkPaperSize, use gtk_paper_size_free() to free it

Since 2.10


gtk_paper_size_new_custom ()

GtkPaperSize *      gtk_paper_size_new_custom           (const gchar *name,
                                                         const gchar *display_name,
                                                         gdouble width,
                                                         gdouble 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 unit

height :

the paper height, in units of unit

unit :

the unit for width and height

Returns :

a new GtkPaperSize object, use gtk_paper_size_free() to free it

Since 2.10


gtk_paper_size_copy ()

GtkPaperSize *      gtk_paper_size_copy                 (GtkPaperSize *other);

Copies an existing GtkPaperSize.

other :

a GtkPaperSize

Returns :

a copy of other

Since 2.10


gtk_paper_size_free ()

void                gtk_paper_size_free                 (GtkPaperSize *size);

Free the given GtkPaperSize object.

size :

a GtkPaperSize

Since 2.10


gtk_paper_size_is_equal ()

gboolean            gtk_paper_size_is_equal             (GtkPaperSize *size1,
                                                         GtkPaperSize *size2);

Compares two GtkPaperSize objects.

size1 :

a GtkPaperSize object

size2 :

another GtkPaperSize object

Returns :

TRUE, if size1 and size2 represent the same paper size

Since 2.10


gtk_paper_size_get_paper_sizes ()

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

Returns :

a newly allocated list of newly allocated GtkPaperSize objects. [element-type GtkPaperSize][transfer full]

Since 2.12


gtk_paper_size_get_name ()

const gchar *       gtk_paper_size_get_name             (GtkPaperSize *size);

Gets the name of the GtkPaperSize.

size :

a GtkPaperSize object

Returns :

the name of size

Since 2.10


gtk_paper_size_get_display_name ()

const gchar *       gtk_paper_size_get_display_name     (GtkPaperSize *size);

Gets the human-readable name of the GtkPaperSize.

size :

a GtkPaperSize object

Returns :

the human-readable name of size

Since 2.10


gtk_paper_size_get_ppd_name ()

const gchar *       gtk_paper_size_get_ppd_name         (GtkPaperSize *size);

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

size :

a GtkPaperSize object

Returns :

the PPD name of size

Since 2.10


gtk_paper_size_get_width ()

gdouble             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

Returns :

the paper width

Since 2.10


gtk_paper_size_get_height ()

gdouble             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

Returns :

the paper height

Since 2.10


gtk_paper_size_is_custom ()

gboolean            gtk_paper_size_is_custom            (GtkPaperSize *size);

Returns TRUE if size is not a standard paper size.

size :

a GtkPaperSize object

Returns :

whether size is a custom paper size.

gtk_paper_size_set_size ()

void                gtk_paper_size_set_size             (GtkPaperSize *size,
                                                         gdouble width,
                                                         gdouble 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 unit

height :

the new height in units of unit

unit :

the unit for width and height

Since 2.10


gtk_paper_size_get_default_top_margin ()

gdouble             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

Returns :

the default top margin

Since 2.10


gtk_paper_size_get_default_bottom_margin ()

gdouble             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

Returns :

the default bottom margin

Since 2.10


gtk_paper_size_get_default_left_margin ()

gdouble             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

Returns :

the default left margin

Since 2.10


gtk_paper_size_get_default_right_margin ()

gdouble             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

Returns :

the default right margin

Since 2.10


gtk_paper_size_get_default ()

const gchar *       gtk_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 GTK+ and should not be modified.

Since 2.10


gtk_paper_size_new_from_key_file ()

GtkPaperSize *      gtk_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.

key_file :

the GKeyFile to retrieve the papersize from

group_name :

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

error :

return location for an error, or NULL. [allow-none]

Returns :

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

Since 2.12


gtk_paper_size_to_key_file ()

void                gtk_paper_size_to_key_file          (GtkPaperSize *size,
                                                         GKeyFile *key_file,
                                                         const gchar *group_name);

This function adds the paper size from size to key_file.

size :

a GtkPaperSize

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

See Also

GtkPageSetup