X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkpapersize.c;h=1ab622e1949135b67345cb7d45e34f2b0809bebc;hb=32825a66ac8e65bf98cafed26a339fa1f31eddd4;hp=894dca0b87969dae23a89052b1ff2407e405f389;hpb=37bb7ea2a003c7cc24dbc88012fa1e1aef3c1212;p=~andy%2Fgtk
diff --git a/gtk/gtkpapersize.c b/gtk/gtkpapersize.c
index 894dca0b8..1ab622e19 100644
--- a/gtk/gtkpapersize.c
+++ b/gtk/gtkpapersize.c
@@ -14,9 +14,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see .
*/
#include "config.h"
@@ -31,10 +29,34 @@
#include "gtkprintutils.h"
#include "gtkprintoperation.h" /* for GtkPrintError */
#include "gtkintl.h"
-#include "gtkalias.h"
+
+#ifdef G_OS_UNIX /* _gtk_load_custom_papers() only on Unix so far */
+#include "gtkcustompaperunixdialog.h"
+#endif
#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
+ * "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.
+ */
+
+
struct _GtkPaperSize
{
const PaperInfo *info;
@@ -43,22 +65,14 @@ struct _GtkPaperSize
gchar *name;
gchar *display_name;
gchar *ppd_name;
-
+
gdouble width, height; /* Stored in mm */
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)
@@ -68,7 +82,7 @@ lookup_paper_info (const gchar *name)
int mid;
int cmp;
- do
+ do
{
mid = (lower + upper) / 2;
cmp = strcmp (name, paper_names + standard_names_offsets[mid].name);
@@ -77,7 +91,7 @@ lookup_paper_info (const gchar *name)
else if (cmp > 0)
lower = mid + 1;
else
- return &standard_names_offsets[mid];
+ return &standard_names_offsets[mid];
}
while (lower <= upper);
@@ -86,15 +100,15 @@ lookup_paper_info (const gchar *name)
static gboolean
parse_media_size (const gchar *size,
- gdouble *width_mm,
- gdouble *height_mm)
+ gdouble *width_mm,
+ gdouble *height_mm)
{
const char *p;
char *e;
double short_dim, long_dim;
p = size;
-
+
short_dim = g_ascii_strtod (p, &e);
if (p == e || *e != 'x')
@@ -121,19 +135,19 @@ parse_media_size (const gchar *size,
*width_mm = short_dim;
if (height_mm)
*height_mm = long_dim;
-
- return TRUE;
+
+ return TRUE;
}
static gboolean
parse_full_media_size_name (const gchar *full_name,
- gchar **name,
- gdouble *width_mm,
- gdouble *height_mm)
+ gchar **name,
+ gdouble *width_mm,
+ gdouble *height_mm)
{
const char *p;
const char *end_of_name;
-
+
/* From the spec:
media-size-self-describing-name =
( class-in "_" size-name "_" short-dim "x" long-dim "in" ) |
@@ -158,7 +172,7 @@ parse_full_media_size_name (const gchar *full_name,
return FALSE;
p++; /* Skip _ */
-
+
p = strchr (p, '_');
if (p == NULL)
return FALSE;
@@ -172,20 +186,20 @@ parse_full_media_size_name (const gchar *full_name,
if (name)
*name = g_strndup (full_name, end_of_name - full_name);
-
- return TRUE;
+
+ return TRUE;
}
static GtkPaperSize *
gtk_paper_size_new_from_info (const PaperInfo *info)
{
GtkPaperSize *size;
-
+
size = g_slice_new0 (GtkPaperSize);
size->info = info;
size->width = info->width;
size->height = info->height;
-
+
return size;
}
@@ -199,7 +213,7 @@ gtk_paper_size_new_from_info (const PaperInfo *info)
*
* If @name is %NULL, the default paper size is returned,
* see gtk_paper_size_get_default().
- *
+ *
* Return value: a new #GtkPaperSize, use gtk_paper_size_free()
* to free it
*
@@ -215,35 +229,44 @@ gtk_paper_size_new (const gchar *name)
if (name == NULL)
name = gtk_paper_size_get_default ();
-
+
if (parse_full_media_size_name (name, &short_name, &width, &height))
{
- size = g_slice_new0 (GtkPaperSize);
-
- size->width = width;
- size->height = height;
- size->name = short_name;
- size->display_name = g_strdup (short_name);
- if (strncmp (short_name, "custom", 6) == 0)
- size->is_custom = TRUE;
+ info = lookup_paper_info (short_name);
+ if (info != NULL && info->width == width && info->height == height)
+ {
+ size = gtk_paper_size_new_from_info (info);
+ g_free (short_name);
+ }
+ else
+ {
+ size = g_slice_new0 (GtkPaperSize);
+
+ size->width = width;
+ size->height = height;
+ size->name = short_name;
+ size->display_name = g_strdup (short_name);
+ if (strncmp (short_name, "custom", 6) == 0)
+ size->is_custom = TRUE;
+ }
}
else
{
info = lookup_paper_info (name);
if (info != NULL)
- size = gtk_paper_size_new_from_info (info);
+ size = gtk_paper_size_new_from_info (info);
else
- {
- g_warning ("Unknown paper size %s\n", name);
- size = g_slice_new0 (GtkPaperSize);
- size->name = g_strdup (name);
- size->display_name = g_strdup (name);
- /* Default to A4 size */
- size->width = 210;
- size->height = 297;
- }
+ {
+ g_warning ("Unknown paper size %s\n", name);
+ size = g_slice_new0 (GtkPaperSize);
+ size->name = g_strdup (name);
+ size->display_name = g_strdup (name);
+ /* Default to A4 size */
+ size->width = 210;
+ size->height = 297;
+ }
}
-
+
return size;
}
@@ -253,12 +276,12 @@ gtk_paper_size_new (const gchar *name)
* @ppd_display_name: the corresponding human-readable name
* @width: the paper width, in points
* @height: the paper height in points
- *
- * 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
+ *
+ * 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.
*
* Return value: a new #GtkPaperSize, use gtk_paper_size_free()
@@ -268,9 +291,9 @@ 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)
+ const gchar *ppd_display_name,
+ gdouble width,
+ gdouble height)
{
char *name;
const char *lookup_ppd_name;
@@ -279,32 +302,32 @@ gtk_paper_size_new_from_ppd (const gchar *ppd_name,
int i;
lookup_ppd_name = ppd_name;
-
+
freeme = NULL;
/* Strip out Traverse suffix in matching. */
if (g_str_has_suffix (ppd_name, ".Transverse"))
{
lookup_ppd_name = freeme =
- g_strndup (ppd_name, strlen (ppd_name) - strlen (".Transverse"));
+ g_strndup (ppd_name, strlen (ppd_name) - strlen (".Transverse"));
}
-
+
for (i = 0; i < G_N_ELEMENTS(standard_names_offsets); i++)
{
if (standard_names_offsets[i].ppd_name != -1 &&
- strcmp (paper_names + standard_names_offsets[i].ppd_name, lookup_ppd_name) == 0)
- {
- size = gtk_paper_size_new_from_info (&standard_names_offsets[i]);
- goto out;
- }
+ strcmp (paper_names + standard_names_offsets[i].ppd_name, lookup_ppd_name) == 0)
+ {
+ size = gtk_paper_size_new_from_info (&standard_names_offsets[i]);
+ goto out;
+ }
}
-
+
for (i = 0; i < G_N_ELEMENTS(extra_ppd_names_offsets); i++)
{
if (strcmp (paper_names + extra_ppd_names_offsets[i].ppd_name, lookup_ppd_name) == 0)
- {
- size = gtk_paper_size_new (paper_names + extra_ppd_names_offsets[i].standard_name);
- goto out;
- }
+ {
+ size = gtk_paper_size_new (paper_names + extra_ppd_names_offsets[i].standard_name);
+ goto out;
+ }
}
name = g_strconcat ("ppd_", ppd_name, NULL);
@@ -317,57 +340,57 @@ gtk_paper_size_new_from_ppd (const gchar *ppd_name,
size->info->ppd_name == -1 ||
strcmp (paper_names + size->info->ppd_name, ppd_name) != 0)
size->ppd_name = g_strdup (ppd_name);
-
+
g_free (freeme);
-
+
return size;
}
/**
* gtk_paper_size_new_custom:
- * @name: the paper name
+ * @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
- *
+ * @unit: the unit for @width and @height. not %GTK_UNIT_NONE.
+ *
* Creates a new #GtkPaperSize object with the
* given parameters.
- *
+ *
* Return value: a new #GtkPaperSize object, use gtk_paper_size_free()
* to free it
*
* Since: 2.10
*/
GtkPaperSize *
-gtk_paper_size_new_custom (const gchar *name,
- const gchar *display_name,
- gdouble width,
- gdouble height,
- GtkUnit unit)
+gtk_paper_size_new_custom (const gchar *name,
+ const gchar *display_name,
+ gdouble width,
+ gdouble height,
+ GtkUnit unit)
{
GtkPaperSize *size;
g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (unit != GTK_UNIT_PIXEL, NULL);
+ g_return_val_if_fail (unit != GTK_UNIT_NONE, NULL);
size = g_slice_new0 (GtkPaperSize);
-
+
size->name = g_strdup (name);
size->display_name = g_strdup (display_name);
size->is_custom = TRUE;
-
+
size->width = _gtk_print_convert_to_mm (width, unit);
size->height = _gtk_print_convert_to_mm (height, unit);
-
+
return size;
}
/**
* gtk_paper_size_copy:
* @other: a #GtkPaperSize
- *
+ *
* Copies an existing #GtkPaperSize.
- *
+ *
* Return value: a copy of @other
*
* Since: 2.10
@@ -386,7 +409,7 @@ gtk_paper_size_copy (GtkPaperSize *other)
size->display_name = g_strdup (other->display_name);
if (other->ppd_name)
size->ppd_name = g_strdup (other->ppd_name);
-
+
size->width = other->width;
size->height = other->height;
size->is_custom = other->is_custom;
@@ -397,7 +420,7 @@ gtk_paper_size_copy (GtkPaperSize *other)
/**
* gtk_paper_size_free:
* @size: a #GtkPaperSize
- *
+ *
* Free the given #GtkPaperSize object.
*
* Since: 2.10
@@ -416,27 +439,25 @@ gtk_paper_size_free (GtkPaperSize *size)
* gtk_paper_size_is_equal:
* @size1: a #GtkPaperSize object
* @size2: another #GtkPaperSize object
- *
+ *
* Compares two #GtkPaperSize objects.
- *
- * Return value: %TRUE, if @size1 and @size2
+ *
+ * Return value: %TRUE, if @size1 and @size2
* represent the same paper size
*
* Since: 2.10
*/
gboolean
gtk_paper_size_is_equal (GtkPaperSize *size1,
- GtkPaperSize *size2)
+ GtkPaperSize *size2)
{
if (size1->info != NULL && size2->info != NULL)
return size1->info == size2->info;
-
+
return strcmp (gtk_paper_size_get_name (size1),
- gtk_paper_size_get_name (size2)) == 0;
+ gtk_paper_size_get_name (size2)) == 0;
}
-GList * _gtk_load_custom_papers (void);
-
/**
* gtk_paper_size_get_paper_sizes:
* @include_custom: whether to include custom paper sizes
@@ -454,7 +475,7 @@ gtk_paper_size_get_paper_sizes (gboolean include_custom)
{
GList *list = NULL;
guint i;
-#ifdef G_OS_UNIX /* _gtk_load_custom_papers() only on Unix so far */
+#ifdef G_OS_UNIX /* _gtk_load_custom_papers() only on Unix so far */
if (include_custom)
{
GList *page_setups, *l;
@@ -469,8 +490,7 @@ gtk_paper_size_get_paper_sizes (gboolean include_custom)
list = g_list_prepend (list, gtk_paper_size_copy (size));
}
- g_list_foreach (page_setups, (GFunc) g_object_unref, NULL);
- g_list_free (page_setups);
+ g_list_free_full (page_setups, g_object_unref);
}
#endif
for (i = 0; i < G_N_ELEMENTS (standard_names_offsets); ++i)
@@ -488,14 +508,14 @@ gtk_paper_size_get_paper_sizes (gboolean include_custom)
/**
* gtk_paper_size_get_name:
* @size: a #GtkPaperSize object
- *
+ *
* Gets the name of the #GtkPaperSize.
- *
+ *
* Return value: the name of @size
*
* Since: 2.10
*/
-G_CONST_RETURN gchar *
+const gchar *
gtk_paper_size_get_name (GtkPaperSize *size)
{
if (size->name)
@@ -507,14 +527,14 @@ gtk_paper_size_get_name (GtkPaperSize *size)
/**
* gtk_paper_size_get_display_name:
* @size: a #GtkPaperSize object
- *
+ *
* Gets the human-readable name of the #GtkPaperSize.
- *
+ *
* Return value: the human-readable name of @size
*
* Since: 2.10
*/
-G_CONST_RETURN gchar *
+const gchar *
gtk_paper_size_get_display_name (GtkPaperSize *size)
{
const gchar *display_name;
@@ -531,15 +551,15 @@ gtk_paper_size_get_display_name (GtkPaperSize *size)
/**
* gtk_paper_size_get_ppd_name:
* @size: a #GtkPaperSize object
- *
+ *
* Gets the PPD name of the #GtkPaperSize, which
* may be %NULL.
- *
+ *
* Return value: the PPD name of @size
*
* Since: 2.10
*/
-G_CONST_RETURN gchar *
+const gchar *
gtk_paper_size_get_ppd_name (GtkPaperSize *size)
{
if (size->ppd_name)
@@ -552,18 +572,18 @@ gtk_paper_size_get_ppd_name (GtkPaperSize *size)
/**
* gtk_paper_size_get_width:
* @size: a #GtkPaperSize object
- * @unit: the unit for the return value
- *
- * Gets the paper width of the #GtkPaperSize, in
+ * @unit: the unit for the return value, not %GTK_UNIT_NONE
+ *
+ * Gets the paper width of the #GtkPaperSize, in
* units of @unit.
- *
- * Return value: the paper width
+ *
+ * Return value: the paper width
*
* Since: 2.10
*/
gdouble
-gtk_paper_size_get_width (GtkPaperSize *size,
- GtkUnit unit)
+gtk_paper_size_get_width (GtkPaperSize *size,
+ GtkUnit unit)
{
return _gtk_print_convert_from_mm (size->width, unit);
}
@@ -571,18 +591,18 @@ gtk_paper_size_get_width (GtkPaperSize *size,
/**
* gtk_paper_size_get_height:
* @size: a #GtkPaperSize object
- * @unit: the unit for the return value
- *
- * Gets the paper height of the #GtkPaperSize, in
+ * @unit: the unit for the return value, not %GTK_UNIT_NONE
+ *
+ * Gets the paper height of the #GtkPaperSize, in
* units of @unit.
- *
- * Return value: the paper height
+ *
+ * Return value: the paper height
*
* Since: 2.10
*/
gdouble
-gtk_paper_size_get_height (GtkPaperSize *size,
- GtkUnit unit)
+gtk_paper_size_get_height (GtkPaperSize *size,
+ GtkUnit unit)
{
return _gtk_print_convert_from_mm (size->height, unit);
}
@@ -590,9 +610,9 @@ gtk_paper_size_get_height (GtkPaperSize *size,
/**
* gtk_paper_size_is_custom:
* @size: a #GtkPaperSize object
- *
+ *
* Returns %TRUE if @size is not a standard paper size.
- *
+ *
* Return value: whether @size is a custom paper size.
**/
gboolean
@@ -607,16 +627,16 @@ gtk_paper_size_is_custom (GtkPaperSize *size)
* @width: the new width in units of @unit
* @height: the new height in units of @unit
* @unit: the unit for @width and @height
- *
+ *
* Changes the dimensions of a @size to @width x @height.
*
* Since: 2.10
*/
void
-gtk_paper_size_set_size (GtkPaperSize *size,
- gdouble width,
- gdouble height,
- GtkUnit unit)
+gtk_paper_size_set_size (GtkPaperSize *size,
+ gdouble width,
+ gdouble height,
+ GtkUnit unit)
{
g_return_if_fail (size != NULL);
g_return_if_fail (size->is_custom);
@@ -631,15 +651,15 @@ gtk_paper_size_set_size (GtkPaperSize *size,
/**
* gtk_paper_size_get_default:
*
- * Returns the name of the default paper size, which
- * depends on the current locale.
- *
+ * Returns the name of the default paper size, which
+ * depends on the current locale.
+ *
* Return value: the name of the default paper size. The string
* is owned by GTK+ and should not be modified.
- *
+ *
* Since: 2.10
*/
-G_CONST_RETURN gchar *
+const gchar *
gtk_paper_size_get_default (void)
{
char *locale, *freeme = NULL;
@@ -649,10 +669,10 @@ gtk_paper_size_get_default (void)
{
int width = NL_PAPER_GET (_NL_PAPER_WIDTH);
int height = NL_PAPER_GET (_NL_PAPER_HEIGHT);
-
+
if (width == 210 && height == 297)
return GTK_PAPER_NAME_A4;
-
+
if (width == 216 && height == 279)
return GTK_PAPER_NAME_LETTER;
}
@@ -689,7 +709,7 @@ gtk_paper_size_get_default (void)
* I've taken the actual values used from the OSX page setup dialog.
* I'm not sure exactly where they got these values for, but might
* correspond to this (from ghostscript docs):
- *
+ *
* All DeskJets have 0.5 inches (1.27cm) of unprintable bottom margin,
* due to the mechanical arrangement used to grab the paper. Side margins
* are approximately 0.25 inches (0.64cm) for U.S. letter paper, and 0.15
@@ -699,17 +719,17 @@ gtk_paper_size_get_default (void)
/**
* gtk_paper_size_get_default_top_margin:
* @size: a #GtkPaperSize object
- * @unit: the unit for the return value
- *
+ * @unit: the unit for the return value, not %GTK_UNIT_NONE
+ *
* Gets the default top margin for the #GtkPaperSize.
- *
+ *
* Return value: the default top margin
*
* Since: 2.10
*/
gdouble
-gtk_paper_size_get_default_top_margin (GtkPaperSize *size,
- GtkUnit unit)
+gtk_paper_size_get_default_top_margin (GtkPaperSize *size,
+ GtkUnit unit)
{
gdouble margin;
@@ -720,17 +740,17 @@ gtk_paper_size_get_default_top_margin (GtkPaperSize *size,
/**
* gtk_paper_size_get_default_bottom_margin:
* @size: a #GtkPaperSize object
- * @unit: the unit for the return value
- *
+ * @unit: the unit for the return value, not %GTK_UNIT_NONE
+ *
* Gets the default bottom margin for the #GtkPaperSize.
- *
+ *
* Return value: the default bottom margin
*
* Since: 2.10
*/
gdouble
-gtk_paper_size_get_default_bottom_margin (GtkPaperSize *size,
- GtkUnit unit)
+gtk_paper_size_get_default_bottom_margin (GtkPaperSize *size,
+ GtkUnit unit)
{
gdouble margin;
const gchar *name;
@@ -742,24 +762,24 @@ gtk_paper_size_get_default_bottom_margin (GtkPaperSize *size,
strcmp (name, "na_legal") == 0 ||
strcmp (name, "iso_a4") == 0)
margin = _gtk_print_convert_to_mm (0.56, GTK_UNIT_INCH);
-
+
return _gtk_print_convert_from_mm (margin, unit);
}
/**
* gtk_paper_size_get_default_left_margin:
* @size: a #GtkPaperSize object
- * @unit: the unit for the return value
- *
+ * @unit: the unit for the return value, not %GTK_UNIT_NONE
+ *
* Gets the default left margin for the #GtkPaperSize.
- *
+ *
* Return value: the default left margin
*
* Since: 2.10
*/
gdouble
-gtk_paper_size_get_default_left_margin (GtkPaperSize *size,
- GtkUnit unit)
+gtk_paper_size_get_default_left_margin (GtkPaperSize *size,
+ GtkUnit unit)
{
gdouble margin;
@@ -770,17 +790,17 @@ gtk_paper_size_get_default_left_margin (GtkPaperSize *size,
/**
* gtk_paper_size_get_default_right_margin:
* @size: a #GtkPaperSize object
- * @unit: the unit for the return value
- *
+ * @unit: the unit for the return value, not %GTK_UNIT_NONE
+ *
* Gets the default right margin for the #GtkPaperSize.
- *
+ *
* Return value: the default right margin
*
* Since: 2.10
*/
gdouble
-gtk_paper_size_get_default_right_margin (GtkPaperSize *size,
- GtkUnit unit)
+gtk_paper_size_get_default_right_margin (GtkPaperSize *size,
+ GtkUnit unit)
{
gdouble margin;
@@ -796,22 +816,24 @@ gtk_paper_size_get_default_right_margin (GtkPaperSize *size,
* @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.
+ * @key_file.
*
* Returns: a new #GtkPaperSize object with the restored
- * paper size, or %NULL if an error occurred.
+ * paper size, or %NULL if an error occurred
*
* Since: 2.12
*/
GtkPaperSize *
-gtk_paper_size_new_from_key_file (GKeyFile *key_file,
- const gchar *group_name,
- GError **error)
+gtk_paper_size_new_from_key_file (GKeyFile *key_file,
+ const gchar *group_name,
+ GError **error)
{
GtkPaperSize *paper_size = NULL;
- char *name = NULL, *ppd_name = NULL, *display_name = NULL, *freeme = NULL;
+ gchar *name = NULL;
+ gchar *ppd_name = NULL;
+ gchar *display_name = NULL;
+ gchar *freeme = NULL;
gdouble width, height;
- gboolean retval = TRUE;
GError *err = NULL;
g_return_val_if_fail (key_file != NULL, NULL);
@@ -824,7 +846,6 @@ gtk_paper_size_new_from_key_file (GKeyFile *key_file,
GTK_PRINT_ERROR,
GTK_PRINT_ERROR_INVALID_FILE,
_("Not a valid page setup file"));
- retval = FALSE;
goto out;
}
@@ -833,7 +854,6 @@ gtk_paper_size_new_from_key_file (GKeyFile *key_file,
if (err != NULL) \
{\
g_propagate_error (error, err);\
- retval = FALSE;\
goto out;\
}
@@ -843,11 +863,11 @@ gtk_paper_size_new_from_key_file (GKeyFile *key_file,
#undef GET_DOUBLE
name = g_key_file_get_string (key_file, group_name,
- "Name", NULL);
+ "Name", NULL);
ppd_name = g_key_file_get_string (key_file, group_name,
- "PPDName", NULL);
+ "PPDName", NULL);
display_name = g_key_file_get_string (key_file, group_name,
- "DisplayName", NULL);
+ "DisplayName", NULL);
/* Fallback for old ~/.gtk-custom-paper entries */
if (!display_name)
display_name = g_strdup (name);
@@ -859,16 +879,16 @@ gtk_paper_size_new_from_key_file (GKeyFile *key_file,
_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);
+ width, height, GTK_UNIT_MM);
else
{
g_set_error_literal (error,
GTK_PRINT_ERROR,
GTK_PRINT_ERROR_INVALID_FILE,
_("Not a valid page setup file"));
- retval = FALSE;
goto out;
}
+
g_assert (paper_size != NULL);
out:
@@ -892,8 +912,8 @@ out:
*/
void
gtk_paper_size_to_key_file (GtkPaperSize *size,
- GKeyFile *key_file,
- const gchar *group_name)
+ GKeyFile *key_file,
+ const gchar *group_name)
{
const char *name, *ppd_name, *display_name;
@@ -904,23 +924,19 @@ gtk_paper_size_to_key_file (GtkPaperSize *size,
display_name = gtk_paper_size_get_display_name (size);
ppd_name = gtk_paper_size_get_ppd_name (size);
- if (ppd_name != NULL)
+ if (ppd_name != NULL)
g_key_file_set_string (key_file, group_name,
- "PPDName", ppd_name);
+ "PPDName", ppd_name);
else
g_key_file_set_string (key_file, group_name,
- "Name", name);
+ "Name", name);
- if (display_name)
+ if (display_name)
g_key_file_set_string (key_file, group_name,
- "DisplayName", display_name);
+ "DisplayName", display_name);
g_key_file_set_double (key_file, group_name,
- "Width", gtk_paper_size_get_width (size, GTK_UNIT_MM));
+ "Width", gtk_paper_size_get_width (size, GTK_UNIT_MM));
g_key_file_set_double (key_file, group_name,
- "Height", gtk_paper_size_get_height (size, GTK_UNIT_MM));
+ "Height", gtk_paper_size_get_height (size, GTK_UNIT_MM));
}
-
-
-#define __GTK_PAPER_SIZE_C__
-#include "gtkaliasdef.c"