From b6b3c53f47e4e3f03b572591a584d817dfba44f7 Mon Sep 17 00:00:00 2001 From: "Nickolay V. Shmyrev" Date: Thu, 21 Dec 2006 00:44:53 +0000 Subject: [PATCH] Check for NL_MEASUREMENT. Fixes bug #376469. Thanks to Damien Carbery 2006-12-21 Nickolay V. Shmyrev * configure.ac: * properties/ev-properties-view.c: (ev_get_default_user_units), (ev_regular_paper_size): Check for NL_MEASUREMENT. Fixes bug #376469. Thanks to Damien Carbery and Yevgen Muntyan . --- ChangeLog | 10 ++++++++ configure.ac | 4 +++ properties/ev-properties-view.c | 45 ++++++++++++++++++++++++++++++--- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab0913c3..72a1cb71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-12-21 Nickolay V. Shmyrev + + * configure.ac: + * properties/ev-properties-view.c: (ev_get_default_user_units), + (ev_regular_paper_size): + + Check for NL_MEASUREMENT. Fixes bug #376469. Thanks + to Damien Carbery and + Yevgen Muntyan . + 2006-12-20 Wouter Bolsterlee * shell/ev-window.c: (setup_document_from_metadata): diff --git a/configure.ac b/configure.ac index 21d0f8ba..389de185 100644 --- a/configure.ac +++ b/configure.ac @@ -189,6 +189,10 @@ dnl ================== portability checks ====================================== dnl for backtrace() AC_CHECK_HEADERS([execinfo.h]) +AC_CHECK_DECL([_NL_MEASUREMENT_MEASUREMENT],[ + AC_DEFINE([HAVE__NL_MEASUREMENT_MEASUREMENT],[1],[Define if _NL_MEASUREMENT_MEASUREMENT is available]) + ],[],[#include ]) + dnl ================== pdf checks =================================================== AC_ARG_ENABLE(pdf, [AC_HELP_STRING([--enable-pdf], [Compile with pdf support])],enable_pdf="$enableval",enable_pdf=yes) diff --git a/properties/ev-properties-view.c b/properties/ev-properties-view.c index 98aecb56..1b8f1fb7 100644 --- a/properties/ev-properties-view.c +++ b/properties/ev-properties-view.c @@ -31,7 +31,10 @@ #include #include #include + +#ifdef HAVE__NL_MEASUREMENT_MEASUREMENT #include +#endif typedef enum { @@ -240,17 +243,51 @@ struct regular_paper_size { { 432.0f, 279.0f, 3.0f, 3.0f, "Ledger" } }; +typedef enum { + EV_UNIT_INCH, + EV_UNIT_MM +} EvUnit; + +static EvUnit +ev_get_default_user_units (void) +{ + /* Translate to the default units to use for presenting + * lengths to the user. Translate to default:inch if you + * want inches, otherwise translate to default:mm. + * Do *not* translate it to "predefinito:mm", if it + * it isn't default:mm or default:inch it will not work + */ + gchar *e = _("default:mm"); + +#ifdef HAVE__NL_MEASUREMENT_MEASUREMENT + gchar *imperial = NULL; + + imperial = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT); + if (imperial && imperial[0] == 2 ) + return EV_UNIT_INCH; /* imperial */ + if (imperial && imperial[0] == 1 ) + return EV_UNIT_MM; /* metric */ +#endif + + if (strcmp (e, "default:inch")==0) + return EV_UNIT_INCH; + else if (strcmp (e, "default:mm")) + g_warning ("Whoever translated default:mm did so wrongly.\n"); + return EV_UNIT_MM; +} + static char * ev_regular_paper_size (const EvDocumentInfo *info) { const struct regular_paper_size *size; + EvUnit unit; char *exact_size = NULL; - char *imperial = NULL; char *str = NULL; int i; - - imperial = nl_langinfo(_NL_MEASUREMENT_MEASUREMENT); - if ( imperial && imperial[0] == 2 ) + + unit = ev_get_default_user_units (); + + if (unit == EV_UNIT_INCH) /* Imperial measurement (inches) */ exact_size = g_strdup_printf( _("%.2f x %.2f in"), info->paper_width / 25.4f, -- 2.43.5