provide preview data of albums
[booh] / bin / booh
index 16233a21f3a00e35f41539c8da662ffb75d6e2b3..5006065690f8a3d126fd75a9cab8e5f13e7942b7 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -3041,6 +3041,37 @@ def open_file_popup
     fc.add_shortcut_folder(File.expand_path("~/.booh"))
     fc.set_current_folder(File.expand_path("~/.booh"))
     fc.transient_for = $main_window
+    fc.preview_widget = previewlabel = Gtk::Label.new.show
+    fc.signal_connect('update-preview') { |w|
+        if fc.preview_filename
+            begin
+                push_mousecursor_wait(fc)
+                xmldoc = REXML::Document.new(File.new(fc.preview_filename))
+                subalbums = 0
+                images = 0
+                videos = 0
+                xmldoc.elements.each('//*') { |elem|
+                    if elem.name == 'dir'
+                        subalbums += 1
+                    elsif elem.name == 'image'
+                        images += 1
+                    elsif elem.name == 'video'
+                        videos += 1
+                    end
+                }
+            rescue Exception
+            ensure
+                pop_mousecursor(fc)
+            end
+            if !xmldoc || !xmldoc.root || xmldoc.root.name != 'booh'
+                fc.preview_widget_active = false
+            else
+                previewlabel.markup = utf8(_("<i>Source:</i> %s\n<i>Destination:</i> %s\n<i>Subalbums:</i> %s\n<i>Images:</i> %s\n<i>Videos:</i> %s") %
+                                           [ xmldoc.root.attributes['source'], xmldoc.root.attributes['destination'], subalbums, images, videos ])
+                fc.preview_widget_active = true
+            end
+        end
+    }
     ok = false
     while !ok
         if fc.run == Gtk::Dialog::RESPONSE_ACCEPT