aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/codeconv.c34
-rw-r--r--src/codeconv.h3
-rw-r--r--src/compose.c8
-rw-r--r--src/filesel.c7
-rw-r--r--src/summaryview.c6
5 files changed, 54 insertions, 4 deletions
diff --git a/src/codeconv.c b/src/codeconv.c
index 50df350d..c8329681 100644
--- a/src/codeconv.c
+++ b/src/codeconv.c
@@ -1858,3 +1858,37 @@ gint conv_copy_dir(const gchar *src, const gchar *dest, const gchar *encoding)
return 0;
}
+
+gchar *conv_filename_from_utf8(const gchar *utf8_file)
+{
+ gchar *fs_file;
+ GError *error = NULL;
+
+ fs_file = g_filename_from_utf8(utf8_file, -1, NULL, NULL, &error);
+ if (error) {
+ g_warning("failed to convert encoding of file name: %s\n",
+ error->message);
+ g_error_free(error);
+ }
+ if (!fs_file)
+ fs_file = g_strdup(utf8_file);
+
+ return fs_file;
+}
+
+gchar *conv_filename_to_utf8(const gchar *fs_file)
+{
+ gchar *utf8_file;
+ GError *error = NULL;
+
+ utf8_file = g_filename_to_utf8(fs_file, -1, NULL, NULL, &error);
+ if (error) {
+ g_warning("failed to convert encoding of file name: %s\n",
+ error->message);
+ g_error_free(error);
+ }
+ if (!utf8_file)
+ utf8_file = g_strdup(fs_file);
+
+ return utf8_file;
+}
diff --git a/src/codeconv.h b/src/codeconv.h
index e416249f..33dc2c1d 100644
--- a/src/codeconv.h
+++ b/src/codeconv.h
@@ -226,4 +226,7 @@ gint conv_copy_dir (const gchar *src,
const gchar *dest,
const gchar *src_encoding);
+gchar *conv_filename_from_utf8 (const gchar *utf8_file);
+gchar *conv_filename_to_utf8 (const gchar *fs_file);
+
#endif /* __CODECONV_H__ */
diff --git a/src/compose.c b/src/compose.c
index 162bde94..984739a1 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -5450,11 +5450,15 @@ static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget)
{
Compose *compose = (Compose *)data;
const gchar *file;
+ gchar *utf8_filename;
file = filesel_select_file(_("Select file"), NULL);
- if (file && *file)
- compose_attach_append(compose, file, file, NULL);
+ if (file && *file) {
+ utf8_filename = conv_filename_to_utf8(file);
+ compose_attach_append(compose, file, utf8_filename, NULL);
+ g_free(utf8_filename);
+ }
}
static void compose_insert_file_cb(gpointer data, guint action,
diff --git a/src/filesel.c b/src/filesel.c
index 57bc5896..f885eac2 100644
--- a/src/filesel.c
+++ b/src/filesel.c
@@ -29,6 +29,7 @@
#include "filesel.h"
#include "manage_window.h"
#include "gtkutils.h"
+#include "codeconv.h"
static GtkWidget *filesel;
static gboolean filesel_ack;
@@ -60,11 +61,15 @@ gchar *filesel_select_file(const gchar *title, const gchar *file)
gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), cwd);
if (file) {
+ gchar *fs_filename;
+
+ fs_filename = conv_filename_from_utf8(file);
gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel),
- file);
+ fs_filename);
gtk_editable_select_region
(GTK_EDITABLE(GTK_FILE_SELECTION(filesel)->selection_entry),
0, -1);
+ g_free(fs_filename);
}
gtk_widget_show(filesel);
diff --git a/src/summaryview.c b/src/summaryview.c
index 0df95d95..8c778971 100644
--- a/src/summaryview.c
+++ b/src/summaryview.c
@@ -2722,8 +2722,12 @@ void summary_save_as(SummaryView *summaryview)
src = procmsg_get_message_file(msginfo);
if (copy_file(src, dest, TRUE) < 0) {
+ gchar *utf8_dest;
+
+ utf8_dest = conv_filename_to_utf8(dest);
alertpanel_error(_("Can't save the file `%s'."),
- g_basename(dest));
+ g_basename(utf8_dest));
+ g_free(utf8_dest);
}
g_free(src);
}