nemo r60 - trunk/gtk



Author: arj
Date: Wed Jan  9 13:26:23 2008
New Revision: 60
URL: http://svn.gnome.org/viewvc/nemo?rev=60&view=rev

Log:
Fix prev/next in search popup



Modified:
   trunk/gtk/SearchPopup.cs

Modified: trunk/gtk/SearchPopup.cs
==============================================================================
--- trunk/gtk/SearchPopup.cs	(original)
+++ trunk/gtk/SearchPopup.cs	Wed Jan  9 13:26:23 2008
@@ -17,7 +17,8 @@
 		List<Item> items;
 		string search_text;
 		int offset;
-		int last_page_size;
+		Stack<int> sizes_of_last_pages;
+		int current_page_size;
 		
 		public SearchPopup(VoidFunction<CalendarDriver.View, DateTime> set_view)
 		{
@@ -26,7 +27,7 @@
 			set_view_callback = set_view;
 			name = "search_popup";
 			offset = 0;
-			last_page_size = 0;
+			sizes_of_last_pages = new Stack<int>();
 		}
 
 		public override void hide()
@@ -48,8 +49,6 @@
 		
 		public override void resize()
 		{
-			if (offset > 0)
-				offset = offset - last_page_size;
 			add_elements();
 		}
 		
@@ -89,6 +88,8 @@
 				elements.PackStart(create_element(item, search_text, "", delegate { popup.ShowAll(); }), true, true, 5);
 			}
 			
+			current_page_size = index - offset;
+			
 			if (items.Count == 0) {
 				Gtk.Alignment tmp = new Gtk.Alignment(0.5f, 1f, 1f, 1f);
 				tmp.BorderWidth = 5;
@@ -103,9 +104,9 @@
 			Gtk.HBox page_navigation = new Gtk.HBox();
 
 			if (offset > 0) // prev
-				add_page_link(Mono.Unix.Catalog.GetString("Prev page"), page_navigation, offset-last_page_size);
+				add_page_link(Mono.Unix.Catalog.GetString("Prev page"), page_navigation, offset, -1);
 			if (items.Count > index) // next
-				add_page_link(Mono.Unix.Catalog.GetString("Next page"), page_navigation, index);
+				add_page_link(Mono.Unix.Catalog.GetString("Next page"), page_navigation, offset, current_page_size);
 			else {
 				Gtk.Alignment empty_box = new Gtk.Alignment(1,1,1,1);
 				empty_box.LeftPadding = 27;
@@ -118,15 +119,12 @@
 			alignment.Add(page_navigation);
 			elements.PackStart(alignment, true, true, 5);
 
-			last_page_size = index - offset;
-			offset = index;
-
 			popup.ShowAll();
 
 			System.Console.WriteLine("elements size {0}", items.Count);
 		}
 		
-		private void add_page_link(string text, Gtk.HBox page_navigation, int offset)
+		private void add_page_link(string text, Gtk.HBox page_navigation, int offset, int current_page)
 		{
 			Gtk.EventBox link_wrapper = new Gtk.EventBox();
 			Gtk.Label link = new Gtk.Label();
@@ -138,7 +136,13 @@
 			
 			link_wrapper.Add(link);
 			link_wrapper.ButtonPressEvent += delegate(object sender, Gtk.ButtonPressEventArgs args) {
-				this.offset = offset;
+				if (current_page != -1) { // next
+					sizes_of_last_pages.Push(current_page);
+					this.offset = offset + current_page;
+				} else {
+					int last_page = sizes_of_last_pages.Pop();
+					this.offset = offset - last_page;
+				}
 				add_elements();
 			};
 			



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