summaryrefslogtreecommitdiff
path: root/gtk/gtkprintsettings.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2006-04-23 05:48:04 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2006-04-23 05:48:04 +0000
commit935482e3b2fceba53fea4725c18ec4923c340837 (patch)
tree280ca9cec2db19c3d50a0f873b3db34822ba78ab /gtk/gtkprintsettings.c
parent46548ae53ade695005ce254ce3df3649031c1966 (diff)
downloadgtk+-935482e3b2fceba53fea4725c18ec4923c340837.tar.gz
Add gtkprintutils.[hc]
2006-04-23 Matthias Clasen <mclasen@redhat.com> * gtk/Makefile.am: Add gtkprintutils.[hc] * gtk/gtkprintutils.[hc]: New files, move the unit conversion functions here. * gtk/gtkpagesetupunixdialog.c: * gtk/gtkprintsettings.c: * gtk/gtkpagesetup.c: * gtk/gtkpapersize.c: Replace all static copies of to_mm/from_mm by the copies in gtkprintutils.c. * gtk/gtkpagesetup.[hc]: Use g types, add documentation.
Diffstat (limited to 'gtk/gtkprintsettings.c')
-rw-r--r--gtk/gtkprintsettings.c45
1 files changed, 3 insertions, 42 deletions
diff --git a/gtk/gtkprintsettings.c b/gtk/gtkprintsettings.c
index 3ef6f62b9e..5bd47202c3 100644
--- a/gtk/gtkprintsettings.c
+++ b/gtk/gtkprintsettings.c
@@ -23,10 +23,9 @@
#include <stdlib.h>
#include <glib/gprintf.h>
#include "gtkprintsettings.h"
+#include "gtkprintutils.h"
#include "gtkalias.h"
-#define MM_PER_INCH 25.4
-#define POINTS_PER_INCH 72
typedef struct _GtkPrintSettingsClass GtkPrintSettingsClass;
@@ -48,44 +47,6 @@ struct _GtkPrintSettingsClass
G_DEFINE_TYPE (GtkPrintSettings, gtk_print_settings, G_TYPE_OBJECT)
-static gdouble
-to_mm (gdouble len, GtkUnit unit)
-{
- switch (unit)
- {
- case GTK_UNIT_MM:
- return len;
- case GTK_UNIT_INCH:
- return len * MM_PER_INCH;
- default:
- case GTK_UNIT_PIXEL:
- g_warning ("Unsupported unit");
- /* Fall through */
- case GTK_UNIT_POINTS:
- return len * (MM_PER_INCH / POINTS_PER_INCH);
- break;
- }
-}
-
-static gdouble
-from_mm (gdouble len, GtkUnit unit)
-{
- switch (unit)
- {
- case GTK_UNIT_MM:
- return len;
- case GTK_UNIT_INCH:
- return len / MM_PER_INCH;
- default:
- case GTK_UNIT_PIXEL:
- g_warning ("Unsupported unit");
- /* Fall through */
- case GTK_UNIT_POINTS:
- return len / (MM_PER_INCH / POINTS_PER_INCH);
- break;
- }
-}
-
static void
gtk_print_settings_finalize (GObject *object)
{
@@ -417,7 +378,7 @@ gtk_print_settings_get_length (GtkPrintSettings *settings,
GtkUnit unit)
{
gdouble length = gtk_print_settings_get_double (settings, key);
- return from_mm (length, unit);
+ return _gtk_print_convert_from_mm (length, unit);
}
/**
@@ -438,7 +399,7 @@ gtk_print_settings_set_length (GtkPrintSettings *settings,
GtkUnit unit)
{
gtk_print_settings_set_double (settings, key,
- to_mm (length, unit));
+ _gtk_print_convert_to_mm (length, unit));
}
/**