[PATCH] Fix scroll position code for manual layout



Filed as bug 157415 [1]:
The old scroll position code just took the next best icon matching the
scrolled window criterion, and didn't take into account that
permutations of container->details->icons should lead to the same result
to work correctly in manual layout.

Proposed patch attached.

[1] http://bugzilla.gnome.org/show_bug.cgi?id=157415

-- 
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-icon-container.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.c,v
retrieving revision 1.393
diff -u -p -r1.393 nautilus-icon-container.c
--- libnautilus-private/nautilus-icon-container.c	12 Aug 2005 18:11:29 -0000	1.393
+++ libnautilus-private/nautilus-icon-container.c	25 Aug 2005 21:20:43 -0000
@@ -4635,10 +4642,11 @@ NautilusIconData *
 nautilus_icon_container_get_first_visible_icon (NautilusIconContainer *container)
 {
 	GList *l;
-	NautilusIcon *icon;
+	NautilusIcon *icon, *best_icon;
 	GtkAdjustment *vadj;
 	double x, y;
 	double x1, y1, x2, y2;
+	double best_y1;
 
 	vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (container));
 
@@ -4647,6 +4655,8 @@ nautilus_icon_container_get_first_visibl
 			&x, &y);
 
 	l = container->details->icons;
+	best_icon = NULL;
+	best_y1 = 0;
 	while (l != NULL) {
 		icon = l->data;
 
@@ -4654,13 +4664,22 @@ nautilus_icon_container_get_first_visibl
 			eel_canvas_item_get_bounds (EEL_CANVAS_ITEM (icon->item),
 						    &x1, &y1, &x2, &y2);
 			if (y2 > y) {
-				return icon->data;
+				if (best_icon != NULL) {
+					if (best_y1 > y1) {
+						best_icon = icon;
+						best_y1 = y1;
+					}
+				} else {
+					best_icon = icon;
+					best_y1 = y1;
+				}
 			}
 		}
 		
 		l = l->next;
 	}
-	return NULL;
+
+	return best_icon ? best_icon->data : NULL;
 }
 
 /* puts the icon at the top of the screen */

Attachment: signature.asc
Description: This is a digitally signed message part



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