view videos with mplayer
authorgc <gc>
Mon, 28 Mar 2005 16:29:29 +0000 (16:29 +0000)
committergc <gc>
Mon, 28 Mar 2005 16:29:29 +0000 (16:29 +0000)
bin/booh
bin/booh-gui
lib/booh/booh-lib.rb

index 65984c393ce39c1ab535f5c35cca87a6a4bae9e8..80f56f293f2662e7aaa851f09aabbedbd2f29bff 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -222,17 +222,6 @@ def find_captions(xmldir, images)
     return images.collect { |img| find_caption_value(xmldir, img) }
 end
 
-def entry2type(entry)
-    if entry =~ /\.(jpg|jpeg|jpe|gif|bmp|png)$/i
-        return 'image'
-    elsif entry =~ /\.(mov|avi|mpg|mpeg|mpe|wmv|asx)$/i
-        #- might consider using file magic later..
-        return 'video'
-    else
-        return nil
-    end
-end
-
 #- grab the results of a command but don't sleep forever on a runaway process
 def subproc_runaway_aware(command)
     begin
index fe690e44c11e597ff6618b7fc73aa851f1329c25..daee04fcd88636207b50df3fc8f183ccdf337748 100755 (executable)
@@ -79,10 +79,16 @@ def build_full_dest_filename(filename)
     return dest_dir + '/' + make_dest_filename(from_utf8(filename))
 end
 
-def view_image(filename)
+def view_element(filename)
+    if entry2type(filename) == 'video'
+        system("mplayer #{$current_path + '/' + filename}")
+        return
+    end
+
     w = Gtk::Window.new
 
     default_size = $images_size.detect { |sizeobj| sizeobj['default'] }
+    puts "filename: #{filename}"
     dest_img = build_full_dest_filename(filename).sub(/\.[^\.]+$/, '') + "-#{default_size['fullscreen']}.jpg"
     #- typically this file won't exist in case of videos; try with the largest thumbnail around
     if !File.exists?(dest_img)
@@ -220,7 +226,7 @@ def add_thumbnail(autotable, name, type, filename, caption)
                 end
             end
             if event.keyval == Gdk::Keyval::GDK_Return && control_pressed
-                view_image(File.basename(name))
+                view_element(File.basename(name))
                 propagate = false
             end
         end
@@ -235,7 +241,7 @@ def add_thumbnail(autotable, name, type, filename, caption)
     evtbox.signal_connect('button-press-event') { |w, event|
         textview.grab_focus
         if event.event_type == Gdk::Event::BUTTON2_PRESS
-            view_image(File.basename(name))
+            view_element(File.basename(name))
             true
         else
             false  #- propagate
index 94c18b79590b84eaf0bfff008930e86f17e2a5b0..2bc4159dfbe9f2f26d55fcdfc5b51aa72e9793b8 100644 (file)
@@ -96,4 +96,15 @@ module Booh
         require "#{themedir}/parameters.rb"
     end
 
+    def entry2type(entry)
+        if entry =~ /\.(jpg|jpeg|jpe|gif|bmp|png)$/i
+            return 'image'
+        elsif entry =~ /\.(mov|avi|mpg|mpeg|mpe|wmv|asx)$/i
+            #- might consider using file magic later..
+            return 'video'
+        else
+            return nil
+        end
+    end
+
 end