aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-02-08 09:22:58 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-02-08 09:22:58 +0000
commit2a790ab66bf113d914c7a6307d6c3092ab0b936a (patch)
tree7870d07b9c5bc67b89e20d8b4043642299635d41
parent3fe4ea91de3aba0cb629de313ed6c41f4c06b385 (diff)
fixed non-utf8 filename handlings.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@99 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--AUTHORS1
-rw-r--r--ChangeLog11
-rw-r--r--ChangeLog.ja11
-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
8 files changed, 77 insertions, 4 deletions
diff --git a/AUTHORS b/AUTHORS
index 75e5758c..d9629502 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -116,3 +116,4 @@ contributors (beside the above; based on Changelog)
Shawn Houston
Neill Miller
IWAMOTO Kouichi
+ Sergey Pinaev
diff --git a/ChangeLog b/ChangeLog
index 149bcacf..017da0f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2005-02-08
+ * src/codeconv.[ch]
+ conv_filename_from_utf8()
+ conv_filename_to_utf8(): new. They always returns non-NULL strings.
+ * src/filesel.c
+ src/summaryview.c: fixed non-UTF8 filename handling of the file
+ selection dialog (thanks to Sergey Pinaev).
+ * src/compose.c: compose_attach_cb(): fixed attaching of files with
+ non-UTF8 names (thanks to Sergey Pinaev).
+
+2005-02-08
+
* src/prefs_filter.c: use stock buttons.
2005-02-08
diff --git a/ChangeLog.ja b/ChangeLog.ja
index a0b78a9d..504b11ee 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,16 @@
2005-02-08
+ * src/codeconv.[ch]
+ conv_filename_from_utf8()
+ conv_filename_to_utf8(): 新規。常に NULL でない文字列を返す。
+ * src/filesel.c
+ src/summaryview.c: ファイル選択ダイアログの非 UTF-8 ファイル名の
+ 扱いを修正(Sergey Pinaev さん thanks)。
+ * src/compose.c: compose_attach_cb(): 非 UTF-8 ファイル名の
+ ファイルの添付を修正(Sergey Pinaev さん thanks)。
+
+2005-02-08
+
* src/prefs_filter.c: ストックボタンを使用。
2005-02-08
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);
}