changeset 45:311e29c40ed6

2002-10-31 Brian Masney <masneyb@gftp.org> * src/gtk/*.[ch] - don't check for gtk+ version based on the minor version. May cause problems later on. * lib/protocols.c src/gtk/bookmarks.c src/gtk/misc-gtk.c - use UTF8 functions for user data when using glib 2.0
author masneyb
date Thu, 31 Oct 2002 23:55:17 +0000
parents 9c0825c047e7
children 3da7765bc439
files ChangeLog TODO lib/config_file.c lib/protocols.c src/gtk/bookmarks.c src/gtk/chmod_dialog.c src/gtk/delete_dialog.c src/gtk/gftp-gtk.c src/gtk/gftp-gtk.h src/gtk/menu-items.c src/gtk/misc-gtk.c src/gtk/options_dialog.c src/gtk/transfer.c src/gtk/view_dialog.c
diffstat 14 files changed, 168 insertions(+), 89 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Oct 30 22:56:30 2002 +0000
+++ b/ChangeLog	Thu Oct 31 23:55:17 2002 +0000
@@ -1,3 +1,10 @@
+2002-10-31 Brian Masney <masneyb@gftp.org>
+	* src/gtk/*.[ch] - don't check for gtk+ version based on the minor 
+	version. May cause problems later on.
+
+	* lib/protocols.c src/gtk/bookmarks.c src/gtk/misc-gtk.c - use UTF8
+	functions for user data when using glib 2.0
+
 2002-10-30 Brian Masney <masneyb@gftp.org>
 	* src/gtk/gftp-gtk.c (CreateMenus) - no longer use depreciated
 	_gtk_accel_group_attach in GTK+ 2.0 port. Instead use 
@@ -115,7 +122,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.23 2002/10/30 22:56:29 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.24 2002/10/31 23:55:15 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/TODO	Wed Oct 30 22:56:30 2002 +0000
+++ b/TODO	Thu Oct 31 23:55:17 2002 +0000
@@ -2,6 +2,8 @@
 of gFTP. If there is something you feel should be included in a future
 version of gFTP, please email me about it.
 
+* Be able to save the state of the transfer queue. Be able to pause transfers.
+  Be able to edit the transfer information (hostname, user, etc)
 * For bookmarks, be able to specify a local protocol, host, port, directory
   to connect to
 * SSH login sequence could be improved
--- a/lib/config_file.c	Wed Oct 30 22:56:30 2002 +0000
+++ b/lib/config_file.c	Thu Oct 31 23:55:17 2002 +0000
@@ -962,9 +962,6 @@
 {
   const char *pos, *endpos;
 
-  /* FIXME - need to use UTF functions here. I need to check to see how 
-     portable they are before I do this though */
-
   fwrite ("# ", 1, 2, fd);
   pos = comment;
   while (strlen (pos) > 76)
--- a/lib/protocols.c	Wed Oct 30 22:56:30 2002 +0000
+++ b/lib/protocols.c	Thu Oct 31 23:55:17 2002 +0000
@@ -459,6 +459,10 @@
 {
   FILE * fd;
   int ret;
+#if GLIB_MAJOR_VERSION > 1
+  gsize bread, bwrite;
+  char *tempstr;
+#endif
 
   g_return_val_if_fail (request != NULL, -2);
 
@@ -476,6 +480,25 @@
       gftp_file_destroy (fle);
       ret = request->get_next_file (request, fle, fd);
 
+#if GLIB_MAJOR_VERSION > 1
+      if (fle->file != NULL && !g_utf8_validate (fle->file, -1, NULL))
+        {
+          if ((tempstr = g_locale_to_utf8 (fle->file, -1, &bread, 
+                                           &bwrite, NULL)) != NULL)
+            {
+              g_free (fle->file);
+              fle->file = tempstr;
+            }
+          else if ((tempstr = g_filename_to_utf8 (fle->file, -1, &bread, 
+                                                  &bwrite, NULL)) != NULL)
+            {
+              g_free (fle->file);
+              fle->file = tempstr;
+            }
+
+        }
+#endif
+
       if (ret >= 0 && !request->cached && request->cachefd != NULL && 
           request->last_dir_entry != NULL)
         {
--- a/src/gtk/bookmarks.c	Wed Oct 30 22:56:30 2002 +0000
+++ b/src/gtk/bookmarks.c	Thu Oct 31 23:55:17 2002 +0000
@@ -265,7 +265,7 @@
 }
 
 
-#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2)
+#if GTK_MAJOR_VERSION > 1 
 static void
 editbm_action (GtkWidget * widget, gint response, gpointer user_data)
 {
@@ -296,14 +296,14 @@
     {N_("/File/sep"), NULL, 0, 0, "<Separator>"},
     {N_("/File/Close"), NULL, gtk_widget_destroy, 0, MS_(GTK_STOCK_CLOSE)}
   };
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   GtkWidget * tempwid;
 #endif
 
   new_bookmarks = copy_bookmarks (bookmarks);
   new_bookmarks_htable = build_bookmarks_hash_table (new_bookmarks);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   dialog = gtk_dialog_new ();
   gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Bookmarks"));
   gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15);
