Reinstate mouse scroll actions (audio clocks, shuttle wheel, faders), clearing select...
[ardour.git] / gtk2_ardour / editor_ops.cc
index bff2f14c441e173487918039d7fc99c65a9c31cf..192269eb15bc3d6ff909d2b5b177491b918150a2 100644 (file)
@@ -38,7 +38,7 @@
 #include <ardour/audioregion.h>
 #include <ardour/diskstream.h>
 #include <ardour/filesource.h>
-#include <ardour/sndfilesource.h>
+#include <ardour/externalsource.h>
 #include <ardour/utils.h>
 #include <ardour/location.h>
 #include <ardour/named_selection.h>
@@ -60,6 +60,7 @@
 #include "sfdb_ui.h"
 #include "editing.h"
 #include "gtk-custom-hruler.h"
+#include "gui_thread.h"
 
 #include "i18n.h"
 
@@ -198,13 +199,8 @@ Do you really want to destroy %1 ?"),
        choices.push_back (_("No, do nothing."));
 
        Gtkmm2ext::Choice prompter (prompt, choices);
-
-       prompter.chosen.connect (ptr_fun (Main::quit));
-       prompter.show_all ();
-
-       Main::run ();
-               
-       if (prompter.get_choice() != 0) {
+       
+       if (prompter.run() != 0) { /* first choice */
                return;
        }
 
@@ -398,7 +394,7 @@ Editor::nudge_backward (bool next)
                if (playhead_cursor->current_frame > distance) {
                        session->request_locate (playhead_cursor->current_frame - distance);
                } else {
-                       session->request_locate (0);
+                       session->goto_start();
                }
        }
 }
@@ -464,7 +460,7 @@ Editor::nudge_backward_capture_offset ()
 void
 Editor::move_to_start ()
 {
-       session->request_locate (0);
+       session->goto_start ();
 }
 
 void
@@ -988,7 +984,12 @@ Editor::scroll_tracks_down ()
                cnt = (int) floor (prefix);
        }
 
-       vertical_adjustment.set_value (vertical_adjustment.get_value() + (cnt * vertical_adjustment.get_page_size()));
+       double vert_value = vertical_adjustment.get_value() + (cnt *
+               vertical_adjustment.get_page_size());
+       if (vert_value > vertical_adjustment.get_upper() - canvas_height) {
+               vert_value = vertical_adjustment.get_upper() - canvas_height;
+       }
+       vertical_adjustment.set_value (vert_value);
 }
 
 void
@@ -1010,15 +1011,21 @@ Editor::scroll_tracks_up ()
 void
 Editor::scroll_tracks_down_line ()
 {
+
         Gtk::Adjustment* adj = edit_vscrollbar.get_adjustment();
-       adj->set_value (adj->get_value() + 10);
+       double vert_value = adj->get_value() + 20;
+
+       if (vert_value>adj->get_upper() - canvas_height) {
+               vert_value = adj->get_upper() - canvas_height;
+       }
+       adj->set_value (vert_value);
 }
 
 void
 Editor::scroll_tracks_up_line ()
 {
         Gtk::Adjustment* adj = edit_vscrollbar.get_adjustment();
-       adj->set_value (adj->get_value() - 10);
+       adj->set_value (adj->get_value() - 20);
 }
 
 /* ZOOM */
@@ -1026,6 +1033,8 @@ Editor::scroll_tracks_up_line ()
 void
 Editor::temporal_zoom_step (bool coarser)
 {
+       ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::temporal_zoom_step), coarser));
+
        double nfpu;
 
        nfpu = frames_per_unit;
@@ -1127,8 +1136,10 @@ Editor::temporal_zoom_selection ()
 void
 Editor::temporal_zoom_session ()
 {
+       ENSURE_GUI_THREAD (mem_fun (*this, &Editor::temporal_zoom_session));
+
        if (session) {
-               temporal_zoom_by_frame (0, session->current_end_frame(), "zoom to session");
+               temporal_zoom_by_frame (session->current_start_frame(), session->current_end_frame(), "zoom to session");
        }
 }
 
