Commit 7392679b authored by Petr Kubiznak's avatar Petr Kubiznak Committed by Michael Henning

Bug 593167 - Support Windows in gimp_get_default_unit()

Function gimp_get_default_unit ported for Windows using standard GetLocaleInfo() function (from windows.h).
(cherry picked from commit 194ef70d)
parent 234e269b
......@@ -347,7 +347,7 @@ gimp_get_default_language (const gchar *category)
GimpUnit
gimp_get_default_unit (void)
{
#ifdef HAVE__NL_MEASUREMENT_MEASUREMENT
#if defined (HAVE__NL_MEASUREMENT_MEASUREMENT)
const gchar *measurement = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT);
switch (*((guchar *) measurement))
......@@ -358,6 +358,27 @@ gimp_get_default_unit (void)
case 2: /* imperial */
return GIMP_UNIT_INCH;
}
#elif defined (G_OS_WIN32)
DWORD measurement;
int ret;
ret = GetLocaleInfo(LOCALE_USER_DEFAULT,
LOCALE_IMEASURE | LOCALE_RETURN_NUMBER,
(LPTSTR)&measurement,
sizeof(measurement) / sizeof(TCHAR) );
if (ret != 0) /* GetLocaleInfo succeeded */
{
switch ((guint) measurement)
{
case 0: /* metric */
return GIMP_UNIT_MM;
case 1: /* imperial */
return GIMP_UNIT_INCH;
}
}
#endif
return GIMP_UNIT_MM;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment