[Nautilus-list] [PATCH]: avoid directory reloading when not needed.



[first mail didn't get throught, retrying...]

Here it is, 

What the patch does currently is that it make reloading
happen either :

- when the refresh button is used.
- when a new window is opened.

For the second case, it would be good to be able to know
if a window already display the directory.

Is the patch clean / right enough to commit ?

Index: src/nautilus-window-manage-views.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-manage-views.c,v
retrieving revision 1.266
diff -u -p -r1.266 nautilus-window-manage-views.c
--- src/nautilus-window-manage-views.c	2001/06/02 19:39:16	1.266
+++ src/nautilus-window-manage-views.c	2001/06/14 18:11:00
@@ -685,6 +685,8 @@ open_location (NautilusWindow *window,
 {
         NautilusWindow *target_window;
         gboolean create_new_window;
+        NautilusDirectory *directory;
+        NautilusFile *file;
         
         target_window = window;
         create_new_window = force_new_window;
@@ -708,13 +710,20 @@ open_location (NautilusWindow *window,
                 }
         }
 
+        directory = nautilus_directory_get (location);
+        
         if (create_new_window) {
+                /* In all 4 cases, we want fresh information. */
+                file = nautilus_directory_get_corresponding_file (directory);
+                nautilus_file_invalidate_all_attributes (file);
+                nautilus_file_unref (file);
+                nautilus_directory_force_reload (directory);
                 target_window = nautilus_application_create_window (window->application);
         }
 
 	eel_g_list_free_deep (target_window->details->pending_selection);
         target_window->details->pending_selection = eel_g_str_list_copy (new_selection);
-
+        
         begin_location_change (target_window, location,
                                NAUTILUS_LOCATION_CHANGE_STANDARD, 0);
 }
@@ -1366,9 +1375,6 @@ begin_location_change (NautilusWindow *w
                        NautilusLocationChangeType type,
                        guint distance)
 {
-        NautilusDirectory *directory;
-        NautilusFile *file;
-
         g_assert (NAUTILUS_IS_WINDOW (window));
         g_assert (location != NULL);
         g_assert (type == NAUTILUS_LOCATION_CHANGE_BACK
@@ -1383,14 +1389,6 @@ begin_location_change (NautilusWindow *w
         window->details->location_change_type = type;
         window->details->location_change_distance = distance;
 
-        directory = nautilus_directory_get (location);
-
-        /* In all 4 cases, we want fresh information. */
-        nautilus_directory_force_reload (directory);
-        file = nautilus_directory_get_corresponding_file (directory);
-        nautilus_file_invalidate_all_attributes (file);
-        nautilus_file_unref (file);
-
         window->details->determine_view_handle = nautilus_determine_initial_view
                 (location,
                  determined_initial_view_callback,
@@ -1796,7 +1794,7 @@ open_location_force_new_window_callback 
                                          NautilusWindow *window)
 {
         g_assert (NAUTILUS_IS_WINDOW (window));
-
+        
         open_location (window, location, TRUE, selection);
 }
 
@@ -1985,9 +1983,10 @@ nautilus_window_back_or_forward (Nautilu
 	
 	list = back ? window->back_list : window->forward_list;
 	g_assert (g_list_length (list) > distance);
+
+        uri = nautilus_bookmark_get_uri (g_list_nth_data (list, distance));
 
-	uri = nautilus_bookmark_get_uri (g_list_nth_data (list, distance));
-	begin_location_change
+        begin_location_change
 		(window,
 		 uri,
 		 back ? NAUTILUS_LOCATION_CHANGE_BACK : NAUTILUS_LOCATION_CHANGE_FORWARD,
@@ -2001,14 +2000,25 @@ void
 nautilus_window_reload (NautilusWindow *window)
 {
 	char *location;
-	
+	NautilusDirectory *directory;
+        NautilusFile *file;
+        
         g_return_if_fail (NAUTILUS_IS_WINDOW (window));
 
 	/* window->details->location can be free'd during the processing
 	 * of begin_location_change, so make a copy
 	 */
 	location = g_strdup (window->details->location);
-	begin_location_change
+
+        directory = nautilus_directory_get (location);
+
+        /* In all 4 cases, we want fresh information. */
+        nautilus_directory_force_reload (directory);
+        file = nautilus_directory_get_corresponding_file (directory);
+        nautilus_file_invalidate_all_attributes (file);
+        nautilus_file_unref (file);
+        
+        begin_location_change
 		(window, location,
 		 NAUTILUS_LOCATION_CHANGE_RELOAD, 0);
 	g_free (location);
-- 
Yoann Vandoorselaere | In a world without walls or fences,
MandrakeSoft         | what use do we have for windows or gates?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]