Index: gtkfilesel.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilesel.c,v
retrieving revision 1.93
diff -u -r1.93 gtkfilesel.c
--- gtkfilesel.c	2001/11/21 17:04:34	1.93
+++ gtkfilesel.c	2001/11/29 21:29:40
@@ -92,6 +92,8 @@
 #define FILE_LIST_WIDTH  180
 #define FILE_LIST_HEIGHT 180
 
+#define OLD_FILENAME_KEY "gtk-filename-before-dir-selection"
+
 /* The Hurd doesn't define either PATH_MAX or MAXPATHLEN, so we put this
  * in here, since the rest of the code in the file does require some
  * fixed maximum.
@@ -1832,6 +1834,7 @@
 {
   GtkFileSelection *fs = NULL;
   gchar *filename, *temp = NULL;
+  const gchar *old_filename;
 
   g_return_if_fail (GTK_IS_CLIST (widget));
 
@@ -1840,6 +1843,19 @@
 
   gtk_clist_get_text (GTK_CLIST (fs->dir_list), row, 0, &temp);
   filename = g_strdup (temp);
+  old_filename = gtk_entry_get_text (GTK_ENTRY (fs->selection_entry));
+
+  if (bevent && bevent->type != GDK_2BUTTON_PRESS)
+    {
+      gchar *tmp = g_object_get_data (G_OBJECT (fs->selection_entry),
+				      OLD_FILENAME_KEY);
+      
+      if (tmp)
+	g_free (tmp);
+      
+      g_object_set_data (G_OBJECT (fs->selection_entry),
+			 OLD_FILENAME_KEY, NULL);
+    }
 
   if (filename)
     {
@@ -1851,6 +1867,8 @@
 	    break;
 	  
 	  default:
+	    g_object_set_data (G_OBJECT (fs->selection_entry),
+			       OLD_FILENAME_KEY, g_strdup (old_filename));
 	    gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), filename);
 	    break;
 	  }
@@ -2023,7 +2041,20 @@
   else
     {
       if (fs->selection_entry)
-	gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), "");
+	{
+	  gchar *tmp = g_object_get_data (G_OBJECT (fs->selection_entry),
+					  OLD_FILENAME_KEY);
+	  g_object_set_data (G_OBJECT (fs->selection_entry),
+			     OLD_FILENAME_KEY, NULL);
+	  
+	  if (tmp)
+	    {
+	      gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), tmp);
+	      g_free (tmp);
+	    }
+	  else
+	    gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), "");
+	}
     }
 
   if (!did_recurse)