@@ -361,7 +361,7 @@
 			    GTK_SIGNAL_FUNC (bm_dblclick), (gpointer) tree);
   gtk_widget_show (tree);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   tempwid = gtk_button_new_with_label (_("OK"));
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
 		      TRUE, TRUE, 0);
@@ -789,6 +789,9 @@
   GtkCTreeNode * sibling;
   char *pos, *text[2];
   const char *str;
+#if GTK_MAJOR_VERSION > 1
+  gsize bread, bwrite;
+#endif
 
   gftp_get_pixmap (tree, "open_dir.xpm", &opendir_pixmap, &opendir_bitmap);
   gftp_get_pixmap (tree, "dir.xpm", &closedir_pixmap, &closedir_bitmap);
@@ -796,10 +799,20 @@
   str = gtk_entry_get_text (GTK_ENTRY (ddata->edit));
 
   newentry = g_malloc0 (sizeof (*newentry));
-  newentry->path = g_malloc (strlen (str) + 1);
-  strcpy (newentry->path, str);
+#if GTK_MAJOR_VERSION == 1
+  newentry->path = g_strdup (str);
+
   while ((pos = strchr (str, '/')) != NULL)
     *pos++ = ' ';
+#else
+  if (g_utf8_validate (str, -1, NULL))
+    newentry->path = g_strdup (str);
+  else
+    newentry->path = g_locale_to_utf8 (str, -1, &bread, &bwrite, NULL);
+
+  while ((pos = g_utf8_strchr (str, -1, '/')) != NULL)
+    *pos++ = ' ';
+#endif
 
   newentry->prev = new_bookmarks;
   if (data)
@@ -838,7 +851,7 @@
 }
 
 
-#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2)
+#if GTK_MAJOR_VERSION > 1
 static void
 bmedit_action (GtkWidget * widget, gint response, gpointer user_data)
 {
@@ -874,7 +887,7 @@
   if (entry == NULL || entry == new_bookmarks)
     return;
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   dialog = gtk_dialog_new ();
   gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Entry"));
   gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 15);
@@ -1078,7 +1091,7 @@
     }
   gtk_widget_show (anon_chk);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   tempwid = gtk_button_new_with_label (_("OK"));
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
 		      TRUE, TRUE, 0);
--- a/src/gtk/chmod_dialog.c	Wed Oct 30 22:56:30 2002 +0000
+++ b/src/gtk/chmod_dialog.c	Thu Oct 31 23:55:17 2002 +0000
@@ -28,7 +28,7 @@
                  *ox;
 static int mode; 
 
-#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2)
+#if GTK_MAJOR_VERSION > 1
 static void
 chmod_action (GtkWidget * widget, gint response, gpointer wdata)
 {
@@ -58,7 +58,7 @@
                      wdata->request->chmod != NULL))
     return;
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   dialog = gtk_dialog_new ();
   gtk_window_set_title (GTK_WINDOW (dialog), _("Chmod"));
   gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area),
@@ -175,7 +175,7 @@
   gtk_box_pack_start (GTK_BOX (vbox), ox, FALSE, FALSE, 0);
   gtk_widget_show (ox);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   tempwid = gtk_button_new_with_label (_("OK"));
   GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