@@ -1197,6 +1208,60 @@ Editor::temporal_zoom_to_frame (bool coarser, jack_nframes_t frame)
        reposition_and_zoom (new_leftmost, new_fpu);
 }
 
+void
+Editor::add_location_from_selection ()
+{
+       if (selection->time.empty()) {
+               return;
+       }
+
+       if (session == 0 || clicked_trackview == 0) {
+               return;
+       }
+
+       jack_nframes_t start = selection->time[clicked_selection].start;
+       jack_nframes_t end = selection->time[clicked_selection].end;
+
+       Location *location = new Location (start, end, "selection");
+
+       session->begin_reversible_command (_("add marker"));
+       session->add_undo (session->locations()->get_memento());
+       session->locations()->add (location, true);
+       session->add_redo_no_execute (session->locations()->get_memento());
+       session->commit_reversible_command ();
+}
+
+void
+Editor::add_location_from_playhead_cursor ()
+{
+       jack_nframes_t where = session->audible_frame();
+       
+       Location *location = new Location (where, where, "mark", Location::IsMark);
+       session->begin_reversible_command (_("add marker"));
+       session->add_undo (session->locations()->get_memento());
+       session->locations()->add (location, true);
+       session->add_redo_no_execute (session->locations()->get_memento());
+       session->commit_reversible_command ();
+}
+
+void
+Editor::add_location_from_audio_region ()
+{
+       if (selection->audio_regions.empty()) {
+               return;
+       }
+
+       AudioRegionView* rv = *(selection->audio_regions.begin());
+       Region& region = rv->region;
+       
+       Location *location = new Location (region.position(), region.last_frame(), region.name());
+       session->begin_reversible_command (_("add marker"));
+       session->add_undo (session->locations()->get_memento());
+       session->locations()->add (location, true);
+       session->add_redo_no_execute (session->locations()->get_memento());
+       session->commit_reversible_command ();
+}
+
 void
 Editor::select_all_in_track (Selection::Operation op)
 {
@@ -1302,6 +1367,23 @@ Editor::select_all_within (jack_nframes_t start, jack_nframes_t end, double top,
        return !touched.empty();
 }
 
+void
+Editor::set_selection_from_audio_region ()
+{
+       if (selection->audio_regions.empty()) {
+               return;
+       }
+
+       AudioRegionView* rv = *(selection->audio_regions.begin());
+       Region& region = rv->region;
+       
+       begin_reversible_command (_("set selection from region"));
+       selection->set (0, region.position(), region.last_frame());
+       commit_reversible_command ();
+
+       set_mouse_mode (Editing::MouseRange, false);
+}
+
 void
 Editor::set_selection_from_punch()
 {
@@ -1328,25 +1410,18 @@ Editor::set_selection_from_loop()
 void
 Editor::set_selection_from_range (Location& loc)
 {
-        if (clicked_trackview == 0) {
-               return;
-       }
-       
        begin_reversible_command (_("set selection from range"));
        selection->set (0, loc.start(), loc.end());
        commit_reversible_command ();
+
+       set_mouse_mode (Editing::MouseRange, false);
 }
 
 void
 Editor::select_all_selectables_using_time_selection ()
 {
-
        list<Selectable *> touched;
 
-       if (clicked_trackview == 0) {
-               return;
-       }
-
        if (selection->time.empty()) {
                return;
        }
@@ -1364,10 +1439,10 @@ Editor::select_all_selectables_using_time_selection ()
                }
                (*iter)->get_selectables (start, end - 1, 0, DBL_MAX, touched);
        }
+
        begin_reversible_command (_("select all from range"));
        selection->set (touched);
        commit_reversible_command ();
-
 }
 
 
