1 /* GTK - The GIMP Toolkit 2 * gtkpapersize.c: Paper Size 3 * Copyright (C) 2006, Red Hat, Inc. 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #include "config.h" 20 #include "gtkprintutils.h" 21 22 gdouble _gtk_print_convert_to_mm(gdouble len,GtkUnit unit)23_gtk_print_convert_to_mm (gdouble len, 24 GtkUnit unit) 25 { 26 switch (unit) 27 { 28 case GTK_UNIT_MM: 29 return len; 30 case GTK_UNIT_INCH: 31 return len * MM_PER_INCH; 32 default: 33 g_warning ("Unsupported unit"); 34 /* Fall through */ 35 case GTK_UNIT_POINTS: 36 return len * (MM_PER_INCH / POINTS_PER_INCH); 37 break; 38 } 39 } 40 41 gdouble _gtk_print_convert_from_mm(gdouble len,GtkUnit unit)42_gtk_print_convert_from_mm (gdouble len, 43 GtkUnit unit) 44 { 45 switch (unit) 46 { 47 case GTK_UNIT_MM: 48 return len; 49 case GTK_UNIT_INCH: 50 return len / MM_PER_INCH; 51 default: 52 g_warning ("Unsupported unit"); 53 /* Fall through */ 54 case GTK_UNIT_POINTS: 55 return len / (MM_PER_INCH / POINTS_PER_INCH); 56 break; 57 } 58 } 59