workaround progression pipe bug
[booh] / bin / booh
index 15408efc76434831fb383636a8694fc3524a75e5..5766217ce57cc70ddd8ba30eb0682d7a15abd51c 100644 (file)
--- a/bin/booh
+++ b/bin/booh
@@ -10,7 +10,7 @@
 # called Boo, so this one will be it "Booh". Or whatever.
 #
 #
-# Copyright (c) 2004-2011 Guillaume Cottenceau <http://zarb.org/~gc/resource/gc_mail.png>
+# Copyright (c) 2004-2013 Guillaume Cottenceau <http://zarb.org/~gc/resource/gc_mail.png>
 #
 # This software may be freely redistributed under the terms of the GNU
 # public license version 2.
@@ -36,7 +36,7 @@ require 'gettext'
 include GetText
 bindtextdomain("booh")
 
-require 'booh/rexml/document'
+require 'rexml/document'
 include REXML
 
 require 'booh/booh-lib'
@@ -79,7 +79,7 @@ def handle_options
             when '--version'
                 puts _("Booh version %s
 
-Copyright (c) 2005-2011 Guillaume Cottenceau.
+Copyright (c) 2005-2013 Guillaume Cottenceau.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") % $VERSION
 
@@ -139,8 +139,8 @@ def read_config
     $config['video-viewer'] ||= '/usr/bin/mplayer %f || /usr/bin/vlc %f'
     $config['image-editor'] ||= '/usr/bin/gimp-remote %f || /usr/bin/gimp %f'
     $config['browser'] ||= "/usr/bin/mozilla-firefox -remote 'openURL(%f,new-window)' || /usr/bin/mozilla-firefox %f || /usr/bin/firefox -remote 'openURL(%f,new-window)' || /usr/bin/firefox %f"
-    $config['use-flv'] ||= "true"
-    $config['flv-generator'] ||= "/usr/bin/ffmpeg -i %f -b 800k -ar 22050 -ab 32k %o"
+    $config['use-mp4'] ||= "true"
+    $config['mp4-generator'] ||= "/usr/bin/ffmpeg -i %f -b 800k -ar 22050 -ab 32k %o"
     $config['comments-format'] ||= '%t'
     if !FileTest.directory?(File.expand_path('~/.booh'))
         system("mkdir ~/.booh")
@@ -167,15 +167,15 @@ Hint: don't forget to specify the full path to the executable,
 e.g. '/usr/bin/mplayer' is correct but 'mplayer' only is not.") % viewer_binary), { :pos_centered => true, :not_transient => true })
     end
 
-    flv_generator_binary = $config['use-flv'] == 'true' && $config['flv-generator'].split.first
-    if flv_generator_binary && !File.executable?(flv_generator_binary)
-        show_popup($main_window, utf8(_("The configured .flv generator seems to be unavailable.
+    mp4_generator_binary = $config['use-mp4'] == 'true' && $config['mp4-generator'].split.first
+    if mp4_generator_binary && !File.executable?(mp4_generator_binary)
+        show_popup($main_window, utf8(_("The configured .mp4 generator seems to be unavailable.
 You should fix this in Edit/Preferences so that you can have working
 embedded flash videos.
 
 Problem was: '%s' is not an executable file.
 Hint: don't forget to specify the full path to the executable,
-e.g. '/usr/bin/ffmpeg' is correct but 'ffmpeg' only is not.") % flv_generator_binary), { :pos_centered => true, :not_transient => true })
+e.g. '/usr/bin/ffmpeg' is correct but 'ffmpeg' only is not.") % mp4_generator_binary), { :pos_centered => true, :not_transient => true })
     end
 end
 
@@ -501,9 +501,9 @@ def update_shown_pixbuf(thumbnail_img, img, desired_x, desired_y)
         pixbuf = rotate_pixbuf(pixbuf, $modified_pixbufs[thumbnail_img][:angle_to_orig])
         msg 3, "sizes: #{pixbuf.width} #{pixbuf.height} - desired #{desired_x}x#{desired_x}"
         if pixbuf.height > desired_y
-            pixbuf = pixbuf.scale(pixbuf.width * (desired_y.to_f/pixbuf.height), desired_y, Gdk::Pixbuf::INTERP_BILINEAR)
+            pixbuf = pixbuf.scale(pixbuf.width * (desired_y.to_f/pixbuf.height), desired_y, :bilinear)
         elsif pixbuf.width < desired_x && pixbuf.height < desired_y
-            pixbuf = pixbuf.scale(desired_x, pixbuf.height * (desired_x.to_f/pixbuf.width), Gdk::Pixbuf::INTERP_BILINEAR)
+            pixbuf = pixbuf.scale(desired_x, pixbuf.height * (desired_x.to_f/pixbuf.width), :bilinear)
         end
     end
 
@@ -1193,7 +1193,7 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
     }
 
     if type == 'video'
-        pxb = Gdk::Pixbuf.new("#{$FPATH}/images/video_border.png")
+        pxb = GdkPixbuf::Pixbuf.new(:file => "#{$FPATH}/images/video_border.png")
         frame1.add(Gtk::HBox.new.pack_start(da1 = Gtk::DrawingArea.new.set_size_request(pxb.width, -1), false, false).
                                  pack_start(img = Gtk::Image.new).
                                  pack_start(da2 = Gtk::DrawingArea.new.set_size_request(pxb.width, -1), false, false))
@@ -2126,6 +2126,8 @@ def backend_wait_message(parent, msg, infopipe_path, mode)
     infopipe = File.open(infopipe_path, File::RDONLY | File::NONBLOCK)
     refresh_thread = Thread.new {
         directories_counter = 0
+        #- immediately stops if trying to read before file is written from backend.. simple dirty solution for the moment
+        sleep 1 
         while line = infopipe.gets
             msg 3, "infopipe got data: #{line}"
             if line =~ /^directories: (\d+), sizes: (\d+)/
@@ -2359,6 +2361,8 @@ def sort_by_exif_date
                 date_time = Exif.datetimeoriginal(from_utf8($current_path + "/" + f))
                 if ! date_time.nil?
                     dates[f] = date_time
+                elsif f =~ /(20\d{2}).?(\d{2}).?(\d{2}).(\d{2}).?(\d{2}).?(\d{2})/
+                    dates[f] = "#$1:#$2:#$3 #$4:#$5:#$6"
                 end
             end
             if aborted
@@ -2375,6 +2379,8 @@ def sort_by_exif_date
             date_time = Exif.datetimeoriginal(from_utf8($current_path + "/" + f))
             if ! date_time.nil?
                 dates[f] = date_time
+            elsif f =~ /(20\d{2}).?(\d{2}).?(\d{2}).(\d{2}).?(\d{2}).?(\d{2})/
+                dates[f] = "#$1:#$2:#$3 #$4:#$5:#$6"
             end
         }
     end
@@ -2514,7 +2520,8 @@ def change_dir
                             else
                                 tmpimage = "#{tmpdir}/00000001.jpg"
                                 begin
-                                    preview_img.pixbuf = Gdk::Pixbuf.new(tmpimage, 240, 180)
+                                    preview_img.pixbuf = GdkPixbuf::Pixbuf.new(:file => tmpimage, :width => 240,
+                                                                               :height => 180)
                                     fc.preview_widget_active = true
                                 rescue Gdk::PixbufError
                                     fc.preview_widget_active = false
@@ -2526,7 +2533,7 @@ def change_dir
                         end
                     else
                         begin
-                            preview_img.pixbuf = rotate_pixbuf(Gdk::Pixbuf.new(fc.preview_filename, 240, 180), guess_rotate(fc.preview_filename))
+                            preview_img.pixbuf = rotate_pixbuf(GdkPixbuf::Pixbuf.new(:file => fc.preview_filename, :width => 240, :height => 180), guess_rotate(fc.preview_filename))
                             fc.preview_widget_active = true
                         rescue Gdk::PixbufError
                             fc.preview_widget_active = false
@@ -2835,7 +2842,7 @@ end
 
 def pixbuf_or_nil(filename)
     begin
-        return Gdk::Pixbuf.new(filename)
+        return GdkPixbuf::Pixbuf.new(:file => filename)
     rescue
         return nil
     end
@@ -2863,7 +2870,7 @@ def theme_choose(current)
 
     dialog.vbox.add(sw = Gtk::ScrolledWindow.new(nil, nil).add(treeview).set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC))
 
-    ([ $FPATH + '/themes/simple' ] + (`find '#{$FPATH}/themes' ~/.booh-themes -mindepth 1 -maxdepth 1 -type d 2>/dev/null`.split("\n").find_all { |e| e !~ /simple$/ }.sort)).each { |dir|
+    ([ $FPATH + '/themes/gradient' ] + (`find '#{$FPATH}/themes' ~/.booh-themes -mindepth 1 -maxdepth 1 -type d 2>/dev/null`.split("\n").find_all { |e| e !~ /\bgradient\b/ }.sort)).each { |dir|
         dir.chomp!
         iter = model.append
         iter[0] = File.basename(dir)
@@ -3143,8 +3150,8 @@ def additional_booh_options
     if $config['transcode-videos']
         options += "--transcode-videos '#{$config['transcode-videos']}' "
     end
-    if $config['use-flv'] == 'true'
-        options += "--flv-generator '#{$config['flv-generator']}' "
+    if $config['use-mp4'] == 'true'
+        options += "--mp4-generator '#{$config['mp4-generator']}' "
     end
     return options
 end
@@ -3972,12 +3979,11 @@ for example: /usr/bin/gimp-remote %f")), nil)
 for example: /usr/bin/mozilla-firefox -remote 'openURL(%f,new-window)' || /usr/bin/mozilla-firefox %f")), nil)
 
     table_counter += 1
-    tbl.attach(Gtk::Alignment.new(1, 0.5, 0, 0).add(flv_check = Gtk::CheckButton.new(utf8(_("Use embedded flash player for videos,\nand use this .flv generator:")))),
+    tbl.attach(Gtk::Alignment.new(1, 0.5, 0, 0).add(mp4_check = Gtk::CheckButton.new(utf8(_("Use this .mp4 generator for videos:")))),
                0, 1, table_counter, table_counter + 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
-    tbl.attach(Gtk::Alignment.new(0, 0.5, 1, 0).add(flv_generator_entry = Gtk::Entry.new.set_text($config['flv-generator']).set_sensitive(false)),
+    tbl.attach(Gtk::Alignment.new(0, 0.5, 1, 0).add(mp4_generator_entry = Gtk::Entry.new.set_text($config['mp4-generator']).set_sensitive(false)),
                1, 2, table_counter, table_counter + 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
-    tooltips.set_tip(flv_check, utf8(_("Flowplayer will be used for embedded video playback")), nil)
-    tooltips.set_tip(flv_generator_entry, utf8(_("Use %f to specify the input filename, %o the output filename;
+    tooltips.set_tip(mp4_generator_entry, utf8(_("Use %f to specify the input filename, %o the output filename;
 for example: /usr/bin/ffmpeg -i %f -b ${i}k -ar 22050 -ab 32k %o")), nil)
 
     table_counter += 1
@@ -3997,11 +4003,11 @@ for example: /usr/bin/ffmpeg -i %f -b ${i}k -ar 22050 -ab 32k %o")), nil)
                0, 2, table_counter, table_counter + 1, Gtk::FILL, Gtk::SHRINK, 2, 2)
     tooltips.set_tip(deleteondisk_check, utf8(_("Normally, deleting a photo or video in booh only removes it from the web-album. If you check this option, the original file in source directory will be removed as well. Undo is possible, since actual deletion is performed only when web-album is saved.")), nil)
 
-    flv_check.signal_connect('toggled') {
-        flv_generator_entry.sensitive = flv_check.active?
+    mp4_check.signal_connect('toggled') {
+        mp4_generator_entry.sensitive = mp4_check.active?
     }
-    if $config['use-flv'] == 'true'
-        flv_check.active = true
+    if $config['use-mp4'] == 'true'
+        mp4_check.active = true
     end
     smp_check.signal_connect('toggled') {
         smp_hbox.sensitive = smp_check.active?
@@ -4189,11 +4195,11 @@ for example: avi:mencoder -nosound -ovc xvid -xvidencopts bitrate=800:me_quality
             $config['video-viewer'] = from_utf8(video_viewer_entry.text)
             $config['image-editor'] = from_utf8(image_editor_entry.text)
             $config['browser'] = from_utf8(browser_entry.text)
-            if flv_check.active?
-                $config['use-flv'] = 'true'
-                $config['flv-generator'] = from_utf8(flv_generator_entry.text)
+            if mp4_check.active?
+                $config['use-mp4'] = 'true'
+                $config['mp4-generator'] = from_utf8(mp4_generator_entry.text)
             else
-                $config['use-flv'] = 'false'
+                $config['use-mp4'] = 'false'
             end
             if smp_check.active?
                 $config['mproc'] = smp_spin.value.to_i
@@ -4466,7 +4472,6 @@ def create_menu_and_toolbar
     $extend.signal_connect('activate') { extend_ }
     $generate.signal_connect('activate') {
         save_current_file
-        warning_flv_not_working = $config['use-flv'] == 'true' ? _("Notice: flash videos normally don't play locally.\n") : ''
         call_backend("booh-backend --config '#{$filename}' --verbose-level #{$verbose_level} #{additional_booh_options}",
                      utf8(_("Please wait while generating web-album...\nThis may take a while, please be patient.")),
                      'web-album',
@@ -4475,8 +4480,7 @@ def create_menu_and_toolbar
 As multi-languages is activated, you will not be able to view it
 locally in your browser though.") % $xmldoc.root.attributes['destination']) :
                          utf8(_("Your web-album is now ready in directory '%s'.
-%s
-Click to view it in your browser:") % [ $xmldoc.root.attributes['destination'], warning_flv_not_working ]),
+Click to view it in your browser:") % [ $xmldoc.root.attributes['destination'] ]),
                        :successmsg_linkurl => $xmldoc.root.attributes['multi-languages'] ? $xmldoc.root.attributes['destination'] :
                                                                                            $xmldoc.root.attributes['destination'] + '/index.html',
                        :closure_after => proc {
@@ -5053,7 +5057,7 @@ def create_main_window
         end
     }
 
-    $albums_ts = Gtk::TreeStore.new(String, String, Gdk::Pixbuf)
+    $albums_ts = Gtk::TreeStore.new(String, String, GdkPixbuf::Pixbuf)
     $albums_tv.set_model($albums_ts)
     $albums_tv.signal_connect('realize') { $albums_tv.grab_focus }