@@ -1423,18 +1498,51 @@ Editor::select_all_selectables_using_cursor (Cursor *cursor, bool after)
        list<Selectable *> touched;
 
        if (after) {
-         begin_reversible_command (_("select all after cursor"));
-         start = cursor->current_frame ;
-         end = session->current_end_frame();
+               begin_reversible_command (_("select all after cursor"));
+               start = cursor->current_frame ;
+               end = session->current_end_frame();
+       } else {
+               if (cursor->current_frame > 0) {
+                       begin_reversible_command (_("select all before cursor"));
+                       start = 0;
+                       end = cursor->current_frame - 1;
+               } else {
+                       return;
+               }
+       }
+
+       for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
+               if ((*iter)->hidden()) {
+                       continue;
+               }
+               (*iter)->get_selectables (start, end, 0, DBL_MAX, touched);
+       }
+       selection->set (touched);
+       commit_reversible_command ();
+}
+
+void
+Editor::select_all_selectables_between_cursors (Cursor *cursor, Cursor *other_cursor)
+{
+        jack_nframes_t start;
+       jack_nframes_t end;
+       list<Selectable *> touched;
+       bool  other_cursor_is_first = cursor->current_frame > other_cursor->current_frame;
+
+       if (cursor->current_frame == other_cursor->current_frame) {
+               return;
+       }
+
+       begin_reversible_command (_("select all between cursors"));
+       if (other_cursor_is_first) {
+               start = other_cursor->current_frame;
+               end = cursor->current_frame - 1;
+               
        } else {
-         if (cursor->current_frame > 0) {
-           begin_reversible_command (_("select all before cursor"));
-           start = 0;
-           end = cursor->current_frame - 1;
-         } else {
-           return;
-         }
+               start = cursor->current_frame;
+               end = other_cursor->current_frame - 1;
        }
+       
        for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) {
                if ((*iter)->hidden()) {
                        continue;
@@ -1528,7 +1636,7 @@ Editor::jump_backward_to_mark ()
        if (location) {
                session->request_locate (location->start(), session->transport_rolling());
        } else {
-               session->request_locate (0);
+               session->goto_start ();
        }
 }
 
@@ -1732,7 +1840,7 @@ Editor::toggle_playback (bool with_abort)
 void
 Editor::play_from_start ()
 {
-       session->request_locate (0, true);
+       session->request_locate (session->current_start_frame(), true);
 }
 
 void
@@ -1973,476 +2081,6 @@ Editor::interthread_cancel_clicked ()
        }
 }
 
