]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkpapersize.c
GtkStyle: set style context state before calling gtk_render_icon_pixbuf()
[~andy/gtk] / gtk / gtkpapersize.c
index 44de5c9ec09f69117d53a12c087ea67b7949f7ee..7601aba552f7812227e580b6bd84e76961634b68 100644 (file)
 #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;
@@ -48,17 +68,9 @@ struct _GtkPaperSize
   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)
@@ -191,11 +203,11 @@ gtk_paper_size_new_from_info (const PaperInfo *info)
 
 /**
  * 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().
@@ -443,8 +455,8 @@ GList * _gtk_load_custom_papers (void);
  *     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
@@ -525,7 +537,7 @@ gtk_paper_size_get_display_name (GtkPaperSize *size)
   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);
 }
 
 /**
@@ -669,10 +681,11 @@ gtk_paper_size_get_default (void)
   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;
@@ -792,7 +805,7 @@ gtk_paper_size_get_default_right_margin (GtkPaperSize *size,
  * @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. 
@@ -852,8 +865,10 @@ gtk_paper_size_new_from_key_file (GKeyFile    *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);
@@ -917,7 +932,3 @@ gtk_paper_size_to_key_file (GtkPaperSize *size,
   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"