--- a/src/gtk/delete_dialog.c	Wed Oct 30 22:56:30 2002 +0000
+++ b/src/gtk/delete_dialog.c	Thu Oct 31 23:55:17 2002 +0000
@@ -81,7 +81,7 @@
       while (transfer->fromreq->stopable)
         {
           GDK_THREADS_LEAVE ();
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
           g_main_iteration (TRUE);
 #else
           g_main_context_iteration (NULL, TRUE);
@@ -153,7 +153,7 @@
       while (transfer->fromreq->stopable)
         {
           GDK_THREADS_LEAVE ();
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
           g_main_iteration (TRUE);
 #else
           g_main_context_iteration (NULL, TRUE);
--- a/src/gtk/gftp-gtk.c	Wed Oct 30 22:56:30 2002 +0000
+++ b/src/gtk/gftp-gtk.c	Thu Oct 31 23:55:17 2002 +0000
@@ -63,7 +63,7 @@
 GtkWidget * stop_btn, * hostedit, * useredit, * passedit, * portedit, * logwdw,
           * dlwdw, * protocol_menu, * optionmenu;
 GtkAdjustment * logwdw_vadj;
-#if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION == 0
+#if GTK_MAJOR_VERSION > 1
 GtkTextMark * logwdw_textmark;
 #endif
 int local_start, remote_start, trans_start, log_start, tools_start;
@@ -86,7 +86,7 @@
 #ifdef HAVE_GETTEXT
   setlocale (LC_ALL, "");
   bindtextdomain ("gftp", LOCALE_DIR);
-#if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION == 0
+#if GTK_MAJOR_VERSION > 1
   bind_textdomain_codeset ("gftp", "UTF-8");
 #endif
   textdomain ("gftp");
@@ -194,7 +194,7 @@
   GtkWidget *box, *dlbox, *winpane, *dlpane, *logpane, *mainvbox, *tempwid,
             *button;
   char *dltitles[2];
-#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2)
+#if GTK_MAJOR_VERSION > 1
   GtkTextBuffer * textbuf;
   GtkTextIter iter;
   GtkTextTag *tag;
@@ -229,7 +229,7 @@
   gtk_container_border_width (GTK_CONTAINER (dlbox), 5);
   gtk_box_pack_start (GTK_BOX (box), dlbox, FALSE, FALSE, 0);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   tempwid = toolbar_pixmap (ui, "right.xpm");
 #else
   tempwid = gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD,
@@ -242,7 +242,7 @@
 			     GTK_SIGNAL_FUNC (put_files), NULL);
   gtk_container_add (GTK_CONTAINER (button), tempwid);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   tempwid = toolbar_pixmap (ui, "left.xpm");
 #else
   tempwid = gtk_image_new_from_stock (GTK_STOCK_GO_BACK,
@@ -293,7 +293,7 @@
   log_table = gtk_table_new (1, 2, FALSE);
   gtk_widget_set_size_request (log_table, -1, log_height);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   logwdw = gtk_text_new (NULL, NULL);
 
   gtk_text_set_editable (GTK_TEXT (logwdw), FALSE);
@@ -645,7 +645,7 @@
   gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), protocol_menu);
   gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), num);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   tempwid = toolbar_pixmap (parent, "stop.xpm");
 #else
   tempwid = gtk_image_new_from_stock (GTK_STOCK_STOP,
@@ -810,7 +810,7 @@
 		      (gpointer) wdata);
   gtk_signal_connect_after (GTK_OBJECT (wdata->listbox), "key_press_event",
                             GTK_SIGNAL_FUNC (list_enter), (gpointer) wdata);
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   gtk_signal_connect_after (GTK_OBJECT (wdata->listbox), "button_press_event",
                             GTK_SIGNAL_FUNC (list_dblclick), (gpointer) wdata);
 #else
