hopefully fix inconsistent main and thumbnail view after quick labelization
authorgc <gc>
Sun, 27 Apr 2008 21:35:49 +0000 (21:35 +0000)
committergc <gc>
Sun, 27 Apr 2008 21:35:49 +0000 (21:35 +0000)
bin/booh-classifier

index f118b12..26160ec 100644 (file)
@@ -515,6 +515,10 @@ def run_preloader_real
             get_mem
             return
         end
+        if $config['preload-distance'].to_i == 0
+            free_cache([])
+            return
+        end
         index = $allentries.index($mainview.get_shown_entry)
         index_right = index
         index_left = index
@@ -614,18 +618,20 @@ class MainView < Gtk::DrawingArea
         signal_connect('configure-event') { update_shown }
     end
 
+    def try_show_entry(entry)
+        if entry && entry.button
+            entry.button.grab_focus
+        end
+    end
+
     def set_shown_entry(entry)
         t1 = Time.now
-        if ! entry.nil? && entry == @entry
+        if entry && entry == @entry
             return
         end
-        if ! entry.nil?
-            if ! entry.button
-                #- not loaded yet
-                return
-            else
-                entry.button.grab_focus
-            end
+        if entry && ! entry.button
+            #- not loaded yet
+            return
         end
         @entry = entry
         redraw
@@ -649,7 +655,7 @@ class MainView < Gtk::DrawingArea
             index -= 1
         end
         if index < $allentries.size && $allentries[index] && $allentries[index].button.visible?
-            set_shown_entry($allentries[index])
+            try_show_entry($allentries[index])
         end
     end
 
@@ -891,7 +897,7 @@ def thumbnail_keypressed(entry, event)
                           entry.show_bg
                           update_visibility(entry)
                           if entry.button.visible?
-                              $mainview.set_shown_entry(entry)
+                              $mainview.try_show_entry(entry)
                           end
                           proc {
                               entry.removed = true
@@ -899,7 +905,7 @@ def thumbnail_keypressed(entry, event)
                               entry.show_bg
                               update_visibility(entry)
                               if entry.button.visible?
-                                  $mainview.set_shown_entry(entry)
+                                  $mainview.try_show_entry(entry)
                               end
                           }
                       })
@@ -920,12 +926,12 @@ def thumbnail_keypressed(entry, event)
                           entry.removed = removed_before
                           entry.labeled = label_before
                           entry.show_bg
-                          $mainview.set_shown_entry(entry)
+                          $mainview.try_show_entry(entry)
                           proc {
                               entry.removed = false
                               entry.labeled = nil
                               entry.show_bg
-                              $mainview.set_shown_entry(entry)
+                              $mainview.try_show_entry(entry)
                           }
                       })
 
@@ -986,7 +992,7 @@ def thumbnail_keypressed(entry, event)
                                   entry.show_bg
                                   update_visibility(entry)
                                   if entry.button.visible?
-                                      $mainview.set_shown_entry(entry)
+                                      $mainview.try_show_entry(entry)
                                   end
                                   proc {
                                       entry.removed = false
@@ -994,7 +1000,7 @@ def thumbnail_keypressed(entry, event)
                                       entry.show_bg
                                       update_visibility(entry)
                                       if entry.button.visible?
-                                          $mainview.set_shown_entry(entry)
+                                          $mainview.try_show_entry(entry)
                                       end
                                   }
                               })
@@ -1115,7 +1121,7 @@ end
 def reset_all
     reset_labels
     reset_thumbnails
-    $mainview.set_shown_entry(nil)
+    $mainview.try_show_entry(nil)
     sb_msg(nil)
     $preloader_allowed = false
     $execute.sensitive = false