--- gtk+-1.2.10/gtk/gtkfilesel.c.deletedir	Thu Feb 15 23:36:19 2001
+++ gtk+-1.2.10/gtk/gtkfilesel.c	Wed Apr 17 20:36:25 2002
@@ -325,7 +325,8 @@
 
 static void gtk_file_selection_populate      (GtkFileSelection      *fs,
 					      gchar                 *rel_path,
-					      gint                   try_complete);
+					      gboolean               try_complete,
+					      gboolean               reset_entry);
 static void gtk_file_selection_abort         (GtkFileSelection      *fs);
 
 static void gtk_file_selection_update_history_menu (GtkFileSelection       *fs,
@@ -522,7 +523,7 @@
     }
   else
     {
-      gtk_file_selection_populate (filesel, "", FALSE);
+      gtk_file_selection_populate (filesel, "", FALSE, TRUE);
     }
 
   gtk_widget_grab_focus (filesel->selection_entry);
@@ -637,7 +638,7 @@
       name = last_slash + 1;
     }
 
-  gtk_file_selection_populate (filesel, buf, FALSE);
+  gtk_file_selection_populate (filesel, buf, FALSE, TRUE);
 
   if (filesel->selection_entry)
     gtk_entry_set_text (GTK_ENTRY (filesel->selection_entry), name);
@@ -673,7 +674,7 @@
 
   if (filesel->selection_entry)
     gtk_entry_set_text (GTK_ENTRY (filesel->selection_entry), pattern);
-  gtk_file_selection_populate (filesel, (gchar*) pattern, TRUE);
+  gtk_file_selection_populate (filesel, (gchar*) pattern, TRUE, TRUE);
 }
 
 static void
@@ -806,7 +807,7 @@
   g_free (full_path);
   
   gtk_widget_destroy (fs->fileop_dialog);
-  gtk_file_selection_populate (fs, "", FALSE);
+  gtk_file_selection_populate (fs, "", FALSE, FALSE);
 }
   
 static void
@@ -903,7 +904,7 @@
   g_free (full_path);
   
   gtk_widget_destroy (fs->fileop_dialog);
-  gtk_file_selection_populate (fs, "", FALSE);
+  gtk_file_selection_populate (fs, "", FALSE, TRUE);
 }
 
 static void
@@ -1009,8 +1010,9 @@
   g_free (new_filename);
   g_free (old_filename);
   
+  gtk_file_selection_populate (fs, "", FALSE, FALSE);
+  gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), file);
   gtk_widget_destroy (fs->fileop_dialog);
-  gtk_file_selection_populate (fs, "", FALSE);
 }
   
 static void
@@ -1112,7 +1114,7 @@
 
       text = g_strdup (text);
 
-      gtk_file_selection_populate (fs, text, TRUE);
+      gtk_file_selection_populate (fs, text, TRUE, TRUE);
 
       g_free (text);
 
@@ -1124,7 +1126,6 @@
   return FALSE;
 }
 
-
 static void
 gtk_file_selection_history_callback (GtkWidget *widget, gpointer data)
 {
@@ -1142,7 +1143,7 @@
     
     if (callback_arg->menu_item == widget)
       {
-	gtk_file_selection_populate (fs, callback_arg->directory, FALSE);
+	gtk_file_selection_populate (fs, callback_arg->directory, FALSE, FALSE);
 	break;
       }
     
@@ -1272,7 +1273,7 @@
 			       gpointer user_data)
 {
   GtkFileSelection *fs = NULL;
-  gchar *filename, *temp = NULL;
+  gchar *filename = NULL;
 
   g_return_if_fail (GTK_IS_CLIST (widget));
 
@@ -1280,39 +1281,23 @@
   g_return_if_fail (fs != NULL);
   g_return_if_fail (GTK_IS_FILE_SELECTION (fs));
 
-  gtk_clist_get_text (GTK_CLIST (fs->dir_list), row, 0, &temp);
-  filename = g_strdup (temp);
-
-  if (filename)
-    {
-      if (bevent)
-	switch (bevent->type)
-	  {
-	  case GDK_2BUTTON_PRESS:
-	    gtk_file_selection_populate (fs, filename, FALSE);
-	    break;
-	  
-	  default:
-	    gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), filename);
-	    break;
-	  }
-      else
-	gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), filename);
-
-      g_free (filename);
-    }
+  gtk_clist_get_text (GTK_CLIST (fs->dir_list), row, 0, &filename);
+  
+  if (filename && bevent && bevent->type == GDK_2BUTTON_PRESS)
+    gtk_file_selection_populate (fs, filename, FALSE, FALSE);
 }
 
 static void
 gtk_file_selection_populate (GtkFileSelection *fs,
 			     gchar            *rel_path,
-			     gint              try_complete)
+			     gboolean          try_complete,
+			     gboolean          reset_entry)
 {
   CompletionState *cmpl_state;
   PossibleCompletion* poss;
   gchar* filename;
   gint row;
-  gchar* rem_path = rel_path;
+  gchar* rem_path;
   gchar* sel_text;
   gchar* text[2];
   gint did_recurse = FALSE;
@@ -1323,6 +1308,8 @@
   
   g_return_if_fail (fs != NULL);
   g_return_if_fail (GTK_IS_FILE_SELECTION (fs));
+
+  rem_path = rel_path = g_strdup (rel_path);
   
   cmpl_state = (CompletionState*) fs->cmpl_state;
   poss = cmpl_completion_matches (rel_path, &rem_path, cmpl_state);
@@ -1422,7 +1409,7 @@
 
               did_recurse = TRUE;
 
-              gtk_file_selection_populate (fs, dir_name, TRUE);
+              gtk_file_selection_populate (fs, dir_name, TRUE, TRUE);
 
               g_free (dir_name);
             }
@@ -1441,7 +1428,7 @@
 	    gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), rem_path);
         }
     }
-  else
+  else if (reset_entry)
     {
       if (fs->selection_entry)
 	gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), "");
@@ -1466,8 +1453,9 @@
 	{
 	  gtk_file_selection_update_history_menu (fs, cmpl_reference_position (cmpl_state));
 	}
-      
     }
+
+  g_free (rel_path);
 }
 
 static void
