#include "gtkprintutils.h"
#include "gtkprintoperation.h" /* for GtkPrintError */
#include "gtkintl.h"
-#include "gtkalias.h"
#include "paper_names_offsets.c"
+
+/**
+ * SECTION:gtkpapersize
+ * @Short_description: Support for named paper sizes
+ * @Title: GtkPaperSize
+ * @See_also:#GtkPageSetup
+ *
+ * GtkPaperSize handles paper sizes. It uses the standard called
+ * <ulink url="http://www.pwg.org/standards.html">"PWG 5101.1-2002 PWG: Standard for Media Standardized Names"</ulink>
+ * 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 <link linkend="print-margins">print margins</link>.
+ *
+ * Printing support has been added in GTK+ 2.10.
+ */
+
+
struct _GtkPaperSize
{
const PaperInfo *info;
gboolean is_custom;
};
-GType
-gtk_paper_size_get_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- our_type = g_boxed_type_register_static (I_("GtkPaperSize"),
- (GBoxedCopyFunc)gtk_paper_size_copy,
- (GBoxedFreeFunc)gtk_paper_size_free);
- return our_type;
-}
+G_DEFINE_BOXED_TYPE (GtkPaperSize, gtk_paper_size,
+ gtk_paper_size_copy,
+ gtk_paper_size_free)
static const PaperInfo *
lookup_paper_info (const gchar *name)
/**
* gtk_paper_size_new:
- * @name: a paper size name, or %NULL
- *
- * Creates a new #GtkPaperSize object by parsing a
+ * @name: (allow-none): a paper size name, or %NULL
+ *
+ * Creates a new #GtkPaperSize object by parsing a
* <ulink url="ftp://ftp.pwg.org/pub/pwg/candidates/cs-pwgmsn10-20020226-5101.1.pdf">PWG 5101.1-2002</ulink>
- * paper name.
+ * paper name.
*
* If @name is %NULL, the default paper size is returned,
* see gtk_paper_size_get_default().
* as defined in the page setup dialog
*
* Creates a list of known paper sizes.
- *
- * Return value: a newly allocated list of newly
+ *
+ * Return value: (element-type GtkPaperSize) (transfer full): a newly allocated list of newly
* allocated #GtkPaperSize objects
*
* Since: 2.12
g_assert (size->info != NULL);
display_name = paper_names + size->info->display_name;
- return g_strip_context (display_name, _(display_name));
+ return g_dpgettext2 (GETTEXT_PACKAGE, "paper size", display_name);
}
/**
if (!locale)
return GTK_PAPER_NAME_A4;
- if (g_str_has_prefix (locale, "en_CA") ||
- g_str_has_prefix (locale, "en_US") ||
- g_str_has_prefix (locale, "es_PR") ||
- g_str_has_prefix (locale, "es_US"))
+ /* CLDR 1.8.1
+ * http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/territory_language_information.html
+ */
+ if (g_regex_match_simple("[^_.@]{2,3}_(BZ|CA|CL|CO|CR|GT|MX|NI|PA|PH|PR|SV|US|VE)",
+ locale, G_REGEX_ANCHORED, G_REGEX_MATCH_ANCHORED))
paper_size = GTK_PAPER_NAME_LETTER;
else
paper_size = GTK_PAPER_NAME_A4;
* @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
+ * @error: (allow-none): return location for an error, or %NULL
*
* Reads a paper size from the group @group_name in the key file
* @key_file.
display_name = g_strdup (name);
if (ppd_name != NULL)
- paper_size = gtk_paper_size_new_from_ppd (ppd_name, display_name,
- width, height);
+ paper_size = gtk_paper_size_new_from_ppd (ppd_name,
+ display_name,
+ _gtk_print_convert_from_mm (width, GTK_UNIT_POINTS),
+ _gtk_print_convert_from_mm (height, GTK_UNIT_POINTS));
else if (name != NULL)
paper_size = gtk_paper_size_new_custom (name, display_name,
width, height, GTK_UNIT_MM);
g_key_file_set_double (key_file, group_name,
"Height", gtk_paper_size_get_height (size, GTK_UNIT_MM));
}
-
-
-#define __GTK_PAPER_SIZE_C__
-#include "gtkaliasdef.c"