<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -160,44 +160,32 @@ static VALUE movie_track_count(VALUE obj)
 }
 
 /*
-  call-seq: composite_movie(movie, position)
+  call-seq: select(position, duration)
   
-  Adds the tracks of given movie into called movie at given position (in seconds).
-  
-  You can track the progress of this operation by passing a block to this 
-  method. It will be called regularly during the process and pass the 
-  percentage complete (0.0 to 1.0) as an argument to the block.
+  Select a portion of a movie. Both position and duration should be
+  floats representing seconds.
 */
-static VALUE movie_composite_movie(VALUE obj, VALUE src, VALUE position)
+static VALUE movie_select(VALUE obj, VALUE position, VALUE duration)
 {
-  if (rb_block_given_p())
-    SetMovieProgressProc(MOVIE(obj), (MovieProgressUPP)movie_progress_proc, rb_block_proc());
-  
-  SetMovieSelection(MOVIE(obj), MOVIE_TIME(obj, position), 0);
-  AddMovieSelection(MOVIE(obj), MOVIE(src));
-  
-  if (rb_block_given_p())
-    SetMovieProgressProc(MOVIE(obj), 0, 0);
-  
+  SetMovieSelection(MOVIE(obj), MOVIE_TIME(obj, position), MOVIE_TIME(obj, duration));
   return obj;
 }
 
 /*
-  call-seq: append_movie(movie, position)
+  call-seq: add_into_selection(movie)
+  
+  Adds the tracks of given movie into called movie's current selection.
   
-  Inserts given movie into called movie at given position (in seconds).
-
   You can track the progress of this operation by passing a block to this 
   method. It will be called regularly during the process and pass the 
   percentage complete (0.0 to 1.0) as an argument to the block.
 */
-static VALUE movie_insert_movie(VALUE obj, VALUE src, VALUE position)
+static VALUE movie_add_into_selection(VALUE obj, VALUE src)
 {
   if (rb_block_given_p())
     SetMovieProgressProc(MOVIE(obj), (MovieProgressUPP)movie_progress_proc, rb_block_proc());
   
-  SetMovieSelection(MOVIE(obj), MOVIE_TIME(obj, position), 0);
-  PasteMovieSelection(MOVIE(obj), MOVIE(src));
+  AddMovieSelection(MOVIE(obj), MOVIE(src));
   
   if (rb_block_given_p())
     SetMovieProgressProc(MOVIE(obj), 0, 0);
@@ -206,20 +194,19 @@ static VALUE movie_insert_movie(VALUE obj, VALUE src, VALUE position)
 }
 
 /*
-  call-seq: append_movie(movie)
+  call-seq: insert_into_selection(movie)
+  
+  Inserts the given movie into called movie, replacing any current selection.
   
-  Adds given movie to the end of movie which this method is called on.
-
   You can track the progress of this operation by passing a block to this 
   method. It will be called regularly during the process and pass the 
   percentage complete (0.0 to 1.0) as an argument to the block.
 */
-static VALUE movie_append_movie(VALUE obj, VALUE src)
+static VALUE movie_insert_into_selection(VALUE obj, VALUE src)
 {
   if (rb_block_given_p())
     SetMovieProgressProc(MOVIE(obj), (MovieProgressUPP)movie_progress_proc, rb_block_proc());
   
-  SetMovieSelection(MOVIE(obj), GetMovieDuration(MOVIE(obj)), 0);
   PasteMovieSelection(MOVIE(obj), MOVIE(src));
   
   if (rb_block_given_p())
@@ -229,37 +216,22 @@ static VALUE movie_append_movie(VALUE obj, VALUE src)
 }
 
 /*
-  call-seq: delete_section(start_time, duration)
+  call-seq: clone_selection()
   
-  Deletes given section from movie. Both start_time and duration 
-  should be floats representing seconds.
-*/
-static VALUE movie_delete_section(VALUE obj, VALUE start, VALUE duration)
-{
-  SetMovieSelection(MOVIE(obj), MOVIE_TIME(obj, start), MOVIE_TIME(obj, duration));
-  ClearMovieSelection(MOVIE(obj));
-  return obj;
-}
-
-/*
-  call-seq: clone_section(start_time, duration) -&gt; movie
+  Returns a new movie from the current selection. Does not modify original 
+  movie. 
   
-  Returns a new movie in the given section. Does not modify original 
-  movie. Both start_time and duration should be floats representing 
-  seconds.
-
   You can track the progress of this operation by passing a block to this 
   method. It will be called regularly during the process and pass the 
   percentage complete (0.0 to 1.0) as an argument to the block.
 */
