[PATCH] Resort changed files



When files are changed, the directory view has to resort them, because
an attribut relevant to sorting might have changed (e.g. the deep folder
count). To do this, you need to implement sort_files in the list view.
You won't notice this bug currently, because of the way the view
scheduling works now, but when you implement a more defensive scheduling
(I'm working on that) you'll notice that the list view doesn't get
properly resorted by size.

Martin

? mkinstalldirs
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.638
diff -u -p -r1.638 fm-directory-view.c
--- src/file-manager/fm-directory-view.c	1 Oct 2004 15:57:40 -0000	1.638
+++ src/file-manager/fm-directory-view.c	3 Oct 2004 16:49:42 -0000
@@ -2304,7 +2304,7 @@ ready_to_load (NautilusFile *file)
 /* Go through all the new added and changed files.
  * Put any that are not ready to load in the non_ready_files hash table.
  * Add all the rest to the old_added_files and old_changed_files lists.
- * Sort the old_added_files list if anything is added to it.
+ * Sort the old_*_files lists if anything was added to them.
  */
 static void
 process_new_files (FMDirectoryView *view)
@@ -2379,7 +2379,16 @@ process_new_files (FMDirectoryView *view
 		EEL_INVOKE_METHOD (FM_DIRECTORY_VIEW_CLASS, view, sort_files,
 				   (view, &view->details->old_added_files));
 	}
-	view->details->old_changed_files = old_changed_files;
+
+	/* Resort old_changed_files too, since file attributes
+	 * relevant to sorting could have changed.
+	 */
+	if (old_changed_files != view->details->old_changed_files) {
+		view->details->old_changed_files = old_changed_files;
+		EEL_INVOKE_METHOD (FM_DIRECTORY_VIEW_CLASS, view, sort_files,
+				   (view, &view->details->old_changed_files));
+	}
+
 }
 
 static GList *
Index: src/file-manager/fm-list-model.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-model.c,v
retrieving revision 1.33
diff -u -p -r1.33 fm-list-model.c
--- src/file-manager/fm-list-model.c	1 Oct 2004 12:55:45 -0000	1.33
+++ src/file-manager/fm-list-model.c	3 Oct 2004 16:49:42 -0000
@@ -472,6 +472,11 @@ fm_list_model_sort (FMListModel *model)
 	g_free (new_order);
 }
 
+void
+fm_list_model_sort_files (FMListModel *model, GList **files)
+{
+	*files = g_list_sort_with_data (*files, fm_list_model_compare_func, model);
+}
 
 static gboolean
 fm_list_model_get_sort_column_id (GtkTreeSortable *sortable,
Index: src/file-manager/fm-list-model.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-model.h,v
retrieving revision 1.11
diff -u -p -r1.11 fm-list-model.h
--- src/file-manager/fm-list-model.h	27 Feb 2004 21:59:59 -0000	1.11
+++ src/file-manager/fm-list-model.h	3 Oct 2004 16:49:42 -0000
@@ -90,6 +90,8 @@ int      fm_list_model_get_sort_column_i
 							  const char           *attribute);
 char    *fm_list_model_get_attribute_from_sort_column_id (FMListModel *model,
 							  int sort_column_id);
+void     fm_list_model_sort_files (FMListModel *model,
+							  GList **files);
 
 NautilusZoomLevel fm_list_model_get_zoom_level_from_column_id (int               column);
 int               fm_list_model_get_column_id_from_zoom_level (NautilusZoomLevel zoom_level);
Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.228
diff -u -p -r1.228 fm-list-view.c
--- src/file-manager/fm-list-view.c	6 Sep 2004 09:00:51 -0000	1.228
+++ src/file-manager/fm-list-view.c	3 Oct 2004 16:49:43 -0000
@@ -1935,6 +1935,16 @@ fm_list_view_sort_directories_first_chan
 }
 
 static void
+fm_list_view_sort_files (FMDirectoryView *view, GList **files)
+{
+	FMListView *list_view;
+
+	list_view = FM_LIST_VIEW (view);
+
+	fm_list_model_sort_files (list_view->details->model, files);
+}
+
+static void
 fm_list_view_dispose (GObject *object)
 {
 	FMListView *list_view;
@@ -2096,6 +2106,7 @@ fm_list_view_class_init (FMListViewClass
 	fm_directory_view_class->reveal_selection = fm_list_view_reveal_selection;
 	fm_directory_view_class->select_all = fm_list_view_select_all;
 	fm_directory_view_class->set_selection = fm_list_view_set_selection;
+	fm_directory_view_class->sort_files = fm_list_view_sort_files;
 	fm_directory_view_class->sort_directories_first_changed = fm_list_view_sort_directories_first_changed;
 	fm_directory_view_class->start_renaming_file = fm_list_view_start_renaming_file;
 	fm_directory_view_class->zoom_to_level = fm_list_view_zoom_to_level;


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