--- file-manager/fm-directory-view.c.ORG	Thu Oct 16 01:18:38 2003
+++ file-manager/fm-directory-view.c	Thu Oct 16 03:02:22 2003
@@ -191,6 +191,12 @@ static gboolean use_new_window_auto_valu
 static char *scripts_directory_uri;
 static int scripts_directory_uri_length;
 
+typedef struct FMDirectoryViewDir
+{
+        FMDirectoryView *view;
+        NautilusDirectory *current;
+} FMDirectoryViewDir;
+
 struct FMDirectoryViewDetails
 {
 	NautilusView *nautilus_view;
@@ -4149,7 +4155,7 @@ directory_belongs_in_scripts_menu (const
 }
 
 static gboolean
-update_directory_in_scripts_menu (FMDirectoryView *view, NautilusDirectory *directory)
+update_directory_in_scripts_menu2 (FMDirectoryView *view, NautilusDirectory *directory)
 {
 	char *menu_path, *popup_path, *popup_bg_path;
 	GList *file_list, *filtered, *node;
@@ -4205,10 +4211,35 @@ update_directory_in_scripts_menu (FMDire
 	g_free (popup_path);
 	g_free (popup_bg_path);
 	g_free (menu_path);
+        g_free (directory);
 
 	return any_scripts;
 }
 
+static gboolean
+update_directory_in_scripts_menu_cbk (gpointer data)
+{
+        FMDirectoryViewDir *viewDir;
+                                                                                
+        viewDir = (FMDirectoryViewDir *)data;
+        update_directory_in_scripts_menu2(viewDir->view, viewDir->current);
+        g_free(viewDir);
+                                                                                
+        return FALSE;
+}
+
+static gboolean
+update_directory_in_scripts_menu (FMDirectoryView *view, NautilusDirectory *directory, int dlay)
+{
+        FMDirectoryViewDir *viewDir;
+
+        viewDir = g_new(FMDirectoryViewDir, 1);
+        viewDir->view = view;
+        viewDir->current = g_new(NautilusDirectory, 1);
+        memcpy(viewDir->current, directory, sizeof(NautilusDirectory));
+        g_timeout_add (dlay, update_directory_in_scripts_menu_cbk, viewDir);
+}
+
 static void
 update_scripts_menu (FMDirectoryView *view)
 {
@@ -4216,6 +4247,7 @@ update_scripts_menu (FMDirectoryView *vi
 	GList *sorted_copy, *node;
 	NautilusDirectory *directory;
 	char *uri;
+        int  dlay=50;
 
 	/* There is a race condition here.  If we don't mark the scripts menu as
 	   valid before we begin our task then we can lose script menu updates that
@@ -4239,8 +4271,9 @@ update_scripts_menu (FMDirectoryView *vi
 		uri = nautilus_directory_get_uri (directory);
 		if (!directory_belongs_in_scripts_menu (uri)) {
 			remove_directory_from_scripts_directory_list (view, directory);
-		} else if (update_directory_in_scripts_menu (view, directory)) {
+		} else if (update_directory_in_scripts_menu (view, directory, dlay)) {
 			any_scripts = TRUE;
+ 			dlay += 1000;
 		}
 		g_free (uri);
 	}
@@ -4983,7 +5016,7 @@ schedule_update_menus (FMDirectoryView *
 	if (view->details->menus_merged
 	    && view->details->update_menus_timeout_id == 0) {
 		view->details->update_menus_timeout_id
-			= g_timeout_add (300, update_menus_timeout_callback, view);
+			= g_timeout_add (10000, update_menus_timeout_callback, view);
 	}
 }
 