@@ -858,7 +858,7 @@
   else if (!GFTP_IS_CONNECTED (wdata->request) || !IS_ONE_SELECTED (wdata))
     return (TRUE);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   if (event->type == GDK_2BUTTON_PRESS && event->button == 1)
     {
       list_doaction (wdata);
@@ -1042,7 +1042,7 @@
     {
       sort_wid = gtk_clist_get_column_widget (clist, 0);
       gtk_widget_destroy (sort_wid);
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
       if (*wdata->sortasds)
 	sort_wid = toolbar_pixmap (wdata->listbox, "down.xpm");
       else
--- a/src/gtk/gftp-gtk.h	Wed Oct 30 22:56:30 2002 +0000
+++ b/src/gtk/gftp-gtk.h	Thu Oct 31 23:55:17 2002 +0000
@@ -30,7 +30,7 @@
 #define IS_ONE_SELECTED(wdata)		(GTK_CLIST ((wdata)->listbox)->selection && GTK_CLIST ((wdata)->listbox)->selection->next == NULL)
 #define IS_NONE_SELECTED(wdata)		(GTK_CLIST ((wdata)->listbox)->selection == NULL)
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   #define gtk_widget_set_size_request(widget, width, height)	\
 				gtk_widget_set_usize (widget, width, height)
 #endif
@@ -139,7 +139,7 @@
 extern GtkWidget * stop_btn, * hostedit, * useredit, * passedit,
                  * portedit, * logwdw, * dlwdw, * protocol_menu, * optionmenu;
 extern GtkAdjustment * logwdw_vadj;
-#if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION == 0
+#if GTK_MAJOR_VERSION > 1
 extern GtkTextMark * logwdw_textmark;
 #endif
 extern int local_start, remote_start, trans_start, log_start, tools_start;
--- a/src/gtk/menu-items.c	Wed Oct 30 22:56:30 2002 +0000
+++ b/src/gtk/menu-items.c	Thu Oct 31 23:55:17 2002 +0000
@@ -587,7 +587,7 @@
 clearlog (gpointer data)
 {
   guint len;
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   len = gtk_text_get_length (GTK_TEXT (logwdw));
   gtk_text_set_point (GTK_TEXT (logwdw), len);
   gtk_text_backward_delete (GTK_TEXT (logwdw), len);
@@ -611,7 +611,7 @@
   guint textlen;
   ssize_t len;
   int fd;
-#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2)
+#if GTK_MAJOR_VERSION > 1
   GtkTextBuffer * textbuf;
   GtkTextIter iter, iter2;
 #endif
@@ -628,7 +628,7 @@
   chmod (tempstr, S_IRUSR | S_IWUSR);
   unlink (tempstr);
   
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   textlen = gtk_text_get_length (GTK_TEXT (logwdw));
   txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1);
 #else
@@ -667,7 +667,7 @@
   ssize_t len;
   FILE *fd;
   int ok;
-#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2)
+#if GTK_MAJOR_VERSION > 1
   GtkTextBuffer * textbuf;
   GtkTextIter iter, iter2;
 #endif
@@ -681,7 +681,7 @@
       return;
     }
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   textlen = gtk_text_get_length (GTK_TEXT (logwdw));
   txt = gtk_editable_get_chars (GTK_EDITABLE (logwdw), 0, -1);
 #else
@@ -751,7 +751,7 @@
   char *tempstr, *no_license_agreement, *str, buf[255];
   size_t len;
   FILE * fd;
-#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2)
+#if GTK_MAJOR_VERSION > 1
   GtkTextBuffer * textbuf;
   GtkTextIter iter;
   guint textlen;
@@ -759,7 +759,7 @@
 
   no_license_agreement = g_strdup_printf (_("Cannot find the license agreement file COPYING. Please make sure it is in either %s or in %s"), BASE_CONF_DIR, SHARE_DIR);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   dialog = gtk_dialog_new ();
   gtk_window_set_title (GTK_WINDOW (dialog), _("About gFTP"));
   gtk_container_border_width (GTK_CONTAINER
@@ -823,7 +823,7 @@
   gtk_box_pack_start (GTK_BOX (box), tempwid, TRUE, TRUE, 0);
   gtk_widget_show (tempwid);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   view = gtk_text_new (NULL, NULL);
   gtk_text_set_editable (GTK_TEXT (view), FALSE);
   gtk_text_set_word_wrap (GTK_TEXT (view), TRUE);
@@ -864,7 +864,7 @@
 
   gtk_notebook_append_page (GTK_NOTEBOOK (notebook), box, label);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   tempwid = gtk_button_new_with_label (_("  Close  "));
   GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
@@ -891,7 +891,7 @@
           tempstr = expand_path (BASE_CONF_DIR "/COPYING");
 	  if (access (tempstr, F_OK) != 0)
 	    {
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
 	      gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL,
 			       no_license_agreement, -1);
 #else
@@ -907,7 +907,7 @@
 
   if ((fd = fopen (tempstr, "r")) == NULL)
     {
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
       gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL,
 		       no_license_agreement, -1);
 #else
@@ -925,7 +925,7 @@
   while ((len = fread (buf, 1, sizeof (buf) - 1, fd)))
     {
       buf[len] = '\0';
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
       gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, buf, -1);
 #else
       textlen = gtk_text_buffer_get_char_count (textbuf);
--- a/src/gtk/misc-gtk.c	Wed Oct 30 22:56:30 2002 +0000
+++ b/src/gtk/misc-gtk.c	Thu Oct 31 23:55:17 2002 +0000
@@ -44,7 +44,7 @@
   while (ret)
     {
       GDK_THREADS_LEAVE ();
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
       ret = g_main_iteration (FALSE);
 #else
       ret = g_main_context_iteration (NULL, FALSE);
@@ -69,20 +69,21 @@
 void
 ftp_log (gftp_logging_level level, void *ptr, const char *string, ...)
 {
-  char tempstr[512];
+  int upd, free_logstr;
   gftp_log * newlog;
+  char *logstr;
   gint delsize;
   va_list argp;
   guint len;
-  int upd;
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   gftp_color * color;
   GdkColor fore;
 #else
   GtkTextBuffer * textbuf;
   GtkTextIter iter, iter2;
+  gsize bread, bwrite;
   const char *descr;
-  guint inslen;
+  char *tempstr;
 #endif
 
   if (ptr == (void *) 0x1)
@@ -100,23 +101,39 @@
     }
 
   va_start (argp, string);
-  g_vsnprintf (tempstr, sizeof (tempstr), string, argp);
+  if (strcmp (string, "%s") == 0)
+    {
+      logstr = va_arg (argp, char *);
+      free_logstr = 0;
+    }
+  else
+    {
+      logstr = g_strdup_vprintf (string, argp);
+      free_logstr = 1;
+    }
   va_end (argp);
 
   if (logfd != NULL)
     {
-      if (fwrite (tempstr, strlen (tempstr), 1, logfd) != 1)
+      if (fwrite (logstr, strlen (logstr), 1, logfd) != 1)
         {
           fclose (logfd);
           logfd = NULL;
         }
       else
-        fflush (logfd);
+        {
+          fflush (logfd);
+          if (ferror (logfd))
+            {
+              fclose (logfd);
+              logfd = NULL;
+            }
+        }
     }
 
   upd = logwdw_vadj->upper - logwdw_vadj->page_size == logwdw_vadj->value;
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   switch (level)
     {
       case gftp_logging_send:
@@ -139,7 +156,7 @@
   fore.blue = color->blue;
 
   gtk_text_freeze (GTK_TEXT (logwdw));
-  gtk_text_insert (GTK_TEXT (logwdw), NULL, &fore, NULL, tempstr, -1);
+  gtk_text_insert (GTK_TEXT (logwdw), NULL, &fore, NULL, logstr, -1);
 
   len = gtk_text_get_length (GTK_TEXT (logwdw));
   if (max_log_window_size > 0 && len > max_log_window_size)
@@ -172,11 +189,24 @@
         break;
     }
 
+  /* If the current log message is not in UTF8 format, convert it to UTF8 
+     format based on the current locale */
+  if (!g_utf8_validate (logstr, -1, NULL))
+    {
+      tempstr = g_locale_to_utf8 (logstr, -1, &bread, &bwrite, NULL);
+      if (tempstr != NULL)
+        {
+          if (free_logstr)
+            g_free (logstr);
+          logstr = tempstr;
+          free_logstr = 1;
+        }
+    }
+
   textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (logwdw));
   len = gtk_text_buffer_get_char_count (textbuf);
-  inslen = strlen (tempstr);
   gtk_text_buffer_get_iter_at_offset (textbuf, &iter, len);
-  gtk_text_buffer_insert_with_tags_by_name (textbuf, &iter, tempstr, inslen, 
+  gtk_text_buffer_insert_with_tags_by_name (textbuf, &iter, logstr, -1, 
                                             descr, NULL);
 
   if (upd)
@@ -186,15 +216,22 @@
                                      0, 1, 1, 1);
     }
 
-  delsize = len + inslen - max_log_window_size;
-  if (max_log_window_size > 0 && delsize > 0)
+  if (max_log_window_size > 0)
     {
-      gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0);
-      gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, delsize);
-      gtk_text_buffer_delete (textbuf, &iter, &iter2);
+      delsize = len + g_utf8_strlen (logstr, -1) - max_log_window_size;
+
+      if (delsize > 0)
+        {
+          gtk_text_buffer_get_iter_at_offset (textbuf, &iter, 0);
+          gtk_text_buffer_get_iter_at_offset (textbuf, &iter2, delsize);
+          gtk_text_buffer_delete (textbuf, &iter, &iter2);
+        }
     }
 #endif
 
