diff options
author | Matthias Clasen <mclasen@redhat.com> | 2006-04-23 05:48:04 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2006-04-23 05:48:04 +0000 |
commit | 935482e3b2fceba53fea4725c18ec4923c340837 (patch) | |
tree | 280ca9cec2db19c3d50a0f873b3db34822ba78ab /gtk/gtkpagesetupunixdialog.c | |
parent | 46548ae53ade695005ce254ce3df3649031c1966 (diff) | |
download | gtk+-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/gtkpagesetupunixdialog.c')
-rw-r--r-- | gtk/gtkpagesetupunixdialog.c | 54 |
1 files changed, 7 insertions, 47 deletions
diff --git a/gtk/gtkpagesetupunixdialog.c b/gtk/gtkpagesetupunixdialog.c index 0815f17a4b..e3743f56e1 100644 --- a/gtk/gtkpagesetupunixdialog.c +++ b/gtk/gtkpagesetupunixdialog.c @@ -52,13 +52,11 @@ #include "gtkprintbackend.h" #include "gtkprinter-private.h" #include "gtkpapersize.h" +#include "gtkprintutils.h" #include "gtkalias.h" #define CUSTOM_PAPER_FILENAME ".gtk-custom-papers" -#define MM_PER_INCH 25.4 -#define POINTS_PER_INCH 72 - struct GtkPageSetupUnixDialogPrivate { @@ -128,44 +126,6 @@ static const char * const common_paper_sizes[] = { "iso_a3", }; -static double -to_mm (double 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 double -from_mm (double 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 GtkUnit get_default_user_units (void) { @@ -1376,7 +1336,7 @@ static double unit_widget_get (GtkWidget *unit_widget) { UnitWidget *data = g_object_get_data (G_OBJECT (unit_widget), "unit-data"); - return to_mm (gtk_spin_button_get_value (GTK_SPIN_BUTTON (data->spin_button)), + return _gtk_print_convert_to_mm (gtk_spin_button_get_value (GTK_SPIN_BUTTON (data->spin_button)), data->display_unit); } @@ -1385,7 +1345,7 @@ unit_widget_set (GtkWidget *unit_widget, double val) { UnitWidget *data = g_object_get_data (G_OBJECT (unit_widget), "unit-data"); gtk_spin_button_set_value (GTK_SPIN_BUTTON (data->spin_button), - from_mm (val, data->display_unit)); + _gtk_print_convert_from_mm (val, data->display_unit)); } @@ -1639,10 +1599,10 @@ set_margins_from_printer (CustomPaperDialog *data, _gtk_printer_get_hard_margins (printer, &top, &bottom, &left, &right); data->non_user_change = TRUE; - unit_widget_set (data->top_widget, to_mm (top, GTK_UNIT_POINTS)); - unit_widget_set (data->bottom_widget, to_mm (bottom, GTK_UNIT_POINTS)); - unit_widget_set (data->left_widget, to_mm (left, GTK_UNIT_POINTS)); - unit_widget_set (data->right_widget, to_mm (right, GTK_UNIT_POINTS)); + unit_widget_set (data->top_widget, _gtk_print_convert_to_mm (top, GTK_UNIT_POINTS)); + unit_widget_set (data->bottom_widget, _gtk_print_convert_to_mm (bottom, GTK_UNIT_POINTS)); + unit_widget_set (data->left_widget, _gtk_print_convert_to_mm (left, GTK_UNIT_POINTS)); + unit_widget_set (data->right_widget, _gtk_print_convert_to_mm (right, GTK_UNIT_POINTS)); data->non_user_change = FALSE; /* Only send one change */ |