-void *
-Editor::_import_thread (void *arg)
-{
-       PBD::ThreadCreated (pthread_self(), X_("Import"));
-
-       Editor *ed = (Editor *) arg;
-       return ed->import_thread ();
-}
-
-void *
-Editor::import_thread ()
-{
-       session->import_audiofile (import_status);
-       return 0;
-}
-
-gint
-Editor::import_progress_timeout (void *arg)
-{
-       interthread_progress_label.set_text (import_status.doing_what);
-
-       if (import_status.freeze) {
-               interthread_cancel_button.set_sensitive(false);
-       } else {
-               interthread_cancel_button.set_sensitive(true);
-       }
-
-       if (import_status.doing_what == "building peak files") {
-               interthread_progress_bar.pulse ();
-               return FALSE;
-       } else {
-               interthread_progress_bar.set_fraction (import_status.progress/100);
-       }
-
-       return !(import_status.done || import_status.cancel);
-}
-
-void
-Editor::import_audio (bool as_tracks)
-{
-       if (session == 0) {
-               warning << _("You can't import an audiofile until you have a session loaded.") << endmsg;
-               return;
-       }
-
-       string str;
-
-       if (as_tracks) {
-               str =_("Import selected as tracks");
-       } else {
-               str = _("Import selected to region list");
-       }
-
-       SoundFileOmega sfdb (str);
-       sfdb.Imported.connect (bind (mem_fun (*this, &Editor::do_import), as_tracks));
-
-       sfdb.run();
-}
-
-void
-Editor::catch_new_audio_region (AudioRegion* ar)
-{
-       last_audio_region = ar;
-}
-
-void
-Editor::do_import (vector<string> paths, bool split, bool as_tracks)
-{
-       sigc::connection c;
-       
-       /* SFDB sets "multichan" to true to indicate "split channels"
-          so reverse the setting to match the way libardour
-          interprets it.
-       */
-       
-       import_status.multichan = !split;
-
-       if (interthread_progress_window == 0) {
-               build_interthread_progress_window ();
-       }
-       
-       interthread_progress_window->set_title (_("ardour: audio import in progress"));
-       interthread_progress_window->set_position (Gtk::WIN_POS_MOUSE);
-       interthread_progress_window->show_all ();
-       interthread_progress_bar.set_fraction (0.0f);
-       interthread_cancel_label.set_text (_("Cancel Import"));
-       current_interthread_info = &import_status;
-
-       c = session->AudioRegionAdded.connect (mem_fun(*this, &Editor::catch_new_audio_region));
-
-       for (vector<string>::iterator i = paths.begin(); i != paths.end(); ++i ) {
-
-               interthread_progress_window->set_title (string_compose (_("ardour: importing %1"), (*i)));
-       
-               import_status.pathname = (*i);
-               import_status.done = false;
-               import_status.cancel = false;
-               import_status.freeze = false;
-               import_status.done = 0.0;
-               
-               interthread_progress_connection = 
-                 Glib::signal_timeout().connect (bind (mem_fun(*this, &Editor::import_progress_timeout), (gpointer) 0), 100);
-               
-               last_audio_region = 0;
-               
-               pthread_create_and_store ("import", &import_status.thread, 0, _import_thread, this);
-               pthread_detach (import_status.thread);
-               
-               while (!(import_status.done || import_status.cancel)) {
-                       gtk_main_iteration ();
-               }
-               
-               import_status.done = true;
-               interthread_progress_connection.disconnect ();
-
-               if (as_tracks && last_audio_region != 0) {
-                       uint32_t channels = last_audio_region->n_channels();
-
-                       AudioTrack* at = session->new_audio_track (channels, channels);
-                       AudioRegion* copy = new AudioRegion (*last_audio_region);
-                       at->disk_stream().playlist()->add_region (*copy, 0);
-               }
-       }
-
-       c.disconnect ();
-       interthread_progress_window->hide_all ();
-}
-
-int
-Editor::reject_because_rate_differs (const string & path, SoundFileInfo& finfo, const string & action, bool multiple_pending)
-{
-       if (!session) {
-               return 1;
-       }
-
-       if (finfo.samplerate != (int) session->frame_rate()) {
-               vector<string> choices;
-
-               choices.push_back (string_compose (_("%1 it anyway"), action));
-
-               if (multiple_pending) {
-                       /* XXX assumptions about sentence structure
-                          here for translators. Sorry.
-                       */
-                       choices.push_back (string_compose (_("Don't %1 it"), action));
-                       choices.push_back (string_compose (_("%1 all without questions"), action));
-                       choices.push_back (_("Cancel entire import"));
-               } else {
-                       choices.push_back (_("Cancel"));
-               }
-
-               Gtkmm2ext::Choice rate_choice (
-                       string_compose (_("%1\nThis audiofile's sample rate doesn't match the session sample rate!"), path),
-                       choices);
-
-               rate_choice.chosen.connect (ptr_fun (Main::quit));
-               rate_choice.show_all ();
-
-               Main::run ();
-
-               switch (rate_choice.get_choice()) {
-               case 0: /* do it anyway */
-                       return 0;
-               case 1: /* don't import this one */
-                       return 1;
-               case 2: /* do the rest without asking */
-                       return -1;
-               case 3: /* stop a multi-file import */
-               default:
-                       return -2;
-               }
-       }
-
-       return 0;
-}
-
-void 
-Editor::embed_audio ()
-{
-       if (session == 0) {
-               warning << _("You can't embed an audiofile until you have a session loaded.") << endmsg;
-               return;
-       }
-
-       SoundFileOmega sfdb (_("Add to External Region list"));
-       sfdb.Embedded.connect (mem_fun (*this, &Editor::do_embed_sndfiles));
-
-       sfdb.run ();
-}
-
-void
-Editor::do_embed_sndfiles (vector<string> paths, bool split)
-{
-       bool multiple_files = paths.size() > 1;
-       bool check_sample_rate = true;
-
-       for (vector<string>::iterator i = paths.begin(); i != paths.end(); ++i) {
-               embed_sndfile (*i, split, multiple_files, check_sample_rate);
-       }
-
-       session->save_state ("");
-}
-
-void
-Editor::embed_sndfile (string path, bool split, bool multiple_files, bool& check_sample_rate)
-{
-       SndFileSource *source = 0; /* keep g++ quiet */
-       AudioRegion::SourceList sources;
-       string idspec;
-       string linked_path;
-       SoundFileInfo finfo;
-
-       /* lets see if we can link it into the session */
-       
-       linked_path = session->sound_dir();
-       linked_path += PBD::basename (path);
-
-       if (link (path.c_str(), linked_path.c_str()) == 0) {
-
-               /* there are many reasons why link(2) might have failed.
-                  but if it succeeds, we now have a link in the
-                  session sound dir that will protect against
-                  unlinking of the original path. nice.
-               */
-
-               path = linked_path;
-       }
-
-       /* note that we temporarily truncated _id at the colon */
-       if (!get_soundfile_info (path, finfo)) {
-               error << string_compose(_("Editor: cannot open file \"%1\""), selection ) << endmsg;
-               return;
-       }
-       
-       if (check_sample_rate) {
-               switch (reject_because_rate_differs (path, finfo, "Embed", multiple_files)) {
-               case 0:
-                       break;
-               case 1:
-                       return;
-               case -1:
-                       check_sample_rate = false;
-                       break;
-                       
-               case -2:
-               default:
-                       return;
-               }
-       }
-
-       track_canvas.get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH));
-       ARDOUR_UI::instance()->flush_pending ();
-
-       /* make the proper number of channels in the region */
-
-       for (int n=0; n < finfo.channels; ++n)
-       {
-               idspec = path;
-               idspec += string_compose(":%1", n);
-               
-               try {
-                       source = new SndFileSource (idspec.c_str());
-                       sources.push_back(source);
-               } 
-
-               catch (failed_constructor& err) {
-                       error << string_compose(_("could not open %1"), path) << endmsg;
-                       goto out;
-               }
-
-               ARDOUR_UI::instance()->flush_pending ();
-       }
-
-       if (sources.size() > 0) {
-
-               string region_name = PBD::basename_nosuffix (path);
-               region_name += "-0";
-
-               /* The created region isn't dropped.  It emits a signal
-                  that is picked up by the session. 
-               */
-
-               new AudioRegion (sources, 0, sources[0]->length(), region_name, 0,
-                                Region::Flag (Region::DefaultFlags|Region::WholeFile|Region::External));
-               
-               /* make sure we can see it in the list */
-
-                /* its the second node, always */
-
-               // GTK2FIX ?? is it still always the 2nd node
-
-               TreeModel::Path path ("2");
-               region_list_display.expand_row (path, true);
-
-               ARDOUR_UI::instance()->flush_pending ();
-       }
-
-  out:
-       track_canvas.get_window()->set_cursor (*current_canvas_cursor);
-}
-
-void
-Editor::insert_sndfile (bool as_tracks)
-{
-//     SoundFileSelector& sfdb (ARDOUR_UI::instance()->get_sfdb_window());
-       sigc::connection c;
-       string str;
-
-       if (as_tracks) {
-
-//             c = sfdb.Action.connect (mem_fun(*this, &Editor::insert_paths_as_new_tracks));
-               str = _("Insert selected as new tracks");
-
-       } else {
-
-               jack_nframes_t pos;
-
-               if (clicked_audio_trackview == 0) {
-                       return;
-               }
-
-               if (ensure_cursor (&pos)) {
-                       return;
-               }
-
-//             c = sfdb.Action.connect (bind (mem_fun(*this, &Editor::do_insert_sndfile), pos));
-               str = _("Insert selected");
-       }
-
-//     sfdb.run (str, false);
-//     c.disconnect ();
-}
-
-void
-Editor::insert_paths_as_new_tracks (vector<string> paths, bool split)
-{
-       SoundFileInfo finfo;
-       bool multiple_files;
-       bool check_sample_rate = true;
-
-       multiple_files = paths.size() > 1;      
-
-       for (vector<string>::iterator p = paths.begin(); p != paths.end(); ++p) {
-               
-               if (!get_soundfile_info((*p), finfo)) {
-                       char errbuf[256];
-                       error << string_compose(_("Editor: cannot open file \"%1\""), (*p)) << endmsg;
-                       continue;
-               }
-               
-               /* add a new track */
-               
-               if (check_sample_rate) {
-                       switch (reject_because_rate_differs (*p, finfo, "Insert", multiple_files)) {
-                       case 0:
-                               break;
-                       case 1:
-                               continue;
-                       case -1:
-                               check_sample_rate = false;
-                               break;
-                               
-                       case -2:
-                               return;
-                       }
-               }
-               
-               uint32_t input_chan = finfo.channels;
-               uint32_t output_chan;
-               
-               if (session->get_output_auto_connect() & Session::AutoConnectMaster) {
-                       output_chan = (session->master_out() ? session->master_out()->n_inputs() : input_chan);
-               } else {
-                       output_chan = input_chan;
-               }
-               
-               (void) session->new_audio_track (input_chan, output_chan);
-
-
-               /* get the last (most recently added) track view */
-       
-               AudioTimeAxisView* tv;
-       
-               if ((tv = dynamic_cast<AudioTimeAxisView*>(track_views.back())) == 0) {
-                       fatal << _("programming error: ")
-                             << X_("last trackview after new_audio_track is not an audio track!")
-                             << endmsg;
-                       /*NOTREACHED*/
-               }
-               
-               jack_nframes_t pos = 0;
-               insert_sndfile_into (*p, true, tv, pos, false);
-       }
-}
-
-void
-Editor::do_insert_sndfile (vector<string> paths, bool split, jack_nframes_t pos)
-{
-       for (vector<string>::iterator x = paths.begin(); x != paths.end(); ++x) {
-               insert_sndfile_into (*x, !split, clicked_audio_trackview, pos);
-       }
-}
-
-void
-Editor::insert_sndfile_into (const string & path, bool multi, AudioTimeAxisView* tv, jack_nframes_t& pos, bool prompt)
-{
-       SndFileSource *source = 0; /* keep g++ quiet */
-       AudioRegion::SourceList sources;
-       string idspec;
-       SoundFileInfo finfo;
-
-       /* note that we temporarily truncated _id at the colon */
-       
-       if (!get_soundfile_info (path, finfo)) {
-               char errbuf[256];
-               error << string_compose(_("Editor: cannot open file \"%1\" (%2)"), path) << endmsg;
-               return;
-       }
-       
-       if (prompt && (reject_because_rate_differs (path, finfo, "Insert", false) != 0)) {
-               return;
-       }
-
-       track_canvas.get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH));
-       ARDOUR_UI::instance()->flush_pending ();
-
-       /* make the proper number of channels in the region */
-
-       for (int n=0; n < finfo.channels; ++n)
-       {
-               idspec = path;
-               idspec += string_compose(":%1", n);
-
-               try {
-                       source = new SndFileSource (idspec.c_str());
-                       sources.push_back(source);
-               } 
-
-               catch (failed_constructor& err) {
-                       error << string_compose(_("could not open %1"), path) << endmsg;
-                       goto out;
-               }
-
-               ARDOUR_UI::instance()->flush_pending ();
-       }
-
-       if (sources.size() > 0) {
-
-               string region_name = region_name_from_path (PBD::basename (path));
-               
-               AudioRegion *region = new AudioRegion (sources, 0, sources[0]->length(), region_name, 
-                                                      0, /* irrelevant these days */
-                                                      Region::Flag (Region::DefaultFlags|Region::WholeFile|Region::External));
-
-               begin_reversible_command (_("insert sndfile"));
-               session->add_undo (tv->playlist()->get_memento());
-               tv->playlist()->add_region (*region, pos);
-               session->add_redo_no_execute (tv->playlist()->get_memento());
-               commit_reversible_command ();
-               
-               pos += sources[0]->length();
-
-               ARDOUR_UI::instance()->flush_pending ();
-       }
-
-  out:
-       track_canvas.get_window()->set_cursor (*current_canvas_cursor);
-       return;
-}
-
 void
 Editor::region_from_selection ()
 {
@@ -2586,6 +2224,53 @@ Editor::separate_region_from_selection ()
        if (doing_undo) commit_reversible_command ();
 }
 
