changeset 916:936635b76f02

2007-4-26 Brian Masney <masneyb@gftp.org> * src/gtk/misc-gtk.c lib/gftp.h lib/protocols.c - added filename_utf8_encoded flag to the gftp_file structure. If this is false, then don't attempt to show the filename in the GTK port. The user can still select the blank filename though.
author masneyb
date Thu, 26 Apr 2007 23:47:34 +0000
parents ecac0834d141
children afea4eaec5f0
files ChangeLog lib/gftp.h lib/protocols.c src/gtk/misc-gtk.c
diffstat 4 files changed, 22 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Apr 25 22:23:16 2007 +0000
+++ b/ChangeLog	Thu Apr 26 23:47:34 2007 +0000
@@ -1,3 +1,9 @@
+2007-4-26 Brian Masney <masneyb@gftp.org>
+	* src/gtk/misc-gtk.c lib/gftp.h lib/protocols.c - added
+	filename_utf8_encoded flag to the gftp_file structure. If this is false,
+	then don't attempt to show the filename in the GTK port. The user can
+	still select the blank filename though.
+
 2007-4-18 Brian Masney <masneyb@gftp.org>
 	* src/gtk/gftp-gtk.c src/gtk/gtkui.c src/gtk/gftp-gtk.h - added new
 	function gftp_gtk_init_request(). It will initialize a gftp_request
--- a/lib/gftp.h	Wed Apr 25 22:23:16 2007 +0000
+++ b/lib/gftp.h	Thu Apr 26 23:47:34 2007 +0000
@@ -257,8 +257,11 @@
                done_rm : 1,	/* Remove the file when done */
                transfer_done : 1, /* Is current file transfer done? */
                retry_transfer : 1, /* Is current file transfer done? */
-               exists_other_side; /* The file exists on the other side during
-                                     the file transfer */
+               exists_other_side : 1, /* The file exists on the other side
+                                         during the file transfer */
+               filename_utf8_encoded : 1; /* Is the filename properly UTF8
+                                             encoded? */
+
   char transfer_action;		/* See the GFTP_TRANS_ACTION_* vars above */
   /*@null@*/ void *user_data;
 };
--- a/lib/protocols.c	Wed Apr 25 22:23:16 2007 +0000
+++ b/lib/protocols.c	Thu Apr 26 23:47:34 2007 +0000
@@ -703,12 +703,17 @@
 
       if (ret >= 0 && fle->file != NULL)
         {
-          utf8 = gftp_filename_to_utf8 (request, fle->file, &destlen);
-          if (utf8 != NULL)
+          if (g_utf8_validate (fle->file, -1, NULL))
+            fle->filename_utf8_encoded = 1;
+          else
             {
-              tmpfile = fle->file;
-              fle->file = utf8;
-              g_free (tmpfile);
+              utf8 = gftp_filename_to_utf8 (request, fle->file, &destlen);
+              if (utf8 != NULL)
+                {
+                  g_free (fle->file);
+                  fle->file = utf8;
+                  fle->filename_utf8_encoded = 1;
+                }
             }
         }
 
--- a/src/gtk/misc-gtk.c	Wed Apr 25 22:23:16 2007 +0000
+++ b/src/gtk/misc-gtk.c	Thu Apr 26 23:47:34 2007 +0000
@@ -747,7 +747,7 @@
    
   gtk_clist_set_pixmap (GTK_CLIST (wdata->listbox), clist_num, 0, pix, bitmap);
 
-  if (fle->file != NULL)
+  if (fle->file != NULL && fle->filename_utf8_encoded)
     gtk_clist_set_text (GTK_CLIST (wdata->listbox), clist_num, 1, fle->file);
 
   if (GFTP_IS_SPECIAL_DEVICE (fle->st_mode))