[Nautilus-list] patch for directory view as list



Hi,

when viewing a directory as list, up/down/pageup/pagedown keys do not
work
as expected.  This is happening with the latest (2000-10-16) from cvs.

Switch to "view as list", press up and down arrow keys,
only the last, then the first, file is selected (instead of moving
the selection up and down the list), and these messages are displayed:

** CRITICAL **: file nautilus-gtk-extensions.c: line 133
(nautilus_gtk_clist_get_first_selected_row): assertion `GTK_IS_CLIST
(list)' failed.

** CRITICAL **: file nautilus-gtk-extensions.c: line 161
(nautilus_gtk_clist_get_last_selected_row): assertion `GTK_IS_CLIST
(list)' failed.

Looking in libnautilus-extensions/nautilus-list.c around line 1207:
static int
nautilus_clist_get_first_selected_row (NautilusCList  *list)
{
        return nautilus_gtk_clist_get_first_selected_row ((GtkCList
*)list);
}
                                                          ^^^^^^^^^^^
This cast is incorrect, since GtkCList was replaced with NautilusCList
as the parent class of NautilusList (on 2000-10-03).

I've attached a patch.

Should `nautilus_clist_get_first_selected_row' and
`nautilus_clist_get_last_selected_row' be in:
cut-n-paste-code/widgets/nautilusclist/nautilusclist.[ch] instead?
In this patch I left them in: libnautilus-extensions/nautilus-list.c
because cut-n-paste-code/README said not to modify code under
cut-n-paste-code/
(despite the fact that cut-n-paste-code/widgets/nautilusclist is a
modification of the original gtkclist code).

Matt


? idl/Makefile.in
? idl/Makefile
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.2366
diff -u -r1.2366 ChangeLog
--- ChangeLog	2000/10/15 07:56:04	1.2366
+++ ChangeLog	2000/10/16 06:32:12
@@ -1,3 +1,18 @@
+2000-10-16  Matt Bissiri  <bissiri eecs umich edu>
+
+	* libnautilus-extensions/nautilus-list.c:
+	(nautilus_clist_get_first_selected_row),
+	(nautilus_clist_get_last_selected_row):
+	Now that NautilusList derives from NautilusCList instead of GtkCList,
+	do not call `nautilus_gtk_clist_get_first_selected_row' or
+	`nautilus_gtk_clist_get_last_selected_row'.
+	Instead add implementation using NautilusCList instead of GtkCList.
+	This fixes a bug where up/down/pgup/pgdown keys did not work properly
+	when viewing directory as list.
+	(nautilus_list_get_first_selected_row):
+	To avoid code duplication, replace the body of this function
+	with a call to `nautilus_clist_get_first_selected_row'.
+
 2000-10-15  Andy Hertzfeld  <andy eazel com>
 
 	* src/nautilus-throbber.c: (load_themed_image),
Index: libnautilus-extensions/nautilus-list.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-extensions/nautilus-list.c,v
retrieving revision 1.80
diff -u -r1.80 nautilus-list.c
--- libnautilus-extensions/nautilus-list.c	2000/10/13 06:21:12	1.80
+++ libnautilus-extensions/nautilus-list.c	2000/10/16 06:32:13
@@ -1202,15 +1202,43 @@
 }
 
 static int
-nautilus_clist_get_first_selected_row (NautilusCList  *list)
+nautilus_clist_get_first_selected_row (NautilusCList *list)
 {
-	return nautilus_gtk_clist_get_first_selected_row ((GtkCList *)list);
+	NautilusCListRow *row;
+	GList *p;
+	int row_index;
+
+	g_return_val_if_fail (NAUTILUS_IS_CLIST (list), -1);
+
+	for (p = NAUTILUS_CLIST (list)->row_list, row_index = 0; 
+	     p != NULL; 
+	     p = p->next, ++row_index) {
+		row = p->data;
+		if (row->state == GTK_STATE_SELECTED) 
+			return row_index;
+	}
+
+	return -1;
 }
 
 static int
 nautilus_clist_get_last_selected_row (NautilusCList *list)
 {
-	return nautilus_gtk_clist_get_last_selected_row ((GtkCList *)list);
+	NautilusCListRow *row;
+	GList *p;
+	int row_index;
+
+	g_return_val_if_fail (NAUTILUS_IS_CLIST (list), -1);
+
+	for (p = NAUTILUS_CLIST (list)->row_list_end, row_index = NAUTILUS_CLIST (list)->rows - 1; 
+	     p != NULL; 
+	     p = p->prev, --row_index) {
+		row = p->data;
+		if (row->state == GTK_STATE_SELECTED) 
+			return row_index;
+	}
+
+	return -1;
 }
 
 static void
@@ -3346,21 +3374,13 @@
 int
 nautilus_list_get_first_selected_row (NautilusList *list)
 {
-	NautilusCListRow *row;
-	GList *p;
-	int row_index;
+	NautilusCList *clist;
 
 	g_return_val_if_fail (NAUTILUS_IS_LIST (list), -1);
-
-	for (p = NAUTILUS_CLIST (list)->row_list, row_index = 0; 
-	     p != NULL; 
-	     p = p->next, ++row_index) {
-		row = p->data;
-		if (row->state == GTK_STATE_SELECTED) 
-			return row_index;
-	}
 
-	return -1;
+	clist = NAUTILUS_CLIST (list);
+	
+	return nautilus_clist_get_first_selected_row (clist);
 }
 
 /* Workaround for a bug in GtkCList's insert_row.


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