Index: gtk/gtkfilechooserdefault.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilechooserdefault.c,v
retrieving revision 1.240.2.20
diff -u -p -r1.240.2.20 gtkfilechooserdefault.c
--- gtk/gtkfilechooserdefault.c	23 May 2005 17:02:04 -0000	1.240.2.20
+++ gtk/gtkfilechooserdefault.c	25 May 2005 13:17:01 -0000
@@ -6304,7 +6304,6 @@ location_popup_handler (GtkFileChooserDe
   GtkWidget *hbox;
   GtkWidget *label;
   GtkWidget *entry;
-  gboolean refocus;
   const char *title;
   const char *accept_stock;
 
@@ -6364,8 +6363,6 @@ location_popup_handler (GtkFileChooserDe
   if (path[0])
     gtk_editable_select_region (GTK_EDITABLE (entry), -1, -1);
 
-  refocus = TRUE;
-
   if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
     {
       if (update_from_entry (impl, GTK_WINDOW (dialog), GTK_FILE_CHOOSER_ENTRY (entry)))
@@ -6381,18 +6378,45 @@ location_popup_handler (GtkFileChooserDe
 			|| impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
 	      gtk_widget_grab_focus (impl->save_file_name_entry);
 	    }
-	  refocus = FALSE;
-	}
-    }
 
-  if (refocus)
-    {
-      GtkWindow *toplevel;
+          gtk_widget_destroy (dialog);
 
-      toplevel = get_toplevel (GTK_WIDGET (impl));
-      if (toplevel && toplevel->focus_widget)
-	gtk_widget_grab_focus (toplevel->focus_widget);
+          if (toplevel && GTK_IS_DIALOG (toplevel))
+            {
+              GtkDialog *dialog = GTK_DIALOG (toplevel);
+              GList *children, *l;
+
+              /* There probably isn't a default widget, so make
+               * things easier for the programmer by looking for a
+               * reasonable button on our own.
+               */
+
+              children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area));
+
+              for (l = children; l; l = l->next)
+                {
+                  GtkWidget *widget = GTK_WIDGET (l->data);
+                  int response_id;
+
+                  response_id = _gtk_dialog_get_response_for_widget (dialog,
+                                                                     widget);
+                  if (response_id == GTK_RESPONSE_ACCEPT
+                      || response_id == GTK_RESPONSE_OK
+                      || response_id == GTK_RESPONSE_YES
+                      || response_id == GTK_RESPONSE_APPLY)
+                    {
+                      gtk_dialog_response (dialog, response_id);
+                      break;
+                    }
+                }
+            }
+
+          return;
+	}
     }
+
+  if (toplevel && toplevel->focus_widget)
+    gtk_widget_grab_focus (toplevel->focus_widget);
 
   gtk_widget_destroy (dialog);
 }