+  if (free_logstr)
+    g_free (logstr);
+
   if (ptr == NULL) 
     fix_display ();
 }
@@ -421,7 +458,7 @@
   if ((graphic = g_hash_table_lookup (graphic_hash_table, filename)) == NULL)
     return;
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   gdk_pixmap_unref (graphic->pixmap);
   gdk_bitmap_unref (graphic->bitmap);
 #else
@@ -792,7 +829,7 @@
 }
 
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
 static void
 ok_dialog_response (GtkWidget * widget, gftp_dialog_data * ddata)
 {
@@ -866,7 +903,7 @@
   ddata->nofunc = cancelfunc;
   ddata->nopointer = cancelptr;
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   dialog = gtk_dialog_new ();
   gtk_window_set_title (GTK_WINDOW (dialog), diagtxt);
   gtk_grab_add (dialog);
@@ -942,7 +979,7 @@
       gtk_widget_show (ddata->checkbox);
     }
       
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   switch (okbutton)
     {
       case gftp_dialog_button_create:
@@ -996,7 +1033,7 @@
 {
   GtkWidget * text, * dialog;
   gftp_dialog_data * ddata;
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   GtkWidget * tempwid;
 #endif
 
@@ -1006,7 +1043,7 @@
   ddata->nofunc = nofunc;
   ddata->nopointer = nopointer;
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   dialog = gtk_dialog_new ();
   gtk_grab_add (dialog);
   gtk_window_set_title (GTK_WINDOW (dialog), diagtxt);
@@ -1041,7 +1078,7 @@
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), text, TRUE, TRUE, 0);
   gtk_widget_show (text);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   tempwid = gtk_button_new_with_label (_("  Yes  "));
   GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
