diff --git a/ChangeLog b/ChangeLog index 8593508cd1..c1bcbcd565 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2004-01-14 Tor Lillqvist + + * app/file/file-utils.[ch]: Add new function + file_utils_filename_to_utf8(), which is to be used when converting + file names (which are kept in the on-disk encoding) to UTF-8 for + passing to GTK, or to g_print() etc. + + * app/*/*.c: Call file_utils_filename_to_utf8(). Should fix most + of the warnings generated by non-UTF8 pathnames. See #130118. + + * libgimpbase/gimpenv.b: Document that gimp_directory() etc return + strings in the on-disk encoding. + + * libgimpmodule/gimpmodule.c: Convert filenames to UTF-8 (using + g_filename_to_utf8()) before passing to g_print(). + 2004-01-14 Simon Budig * app/gui/about-dialog.c: Fixed small refresh issue. diff --git a/app/base/temp-buf.c b/app/base/temp-buf.c index 9b3be04fe0..7066a926cd 100644 --- a/app/base/temp-buf.c +++ b/app/base/temp-buf.c @@ -40,6 +40,8 @@ #include "config/gimpbaseconfig.h" #include "config/gimpconfig-path.h" +#include "file/file-utils.h" + #include "pixel-region.h" #include "temp-buf.h" @@ -714,7 +716,8 @@ temp_buf_swap (TempBuf *buf) /* Check if generated filename is valid */ if (g_file_test (filename, G_FILE_TEST_IS_DIR)) { - g_message ("Error in temp buf caching: \"%s\" is a directory (cannot overwrite)", filename); + g_message ("Error in temp buf caching: \"%s\" is a directory (cannot overwrite)", + file_utils_filename_to_utf8 (filename)); g_free (filename); return; } @@ -734,7 +737,8 @@ temp_buf_swap (TempBuf *buf) { unlink (filename); perror ("Write error on temp buf"); - g_message ("Cannot write \"%s\"", filename); + g_message ("Cannot write \"%s\"", + file_utils_filename_to_utf8 (filename)); g_free (filename); return; } @@ -743,7 +747,8 @@ temp_buf_swap (TempBuf *buf) { unlink (filename); perror ("Error in temp buf caching"); - g_message ("Cannot write \"%s\"", filename); + g_message ("Cannot write \"%s\"", + file_utils_filename_to_utf8 (filename)); g_free (filename); return; } diff --git a/app/base/tile-swap.c b/app/base/tile-swap.c index f2faf1deb8..de16bf4552 100644 --- a/app/base/tile-swap.c +++ b/app/base/tile-swap.c @@ -45,6 +45,8 @@ #define _O_TEMPORARY 0 #endif +#include "file/file-utils.h" + #include "tile.h" #include "tile-private.h" #include "tile-swap.h" @@ -182,7 +184,8 @@ tile_swap_exit1 (gpointer key, def_swap_file = swap_file->user_data; if (def_swap_file->swap_file_end != 0) { - g_warning ("swap file not empty: \"%s\"\n", swap_file->filename); + g_warning ("swap file not empty: \"%s\"\n", + file_utils_filename_to_utf8 (swap_file->filename)); tile_swap_print_gaps (def_swap_file); } diff --git a/app/config/gimpconfig-path.c b/app/config/gimpconfig-path.c index eab2b7265d..e98eeb43b4 100644 --- a/app/config/gimpconfig-path.c +++ b/app/config/gimpconfig-path.c @@ -28,6 +28,8 @@ #include "libgimpbase/gimpenv.h" +#include "file/file-utils.h" + #include "gimpconfig-path.h" #include "gimp-intl.h" @@ -104,7 +106,7 @@ gimp_config_path_expand_only (const gchar *path, #ifndef G_OS_WIN32 if (*p == '~') { - length += strlen (g_get_home_dir ()); + length += strlen (file_utils_filename_to_utf8 (g_get_home_dir ())); p += 1; } else @@ -124,18 +126,14 @@ gimp_config_path_expand_only (const gchar *path, { s = NULL; - if (!s && strcmp (token, "gimp_dir") == 0) + if (strcmp (token, "gimp_dir") == 0) s = gimp_directory (); - - if (!s && strcmp (token, "gimp_data_dir") == 0) + else if (strcmp (token, "gimp_data_dir") == 0) s = gimp_data_directory (); - - if (!s && - ((strcmp (token, "gimp_plug_in_dir")) == 0 || - (strcmp (token, "gimp_plugin_dir")) == 0)) + else if (strcmp (token, "gimp_plug_in_dir") == 0 || + strcmp (token, "gimp_plugin_dir") == 0) s = gimp_plug_in_directory (); - - if (!s && strcmp (token, "gimp_sysconf_dir") == 0) + else if (strcmp (token, "gimp_sysconf_dir") == 0) s = gimp_sysconf_directory (); if (!s) @@ -163,7 +161,7 @@ gimp_config_path_expand_only (const gchar *path, substs = g_renew (gchar *, substs, 2 * (n_substs + SUBSTS_ALLOC)); substs[2*n_substs] = token; - substs[2*n_substs + 1] = (gchar *) s; + substs[2*n_substs + 1] = file_utils_filename_to_utf8 (s); n_substs++; length += strlen (s); @@ -190,8 +188,8 @@ gimp_config_path_expand_only (const gchar *path, if (*p == '~') { *n = '\0'; - strcat (n, g_get_home_dir ()); - n += strlen (g_get_home_dir ()); + strcat (n, file_utils_filename_to_utf8 (g_get_home_dir ())); + n += strlen (file_utils_filename_to_utf8 (g_get_home_dir ())); p += 1; } else diff --git a/app/config/gimpconfig-utils.c b/app/config/gimpconfig-utils.c index 73abc0934b..04b81df787 100644 --- a/app/config/gimpconfig-utils.c +++ b/app/config/gimpconfig-utils.c @@ -470,7 +470,7 @@ gimp_config_file_copy (const gchar *source, { g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), _("Could not open '%s' for reading: %s"), - source, g_strerror (errno)); + file_utils_filename_to_utf8 (source), g_strerror (errno)); return FALSE; } @@ -479,7 +479,7 @@ gimp_config_file_copy (const gchar *source, { g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), _("Could not open '%s' for writing: %s"), - dest, g_strerror (errno)); + file_utils_filename_to_utf8 (dest), g_strerror (errno)); fclose (sfile); return FALSE; } @@ -490,7 +490,7 @@ gimp_config_file_copy (const gchar *source, { g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), _("Error while writing '%s': %s"), - dest, g_strerror (errno)); + file_utils_filename_to_utf8 (dest), g_strerror (errno)); fclose (sfile); fclose (dfile); return FALSE; @@ -501,7 +501,7 @@ gimp_config_file_copy (const gchar *source, { g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), _("Error while reading '%s': %s"), - source, g_strerror (errno)); + file_utils_filename_to_utf8 (source), g_strerror (errno)); fclose (sfile); fclose (dfile); return FALSE; @@ -513,7 +513,7 @@ gimp_config_file_copy (const gchar *source, { g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), _("Error while writing '%s': %s"), - dest, g_strerror (errno)); + file_utils_filename_to_utf8 (dest), g_strerror (errno)); return FALSE; } @@ -540,7 +540,7 @@ gimp_config_file_backup_on_error (const gchar *filename, g_message (_("There was an error parsing your '%s' file. " "Default values will be used. A backup of your " "configuration has been created at '%s'."), - name, backup); + name, file_utils_filename_to_utf8 (backup)); g_free (backup); diff --git a/app/config/gimprc.c b/app/config/gimprc.c index ce0e93cc9e..ea1d2e2ba8 100644 --- a/app/config/gimprc.c +++ b/app/config/gimprc.c @@ -37,6 +37,8 @@ #include "config-types.h" +#include "file/file-utils.h" + #include "gimpconfig.h" #include "gimpconfig-deserialize.h" #include "gimpconfig-error.h" @@ -338,7 +340,8 @@ gimp_rc_load (GimpRc *rc) g_return_if_fail (GIMP_IS_RC (rc)); if (rc->verbose) - g_print (_("Parsing '%s'\n"), rc->system_gimprc); + g_print (_("Parsing '%s'\n"), + file_utils_filename_to_utf8 (rc->system_gimprc)); if (! gimp_config_deserialize_file (GIMP_CONFIG (rc), rc->system_gimprc, NULL, &error)) @@ -350,7 +353,8 @@ gimp_rc_load (GimpRc *rc) } if (rc->verbose) - g_print (_("Parsing '%s'\n"), rc->user_gimprc); + g_print (_("Parsing '%s'\n"), + file_utils_filename_to_utf8 (rc->user_gimprc)); if (! gimp_config_deserialize_file (GIMP_CONFIG (rc), rc->user_gimprc, NULL, &error)) @@ -574,7 +578,8 @@ gimp_rc_save (GimpRc *rc) header = g_strconcat (top, rc->system_gimprc, bottom, NULL); if (rc->verbose) - g_print (_("Saving '%s'\n"), rc->user_gimprc); + g_print (_("Saving '%s'\n"), + file_utils_filename_to_utf8 (rc->user_gimprc)); if (! gimp_config_serialize_to_file (GIMP_CONFIG (rc), rc->user_gimprc, diff --git a/app/config/gimpscanner.c b/app/config/gimpscanner.c index 24322500b5..e145904c3e 100644 --- a/app/config/gimpscanner.c +++ b/app/config/gimpscanner.c @@ -41,6 +41,8 @@ #include "libgimpcolor/gimpcolor.h" #include "libgimpmath/gimpmath.h" +#include "file/file-utils.h" + #include "config-types.h" #include "gimpconfig-error.h" @@ -90,12 +92,15 @@ gimp_scanner_new_file (const gchar *filename, g_set_error (error, GIMP_CONFIG_ERROR, code, _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } - scanner = gimp_scanner_new (filename, fd, error); + /* gimp_scanner_new() takes a "name" for the scanner, not a filename. Thus + * do convert to UTF-8. + */ + scanner = gimp_scanner_new (file_utils_filename_to_utf8 (filename), fd, error); g_scanner_input_file (scanner, fd); diff --git a/app/core/gimpbrush-load.c b/app/core/gimpbrush-load.c index 421563cb31..8f98aad0e3 100644 --- a/app/core/gimpbrush-load.c +++ b/app/core/gimpbrush-load.c @@ -51,6 +51,8 @@ #include "config/gimpbaseconfig.h" +#include "file/file-utils.h" + #include "gimpbrush.h" #include "gimpbrush-header.h" #include "gimpbrushgenerated.h" @@ -412,7 +414,7 @@ gimp_brush_load (const gchar *filename, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } @@ -554,7 +556,8 @@ gimp_brush_load_brush (gint fd, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Could not read %d bytes from '%s': %s"), - (gint) sizeof (header), filename, g_strerror (errno)); + (gint) sizeof (header), + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } @@ -589,7 +592,7 @@ gimp_brush_load_brush (gint fd, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "Unknown depth %d."), - filename, header.bytes); + file_utils_filename_to_utf8 (filename), header.bytes); return NULL; } /* fallthrough */ @@ -602,7 +605,7 @@ gimp_brush_load_brush (gint fd, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "Unknown version %d."), - filename, header.version); + file_utils_filename_to_utf8 (filename), header.version); return NULL; } @@ -618,14 +621,14 @@ gimp_brush_load_brush (gint fd, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "File appears truncated."), - filename); + file_utils_filename_to_utf8 (filename)); g_free (name); return NULL; } utf8 = gimp_any_to_utf8 (name, -1, _("Invalid UTF-8 string in brush file '%s'."), - filename); + file_utils_filename_to_utf8 (filename)); g_free (name); name = utf8; } @@ -723,7 +726,7 @@ gimp_brush_load_brush (gint fd, _("Fatal parse error in brush file '%s': " "Unsupported brush depth %d\n" "GIMP brushes must be GRAY or RGBA."), - filename, header.bytes); + file_utils_filename_to_utf8 (filename), header.bytes); g_free (name); return NULL; } @@ -734,7 +737,7 @@ gimp_brush_load_brush (gint fd, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "File appears truncated."), - filename); + file_utils_filename_to_utf8 (filename)); g_free (name); return NULL; } diff --git a/app/core/gimpbrush.c b/app/core/gimpbrush.c index 421563cb31..8f98aad0e3 100644 --- a/app/core/gimpbrush.c +++ b/app/core/gimpbrush.c @@ -51,6 +51,8 @@ #include "config/gimpbaseconfig.h" +#include "file/file-utils.h" + #include "gimpbrush.h" #include "gimpbrush-header.h" #include "gimpbrushgenerated.h" @@ -412,7 +414,7 @@ gimp_brush_load (const gchar *filename, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } @@ -554,7 +556,8 @@ gimp_brush_load_brush (gint fd, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Could not read %d bytes from '%s': %s"), - (gint) sizeof (header), filename, g_strerror (errno)); + (gint) sizeof (header), + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } @@ -589,7 +592,7 @@ gimp_brush_load_brush (gint fd, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "Unknown depth %d."), - filename, header.bytes); + file_utils_filename_to_utf8 (filename), header.bytes); return NULL; } /* fallthrough */ @@ -602,7 +605,7 @@ gimp_brush_load_brush (gint fd, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "Unknown version %d."), - filename, header.version); + file_utils_filename_to_utf8 (filename), header.version); return NULL; } @@ -618,14 +621,14 @@ gimp_brush_load_brush (gint fd, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "File appears truncated."), - filename); + file_utils_filename_to_utf8 (filename)); g_free (name); return NULL; } utf8 = gimp_any_to_utf8 (name, -1, _("Invalid UTF-8 string in brush file '%s'."), - filename); + file_utils_filename_to_utf8 (filename)); g_free (name); name = utf8; } @@ -723,7 +726,7 @@ gimp_brush_load_brush (gint fd, _("Fatal parse error in brush file '%s': " "Unsupported brush depth %d\n" "GIMP brushes must be GRAY or RGBA."), - filename, header.bytes); + file_utils_filename_to_utf8 (filename), header.bytes); g_free (name); return NULL; } @@ -734,7 +737,7 @@ gimp_brush_load_brush (gint fd, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "File appears truncated."), - filename); + file_utils_filename_to_utf8 (filename)); g_free (name); return NULL; } diff --git a/app/core/gimpbrushgenerated-load.c b/app/core/gimpbrushgenerated-load.c index a7bddef191..9309782a89 100644 --- a/app/core/gimpbrushgenerated-load.c +++ b/app/core/gimpbrushgenerated-load.c @@ -36,6 +36,8 @@ #include "base/temp-buf.h" +#include "file/file-utils.h" + #include "gimpbrushgenerated.h" #include "gimp-intl.h" @@ -127,7 +129,8 @@ gimp_brush_generated_save (GimpData *data, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for writing: %s"), - data->filename, g_strerror (errno)); + file_utils_filename_to_utf8 (data->filename), + g_strerror (errno)); return FALSE; } @@ -375,7 +378,7 @@ gimp_brush_generated_load (const gchar *filename, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } @@ -387,7 +390,7 @@ gimp_brush_generated_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "Not a GIMP brush file."), - filename); + file_utils_filename_to_utf8 (filename)); return NULL; } @@ -398,7 +401,7 @@ gimp_brush_generated_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "Unknown GIMP brush version."), - filename); + file_utils_filename_to_utf8 (filename)); return NULL; } diff --git a/app/core/gimpbrushgenerated-save.c b/app/core/gimpbrushgenerated-save.c index a7bddef191..9309782a89 100644 --- a/app/core/gimpbrushgenerated-save.c +++ b/app/core/gimpbrushgenerated-save.c @@ -36,6 +36,8 @@ #include "base/temp-buf.h" +#include "file/file-utils.h" + #include "gimpbrushgenerated.h" #include "gimp-intl.h" @@ -127,7 +129,8 @@ gimp_brush_generated_save (GimpData *data, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for writing: %s"), - data->filename, g_strerror (errno)); + file_utils_filename_to_utf8 (data->filename), + g_strerror (errno)); return FALSE; } @@ -375,7 +378,7 @@ gimp_brush_generated_load (const gchar *filename, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } @@ -387,7 +390,7 @@ gimp_brush_generated_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "Not a GIMP brush file."), - filename); + file_utils_filename_to_utf8 (filename)); return NULL; } @@ -398,7 +401,7 @@ gimp_brush_generated_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "Unknown GIMP brush version."), - filename); + file_utils_filename_to_utf8 (filename)); return NULL; } diff --git a/app/core/gimpbrushgenerated.c b/app/core/gimpbrushgenerated.c index a7bddef191..9309782a89 100644 --- a/app/core/gimpbrushgenerated.c +++ b/app/core/gimpbrushgenerated.c @@ -36,6 +36,8 @@ #include "base/temp-buf.h" +#include "file/file-utils.h" + #include "gimpbrushgenerated.h" #include "gimp-intl.h" @@ -127,7 +129,8 @@ gimp_brush_generated_save (GimpData *data, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for writing: %s"), - data->filename, g_strerror (errno)); + file_utils_filename_to_utf8 (data->filename), + g_strerror (errno)); return FALSE; } @@ -375,7 +378,7 @@ gimp_brush_generated_load (const gchar *filename, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } @@ -387,7 +390,7 @@ gimp_brush_generated_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "Not a GIMP brush file."), - filename); + file_utils_filename_to_utf8 (filename)); return NULL; } @@ -398,7 +401,7 @@ gimp_brush_generated_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "Unknown GIMP brush version."), - filename); + file_utils_filename_to_utf8 (filename)); return NULL; } diff --git a/app/core/gimpbrushpipe-load.c b/app/core/gimpbrushpipe-load.c index ae6848e2be..636e5ccd8b 100644 --- a/app/core/gimpbrushpipe-load.c +++ b/app/core/gimpbrushpipe-load.c @@ -47,6 +47,8 @@ #include "base/temp-buf.h" +#include "file/file-utils.h" + #include "gimpbrush.h" #include "gimpbrush-header.h" #include "gimpbrushpipe.h" @@ -350,7 +352,7 @@ gimp_brush_pipe_load (const gchar *filename, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } @@ -372,7 +374,7 @@ gimp_brush_pipe_load (const gchar *filename, else { g_message (_("Invalid UTF-8 string in brush file '%s'."), - filename); + file_utils_filename_to_utf8 (filename)); gimp_object_set_name (GIMP_OBJECT (pipe), _("Unnamed")); } } @@ -383,7 +385,7 @@ gimp_brush_pipe_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "File is corrupt."), - filename); + file_utils_filename_to_utf8 (filename)); close (fd); return NULL; } @@ -403,7 +405,7 @@ gimp_brush_pipe_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "File is corrupt."), - filename); + file_utils_filename_to_utf8 (filename)); close (fd); g_object_unref (pipe); g_string_free (buffer, TRUE); @@ -493,7 +495,7 @@ gimp_brush_pipe_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "File is corrupt."), - filename); + file_utils_filename_to_utf8 (filename)); close (fd); g_object_unref (pipe); return NULL; diff --git a/app/core/gimpbrushpipe.c b/app/core/gimpbrushpipe.c index ae6848e2be..636e5ccd8b 100644 --- a/app/core/gimpbrushpipe.c +++ b/app/core/gimpbrushpipe.c @@ -47,6 +47,8 @@ #include "base/temp-buf.h" +#include "file/file-utils.h" + #include "gimpbrush.h" #include "gimpbrush-header.h" #include "gimpbrushpipe.h" @@ -350,7 +352,7 @@ gimp_brush_pipe_load (const gchar *filename, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } @@ -372,7 +374,7 @@ gimp_brush_pipe_load (const gchar *filename, else { g_message (_("Invalid UTF-8 string in brush file '%s'."), - filename); + file_utils_filename_to_utf8 (filename)); gimp_object_set_name (GIMP_OBJECT (pipe), _("Unnamed")); } } @@ -383,7 +385,7 @@ gimp_brush_pipe_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "File is corrupt."), - filename); + file_utils_filename_to_utf8 (filename)); close (fd); return NULL; } @@ -403,7 +405,7 @@ gimp_brush_pipe_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "File is corrupt."), - filename); + file_utils_filename_to_utf8 (filename)); close (fd); g_object_unref (pipe); g_string_free (buffer, TRUE); @@ -493,7 +495,7 @@ gimp_brush_pipe_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in brush file '%s': " "File is corrupt."), - filename); + file_utils_filename_to_utf8 (filename)); close (fd); g_object_unref (pipe); return NULL; diff --git a/app/core/gimpenvirontable.c b/app/core/gimpenvirontable.c index 519c079f2e..7c61fecdc8 100644 --- a/app/core/gimpenvirontable.c +++ b/app/core/gimpenvirontable.c @@ -29,6 +29,8 @@ #include "libgimpbase/gimpbase.h" +#include "file/file-utils.h" + #include "core-types.h" #include "gimpenvirontable.h" @@ -283,7 +285,7 @@ gimp_environ_table_load_env_file (const GimpDatafileData *file_data, if (name[0] == '\0') { g_message (_("Empty variable name in environment file %s"), - file_data->filename); + file_utils_filename_to_utf8 (file_data->filename)); continue; } @@ -301,7 +303,7 @@ gimp_environ_table_load_env_file (const GimpDatafileData *file_data, if (! gimp_environ_table_legal_name (name)) { g_message (_("Illegal variable name in environment file %s: %s"), - file_data->filename, name); + file_utils_filename_to_utf8 (file_data->filename), name); continue; } diff --git a/app/core/gimpgradient.c b/app/core/gimpgradient.c index cf43963f1b..40138530a7 100644 --- a/app/core/gimpgradient.c +++ b/app/core/gimpgradient.c @@ -33,6 +33,8 @@ #include "base/temp-buf.h" +#include "file/file-utils.h" + #include "gimpimage.h" #include "gimpgradient.h" @@ -354,7 +356,7 @@ gimp_gradient_load (const gchar *filename, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } @@ -364,7 +366,7 @@ gimp_gradient_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in gradient file '%s': " "Not a GIMP gradient file."), - filename); + file_utils_filename_to_utf8 (filename)); fclose (file); return NULL; } @@ -380,7 +382,7 @@ gimp_gradient_load (const gchar *filename, utf8 = gimp_any_to_utf8 (&line[strlen ("Name: ")], -1, _("Invalid UTF-8 string in gradient file '%s'."), - filename); + file_utils_filename_to_utf8 (filename)); g_strstrip (utf8); gimp_object_set_name (GIMP_OBJECT (gradient), utf8); @@ -409,7 +411,7 @@ gimp_gradient_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in gradient file '%s': " "File is corrupt."), - filename); + file_utils_filename_to_utf8 (filename)); g_object_unref (gradient); fclose (file); return NULL; @@ -465,7 +467,7 @@ gimp_gradient_load (const gchar *filename, else { g_message (_("Corrupt segment %d in gradient file '%s'."), - i, filename); + i, file_utils_filename_to_utf8 (filename)); } prev = seg; @@ -507,7 +509,8 @@ gimp_gradient_save (GimpData *data, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for writing: %s"), - data->filename, g_strerror (errno)); + file_utils_filename_to_utf8 (data->filename), + g_strerror (errno)); return FALSE; } @@ -592,7 +595,7 @@ gimp_gradient_save_as_pov (GimpGradient *gradient, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for writing: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return FALSE; } else diff --git a/app/core/gimppalette-load.c b/app/core/gimppalette-load.c index ebef442de0..a65ce80c43 100644 --- a/app/core/gimppalette-load.c +++ b/app/core/gimppalette-load.c @@ -35,6 +35,8 @@ #include "base/temp-buf.h" +#include "file/file-utils.h" + #include "gimppalette.h" #include "gimp-intl.h" @@ -377,7 +379,7 @@ gimp_palette_load (const gchar *filename, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } @@ -394,12 +396,12 @@ gimp_palette_load (const gchar *filename, _("Fatal parse error in palette file '%s': " "Missing magic header.\n" "Does this file need converting from DOS?"), - filename); + file_utils_filename_to_utf8 (filename)); else g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in palette file '%s': " "Missing magic header."), - filename); + file_utils_filename_to_utf8 (filename)); fclose (fp); @@ -415,7 +417,7 @@ gimp_palette_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in palette file '%s': " "Read error in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); fclose (fp); g_object_unref (palette); return NULL; @@ -429,7 +431,7 @@ gimp_palette_load (const gchar *filename, utf8 = gimp_any_to_utf8 (&str[strlen ("Name: ")], -1, _("Invalid UTF-8 string in palette file '%s'"), - filename); + file_utils_filename_to_utf8 (filename)); g_strstrip (utf8); gimp_object_set_name (GIMP_OBJECT (palette), utf8); @@ -440,7 +442,7 @@ gimp_palette_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in palette file '%s': " "Read error in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); fclose (fp); g_object_unref (palette); return NULL; @@ -459,7 +461,7 @@ gimp_palette_load (const gchar *filename, g_message (_("Reading palette file '%s': " "Invalid number of columns in line %d. " "Using default value."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); columns = 0; } @@ -470,7 +472,7 @@ gimp_palette_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in palette file '%s': " "Read error in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); fclose (fp); g_object_unref (palette); return NULL; @@ -504,7 +506,7 @@ gimp_palette_load (const gchar *filename, /* maybe we should just abort? */ g_message (_("Reading palette file '%s': " "Missing RED component in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); tok = strtok (NULL, " \t"); if (tok) @@ -512,7 +514,7 @@ gimp_palette_load (const gchar *filename, else g_message (_("Reading palette '%s': " "Missing GREEN component in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); tok = strtok (NULL, " \t"); if (tok) @@ -520,7 +522,7 @@ gimp_palette_load (const gchar *filename, else g_message (_("Reading palette file '%s': " "Missing BLUE component in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); /* optional name */ tok = strtok (NULL, "\n"); @@ -530,7 +532,7 @@ gimp_palette_load (const gchar *filename, b < 0 || b > 255) g_message (_("Reading palette file '%s': " "RGB value out of range in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); gimp_rgba_set_uchar (&color, (guchar) r, @@ -549,7 +551,7 @@ gimp_palette_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in palette file '%s': " "Read error in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); fclose (fp); g_object_unref (palette); return NULL; @@ -588,7 +590,8 @@ gimp_palette_save (GimpData *data, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for writing: %s"), - data->filename, g_strerror (errno)); + file_utils_filename_to_utf8 (data->filename), + g_strerror (errno)); return FALSE; } diff --git a/app/core/gimppalette-save.c b/app/core/gimppalette-save.c index ebef442de0..a65ce80c43 100644 --- a/app/core/gimppalette-save.c +++ b/app/core/gimppalette-save.c @@ -35,6 +35,8 @@ #include "base/temp-buf.h" +#include "file/file-utils.h" + #include "gimppalette.h" #include "gimp-intl.h" @@ -377,7 +379,7 @@ gimp_palette_load (const gchar *filename, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } @@ -394,12 +396,12 @@ gimp_palette_load (const gchar *filename, _("Fatal parse error in palette file '%s': " "Missing magic header.\n" "Does this file need converting from DOS?"), - filename); + file_utils_filename_to_utf8 (filename)); else g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in palette file '%s': " "Missing magic header."), - filename); + file_utils_filename_to_utf8 (filename)); fclose (fp); @@ -415,7 +417,7 @@ gimp_palette_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in palette file '%s': " "Read error in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); fclose (fp); g_object_unref (palette); return NULL; @@ -429,7 +431,7 @@ gimp_palette_load (const gchar *filename, utf8 = gimp_any_to_utf8 (&str[strlen ("Name: ")], -1, _("Invalid UTF-8 string in palette file '%s'"), - filename); + file_utils_filename_to_utf8 (filename)); g_strstrip (utf8); gimp_object_set_name (GIMP_OBJECT (palette), utf8); @@ -440,7 +442,7 @@ gimp_palette_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in palette file '%s': " "Read error in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); fclose (fp); g_object_unref (palette); return NULL; @@ -459,7 +461,7 @@ gimp_palette_load (const gchar *filename, g_message (_("Reading palette file '%s': " "Invalid number of columns in line %d. " "Using default value."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); columns = 0; } @@ -470,7 +472,7 @@ gimp_palette_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in palette file '%s': " "Read error in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); fclose (fp); g_object_unref (palette); return NULL; @@ -504,7 +506,7 @@ gimp_palette_load (const gchar *filename, /* maybe we should just abort? */ g_message (_("Reading palette file '%s': " "Missing RED component in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); tok = strtok (NULL, " \t"); if (tok) @@ -512,7 +514,7 @@ gimp_palette_load (const gchar *filename, else g_message (_("Reading palette '%s': " "Missing GREEN component in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); tok = strtok (NULL, " \t"); if (tok) @@ -520,7 +522,7 @@ gimp_palette_load (const gchar *filename, else g_message (_("Reading palette file '%s': " "Missing BLUE component in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); /* optional name */ tok = strtok (NULL, "\n"); @@ -530,7 +532,7 @@ gimp_palette_load (const gchar *filename, b < 0 || b > 255) g_message (_("Reading palette file '%s': " "RGB value out of range in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); gimp_rgba_set_uchar (&color, (guchar) r, @@ -549,7 +551,7 @@ gimp_palette_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in palette file '%s': " "Read error in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); fclose (fp); g_object_unref (palette); return NULL; @@ -588,7 +590,8 @@ gimp_palette_save (GimpData *data, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for writing: %s"), - data->filename, g_strerror (errno)); + file_utils_filename_to_utf8 (data->filename), + g_strerror (errno)); return FALSE; } diff --git a/app/core/gimppalette.c b/app/core/gimppalette.c index ebef442de0..a65ce80c43 100644 --- a/app/core/gimppalette.c +++ b/app/core/gimppalette.c @@ -35,6 +35,8 @@ #include "base/temp-buf.h" +#include "file/file-utils.h" + #include "gimppalette.h" #include "gimp-intl.h" @@ -377,7 +379,7 @@ gimp_palette_load (const gchar *filename, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } @@ -394,12 +396,12 @@ gimp_palette_load (const gchar *filename, _("Fatal parse error in palette file '%s': " "Missing magic header.\n" "Does this file need converting from DOS?"), - filename); + file_utils_filename_to_utf8 (filename)); else g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in palette file '%s': " "Missing magic header."), - filename); + file_utils_filename_to_utf8 (filename)); fclose (fp); @@ -415,7 +417,7 @@ gimp_palette_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in palette file '%s': " "Read error in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); fclose (fp); g_object_unref (palette); return NULL; @@ -429,7 +431,7 @@ gimp_palette_load (const gchar *filename, utf8 = gimp_any_to_utf8 (&str[strlen ("Name: ")], -1, _("Invalid UTF-8 string in palette file '%s'"), - filename); + file_utils_filename_to_utf8 (filename)); g_strstrip (utf8); gimp_object_set_name (GIMP_OBJECT (palette), utf8); @@ -440,7 +442,7 @@ gimp_palette_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in palette file '%s': " "Read error in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); fclose (fp); g_object_unref (palette); return NULL; @@ -459,7 +461,7 @@ gimp_palette_load (const gchar *filename, g_message (_("Reading palette file '%s': " "Invalid number of columns in line %d. " "Using default value."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); columns = 0; } @@ -470,7 +472,7 @@ gimp_palette_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in palette file '%s': " "Read error in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); fclose (fp); g_object_unref (palette); return NULL; @@ -504,7 +506,7 @@ gimp_palette_load (const gchar *filename, /* maybe we should just abort? */ g_message (_("Reading palette file '%s': " "Missing RED component in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); tok = strtok (NULL, " \t"); if (tok) @@ -512,7 +514,7 @@ gimp_palette_load (const gchar *filename, else g_message (_("Reading palette '%s': " "Missing GREEN component in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); tok = strtok (NULL, " \t"); if (tok) @@ -520,7 +522,7 @@ gimp_palette_load (const gchar *filename, else g_message (_("Reading palette file '%s': " "Missing BLUE component in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); /* optional name */ tok = strtok (NULL, "\n"); @@ -530,7 +532,7 @@ gimp_palette_load (const gchar *filename, b < 0 || b > 255) g_message (_("Reading palette file '%s': " "RGB value out of range in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); gimp_rgba_set_uchar (&color, (guchar) r, @@ -549,7 +551,7 @@ gimp_palette_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in palette file '%s': " "Read error in line %d."), - filename, linenum); + file_utils_filename_to_utf8 (filename), linenum); fclose (fp); g_object_unref (palette); return NULL; @@ -588,7 +590,8 @@ gimp_palette_save (GimpData *data, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for writing: %s"), - data->filename, g_strerror (errno)); + file_utils_filename_to_utf8 (data->filename), + g_strerror (errno)); return FALSE; } diff --git a/app/core/gimppattern-load.c b/app/core/gimppattern-load.c index 56e4b04455..788feefb92 100644 --- a/app/core/gimppattern-load.c +++ b/app/core/gimppattern-load.c @@ -49,6 +49,8 @@ #include "base/temp-buf.h" +#include "file/file-utils.h" + #include "gimpimage.h" #include "gimppattern.h" #include "gimppattern-header.h" @@ -342,7 +344,7 @@ gimp_pattern_load (const gchar *filename, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } @@ -352,7 +354,8 @@ gimp_pattern_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in pattern file '%s': " "Could not read %d bytes: %s"), - filename, (gint) sizeof (header), g_strerror (errno)); + file_utils_filename_to_utf8 (filename), + (gint) sizeof (header), g_strerror (errno)); goto error; } @@ -371,7 +374,7 @@ gimp_pattern_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in pattern file '%s': " "Unknown pattern format version %d."), - filename, header.version); + file_utils_filename_to_utf8 (filename), header.version); goto error; } @@ -382,7 +385,7 @@ gimp_pattern_load (const gchar *filename, _("Fatal parse error in pattern file '%s: " "Unsupported pattern depth %d.\n" "GIMP Patterns must be GRAY or RGB."), - filename, header.bytes); + file_utils_filename_to_utf8 (filename), header.bytes); goto error; } @@ -398,13 +401,14 @@ gimp_pattern_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in pattern file '%s': " "Could not read %d bytes: %s"), - filename, bn_size, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), bn_size, + g_strerror (errno)); goto error; } utf8 = gimp_any_to_utf8 (name, -1, _("Invalid UTF-8 string in pattern file '%s'."), - filename); + file_utils_filename_to_utf8 (filename)); g_free (name); name = utf8; } @@ -423,7 +427,8 @@ gimp_pattern_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in pattern file '%s': " "Could not read %d bytes: %s"), - filename, header.width * header.height * header.bytes, + file_utils_filename_to_utf8 (filename), + header.width * header.height * header.bytes, g_strerror (errno)); goto error; } diff --git a/app/core/gimppattern.c b/app/core/gimppattern.c index 56e4b04455..788feefb92 100644 --- a/app/core/gimppattern.c +++ b/app/core/gimppattern.c @@ -49,6 +49,8 @@ #include "base/temp-buf.h" +#include "file/file-utils.h" + #include "gimpimage.h" #include "gimppattern.h" #include "gimppattern-header.h" @@ -342,7 +344,7 @@ gimp_pattern_load (const gchar *filename, { g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN, _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } @@ -352,7 +354,8 @@ gimp_pattern_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in pattern file '%s': " "Could not read %d bytes: %s"), - filename, (gint) sizeof (header), g_strerror (errno)); + file_utils_filename_to_utf8 (filename), + (gint) sizeof (header), g_strerror (errno)); goto error; } @@ -371,7 +374,7 @@ gimp_pattern_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in pattern file '%s': " "Unknown pattern format version %d."), - filename, header.version); + file_utils_filename_to_utf8 (filename), header.version); goto error; } @@ -382,7 +385,7 @@ gimp_pattern_load (const gchar *filename, _("Fatal parse error in pattern file '%s: " "Unsupported pattern depth %d.\n" "GIMP Patterns must be GRAY or RGB."), - filename, header.bytes); + file_utils_filename_to_utf8 (filename), header.bytes); goto error; } @@ -398,13 +401,14 @@ gimp_pattern_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in pattern file '%s': " "Could not read %d bytes: %s"), - filename, bn_size, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), bn_size, + g_strerror (errno)); goto error; } utf8 = gimp_any_to_utf8 (name, -1, _("Invalid UTF-8 string in pattern file '%s'."), - filename); + file_utils_filename_to_utf8 (filename)); g_free (name); name = utf8; } @@ -423,7 +427,8 @@ gimp_pattern_load (const gchar *filename, g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_READ, _("Fatal parse error in pattern file '%s': " "Could not read %d bytes: %s"), - filename, header.width * header.height * header.bytes, + file_utils_filename_to_utf8 (filename), + header.width * header.height * header.bytes, g_strerror (errno)); goto error; } diff --git a/app/dialogs/user-install-dialog.c b/app/dialogs/user-install-dialog.c index 1d3b94c69a..19c4fc3f65 100644 --- a/app/dialogs/user-install-dialog.c +++ b/app/dialogs/user-install-dialog.c @@ -43,6 +43,8 @@ #include "config/gimpconfig-utils.h" #include "config/gimprc.h" +#include "file/file-utils.h" + #include "widgets/gimppropwidgets.h" #include "widgets/gimpwidgets-utils.h" @@ -846,7 +848,7 @@ user_install_dialog_run (const gchar *alternate_system_gimprc, str = g_strdup_printf (_("For a proper GIMP installation, a folder named " "'%s' needs to be created."), - gimp_directory ()); + file_utils_filename_to_utf8 (gimp_directory ())); add_label (GTK_BOX (vbox), str); g_free (str); @@ -880,7 +882,7 @@ user_install_dialog_run (const gchar *alternate_system_gimprc, gtk_tree_store_append (tree, &iter, NULL); gtk_tree_store_set (tree, &iter, - DIRENT_COLUMN, gimp_directory (), + DIRENT_COLUMN, file_utils_filename_to_utf8 (gimp_directory ()), PIXBUF_COLUMN, folder_pixbuf, DESC_COLUMN, 0, -1); @@ -1054,7 +1056,7 @@ user_install_run (void) gtk_widget_show (log_view); g_snprintf (log_line, sizeof (log_line), _("Creating folder '%s'..."), - gimp_directory ()); + file_utils_filename_to_utf8 (gimp_directory ())); gtk_text_buffer_insert_at_cursor (log_buffer, log_line, -1); while (gtk_events_pending ()) @@ -1068,7 +1070,7 @@ user_install_run (void) g_set_error (&error, G_FILE_ERROR, g_file_error_from_errno (errno), _("Cannot create folder '%s': %s"), - gimp_directory (), g_strerror (errno)); + file_utils_filename_to_utf8 (gimp_directory ()), g_strerror (errno)); goto break_out_of_loop; } @@ -1086,7 +1088,8 @@ user_install_run (void) case TREE_ITEM_MKDIR: g_snprintf (log_line, sizeof (log_line), - _("Creating folder '%s'..."), dest); + _("Creating folder '%s'..."), + file_utils_filename_to_utf8 (dest)); gtk_text_buffer_insert_at_cursor (log_buffer, log_line, -1); while (gtk_events_pending ()) @@ -1111,7 +1114,9 @@ user_install_run (void) g_assert (! tree_items[i].directory); g_snprintf (log_line, sizeof (log_line), - _("Copying file '%s' from '%s'..."), dest, source); + _("Copying file '%s' from '%s'..."), + file_utils_filename_to_utf8 (dest), + file_utils_filename_to_utf8 (source)); gtk_text_buffer_insert_at_cursor (log_buffer, log_line, -1); while (gtk_events_pending ()) diff --git a/app/file/file-utils.c b/app/file/file-utils.c index d3c9b2acd5..538c9ffa36 100644 --- a/app/file/file-utils.c +++ b/app/file/file-utils.c @@ -591,3 +591,30 @@ file_check_magic_list (GSList *magics_list, return 0; } + +gchar * +file_utils_filename_to_utf8 (const gchar *filename) +{ + /* Simpleminded implementation, but at least allocates just one copy + * of each translation. Could check if already UTF-8, and if so + * return filename as is. Could perhaps (re)use a suitably large + * cyclic buffer, but then would have to verify that all calls + * really need the return value just for a "short" time. + */ + + static GHashTable *ht = NULL; + gchar *filename_utf8; + + if (ht == NULL) + ht = g_hash_table_new (g_str_hash, g_str_equal); + + filename_utf8 = g_hash_table_lookup (ht, filename); + + if (filename_utf8 == NULL) + { + filename_utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL); + g_hash_table_insert (ht, g_strdup (filename), filename_utf8); + } + + return filename_utf8; +} diff --git a/app/file/file-utils.h b/app/file/file-utils.h index 4a5937535c..1368d6f5fc 100644 --- a/app/file/file-utils.h +++ b/app/file/file-utils.h @@ -23,6 +23,8 @@ #include +#include "plug-in/plug-in-types.h" + gchar * file_utils_filename_to_uri (GSList *procs, const gchar *filename, GError **error); @@ -31,5 +33,6 @@ PlugInProcDef * file_utils_find_proc (GSList *procs, gchar * file_utils_uri_to_utf8_basename (const gchar *uri); gchar * file_utils_uri_to_utf8_filename (const gchar *uri); +gchar * file_utils_filename_to_utf8 (const gchar *filename); #endif /* __FILE_UTILS_H__ */ diff --git a/app/gui/themes.c b/app/gui/themes.c index 557eef0e03..532a2f3797 100644 --- a/app/gui/themes.c +++ b/app/gui/themes.c @@ -33,6 +33,8 @@ #include "core/gimp.h" +#include "file/file-utils.h" + #include "themes.h" #include "gimp-intl.h" @@ -228,14 +230,15 @@ themes_apply_theme (Gimp *gimp, themerc = gimp_personal_rc_file ("themerc"); if (gimp->be_verbose) - g_print (_("Writing '%s'\n"), themerc); + g_print (_("Writing '%s'\n"), + file_utils_filename_to_utf8 (themerc)); file = fopen (themerc, "w"); if (! file) { g_message (_("Could not open '%s' for writing: %s"), - themerc, g_strerror (errno)); + file_utils_filename_to_utf8 (themerc), g_strerror (errno)); goto cleanup; } @@ -281,7 +284,8 @@ themes_directories_foreach (const GimpDatafileData *file_data, if (gimp->be_verbose) g_print (_("Adding theme '%s' (%s)\n"), - file_data->basename, file_data->filename); + file_utils_filename_to_utf8 (file_data->basename), + file_utils_filename_to_utf8 (file_data->filename)); g_hash_table_insert (themes_hash, g_strdup (file_data->basename), diff --git a/app/gui/user-install-dialog.c b/app/gui/user-install-dialog.c index 1d3b94c69a..19c4fc3f65 100644 --- a/app/gui/user-install-dialog.c +++ b/app/gui/user-install-dialog.c @@ -43,6 +43,8 @@ #include "config/gimpconfig-utils.h" #include "config/gimprc.h" +#include "file/file-utils.h" + #include "widgets/gimppropwidgets.h" #include "widgets/gimpwidgets-utils.h" @@ -846,7 +848,7 @@ user_install_dialog_run (const gchar *alternate_system_gimprc, str = g_strdup_printf (_("For a proper GIMP installation, a folder named " "'%s' needs to be created."), - gimp_directory ()); + file_utils_filename_to_utf8 (gimp_directory ())); add_label (GTK_BOX (vbox), str); g_free (str); @@ -880,7 +882,7 @@ user_install_dialog_run (const gchar *alternate_system_gimprc, gtk_tree_store_append (tree, &iter, NULL); gtk_tree_store_set (tree, &iter, - DIRENT_COLUMN, gimp_directory (), + DIRENT_COLUMN, file_utils_filename_to_utf8 (gimp_directory ()), PIXBUF_COLUMN, folder_pixbuf, DESC_COLUMN, 0, -1); @@ -1054,7 +1056,7 @@ user_install_run (void) gtk_widget_show (log_view); g_snprintf (log_line, sizeof (log_line), _("Creating folder '%s'..."), - gimp_directory ()); + file_utils_filename_to_utf8 (gimp_directory ())); gtk_text_buffer_insert_at_cursor (log_buffer, log_line, -1); while (gtk_events_pending ()) @@ -1068,7 +1070,7 @@ user_install_run (void) g_set_error (&error, G_FILE_ERROR, g_file_error_from_errno (errno), _("Cannot create folder '%s': %s"), - gimp_directory (), g_strerror (errno)); + file_utils_filename_to_utf8 (gimp_directory ()), g_strerror (errno)); goto break_out_of_loop; } @@ -1086,7 +1088,8 @@ user_install_run (void) case TREE_ITEM_MKDIR: g_snprintf (log_line, sizeof (log_line), - _("Creating folder '%s'..."), dest); + _("Creating folder '%s'..."), + file_utils_filename_to_utf8 (dest)); gtk_text_buffer_insert_at_cursor (log_buffer, log_line, -1); while (gtk_events_pending ()) @@ -1111,7 +1114,9 @@ user_install_run (void) g_assert (! tree_items[i].directory); g_snprintf (log_line, sizeof (log_line), - _("Copying file '%s' from '%s'..."), dest, source); + _("Copying file '%s' from '%s'..."), + file_utils_filename_to_utf8 (dest), + file_utils_filename_to_utf8 (source)); gtk_text_buffer_insert_at_cursor (log_buffer, log_line, -1); while (gtk_events_pending ()) diff --git a/app/plug-in/gimpenvirontable.c b/app/plug-in/gimpenvirontable.c index 519c079f2e..7c61fecdc8 100644 --- a/app/plug-in/gimpenvirontable.c +++ b/app/plug-in/gimpenvirontable.c @@ -29,6 +29,8 @@ #include "libgimpbase/gimpbase.h" +#include "file/file-utils.h" + #include "core-types.h" #include "gimpenvirontable.h" @@ -283,7 +285,7 @@ gimp_environ_table_load_env_file (const GimpDatafileData *file_data, if (name[0] == '\0') { g_message (_("Empty variable name in environment file %s"), - file_data->filename); + file_utils_filename_to_utf8 (file_data->filename)); continue; } @@ -301,7 +303,7 @@ gimp_environ_table_load_env_file (const GimpDatafileData *file_data, if (! gimp_environ_table_legal_name (name)) { g_message (_("Illegal variable name in environment file %s: %s"), - file_data->filename, name); + file_utils_filename_to_utf8 (file_data->filename), name); continue; } diff --git a/app/plug-in/gimpplugin-message.c b/app/plug-in/gimpplugin-message.c index 4dbd15c3db..22f13564b9 100644 --- a/app/plug-in/gimpplugin-message.c +++ b/app/plug-in/gimpplugin-message.c @@ -34,6 +34,8 @@ #include "core/gimp.h" #include "core/gimpdrawable.h" +#include "file/file-utils.h" + #include "plug-in.h" #include "plug-ins.h" #include "plug-in-def.h" @@ -94,7 +96,8 @@ plug_in_handle_message (PlugIn *plug_in, case GP_CONFIG: g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent a CONFIG message (should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); break; @@ -105,14 +108,16 @@ plug_in_handle_message (PlugIn *plug_in, case GP_TILE_ACK: g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent a TILE_ACK message (should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); break; case GP_TILE_DATA: g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent a TILE_DATA message (should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); break; @@ -127,7 +132,8 @@ plug_in_handle_message (PlugIn *plug_in, case GP_TEMP_PROC_RUN: g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent a TEMP_PROC_RUN message (should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); break; @@ -137,7 +143,8 @@ plug_in_handle_message (PlugIn *plug_in, #else g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent a TEMP_PROC_RETURN message (should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); #endif break; @@ -226,7 +233,8 @@ plug_in_handle_tile_req (PlugIn *plug_in, { g_message ("Plug-In \"%s\"\n(%s)\n\n" "requested invalid drawable (killing)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); return; } @@ -242,7 +250,8 @@ plug_in_handle_tile_req (PlugIn *plug_in, { g_message ("Plug-In \"%s\"\n(%s)\n\n" "requested invalid tile (killing)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); return; } @@ -277,7 +286,8 @@ plug_in_handle_tile_req (PlugIn *plug_in, { g_message ("Plug-In \"%s\"\n(%s)\n\n" "requested invalid drawable (killing)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); return; } @@ -293,7 +303,8 @@ plug_in_handle_tile_req (PlugIn *plug_in, { g_message ("Plug-In \"%s\"\n(%s)\n\n" "requested invalid tile (killing)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); return; } @@ -365,7 +376,8 @@ plug_in_handle_proc_run (PlugIn *plug_in, g_message ("WARNING: Plug-In \"%s\"\n(%s)\n\n" "called deprecated procedure '%s'.\n" "It should call '%s' instead!", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), proc_run->name, proc_name); } } @@ -506,7 +518,8 @@ plug_in_handle_temp_proc_return (PlugIn *plug_in, g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent a TEMP_PROC_RETURN message while not running " "a temp proc (should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); } } @@ -540,7 +553,8 @@ plug_in_handle_proc_install (PlugIn *plug_in, "which does not take the standard Plug-In " "args.\n" "(INT32)", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), proc_install->name); return; } @@ -557,7 +571,8 @@ plug_in_handle_proc_install (PlugIn *plug_in, "which does not take the standard Plug-In " "args.\n" "(INT32, IMAGE, DRAWABLE)", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), proc_install->name); return; } @@ -574,7 +589,8 @@ plug_in_handle_proc_install (PlugIn *plug_in, "which does not take the standard Plug-In " "args.\n" "(INT32, STRING, STRING)", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), proc_install->name); return; } @@ -593,7 +609,8 @@ plug_in_handle_proc_install (PlugIn *plug_in, "which does not take the standard Plug-In " "args.\n" "(INT32, IMAGE, DRAWABLE, STRING, STRING)", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), proc_install->name); return; } @@ -605,7 +622,8 @@ plug_in_handle_proc_install (PlugIn *plug_in, "in an invalid menu location.\n" "Use either \"\", \"\", " "\"\", or \"\".", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), proc_install->name); return; } @@ -626,7 +644,8 @@ plug_in_handle_proc_install (PlugIn *plug_in, "attempted to install procedure \"%s\" " "which fails to comply with the array parameter " "passing standard. Argument %d is noncompliant.", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), proc_install->name, i); return; } @@ -671,7 +690,8 @@ plug_in_handle_proc_install (PlugIn *plug_in, { g_message ("Plug-In \"%s\"\n(%s)\n\n" "attempted to install a procedure with invalid UTF-8 strings.", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); return; } @@ -820,7 +840,8 @@ plug_in_handle_extension_ack (PlugIn *plug_in) g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent an EXTENSION_ACK message while not being started " "as extension (should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); } } @@ -837,7 +858,8 @@ plug_in_handle_has_init (PlugIn *plug_in) g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent an HAS_INIT message while not in query() " "(should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); } } diff --git a/app/plug-in/gimpplugin.c b/app/plug-in/gimpplugin.c index 5a65df86a1..4ce69b0ea1 100644 --- a/app/plug-in/gimpplugin.c +++ b/app/plug-in/gimpplugin.c @@ -74,6 +74,8 @@ #include "core/gimp.h" #include "core/gimpenvirontable.h" +#include "file/file-utils.h" + #include "plug-in.h" #include "plug-ins.h" #include "plug-in-debug.h" @@ -351,7 +353,8 @@ plug_in_open (PlugIn *plug_in) if ((pipe (my_read) == -1) || (pipe (my_write) == -1)) { g_message ("Unable to run Plug-In \"%s\"\n(%s)\n\npipe() failed: %s", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), g_strerror (errno)); return FALSE; } @@ -449,7 +452,8 @@ plug_in_open (PlugIn *plug_in) &error)) { g_message ("Unable to run Plug-In \"%s\"\n(%s)\n\n%s", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), error->message); g_error_free (error); goto cleanup; @@ -549,7 +553,8 @@ plug_in_close (PlugIn *plug_in, } if (STILL_ACTIVE == dwExitCode) { - g_warning ("Terminating %s ...", plug_in->prog); + g_warning ("Terminating %s ...", + file_utils_filename_to_utf8 (plug_in->prog)); TerminateProcess ((HANDLE) plug_in->pid, 0); } } @@ -685,7 +690,8 @@ plug_in_recv_message (GIOChannel *channel, "The dying Plug-In may have messed up GIMP's internal state. " "You may want to save your images and restart GIMP " "to be on the safe side."), - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); if (! plug_in->open) plug_in_unref (plug_in); @@ -764,13 +770,14 @@ plug_in_flush (GIOChannel *channel, if (error) { g_warning ("%s: plug_in_flush(): error: %s", - g_get_prgname (), error->message); + file_utils_filename_to_utf8 (g_get_prgname ()), + error->message); g_error_free (error); } else { g_warning ("%s: plug_in_flush(): error", - g_get_prgname ()); + file_utils_filename_to_utf8 (g_get_prgname ())); } return FALSE; diff --git a/app/plug-in/gimppluginmanager.c b/app/plug-in/gimppluginmanager.c index 372bbf7337..823c939bed 100644 --- a/app/plug-in/gimppluginmanager.c +++ b/app/plug-in/gimppluginmanager.c @@ -36,6 +36,8 @@ #include "core/gimpdrawable.h" #include "core/gimpimage.h" +#include "file/file-utils.h" + #include "plug-in.h" #include "plug-ins.h" #include "plug-in-def.h" @@ -131,7 +133,8 @@ plug_ins_init (Gimp *gimp, filename = gimp_personal_rc_file ("pluginrc"); } - (* status_callback) (_("Resource configuration"), filename, -1); + (* status_callback) (_("Resource configuration"), + file_utils_filename_to_utf8 (filename), -1); if (! plug_in_rc_parse (gimp, filename, &error)) { @@ -152,7 +155,8 @@ plug_ins_init (Gimp *gimp, plug_in_def = tmp->data; basename = g_path_get_basename (plug_in_def->prog); - (* status_callback) (NULL, basename, nth / n_plugins); + (* status_callback) (NULL, file_utils_filename_to_utf8 (basename), + nth / n_plugins); g_free (basename); if (plug_in_def->needs_query) @@ -160,7 +164,8 @@ plug_ins_init (Gimp *gimp, gimp->write_pluginrc = TRUE; if (gimp->be_verbose) - g_print (_("Querying plug-in: '%s'\n"), plug_in_def->prog); + g_print (_("Querying plug-in: '%s'\n"), + file_utils_filename_to_utf8 (plug_in_def->prog)); plug_in_call_query (gimp, plug_in_def); } @@ -215,7 +220,8 @@ plug_ins_init (Gimp *gimp, GError *error = NULL; if (gimp->be_verbose) - g_print (_("Writing '%s'\n"), filename); + g_print (_("Writing '%s'\n"), + file_utils_filename_to_utf8 (filename)); if (! plug_in_rc_write (gimp->plug_in_defs, filename, &error)) { @@ -294,7 +300,8 @@ plug_ins_init (Gimp *gimp, plug_in_def = tmp->data; basename = g_path_get_basename (plug_in_def->prog); - (* status_callback) (NULL, basename, nth / n_plugins); + (* status_callback) (NULL, file_utils_filename_to_utf8 (basename), + nth / n_plugins); g_free (basename); if (plug_in_def->has_init) @@ -866,7 +873,7 @@ plug_ins_init_file (const GimpDatafileData *file_data, if (g_ascii_strcasecmp (file_data->basename, plug_in_name) == 0) { g_printerr ("skipping duplicate plug-in: '%s'\n", - file_data->filename); + file_utils_filename_to_utf8 (file_data->filename)); g_free (plug_in_name); diff --git a/app/plug-in/plug-in-message.c b/app/plug-in/plug-in-message.c index 4dbd15c3db..22f13564b9 100644 --- a/app/plug-in/plug-in-message.c +++ b/app/plug-in/plug-in-message.c @@ -34,6 +34,8 @@ #include "core/gimp.h" #include "core/gimpdrawable.h" +#include "file/file-utils.h" + #include "plug-in.h" #include "plug-ins.h" #include "plug-in-def.h" @@ -94,7 +96,8 @@ plug_in_handle_message (PlugIn *plug_in, case GP_CONFIG: g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent a CONFIG message (should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); break; @@ -105,14 +108,16 @@ plug_in_handle_message (PlugIn *plug_in, case GP_TILE_ACK: g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent a TILE_ACK message (should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); break; case GP_TILE_DATA: g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent a TILE_DATA message (should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); break; @@ -127,7 +132,8 @@ plug_in_handle_message (PlugIn *plug_in, case GP_TEMP_PROC_RUN: g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent a TEMP_PROC_RUN message (should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); break; @@ -137,7 +143,8 @@ plug_in_handle_message (PlugIn *plug_in, #else g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent a TEMP_PROC_RETURN message (should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); #endif break; @@ -226,7 +233,8 @@ plug_in_handle_tile_req (PlugIn *plug_in, { g_message ("Plug-In \"%s\"\n(%s)\n\n" "requested invalid drawable (killing)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); return; } @@ -242,7 +250,8 @@ plug_in_handle_tile_req (PlugIn *plug_in, { g_message ("Plug-In \"%s\"\n(%s)\n\n" "requested invalid tile (killing)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); return; } @@ -277,7 +286,8 @@ plug_in_handle_tile_req (PlugIn *plug_in, { g_message ("Plug-In \"%s\"\n(%s)\n\n" "requested invalid drawable (killing)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); return; } @@ -293,7 +303,8 @@ plug_in_handle_tile_req (PlugIn *plug_in, { g_message ("Plug-In \"%s\"\n(%s)\n\n" "requested invalid tile (killing)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); return; } @@ -365,7 +376,8 @@ plug_in_handle_proc_run (PlugIn *plug_in, g_message ("WARNING: Plug-In \"%s\"\n(%s)\n\n" "called deprecated procedure '%s'.\n" "It should call '%s' instead!", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), proc_run->name, proc_name); } } @@ -506,7 +518,8 @@ plug_in_handle_temp_proc_return (PlugIn *plug_in, g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent a TEMP_PROC_RETURN message while not running " "a temp proc (should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); } } @@ -540,7 +553,8 @@ plug_in_handle_proc_install (PlugIn *plug_in, "which does not take the standard Plug-In " "args.\n" "(INT32)", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), proc_install->name); return; } @@ -557,7 +571,8 @@ plug_in_handle_proc_install (PlugIn *plug_in, "which does not take the standard Plug-In " "args.\n" "(INT32, IMAGE, DRAWABLE)", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), proc_install->name); return; } @@ -574,7 +589,8 @@ plug_in_handle_proc_install (PlugIn *plug_in, "which does not take the standard Plug-In " "args.\n" "(INT32, STRING, STRING)", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), proc_install->name); return; } @@ -593,7 +609,8 @@ plug_in_handle_proc_install (PlugIn *plug_in, "which does not take the standard Plug-In " "args.\n" "(INT32, IMAGE, DRAWABLE, STRING, STRING)", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), proc_install->name); return; } @@ -605,7 +622,8 @@ plug_in_handle_proc_install (PlugIn *plug_in, "in an invalid menu location.\n" "Use either \"\", \"\", " "\"\", or \"\".", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), proc_install->name); return; } @@ -626,7 +644,8 @@ plug_in_handle_proc_install (PlugIn *plug_in, "attempted to install procedure \"%s\" " "which fails to comply with the array parameter " "passing standard. Argument %d is noncompliant.", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), proc_install->name, i); return; } @@ -671,7 +690,8 @@ plug_in_handle_proc_install (PlugIn *plug_in, { g_message ("Plug-In \"%s\"\n(%s)\n\n" "attempted to install a procedure with invalid UTF-8 strings.", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); return; } @@ -820,7 +840,8 @@ plug_in_handle_extension_ack (PlugIn *plug_in) g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent an EXTENSION_ACK message while not being started " "as extension (should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); } } @@ -837,7 +858,8 @@ plug_in_handle_has_init (PlugIn *plug_in) g_message ("Plug-In \"%s\"\n(%s)\n\n" "sent an HAS_INIT message while not in query() " "(should not happen)", - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); plug_in_close (plug_in, TRUE); } } diff --git a/app/plug-in/plug-in-rc.c b/app/plug-in/plug-in-rc.c index e322fb6a81..9ec47909da 100644 --- a/app/plug-in/plug-in-rc.c +++ b/app/plug-in/plug-in-rc.c @@ -34,6 +34,8 @@ #include "core/gimp.h" +#include "file/file-utils.h" + #include "plug-ins.h" #include "plug-in-def.h" #include "plug-in-proc.h" @@ -152,7 +154,8 @@ plug_in_rc_parse (Gimp *gimp, { g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_VERSION, - _("Skipping '%s': wrong GIMP protocol version."), filename); + _("Skipping '%s': wrong GIMP protocol version."), + file_utils_filename_to_utf8 (filename)); } else if (token != G_TOKEN_LEFT_PAREN) { diff --git a/app/plug-in/plug-in.c b/app/plug-in/plug-in.c index 5a65df86a1..4ce69b0ea1 100644 --- a/app/plug-in/plug-in.c +++ b/app/plug-in/plug-in.c @@ -74,6 +74,8 @@ #include "core/gimp.h" #include "core/gimpenvirontable.h" +#include "file/file-utils.h" + #include "plug-in.h" #include "plug-ins.h" #include "plug-in-debug.h" @@ -351,7 +353,8 @@ plug_in_open (PlugIn *plug_in) if ((pipe (my_read) == -1) || (pipe (my_write) == -1)) { g_message ("Unable to run Plug-In \"%s\"\n(%s)\n\npipe() failed: %s", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), g_strerror (errno)); return FALSE; } @@ -449,7 +452,8 @@ plug_in_open (PlugIn *plug_in) &error)) { g_message ("Unable to run Plug-In \"%s\"\n(%s)\n\n%s", - plug_in->name, plug_in->prog, + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog), error->message); g_error_free (error); goto cleanup; @@ -549,7 +553,8 @@ plug_in_close (PlugIn *plug_in, } if (STILL_ACTIVE == dwExitCode) { - g_warning ("Terminating %s ...", plug_in->prog); + g_warning ("Terminating %s ...", + file_utils_filename_to_utf8 (plug_in->prog)); TerminateProcess ((HANDLE) plug_in->pid, 0); } } @@ -685,7 +690,8 @@ plug_in_recv_message (GIOChannel *channel, "The dying Plug-In may have messed up GIMP's internal state. " "You may want to save your images and restart GIMP " "to be on the safe side."), - plug_in->name, plug_in->prog); + file_utils_filename_to_utf8 (plug_in->name), + file_utils_filename_to_utf8 (plug_in->prog)); if (! plug_in->open) plug_in_unref (plug_in); @@ -764,13 +770,14 @@ plug_in_flush (GIOChannel *channel, if (error) { g_warning ("%s: plug_in_flush(): error: %s", - g_get_prgname (), error->message); + file_utils_filename_to_utf8 (g_get_prgname ()), + error->message); g_error_free (error); } else { g_warning ("%s: plug_in_flush(): error", - g_get_prgname ()); + file_utils_filename_to_utf8 (g_get_prgname ())); } return FALSE; diff --git a/app/plug-in/plug-ins.c b/app/plug-in/plug-ins.c index 372bbf7337..823c939bed 100644 --- a/app/plug-in/plug-ins.c +++ b/app/plug-in/plug-ins.c @@ -36,6 +36,8 @@ #include "core/gimpdrawable.h" #include "core/gimpimage.h" +#include "file/file-utils.h" + #include "plug-in.h" #include "plug-ins.h" #include "plug-in-def.h" @@ -131,7 +133,8 @@ plug_ins_init (Gimp *gimp, filename = gimp_personal_rc_file ("pluginrc"); } - (* status_callback) (_("Resource configuration"), filename, -1); + (* status_callback) (_("Resource configuration"), + file_utils_filename_to_utf8 (filename), -1); if (! plug_in_rc_parse (gimp, filename, &error)) { @@ -152,7 +155,8 @@ plug_ins_init (Gimp *gimp, plug_in_def = tmp->data; basename = g_path_get_basename (plug_in_def->prog); - (* status_callback) (NULL, basename, nth / n_plugins); + (* status_callback) (NULL, file_utils_filename_to_utf8 (basename), + nth / n_plugins); g_free (basename); if (plug_in_def->needs_query) @@ -160,7 +164,8 @@ plug_ins_init (Gimp *gimp, gimp->write_pluginrc = TRUE; if (gimp->be_verbose) - g_print (_("Querying plug-in: '%s'\n"), plug_in_def->prog); + g_print (_("Querying plug-in: '%s'\n"), + file_utils_filename_to_utf8 (plug_in_def->prog)); plug_in_call_query (gimp, plug_in_def); } @@ -215,7 +220,8 @@ plug_ins_init (Gimp *gimp, GError *error = NULL; if (gimp->be_verbose) - g_print (_("Writing '%s'\n"), filename); + g_print (_("Writing '%s'\n"), + file_utils_filename_to_utf8 (filename)); if (! plug_in_rc_write (gimp->plug_in_defs, filename, &error)) { @@ -294,7 +300,8 @@ plug_ins_init (Gimp *gimp, plug_in_def = tmp->data; basename = g_path_get_basename (plug_in_def->prog); - (* status_callback) (NULL, basename, nth / n_plugins); + (* status_callback) (NULL, file_utils_filename_to_utf8 (basename), + nth / n_plugins); g_free (basename); if (plug_in_def->has_init) @@ -866,7 +873,7 @@ plug_ins_init_file (const GimpDatafileData *file_data, if (g_ascii_strcasecmp (file_data->basename, plug_in_name) == 0) { g_printerr ("skipping duplicate plug-in: '%s'\n", - file_data->filename); + file_utils_filename_to_utf8 (file_data->filename)); g_free (plug_in_name); diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c index 57f800bb06..41303a7f04 100644 --- a/app/tools/gimpcurvestool.c +++ b/app/tools/gimpcurvestool.c @@ -50,6 +50,8 @@ #include "core/gimpimagemap.h" #include "core/gimptoolinfo.h" +#include "file/file-utils.h" + #include "widgets/gimpcursor.h" #include "widgets/gimpenummenu.h" #include "widgets/gimphelp-ids.h" @@ -1317,7 +1319,8 @@ file_dialog_response (GtkWidget *dialog, g_message (c_tool->is_save ? _("Could not open '%s' for writing: %s") : _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), + g_strerror (errno)); return; } @@ -1327,7 +1330,8 @@ file_dialog_response (GtkWidget *dialog, } else if (! curves_read_from_file (c_tool, file)) { - g_message ("Error in reading file '%s'.", filename); + g_message ("Error in reading file '%s'.", + file_utils_filename_to_utf8 (filename)); } fclose (file); diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c index c663ca0c5e..3871e58c9e 100644 --- a/app/tools/gimplevelstool.c +++ b/app/tools/gimplevelstool.c @@ -49,6 +49,8 @@ #include "core/gimpimagemap.h" #include "core/gimptoolinfo.h" +#include "file/file-utils.h" + #include "widgets/gimpenummenu.h" #include "widgets/gimphelp-ids.h" #include "widgets/gimphistogramview.h" @@ -1486,7 +1488,8 @@ file_dialog_response (GtkWidget *dialog, g_message (l_tool->is_save ? _("Could not open '%s' for writing: %s") : _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), + g_strerror (errno)); return; } @@ -1496,7 +1499,8 @@ file_dialog_response (GtkWidget *dialog, } else if (! levels_read_from_file (l_tool, file)) { - g_message (("Error in reading file '%s'."), filename); + g_message (("Error in reading file '%s'."), + file_utils_filename_to_utf8 (filename)); } fclose (file); diff --git a/app/vectors/gimpvectors-export.c b/app/vectors/gimpvectors-export.c index f71aaea43c..44aad026d0 100644 --- a/app/vectors/gimpvectors-export.c +++ b/app/vectors/gimpvectors-export.c @@ -31,6 +31,8 @@ #include "core/gimplist.h" #include "core/gimpunit.h" +#include "file/file-utils.h" + #include "gimpanchor.h" #include "gimpstroke.h" #include "gimpbezierstroke.h" @@ -79,7 +81,7 @@ gimp_vectors_export_file (const GimpImage *image, if (!file) { g_set_error (error, 0, 0, _("Could not open '%s' for writing: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return FALSE; } @@ -92,7 +94,7 @@ gimp_vectors_export_file (const GimpImage *image, if (fclose (file)) { g_set_error (error, 0, 0, _("Error while writing '%s': %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return FALSE; } diff --git a/app/widgets/gimperrorconsole.c b/app/widgets/gimperrorconsole.c index 78b32e537d..9925707510 100644 --- a/app/widgets/gimperrorconsole.c +++ b/app/widgets/gimperrorconsole.c @@ -55,6 +55,8 @@ #include "core/gimp.h" +#include "file/file-utils.h" + #include "gimperrorconsole.h" #include "gimphelp-ids.h" #include "gimpitemfactory.h" @@ -396,7 +398,7 @@ gimp_error_console_save_response (GtkWidget *dialog, console->save_selection)) { g_message (_("Error writing file '%s':\n%s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return; } } diff --git a/app/widgets/gimptexteditor.c b/app/widgets/gimptexteditor.c index b7c9acd631..d57d8a80e8 100644 --- a/app/widgets/gimptexteditor.c +++ b/app/widgets/gimptexteditor.c @@ -34,6 +34,8 @@ #include "core/gimpmarshal.h" +#include "file/file-utils.h" + #include "gimpenummenu.h" #include "gimphelp-ids.h" #include "gimptexteditor.h" @@ -370,7 +372,7 @@ gimp_text_editor_load_file (GtkTextBuffer *buffer, if (!file) { g_message (_("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return FALSE; } @@ -398,7 +400,8 @@ gimp_text_editor_load_file (GtkTextBuffer *buffer, } if (remaining) - g_message (_("Invalid UTF-8 data in file '%s'."), filename); + g_message (_("Invalid UTF-8 data in file '%s'."), + file_utils_filename_to_utf8 (filename)); return TRUE; } diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c index 2f9a0d88c5..d82a68a023 100644 --- a/app/xcf/xcf.c +++ b/app/xcf/xcf.c @@ -30,6 +30,8 @@ #include "core/gimp.h" #include "core/gimpimage.h" +#include "file/file-utils.h" + #include "pdb/procedural_db.h" #include "plug-in/plug-ins.h" @@ -268,12 +270,8 @@ xcf_load_invoker (Gimp *gimp, fclose (info.fp); } else - { - gchar *utf8_filename = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL); - g_message (_("Could not open '%s' for reading: %s"), - utf8_filename, g_strerror (errno)); - g_free (utf8_filename); - } + g_message (_("Could not open '%s' for reading: %s"), + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return_args = procedural_db_return_args (&xcf_plug_in_load_proc.db_info, success); @@ -329,12 +327,8 @@ xcf_save_invoker (Gimp *gimp, } } else - { - gchar *utf8_filename = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL); - g_message (_("Could not open '%s' for writing: %s"), - utf8_filename, g_strerror (errno)); - g_free (utf8_filename); - } + g_message (_("Could not open '%s' for writing: %s"), + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return_args = procedural_db_return_args (&xcf_plug_in_save_proc.db_info, success); diff --git a/libgimpbase/gimpenv.c b/libgimpbase/gimpenv.c index 9ab8e70e97..19f9ee37ab 100644 --- a/libgimpbase/gimpenv.c +++ b/libgimpbase/gimpenv.c @@ -83,7 +83,9 @@ static gchar * gimp_env_get_dir (const gchar *gimp_env_name, * directory or not. * * The returned string is allocated just once, and should *NOT* be - * freed with g_free(). + * freed with g_free(). The returned string is in the encoding used + * for filenames by the system, which isn't necessarily UTF-8 (never + * is on Windows). * * Returns: The user-specific GIMP settings directory. **/ @@ -172,7 +174,9 @@ gimp_directory (void) * Returns the name of a file in the user-specific GIMP settings directory. * * The returned string is allocated dynamically and *SHOULD* be freed - * with g_free() after use. + * with g_free() after use. The returned string is in the encoding used + * for filenames by the system, which isn't necessarily UTF-8 (never + * is on Windows). * * Returns: The name of a file in the user-specific GIMP settings directory. **/ @@ -249,7 +253,9 @@ gimp_toplevel_directory (void) * from the executable's name is used. * * The returned string is allocated just once, and should *NOT* be - * freed with g_free(). + * freed with g_free(). The returned string is in the encoding used + * for filenames by the system, which isn't necessarily UTF-8 (never + * is on Windows). * * Returns: The top directory for GIMP data. **/ @@ -274,7 +280,9 @@ gimp_data_directory (void) * from the executable's name is used. * * The returned string is allocated just once, and should *NOT* be - * freed with g_free(). + * freed with g_free(). The returned string is in the encoding used + * for filenames by the system, which isn't necessarily UTF-8 (never + * is on Windows). * * Returns: The top directory for GIMP locale files. */ @@ -299,7 +307,9 @@ gimp_locale_directory (void) * from the executable's name is used. * * The returned string is allocated just once, and should *NOT* be - * freed with g_free(). + * freed with g_free(). The returned string is in the encoding used + * for filenames by the system, which isn't necessarily UTF-8 (never + * is on Windows). * * Returns: The top directory for GIMP config files. **/ @@ -324,7 +334,9 @@ gimp_sysconf_directory (void) * deduced from the executable's name is used. * * The returned string is allocated just once, and should *NOT* be - * freed with g_free(). + * freed with g_free(). The returned string is in the encoding used + * for filenames by the system, which isn't necessarily UTF-8 (never + * is on Windows). * * Returns: The top directory for GIMP plug_ins and modules. **/ @@ -345,7 +357,9 @@ gimp_plug_in_directory (void) * Returns the name of the GIMP's application-specific gtkrc file. * * The returned string is allocated just once, and should *NOT* be - * freed with g_free(). + * freed with g_free(). The returned string is in the encoding used + * for filenames by the system, which isn't necessarily UTF-8 (never + * is on Windows). * * Returns: The name of the GIMP's application-specific gtkrc file. **/ diff --git a/libgimpconfig/gimpconfig-path.c b/libgimpconfig/gimpconfig-path.c index eab2b7265d..e98eeb43b4 100644 --- a/libgimpconfig/gimpconfig-path.c +++ b/libgimpconfig/gimpconfig-path.c @@ -28,6 +28,8 @@ #include "libgimpbase/gimpenv.h" +#include "file/file-utils.h" + #include "gimpconfig-path.h" #include "gimp-intl.h" @@ -104,7 +106,7 @@ gimp_config_path_expand_only (const gchar *path, #ifndef G_OS_WIN32 if (*p == '~') { - length += strlen (g_get_home_dir ()); + length += strlen (file_utils_filename_to_utf8 (g_get_home_dir ())); p += 1; } else @@ -124,18 +126,14 @@ gimp_config_path_expand_only (const gchar *path, { s = NULL; - if (!s && strcmp (token, "gimp_dir") == 0) + if (strcmp (token, "gimp_dir") == 0) s = gimp_directory (); - - if (!s && strcmp (token, "gimp_data_dir") == 0) + else if (strcmp (token, "gimp_data_dir") == 0) s = gimp_data_directory (); - - if (!s && - ((strcmp (token, "gimp_plug_in_dir")) == 0 || - (strcmp (token, "gimp_plugin_dir")) == 0)) + else if (strcmp (token, "gimp_plug_in_dir") == 0 || + strcmp (token, "gimp_plugin_dir") == 0) s = gimp_plug_in_directory (); - - if (!s && strcmp (token, "gimp_sysconf_dir") == 0) + else if (strcmp (token, "gimp_sysconf_dir") == 0) s = gimp_sysconf_directory (); if (!s) @@ -163,7 +161,7 @@ gimp_config_path_expand_only (const gchar *path, substs = g_renew (gchar *, substs, 2 * (n_substs + SUBSTS_ALLOC)); substs[2*n_substs] = token; - substs[2*n_substs + 1] = (gchar *) s; + substs[2*n_substs + 1] = file_utils_filename_to_utf8 (s); n_substs++; length += strlen (s); @@ -190,8 +188,8 @@ gimp_config_path_expand_only (const gchar *path, if (*p == '~') { *n = '\0'; - strcat (n, g_get_home_dir ()); - n += strlen (g_get_home_dir ()); + strcat (n, file_utils_filename_to_utf8 (g_get_home_dir ())); + n += strlen (file_utils_filename_to_utf8 (g_get_home_dir ())); p += 1; } else diff --git a/libgimpconfig/gimpconfig-utils.c b/libgimpconfig/gimpconfig-utils.c index 73abc0934b..04b81df787 100644 --- a/libgimpconfig/gimpconfig-utils.c +++ b/libgimpconfig/gimpconfig-utils.c @@ -470,7 +470,7 @@ gimp_config_file_copy (const gchar *source, { g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), _("Could not open '%s' for reading: %s"), - source, g_strerror (errno)); + file_utils_filename_to_utf8 (source), g_strerror (errno)); return FALSE; } @@ -479,7 +479,7 @@ gimp_config_file_copy (const gchar *source, { g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), _("Could not open '%s' for writing: %s"), - dest, g_strerror (errno)); + file_utils_filename_to_utf8 (dest), g_strerror (errno)); fclose (sfile); return FALSE; } @@ -490,7 +490,7 @@ gimp_config_file_copy (const gchar *source, { g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), _("Error while writing '%s': %s"), - dest, g_strerror (errno)); + file_utils_filename_to_utf8 (dest), g_strerror (errno)); fclose (sfile); fclose (dfile); return FALSE; @@ -501,7 +501,7 @@ gimp_config_file_copy (const gchar *source, { g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), _("Error while reading '%s': %s"), - source, g_strerror (errno)); + file_utils_filename_to_utf8 (source), g_strerror (errno)); fclose (sfile); fclose (dfile); return FALSE; @@ -513,7 +513,7 @@ gimp_config_file_copy (const gchar *source, { g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno), _("Error while writing '%s': %s"), - dest, g_strerror (errno)); + file_utils_filename_to_utf8 (dest), g_strerror (errno)); return FALSE; } @@ -540,7 +540,7 @@ gimp_config_file_backup_on_error (const gchar *filename, g_message (_("There was an error parsing your '%s' file. " "Default values will be used. A backup of your " "configuration has been created at '%s'."), - name, backup); + name, file_utils_filename_to_utf8 (backup)); g_free (backup); diff --git a/libgimpconfig/gimpscanner.c b/libgimpconfig/gimpscanner.c index 24322500b5..e145904c3e 100644 --- a/libgimpconfig/gimpscanner.c +++ b/libgimpconfig/gimpscanner.c @@ -41,6 +41,8 @@ #include "libgimpcolor/gimpcolor.h" #include "libgimpmath/gimpmath.h" +#include "file/file-utils.h" + #include "config-types.h" #include "gimpconfig-error.h" @@ -90,12 +92,15 @@ gimp_scanner_new_file (const gchar *filename, g_set_error (error, GIMP_CONFIG_ERROR, code, _("Could not open '%s' for reading: %s"), - filename, g_strerror (errno)); + file_utils_filename_to_utf8 (filename), g_strerror (errno)); return NULL; } - scanner = gimp_scanner_new (filename, fd, error); + /* gimp_scanner_new() takes a "name" for the scanner, not a filename. Thus + * do convert to UTF-8. + */ + scanner = gimp_scanner_new (file_utils_filename_to_utf8 (filename), fd, error); g_scanner_input_file (scanner, fd); diff --git a/libgimpmodule/gimpmodule.c b/libgimpmodule/gimpmodule.c index 637fcf4dbf..c3c7f66224 100644 --- a/libgimpmodule/gimpmodule.c +++ b/libgimpmodule/gimpmodule.c @@ -163,6 +163,7 @@ gimp_module_load (GTypeModule *module) { GimpModule *gimp_module; GimpModuleRegisterFunc func; + gchar *module_filename_utf8; g_return_val_if_fail (GIMP_IS_MODULE (module), FALSE); @@ -171,14 +172,22 @@ gimp_module_load (GTypeModule *module) g_return_val_if_fail (gimp_module->filename != NULL, FALSE); g_return_val_if_fail (gimp_module->module == NULL, FALSE); + module_filename_utf8 = g_filename_to_utf8 (gimp_module->filename, + -1, NULL, NULL, NULL); if (gimp_module->verbose) - g_print (_("Loading module: '%s'\n"), gimp_module->filename); + g_print (_("Loading module: '%s'\n"), module_filename_utf8); if (! gimp_module_open (gimp_module)) - return FALSE; + { + g_free (module_filename_utf8); + return FALSE; + } if (! gimp_module_query_module (gimp_module)) - return FALSE; + { + g_free (module_filename_utf8); + return FALSE; + } /* find the gimp_module_register symbol */ if (! g_module_symbol (gimp_module->module, "gimp_module_register", @@ -189,11 +198,14 @@ gimp_module_load (GTypeModule *module) if (gimp_module->verbose) g_message (_("Module '%s' load error: %s"), - gimp_module->filename, gimp_module->last_module_error); + module_filename_utf8, gimp_module->last_module_error); gimp_module_close (gimp_module); gimp_module->state = GIMP_MODULE_STATE_ERROR; + + g_free (module_filename_utf8); + return FALSE; } @@ -206,15 +218,21 @@ gimp_module_load (GTypeModule *module) if (gimp_module->verbose) g_message (_("Module '%s' load error: %s"), - gimp_module->filename, gimp_module->last_module_error); + module_filename_utf8, gimp_module->last_module_error); gimp_module_close (gimp_module); gimp_module->state = GIMP_MODULE_STATE_LOAD_FAILED; + + g_free (module_filename_utf8); + return FALSE; } gimp_module->state = GIMP_MODULE_STATE_LOADED; + + g_free (module_filename_utf8); + return TRUE; } @@ -269,7 +287,12 @@ gimp_module_new (const gchar *filename, else { if (verbose) - g_print (_("Skipping module: '%s'\n"), filename); + { + gchar *filename_utf8 = g_filename_to_utf8 (filename, + -1, NULL, NULL, NULL); + g_print (_("Skipping module: '%s'\n"), filename_utf8); + g_free (filename_utf8); + } module->state = GIMP_MODULE_STATE_NOT_LOADED; } @@ -312,8 +335,13 @@ gimp_module_query_module (GimpModule *module) "Missing gimp_module_query() symbol"); if (module->verbose) - g_message (_("Module '%s' load error: %s"), - module->filename, module->last_module_error); + { + gchar *filename_utf8 = g_filename_to_utf8 (module->filename, + -1, NULL, NULL, NULL); + g_message (_("Module '%s' load error: %s"), + filename_utf8, module->last_module_error); + g_free (filename_utf8); + } gimp_module_close (module); @@ -339,8 +367,13 @@ gimp_module_query_module (GimpModule *module) "gimp_module_query() returned NULL"); if (module->verbose) - g_message (_("Module '%s' load error: %s"), - module->filename, module->last_module_error); + { + gchar *filename_utf8 = g_filename_to_utf8 (module->filename, + -1, NULL, NULL, NULL); + g_message (_("Module '%s' load error: %s"), + filename_utf8, module->last_module_error); + g_free (filename_utf8); + } gimp_module_close (module); @@ -432,8 +465,13 @@ gimp_module_open (GimpModule *module) gimp_module_set_last_error (module, g_module_error ()); if (module->verbose) - g_message (_("Module '%s' load error: %s"), - module->filename, module->last_module_error); + { + gchar *filename_utf8 = g_filename_to_utf8 (module->filename, + -1, NULL, NULL, NULL); + g_message (_("Module '%s' load error: %s"), + filename_utf8, module->last_module_error); + g_free (filename_utf8); + } return FALSE; }