+void
+Editor::separate_regions_using_location (Location& loc)
+{
+       bool doing_undo = false;
+
+       if (loc.is_mark()) {
+               return;
+       }
+
+       Playlist *playlist;
+
+       /* XXX i'm unsure as to whether this should operate on selected tracks only 
+          or the entire enchillada. uncomment the below line to correct the behaviour 
+          (currently set for all tracks)
+       */
+
+       for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {    
+       //for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
+
+               AudioTimeAxisView* atv;
+
+               if ((atv = dynamic_cast<AudioTimeAxisView*> ((*i))) != 0) {
+
+                       if (atv->is_audio_track()) {
+                                       
+                               if ((playlist = atv->playlist()) != 0) {
+                                       if (!doing_undo) {
+                                               begin_reversible_command (_("separate"));
+                                               doing_undo = true;
+                                       }
+                                       if (doing_undo) session->add_undo ((playlist)->get_memento());
+                       
+                                       /* XXX need to consider musical time selections here at some point */
+
+                                       double speed = atv->get_diskstream()->speed();
+
+
+                                       playlist->partition ((jack_nframes_t)(loc.start() * speed), (jack_nframes_t)(loc.end() * speed), true);
+                                       if (doing_undo) session->add_redo_no_execute (playlist->get_memento());
+                               }
+                       }
+               }
+       }
+
+       if (doing_undo) commit_reversible_command ();
+}
+
 void
 Editor::crop_region_to_selection ()
 {
@@ -3527,26 +3212,6 @@ Editor::nudge_track (bool use_edit_cursor, bool forwards)
        commit_reversible_command ();                   
 }
 
-void
-Editor::toggle_xfades_active ()
-{
-       if (session) {
-               session->set_crossfades_active (!session->get_crossfades_active());
-       }
-}
-
-void
-Editor::set_xfade_visibility (bool yn)
-{
-       
-}
-
-void
-Editor::toggle_xfade_visibility ()
-{
-       set_xfade_visibility (!xfade_visibility());
-}
-
 void
 Editor::remove_last_capture ()
 {
@@ -3565,12 +3230,8 @@ Editor::remove_last_capture ()
                choices.push_back (_("No, do nothing."));
                
                Gtkmm2ext::Choice prompter (prompt, choices);
-               prompter.chosen.connect (ptr_fun (Main::quit));
-               prompter.show_all ();
-
-               Main::run ();
                
-               if (prompter.get_choice() == 0) {
+               if (prompter.run () == 0) {
                        session->remove_last_capture ();
                }