show proper first/last item with home/end keys, taking visibility into account
authorGuillaume Cottenceau <gcottenc@gmail.com>
Fri, 24 Jul 2009 11:21:42 +0000 (13:21 +0200)
committerGuillaume Cottenceau <gcottenc@gmail.com>
Fri, 24 Jul 2009 11:21:42 +0000 (13:21 +0200)
bin/booh-classifier

index 321cd58..44d8c71 100755 (executable)
@@ -989,13 +989,21 @@ def thumbnail_keypressed(entry, event)
             view_entry(entry)
 
         elsif event.keyval == Gdk::Keyval::GDK_Home
-            if $allentries[0] && $allentries[0].button
-                $allentries[0].button.grab_focus
+            index = 0
+            while $allentries[index] && $allentries[index].button && !visible($allentries[index])
+                index += 1
+            end
+            if $allentries[index] && $allentries[index].button
+                $allentries[index].button.grab_focus
             end
 
         elsif event.keyval == Gdk::Keyval::GDK_End
-            if $allentries[-1] && $allentries[-1].button
-                $allentries[-1].button.grab_focus
+            index = $allentries.size - 1
+            while $allentries[index] && $allentries[index].button && !visible($allentries[index])
+                index += 1
+            end
+            if $allentries[index] && $allentries[index].button
+                $allentries[index].button.grab_focus
             end
 
         else