Re: [Nautilus-list] [PATCH] for bug 77174 (Nautilus sorts in opposite order when "sort in reverse order" chosen)



On Sun, 2002-04-07 at 16:49, Alex Larsson wrote:
> On Sun, 7 Apr 2002, David Emory Watson wrote:
> 
> > On Sun, 2002-04-07 at 14:38, Alex Larsson wrote:
> > > 
> > > Hmmm. It seems fm_list_model_add_file() has the same problem.
> > > 
> > > Also, it seems strange that SORT_ASCENDING means reverse sort. That 
> > 
> > Maybe (I also had a hard time deciding this). In any case the choice is
> > dictated by the following code, in src/file-manager/fm-list-view.c,
> > set_sort_order_from_metadata_and_preferences ():
> > 
> > 	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE
> > (list_view->details->model),
> > 					      sort_column_id,
> > 					      sort_reversed ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
> > 
> > --
> > 
> > This choice might be easier to justify if we think about the case of
> > sorting by size.  By default we should put smaller files after bigger
> > files, hence descending in the default case and ascending when the sort
> > is reversed.
> > 
> > What do you think?
> 
> I don't think it's *obvious* that the non-reversed sort by size means 
> smaller sizes last, both seem equally plausible.
>

Your definitely right that it's not obvious (I actually had to dig
around quite a bit to understand this bug).  Inside
libnautilus-private/nautilus-file.c, compare_by_size ():

static int
compare_by_size (NautilusFile *file_1, NautilusFile *file_2)
{
	/* Sort order:
	 *   Directories with n items
	 *   Directories with 0 items
	 *   Directories with "unknowable" # of items
	 *   Directories with unknown # of items
	 *   Files with large sizes.
	 *   Files with smaller sizes.
	 *   Files with "unknowable" size.
	 *   Files with unknown size.
	 */

> But we have to decide something.
> 
> Clearly the meaning of the names ascending and descending are obvious for 

So real meaning of GTK_SORT_ASCENDING is either use the default sort
order or reverse the default sort order.  What this means depends on how
the respective compare_by_* function works.

> both size and names. So let's make them mean the right thing. And 
> obviously the default sort order for names is ascending. So we should pick 
> that as the default one.

I think your right that we should pick GTK_SORT_ASCENDING for the
default.  Unfortunately, when I do this, I see the following bug (not
present otherwise):

1) Start up the list view.
2) Notice that the arrow on the file name column points down and the
files are sorted reverse alphabetically.
3) Click on the file name column.
4) Notice that the arrow on the file name column points up, but that
the.files are still sorted reverse alphabetically.
5) Click on the file name column again.
6) Now arrow points down and files are resorted alphabetically.

I don't quite understand why this happens when GTK_SORT_ASCENDING means
reversed but not when GTK_SORT_DESCENDING means reversed.  I will look
further...


Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5181
diff -p -u -r1.5181 ChangeLog
--- ChangeLog	5 Apr 2002 18:25:54 -0000	1.5181
+++ ChangeLog	8 Apr 2002 03:35:30 -0000
@@ -1,4 +1,22 @@
+2002-04-07  David Emory Watson  <dwatson cs ucr edu>
+
+	* src/file-manager/fm-list-model.c:
+	(fm_list_model_compare_func): Should be GTK_SORT_ASCENDING when
+	sort_reversed, bug 77174.
+
 2002-04-06  David Emory Watson  <dwatson cs ucr edu>
 
 	* src/file-manager/fm-list-model.c:
Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.164
diff -p -u -r1.164 fm-list-view.c
--- src/file-manager/fm-list-view.c	5 Apr 2002 18:25:57 -0000	1.164
+++ src/file-manager/fm-list-view.c	8 Apr 2002 03:35:41 -0000
@@ -329,10 +329,10 @@ set_sort_order_from_metadata_and_prefere
 	sort_reversed = nautilus_file_get_boolean_metadata (file,
 							    NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_REVERSED,
 							    default_sort_reversed_auto_value);

 	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_view->details->model),
 					      sort_column_id,
-					      sort_reversed ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
+					      sort_reversed ? GTK_SORT_DESCENDING : GTK_SORT_ASCENDING);
 }
 
 static void
@@ -451,7 +451,8 @@ fm_list_view_reset_to_defaults (FMDirect
 	gtk_tree_sortable_set_sort_column_id
 		(GTK_TREE_SORTABLE (FM_LIST_VIEW (view)->details->model),
 		 fm_list_model_get_sort_column_id_from_sort_type (default_sort_order_auto_value),
-		 default_sort_reversed_auto_value ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
+		 default_sort_reversed_auto_value ? GTK_SORT_DESCENDING : GTK_SORT_ASCENDING);
         fm_directory_view_restore_default_zoom_level (view);
 }


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