Changeset 2069 for trunk/gui


Ignore:
Timestamp:
Jan 27, 2011, 12:48:57 AM (14 years ago)
Author:
dkearney
Message:

adding ability to pass a directory holding thumbnail images to the videochooer. if it can find a premade thumbnail image, it doesn't have to open each video and dynamically create the images

Location:
trunk/gui/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/videochooser.tcl

    r2067 r2069  
    2222    itk_option define -height height Height 300
    2323    itk_option define -variable variable Variable ""
     24    itk_option define -thumbsdir thumbsdir Thumbsdir ""
    2425
    2526    constructor { args } {
     
    8283
    8384        set ci [Rappture::VideoChooserInfo $f.vi${_vcnt} \
    84                     -variable ${_variable}]
     85                    -variable ${_variable} \
     86                    -thumbsdir $itk_option(-thumbsdir)]
    8587        $ci load $path ""
    8688        pack $ci -expand yes -fill both -side left
  • trunk/gui/scripts/videochooserinfo.tcl

    r2067 r2069  
    2323    itk_option define -selectedheight selectedheight Selectedheight 63
    2424    itk_option define -variable variable Variable ""
     25    itk_option define -thumbsdir thumbsdir Thumbsdir ""
    2526
    2627    constructor { args } {
     
    9495
    9596    set _path $path
    96 
    97     set movie [Rappture::Video file ${_path}]
    98     $movie seek 60
     97    set preview_fname ""
     98    set selected_fname ""
    9999
    100100    set _preview [image create photo]
    101101    set _selected [image create photo]
     102
     103    if {[string compare "" $itk_option(-thumbsdir)] != 0} {
     104        set root [file tail [file rootname ${_path}]]
     105        set preview_fname [file join $itk_option(-thumbsdir) ${root}_${_width}x${_height}.png]
     106        set selected_fname [file join $itk_option(-thumbsdir) ${root}_${_selectedwidth}x${_selectedheight}.png]
     107
     108        if {[file readable $preview_fname] && [file readable $selected_fname]} {
     109            set fid [open $preview_fname r]
     110            fconfigure $fid -translation binary
     111            ${_preview} put [read $fid]
     112            close $fid
     113
     114            set fid [open $selected_fname r]
     115            fconfigure $fid -translation binary
     116            ${_selected} put [read $fid]
     117            close $fid
     118        }
     119    } else {
     120        # there are some incomplete movies that don't open up
     121        set err [catch {
     122            set movie [Rappture::Video file ${_path}]
     123            $movie seek 60
     124
     125            ${_preview} put [$movie get image ${_width} ${_height}]
     126            ${_selected} put [$movie get image ${_selectedwidth} ${_selectedheight}]
     127
     128            $movie release
     129        }]
     130        if {$err} {
     131            puts stderr "Error while opening movie: $movie"
     132            return
     133        }
     134    }
    102135
    103136    set cw [expr round(${_selectedwidth}/2.0)]
     
    109142        -tags preview
    110143
    111     ${_preview} put [$movie get image ${_width} ${_height}]
    112     ${_selected} put [$movie get image ${_selectedwidth} ${_selectedheight}]
    113 
    114     $movie release
    115 
    116144    $itk_component(main) bind preview <ButtonPress-1> [itcl::code $this _bindings b1press]
    117145    $itk_component(main) bind preview <Enter> [itcl::code $this _bindings enter]
Note: See TracChangeset for help on using the changeset viewer.