@@ -1142,7 +1179,7 @@
       while (wdata->request->stopable)
         {
           GDK_THREADS_LEAVE ();
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
           g_main_iteration (TRUE);
 #else
           g_main_context_iteration (NULL, TRUE);
--- a/src/gtk/options_dialog.c	Wed Oct 30 22:56:30 2002 +0000
+++ b/src/gtk/options_dialog.c	Thu Oct 31 23:55:17 2002 +0000
@@ -46,7 +46,7 @@
 static GList * new_proxy_hosts;
 static char *custom_proxy;
 
-#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2)
+#if GTK_MAJOR_VERSION > 1
 static void
 options_action (GtkWidget * widget, gint response, gpointer user_data)
 {
@@ -73,7 +73,7 @@
   int i, tbl_col, tbl_num, combo_num;
   GList * combo_list;
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   dialog = gtk_dialog_new ();
   gtk_window_set_title (GTK_WINDOW (dialog), _("Options"));
   gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area),
@@ -161,7 +161,7 @@
             tbl_num++;
             break;
           case CONFIG_TEXT:
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
             proxy_text = gtk_text_new (NULL, NULL);
             gtk_text_set_editable (GTK_TEXT (proxy_text), TRUE);
 #else
@@ -309,7 +309,7 @@
 
   make_proxy_hosts_tab (notebook);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   tempwid = gtk_button_new_with_label (_("OK"));
   GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
@@ -457,7 +457,7 @@
 }
 
 
-#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2)
+#if GTK_MAJOR_VERSION > 1
 static void
 proxyhosts_action (GtkWidget * widget, gint response, gpointer user_data)
 {
@@ -496,7 +496,7 @@
     }
 
   title = hosts ? _("Edit Host") : _("Add Host");
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   dialog = gtk_dialog_new ();
   gtk_window_set_title (GTK_WINDOW (dialog), title);
   gtk_container_border_width (GTK_CONTAINER
@@ -683,7 +683,7 @@
 	}
     }
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   tempwid = gtk_button_new_with_label (_("OK"));
   GTK_WIDGET_SET_FLAGS (tempwid, GTK_CAN_DEFAULT);
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
@@ -814,7 +814,7 @@
   int proxy_num;
   char *str;
 
