progress bar
authorgc <gc>
Sat, 23 Feb 2008 22:15:30 +0000 (22:15 +0000)
committergc <gc>
Sat, 23 Feb 2008 22:15:30 +0000 (22:15 +0000)
bin/booh-classifier

index b4e84b61b640e509c3abc15b41e7107c65f746bb..41e3de04646aa0fd8db82c54fe60bc6efb1514fe 100644 (file)
@@ -778,7 +778,7 @@ def thumbnail_keypressed(entry, event)
             entry.free_pixbuf_thumbnail
             $mainview.redraw
             entry.image.pixbuf = entry.pixbuf_thumbnail
-            if $config['rotate-set-exif'] == 'true'
+            if $config['rotate-set-exif'] == 'true' && entry.type == 'image'
                 Exif.set_orientation(entry.path, angle_to_exif_orientation(entry.angle))
             end
         end
@@ -967,6 +967,9 @@ end
 
 def show_entries
     sb_msg(_("Loading images..."))
+    $loading_progressbar.fraction = 0
+    $loading_progressbar.text = utf8(_("Loading... %d%") % 0)
+    $loading_progressbar.show
     t1 = Time.now
     total_loaded_files = 0
     total_loaded_size = 0
@@ -1001,6 +1004,8 @@ def show_entries
         else
             $allentries.delete_at(i)
         end
+        $loading_progressbar.fraction = i.to_f / $allentries.size
+        $loading_progressbar.text = utf8(_("Loading... %d%") % (100 * $loading_progressbar.fraction))
     end
     if i <= $config['preload-distance'].to_i * 2
         #- not yet preloaded correctly
@@ -1008,20 +1013,23 @@ def show_entries
         run_preloader
     end
     sb_msg(_("%d images of total %s kB loaded in %3.2f seconds.") % [ total_loaded_files, commify(total_loaded_size / 1024), Time.now - t1 ])
+    $loading_progressbar.hide
+    $execute.sensitive = true
 end
 
 def reset_all
-    $images_loader and $images_loader.kill
     reset_labels
     reset_thumbnails
     $mainview.set_shown_entry(nil)
     sb_msg(nil)
+    $preloader_allowed = false
 end
 
 def open_dir(path)
     #- remove visual stuff, so that user will see something is happening
     reset_all
     sb_msg(_("Scanning source directory..."))
+    Gtk.main_iteration while Gtk.events_pending?
 
     path = File.expand_path(path.sub(%r|/$|, ''))
     examined_dirs = `find '#{path}' -type d -follow`.sort.collect { |v| v.chomp }
@@ -1064,8 +1072,6 @@ def open_dir(path)
         }
     }
     $workingdir = path
-    show_entries
-    $execute.sensitive = true
     return nil
 end
 
@@ -1080,6 +1086,7 @@ def open_dir_popup
         fc.current_folder = $workingdir
     end
     ok = false
+    load = false
     while !ok
         if fc.run == Gtk::Dialog::RESPONSE_ACCEPT
             msg = open_dir(fc.filename)
@@ -1088,12 +1095,16 @@ def open_dir_popup
                 ok = false
             else
                 ok = true
+                load = true
             end
         else
             ok = true
         end
     end
     fc.destroy
+    if load
+        show_entries
+    end
 end
 
 def try_quit(*options)
@@ -1546,7 +1557,10 @@ def create_main_window
     main_vbox = Gtk::VBox.new(false, 0)
     main_vbox.pack_start(mb, false, false)
     mainview_hbox = Gtk::HBox.new
-    mainview_hbox.pack_start(Gtk::Alignment.new(0.5, 0, 0, 0).add($labels_vbox = Gtk::VBox.new(false, 5)), false, true)
+    mainview_hbox.pack_start(Gtk::Alignment.new(0.5, 0, 1, 1).add(left_vbox = Gtk::VBox.new(false, 5)), false, true)
+    left_vbox.pack_start(($labels_vbox = Gtk::VBox.new(false, 5)), false, true)
+    $labels_vbox.pack_start(Gtk::Label.new(utf8(_("Labels list:"))).set_justify(Gtk::Justification::CENTER), false, false).show_all
+    left_vbox.pack_end($loading_progressbar = Gtk::ProgressBar.new.set_text(utf8(_("Loading... %d%") % 0)), false, true)
     reset_labels
     mainview_hbox.pack_start($mainview = MainView.new, true, true)
     main_vbox.pack_start(mainview_hbox, true, true)
@@ -1584,6 +1598,7 @@ def create_main_window
     }
 
     $main_window.show_all
+    $loading_progressbar.hide
 end
 
 
@@ -1596,7 +1611,11 @@ create_main_window
 check_config
 
 if ARGV[0]
-    open_dir(ARGV[0])
+    if msg = open_dir(ARGV[0])
+        puts msg
+    else
+        show_entries
+    end
 end
 Gtk.main