-static VALUE movie_clone_section(VALUE obj, VALUE start, VALUE duration)
+static VALUE movie_clone_selection(VALUE obj)
 {
   VALUE new_movie_obj = rb_obj_alloc(cMovie);
   
   if (rb_block_given_p())
     SetMovieProgressProc(MOVIE(obj), (MovieProgressUPP)movie_progress_proc, rb_block_proc());
   
-  SetMovieSelection(MOVIE(obj), MOVIE_TIME(obj, start), MOVIE_TIME(obj, duration));
   RMOVIE(new_movie_obj)-&gt;movie = CopyMovieSelection(MOVIE(obj));
   
   if (rb_block_given_p())
@@ -269,24 +241,22 @@ static VALUE movie_clone_section(VALUE obj, VALUE start, VALUE duration)
 }
 
 /*
-  call-seq: clip_section(start_time, duration) -&gt; movie
+  call-seq: clip_selection()
+  
+  Deletes current selection on movie and returns a new movie with that 
+  content.
   
-  Deletes given section on movie and returns a new movie with that 
-  section. Both start_time and duration should be floats representing 
-  seconds.
-
   You can track the progress of this operation by passing a block to this 
   method. It will be called regularly during the process and pass the 
   percentage complete (0.0 to 1.0) as an argument to the block.
 */
-static VALUE movie_clip_section(VALUE obj, VALUE start, VALUE duration)
+static VALUE movie_clip_selection(VALUE obj)
 {
   VALUE new_movie_obj = rb_obj_alloc(cMovie);
   
   if (rb_block_given_p())
     SetMovieProgressProc(MOVIE(obj), (MovieProgressUPP)movie_progress_proc, rb_block_proc());
   
-  SetMovieSelection(MOVIE(obj), MOVIE_TIME(obj, start), MOVIE_TIME(obj, duration));
   RMOVIE(new_movie_obj)-&gt;movie = CutMovieSelection(MOVIE(obj));
   
   if (rb_block_given_p())
@@ -296,6 +266,17 @@ static VALUE movie_clip_section(VALUE obj, VALUE start, VALUE duration)
 }
 
 /*
+  call-seq: delete_selection()
+  
+  Removes the portion of the movie which is selected.
+*/
+static VALUE movie_delete_selection(VALUE obj)
+{
+  ClearMovieSelection(MOVIE(obj));
+  return obj;
+}
+
+/*
   call-seq: changed?() -&gt; bool
   
   Determine if a movie has changed since opening. Returns true/false. 
@@ -349,7 +330,7 @@ static VALUE movie_flatten(VALUE obj, VALUE filepath)
 
 
 /*
-  call-seq: save
+  call-seq: save()
   
   Saves the movie to the current file.
 */
@@ -477,12 +458,12 @@ void Init_quicktime_movie()
   rb_define_method(cMovie, &quot;time_scale&quot;, movie_time_scale, 0);
   rb_define_method(cMovie, &quot;bounds&quot;, movie_bounds, 0);
   rb_define_method(cMovie, &quot;track_count&quot;, movie_track_count, 0);
-  rb_define_method(cMovie, &quot;composite_movie&quot;, movie_composite_movie, 2);
-  rb_define_method(cMovie, &quot;insert_movie&quot;, movie_insert_movie, 2);
-  rb_define_method(cMovie, &quot;append_movie&quot;, movie_append_movie, 1);
-  rb_define_method(cMovie, &quot;delete_section&quot;, movie_delete_section, 2);
-  rb_define_method(cMovie, &quot;clone_section&quot;, movie_clone_section, 2);
-  rb_define_method(cMovie, &quot;clip_section&quot;, movie_clip_section, 2);
+  rb_define_method(cMovie, &quot;select&quot;, movie_select, 2);
+  rb_define_method(cMovie, &quot;add_into_selection&quot;, movie_add_into_selection, 1);
+  rb_define_method(cMovie, &quot;insert_into_selection&quot;, movie_insert_into_selection, 1);
+  rb_define_method(cMovie, &quot;clone_selection&quot;, movie_clone_selection, 0);
+  rb_define_method(cMovie, &quot;clip_selection&quot;, movie_clip_selection, 0);
+  rb_define_method(cMovie, &quot;delete_selection&quot;, movie_delete_selection, 0);
   rb_define_method(cMovie, &quot;changed?&quot;, movie_changed, 0);
   rb_define_method(cMovie, &quot;clear_changed_status&quot;, movie_clear_changed_status, 0);
   rb_define_method(cMovie, &quot;flatten&quot;, movie_flatten, 1);</diff>
      <filename>ext/movie.c</filename>
    </modified>
    <modified>
      <diff>@@ -98,5 +98,77 @@ module QuickTime
       end
       export_image_type(filepath, seconds, type)
     end
