Index: panel-run-dialog.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-run-dialog.c,v
retrieving revision 1.23
diff -u -r1.23 panel-run-dialog.c
--- panel-run-dialog.c	12 Feb 2004 09:40:00 -0000	1.23
+++ panel-run-dialog.c	3 Mar 2004 20:55:14 -0000
@@ -76,6 +76,7 @@
 	GtkListStore     *program_list_store;
 
 	GList            *executables;
+	GList						 *valid_executables;
 	GCompletion      *completion;
 	
 	GSList           *add_icon_paths;
@@ -138,6 +139,12 @@
 	g_list_free (dialog->executables);
 	dialog->executables = NULL;
 
+	for (l = dialog->valid_executables; l; l = l->next)
+		g_free (l->data);
+	g_list_free (dialog->valid_executables);
+	dialog->executables = NULL;
+
+
 	if (dialog->completion)
 		g_completion_free (dialog->completion);
 	dialog->completion = NULL;
@@ -1075,7 +1082,6 @@
 	struct dirent *dent;
 	DIR           *dir;
 	char          *file;
-	struct stat    file_stat;
 
 	dir = opendir (dirname);
 
@@ -1085,10 +1091,8 @@
 	while ((dent = readdir (dir))) {
 		file = g_build_filename (dirname, dent->d_name, NULL);
 
-		if (!access (file, X_OK) &&
-		    !stat (file, &file_stat) && !S_ISDIR (file_stat.st_mode))
-			dialog->executables = g_list_prepend (dialog->executables,
-							      g_strdup (dent->d_name));
+		dialog->executables = g_list_prepend (dialog->executables,
+																					g_strdup (file));
 		
 		g_free (file);
 	}
@@ -1112,18 +1116,47 @@
 
 	for (i = 0; pathv [i]; i++)
 		panel_run_dialog_fill_executables_from (dialog, pathv[i]);
-	
+
 	g_strfreev (pathv);
 }
 
+static gboolean
+panel_run_dialog_ensure_completion_idle_handler (PanelRunDialog *dialog)
+{
+	int	i;
+	char *file = NULL;
+	struct stat file_stat;
+	
+	// Handle in batches of 100 to prevent blocking user input
+	for (i = 0; i < 100 && dialog->executables; i++)
+	{
+		file = dialog->executables->data;
+		if (!access (file, X_OK) &&
+		    !stat (file, &file_stat) && !S_ISDIR (file_stat.st_mode))
+
+			dialog->valid_executables = g_list_prepend (dialog->valid_executables, g_path_get_basename (file));
+		
+		dialog->executables = g_list_next (dialog->executables);
+	}
+
+	// Give it what we've got so far.
+	g_completion_add_items (dialog->completion, dialog->valid_executables);
+
+	// We're at the end of the possible executables, our work is over, don't repeat.
+	if (!dialog->executables)
+		return FALSE;
+	
+	return TRUE;
+}
+
 static void
 panel_run_dialog_ensure_completion (PanelRunDialog *dialog)
 {
 	if (!dialog->completion) {
 		dialog->completion = g_completion_new (NULL);
 		panel_run_dialog_fill_executables (dialog);
-
-		g_completion_add_items (dialog->completion, dialog->executables);
+		
+		g_idle_add ((GSourceFunc) panel_run_dialog_ensure_completion_idle_handler, dialog);
 	}
 }
 
@@ -1454,7 +1487,7 @@
 
 	gtk_widget_grab_focus (dialog->gtk_entry);
 	gtk_widget_show (dialog->run_dialog);
-	
+
 	return dialog;
 }
 
