changeset 220:7670d5653e1f

Honor selection while fullscreen navigation. The behavior is now consistent in full screen and windowed mode. It fixes the fact that the selection was discarded on "Next". Patch by Uwe Ohse. Cleanups by Laurent Monin.
author zas_
date Wed, 02 Apr 2008 10:40:54 +0000
parents 92d2444893b8
children 79ef86f3b325
files src/layout_image.c
diffstat 1 files changed, 83 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/layout_image.c	Tue Apr 01 07:42:31 2008 +0000
+++ b/src/layout_image.c	Wed Apr 02 10:40:54 2008 +0000
@@ -1159,6 +1159,44 @@
 		read_ahead_fd = layout_list_get_fd(lw, index + 1);
 		}
 
+ 	if (layout_selection_count(lw, 0) > 1)
+		{
+ 		GList *x = layout_selection_list_by_index(lw);
+ 	  	GList *y;
+ 	  	GList *last;
+
+ 		for (last = y = x; y; y = y->next)
+ 			last = y;
+		for (y = x; y && ((gint)y->data) != index; y = y->next)
+			;
+
+		if (y)
+			{
+			gint newindex;
+
+			if ((index > old && (index != (gint) last->data || old != (gint) x->data))
+ 	        	    || (old == (gint) last->data && index == (gint) x->data))
+			    	{
+				if (y->next)
+ 					newindex = (gint) y->next->data;
+				else
+ 					newindex = (gint) x->data;
+				}
+			else
+				{
+				if (y->prev)
+					newindex = (gint) y->prev->data;
+				else
+					newindex = (gint) last->data;
+ 	    			}
+
+			read_ahead_fd = layout_list_get_fd(lw, newindex);
+			}
+			
+		while (x)
+			x = g_list_remove(x, x->data);
+		}
+
 	layout_image_set_with_ahead(lw, fd, read_ahead_fd);
 }
 
@@ -1260,6 +1298,27 @@
 		return;
 		}
 
+	if (layout_selection_count(lw, 0) > 1)
+		{
+		GList *x = layout_selection_list_by_index(lw);
+		gint old = layout_list_get_index(lw, layout_image_get_path(lw));
+		GList *y;
+
+		for (y = x; y && ((gint) y->data) != old; y = y->next)
+			;
+		if (y)
+			{
+			if (y->next) 
+		    		layout_image_set_index(lw, (gint) y->next->data);
+		  	else
+		    		layout_image_set_index(lw, (gint) x->data);
+			}
+		while (x)
+			x = g_list_remove(x, x->data);
+		if (y) /* not dereferenced */
+			return;
+		}
+
 	cd = image_get_collection(lw->image, &info);
 
 	if (cd && info)
@@ -1309,6 +1368,30 @@
 		return;
 		}
 
+	if (layout_selection_count(lw, 0) > 1)
+		{
+		GList *x = layout_selection_list_by_index(lw);
+		gint old = layout_list_get_index(lw, layout_image_get_path(lw));
+		GList *y;
+		GList *last;
+
+		for (last = y = x; y; y = y->next)
+			last = y;
+		for (y = x; y && ((gint) y->data) != old; y = y->next)
+			;
+		if (y)
+			{
+		  	if (y->prev)
+				layout_image_set_index(lw, (gint) y->prev->data);
+			else
+				layout_image_set_index(lw, (gint) last->data);
+			}
+		while (x)
+			x = g_list_remove(x, x->data);
+		if (y) /* not dereferenced */
+			return;
+		}
+
 	cd = image_get_collection(lw->image, &info);
 
 	if (cd && info)