+    
+    # Reset selection to beginning
+    def deselect
+      select(0, 0)
+    end
+    
+    # Adds the tracks of given movie into called movie. Position will default to
+    # beginning of movie. Duration will default to length of given movie.
+    # 
+    # You can track the progress of this operation by passing a block to this 
+    # method. It will be called regularly during the process and pass the 
+    # percentage complete (0.0 to 1.0) as an argument to the block.
+    def composite_movie(movie, position = 0, duration = 0, &amp;block)
+      select(position, duration)
+      add_into_selection(movie, &amp;block)
+      deselect
+    end
+    
+    # Adds given movie to the end of movie which this method is called on.
+    # 
+    # You can track the progress of this operation by passing a block to this 
+    # method. It will be called regularly during the process and pass the 
+    # percentage complete (0.0 to 1.0) as an argument to the block.
+    def append_movie(movie, &amp;block)
+      select(duration, 0)
+      insert_into_selection(movie, &amp;block)
+      deselect
+    end
+    
+    # Inserts given movie into called movie. The position defaults to the beginning
+    # of the movie. If a duration is passed, that amount of the movie will be replaced.
+    # 
+    # You can track the progress of this operation by passing a block to this 
+    # method. It will be called regularly during the process and pass the 
+    # percentage complete (0.0 to 1.0) as an argument to the block.
+    def insert_movie(movie, position = 0, duration = 0, &amp;block)
+      select(position, duration)
+      insert_into_selection(movie, &amp;block)
+      deselect
+    end
+    
+    # Returns a new movie from the specified portion of called movie.
+    # 
+    # You can track the progress of this operation by passing a block to this 
+    # method. It will be called regularly during the process and pass the 
+    # percentage complete (0.0 to 1.0) as an argument to the block.
+    def clone_section(position = 0, duration = 0, &amp;block)
+      select(position, duration)
+      movie = clone_selection(&amp;block)
+      deselect
+      movie
+    end
+    
+    # Deletes the specified section on movie and returns a new movie
+    # with that content.
+    # 
+    # You can track the progress of this operation by passing a block to this 
+    # method. It will be called regularly during the process and pass the 
+    # percentage complete (0.0 to 1.0) as an argument to the block.
+    def clip_section(position = 0, duration = 0, &amp;block)
+      select(position, duration)
+      movie = clip_selection(&amp;block)
+      deselect
+      movie
+    end
+    
+    # Deletes the specified section on movie.
+    def delete_section(position = 0, duration = 0)
+      select(position, duration)
+      delete_selection
+      deselect
+    end
   end
 end</diff>
      <filename>lib/quicktime/movie.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>fc1be8af601bca45679d04c9a671a430cefb5ffe</id>
    </parent>
  </parents>
  <author>
    <name>Ryan Bates</name>
    <email>ryan@railscasts.com</email>
  </author>
  <url>http://github.com/ryanb/rmov/commit/954dddcc3116be709e5fc0abaec02c60ec7248ac</url>
  <id>954dddcc3116be709e5fc0abaec02c60ec7248ac</id>
  <committed-date>2009-07-13T11:17:20-07:00</committed-date>
  <authored-date>2009-07-13T11:17:20-07:00</authored-date>
  <message>reorganizing how movie operations are performed with selection - closes #4 - closes #5</message>
  <tree>72c4daf65c5bb9cfce0d238739a1b2cabd22c822</tree>
  <committer>
    <name>Ryan Bates</name>
    <email>ryan@railscasts.com</email>
  </committer>
</commit>
