CVS: sylpheedclaws/sylpheed-claws/src/gtk filesel.c,1.2.2.27,1.2.2.28
[email protected] Sun, 17 Dec 2006 13:36:28 +0000
| Newsgroups | gmane.mail.sylpheed.claws.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/gtk
In directory sunsite.dk:/tmp/cvs-serv17847/src/gtk
Modified Files:
Tag: gtk2
filesel.c
Log Message:
2006-12-17 [colin] 2.6.1cvs46
* src/mimeview.c
* src/textview.c
* src/gtk/filesel.c
Correctly convert from/to UTF8/filename encoding
when loading and saving files. Probably fixes
bug 1068, 'Claws-Mail uses 100% CPU when looking
for a file to attach and is blocked...'
Index: filesel.c
===================================================================
RCS file: /pack/anoncvs/sylpheedclaws/sylpheed-claws/src/gtk/filesel.c,v
retrieving revision 1.2.2.27
retrieving revision 1.2.2.28
diff -u -d -r1.2.2.27 -r1.2.2.28
--- filesel.c 2006/11/27 08:06:52 1.2.2.27
+++ filesel.c 2006/12/17 13:36:22 1.2.2.28
@@ -122,6 +122,7 @@
if (path && strlen(path) > 0) {
char *filename = NULL;
char *realpath = strdup(path);
+ char *tmp = NULL;
if (path[strlen(path)-1] == G_DIR_SEPARATOR) {
filename = "";
} else if ((filename = strrchr(path, G_DIR_SEPARATOR)) != NULL) {
@@ -132,15 +133,32 @@
free(realpath);
realpath = strdup(get_home_dir());
}
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(chooser), realpath);
- if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
- gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(chooser), filename);
+ if (g_utf8_validate(realpath, -1, NULL))
+ tmp = g_filename_from_utf8(realpath, -1, NULL, NULL, NULL);
+ else
+ tmp = g_strdup(realpath);
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(chooser), tmp);
+ g_free(tmp);
+
+ if (action == GTK_FILE_CHOOSER_ACTION_SAVE) {
+ if (g_utf8_validate(filename, -1, NULL))
+ tmp = g_filename_from_utf8(filename, -1, NULL, NULL, NULL);
+ else
+ tmp = g_strdup(filename);
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(chooser), tmp);
+ g_free(tmp);
+ }
free(realpath);
} else {
+ gchar *tmp = NULL;
if (!prefs_common.attach_load_dir)
prefs_common.attach_load_dir = g_strdup_printf("%s%c", get_home_dir(), G_DIR_SEPARATOR);
-
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(chooser), prefs_common.attach_load_dir);
+ if (g_utf8_validate(prefs_common.attach_load_dir, -1, NULL))
+ tmp = g_filename_from_utf8(prefs_common.attach_load_dir, -1, NULL, NULL, NULL);
+ else
+ tmp = g_strdup(prefs_common.attach_load_dir);
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(chooser), tmp);
+ g_free(tmp);
}
if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT)
@@ -161,7 +179,7 @@
*(strrchr(tmp, G_DIR_SEPARATOR)+1) = '\0';
if (!path)
- prefs_common.attach_load_dir = g_strdup(tmp);
+ prefs_common.attach_load_dir = g_filename_to_utf8(tmp, -1, NULL, NULL, NULL);
g_free(tmp);
}