-#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2)
+#if GTK_MAJOR_VERSION > 1
   GtkTextIter iter, iter2;
   GtkTextBuffer * textbuf;
   guint len;
@@ -826,7 +826,7 @@
   else
     str = proxy_type[proxy_num].description;
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   gtk_text_set_point (GTK_TEXT (proxy_text), 0);
   gtk_text_forward_delete (GTK_TEXT (proxy_text),
 			   gtk_text_get_length (GTK_TEXT (proxy_text)));
@@ -948,7 +948,7 @@
 {
   char *newstr, *oldstr, *pos, *endpos, *textstr;
   guint len;
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   char tmp[128];
 #else
   GtkTextBuffer * textbuf;
@@ -959,7 +959,7 @@
   newstr = g_malloc (1);
   *newstr = '\0';
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   /*
      GTK_TEXT uses wchar_t instead of char in environment of multibyte encoding
      locale (ex Japanese),  so we must convert from wide character 
@@ -1006,7 +1006,7 @@
     }
   while (endpos != NULL);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   if (!GTK_TEXT (proxy_text)->use_wchar)
     g_free (textstr);
 #else
--- a/src/gtk/transfer.c	Wed Oct 30 22:56:30 2002 +0000
+++ b/src/gtk/transfer.c	Thu Oct 31 23:55:17 2002 +0000
@@ -89,7 +89,7 @@
           while (wdata->request->stopable)
             {
               GDK_THREADS_LEAVE ();
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
               g_main_iteration (TRUE);
 #else
               g_main_context_iteration (NULL, TRUE);
@@ -258,7 +258,7 @@
           while (request->stopable)
             {
               GDK_THREADS_LEAVE ();
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
               g_main_iteration (TRUE);
 #else
               g_main_context_iteration (NULL, TRUE);
@@ -285,7 +285,7 @@
       while (request->stopable)
         {
           GDK_THREADS_LEAVE ();
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
           g_main_iteration (TRUE);
 #else
           g_main_context_iteration (NULL, TRUE);
@@ -450,7 +450,7 @@
           while (transfer->fromreq->stopable)
             {
               GDK_THREADS_LEAVE ();
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
               g_main_iteration (TRUE);
 #else
               g_main_context_iteration (NULL, TRUE);
@@ -1646,7 +1646,7 @@
   tdata->clist = gtk_clist_new_with_titles (4, dltitles);
   gtk_container_add (GTK_CONTAINER (scroll), tdata->clist);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   gtk_clist_set_selection_mode (GTK_CLIST (tdata->clist),
 				GTK_SELECTION_EXTENDED);
 #else
--- a/src/gtk/view_dialog.c	Wed Oct 30 22:56:30 2002 +0000
+++ b/src/gtk/view_dialog.c	Thu Oct 31 23:55:17 2002 +0000
@@ -174,7 +174,7 @@
   GList * templist;
   char buf[8192];
   ssize_t n;
-#if !(GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2)
+#if GTK_MAJOR_VERSION > 1
   GtkTextBuffer * textbuf;
   GtkTextIter iter;
   guint len;
@@ -244,7 +244,7 @@
                  g_strerror (errno));
     }
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   dialog = gtk_dialog_new ();
   gtk_window_set_title (GTK_WINDOW (dialog), filename);
   gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area),
@@ -271,7 +271,7 @@
   table = gtk_table_new (1, 2, FALSE);
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), table, TRUE, TRUE, 0);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   view = gtk_text_new (NULL, NULL);
   gtk_text_set_editable (GTK_TEXT (view), FALSE);
   gtk_text_set_word_wrap (GTK_TEXT (view), TRUE);
@@ -311,7 +311,7 @@
   gtk_widget_set_size_request (table, 500, 400);
   gtk_widget_show (table);
 
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
   tempwid = gtk_button_new_with_label (_("  Close  "));
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), tempwid,
 		      FALSE, FALSE, 0);
@@ -329,7 +329,7 @@
   while ((n = read (fd, buf, sizeof (buf) - 1)))
     {
       buf[n] = '\0';
-#if GTK_MAJOR_VERSION == 1 && GTK_MINOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 1
       gtk_text_insert (GTK_TEXT (view), NULL, NULL, NULL, buf, -1);
 #else
       textbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));