Use g_win32_locale_filename_from_utf8() instead of duplicating its code.

2007-12-12  Tor Lillqvist  <tml@novell.com>

	* libgimpbase/gimpenv.c (gimp_locale_directory) [Win32]: Use
	g_win32_locale_filename_from_utf8() instead of duplicating its
	code.


svn path=/trunk/; revision=24345
This commit is contained in:
Tor Lillqvist 2007-12-12 23:35:00 +00:00 committed by Tor Lillqvist
parent c0ab783568
commit 2159cbbc81
2 changed files with 7 additions and 18 deletions

View File

@ -1,3 +1,9 @@
2007-12-12 Tor Lillqvist <tml@novell.com>
* libgimpbase/gimpenv.c (gimp_locale_directory) [Win32]: Use
g_win32_locale_filename_from_utf8() instead of duplicating its
code.
2007-12-12 Martin Nordholts <martinn@svn.gnome.org>
* app/tools/gimprectangletool.c: Extended public interface a bit.

View File

@ -367,24 +367,7 @@ gimp_locale_directory (void)
gimp_locale_dir = gimp_env_get_dir ("GIMP2_LOCALEDIR", tmp);
g_free (tmp);
#ifdef G_OS_WIN32
tmp = g_locale_from_utf8 (gimp_locale_dir, -1, NULL, NULL, NULL);
/* g_locale_from_utf8() can fail in pathological cases, namely
* when the folder contains characters not in the system codepage,
* like Hebrew on a Western European machine.
*/
if (tmp == NULL)
{
/* Try to get the short name instead */
wchar_t *w_name = g_utf8_to_utf16 (gimp_locale_dir, -1, NULL, NULL, NULL);
wchar_t short_name[MAX_PATH];
DWORD rc = GetShortPathNameW (w_name, short_name, G_N_ELEMENTS (short_name));
if (rc > G_N_ELEMENTS (short_name) || rc == 0)
tmp = "."; /* eek */
else
tmp = g_utf16_to_utf8 (short_name, -1, NULL, NULL, NULL);
g_free (w_name);
}
tmp = g_win32_locale_filename_from_utf8 (gimp_locale_dir);
g_free (gimp_locale_dir);
gimp_locale_dir = tmp;
#endif