file selector for image of subalbums: provide a preview of videos as well
[booh] / bin / booh
index a86bb630fe0e8a2e9996da720e548bf650622dd7..b9c87e5f6555bb6d1cb6c7cc0c002629390e9095 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -2458,13 +2458,35 @@ def change_dir
             f.add(preview_img = Gtk::Image.new)
             preview.show_all
             fc.signal_connect('update-preview') { |w|
             f.add(preview_img = Gtk::Image.new)
             preview.show_all
             fc.signal_connect('update-preview') { |w|
-                begin
-                    if fc.preview_filename
-                        preview_img.pixbuf = rotate_pixbuf(Gdk::Pixbuf.new(fc.preview_filename, 240, 180), guess_rotate(fc.preview_filename))
-                        fc.preview_widget_active = true
+                if fc.preview_filename
+                    if entry2type(fc.preview_filename) == 'video'
+                        image_path = nil
+                        tmpdir = nil
+                        begin
+                            tmpdir = gen_video_thumbnail(fc.preview_filename, false, 0)
+                            if tmpdir.nil?
+                                fc.preview_widget_active = false
+                            else
+                                tmpimage = "#{tmpdir}/00000001.jpg"
+                                begin
+                                    preview_img.pixbuf = Gdk::Pixbuf.new(tmpimage, 240, 180)
+                                    fc.preview_widget_active = true
+                                rescue Gdk::PixbufError
+                                    fc.preview_widget_active = false
+                                ensure
+                                    File.delete(tmpimage)
+                                    Dir.rmdir(tmpdir)
+                                end
+                            end
+                        end
+                    else
+                        begin
+                            preview_img.pixbuf = rotate_pixbuf(Gdk::Pixbuf.new(fc.preview_filename, 240, 180), guess_rotate(fc.preview_filename))
+                            fc.preview_widget_active = true
+                        rescue Gdk::PixbufError
+                            fc.preview_widget_active = false
+                        end
                     end
                     end
-                rescue Gdk::PixbufError
-                    fc.preview_widget_active = false
                 end
             }
             if fc.run == Gtk::Dialog::RESPONSE_ACCEPT
                 end
             }
             if fc.run == Gtk::Dialog::RESPONSE_ACCEPT