rationalize incorrect design for removing tracks.

Still requires a way to make this work correctly from the mixer window
This commit is contained in:
Paul Davis 2015-04-06 17:56:18 -04:00
parent 537b3a2a0e
commit 803853b4a4
8 changed files with 33 additions and 90 deletions

View File

@ -261,6 +261,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void set_selected_regionview_from_region_list (boost::shared_ptr<ARDOUR::Region> region, Selection::Operation op = Selection::Set);
void remove_tracks ();
/* tempo */
void set_show_measures (bool yn);
@ -2134,7 +2136,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void fit_selection ();
void set_track_height (Height);
void remove_tracks ();
void _remove_tracks ();
bool idle_remove_tracks ();
void toggle_tracks_active ();
bool _have_idled;

View File

@ -401,11 +401,9 @@ Editor::register_actions ()
act = reg_sens (editor_actions, "toggle-track-active", _("Toggle Active"), (sigc::mem_fun(*this, &Editor::toggle_tracks_active)));
ActionManager::track_selection_sensitive_actions.push_back (act);
if (Profile->get_sae()) {
act = reg_sens (editor_actions, "remove-track", _("Delete"), (sigc::mem_fun(*this, &Editor::remove_tracks)));
} else {
act = reg_sens (editor_actions, "remove-track", _("Remove"), (sigc::mem_fun(*this, &Editor::remove_tracks)));
}
act = reg_sens (editor_actions, "remove-track", _("Remove"), (sigc::mem_fun(*this, &Editor::remove_tracks)));
/* not selection sensitive? */
ActionManager::track_selection_sensitive_actions.push_back (act);
act = reg_sens (editor_actions, "fit-selection", _("Fit Selection (Vertical)"), sigc::mem_fun(*this, &Editor::fit_selection));

View File

@ -6749,6 +6749,23 @@ Editor::toggle_tracks_active ()
void
Editor::remove_tracks ()
{
/* this will delete GUI objects that may be the subject of an event
handler in which this method is called. Defer actual deletion to the
next idle callback, when all event handling is finished.
*/
Glib::signal_idle().connect (sigc::mem_fun (*this, &Editor::idle_remove_tracks));
}
bool
Editor::idle_remove_tracks ()
{
_remove_tracks ();
return false; /* do not call again */
}
void
Editor::_remove_tracks ()
{
TrackSelection& ts (selection->tracks);
@ -6804,19 +6821,9 @@ edit your ardour.rc file to set the\n\
return;
}
// XXX should be using gettext plural forms, maybe?
if (ntracks > 1) {
trackstr = _("tracks");
} else {
trackstr = _("track");
}
if (nbusses > 1) {
busstr = _("busses");
} else {
busstr = _("bus");
}
trackstr = P_("track", "tracks", ntracks);
busstr = P_("bus", "busses", nbusses);
if (ntracks) {
if (nbusses) {
prompt = string_compose (_("Do you really want to remove %1 %2 and %3 %4?\n"

View File

@ -1540,7 +1540,8 @@ MixerStrip::build_route_ops_menu ()
}
items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Remove"), sigc::bind (sigc::mem_fun(*this, &RouteUI::remove_this_route), false)));
/* gah, this is wrong ... it will operate on the wrong selection */
items.push_front (MenuElem (_("Remove"), sigc::mem_fun(PublicEditor::instance(), &PublicEditor::remove_tracks)));
}
gboolean

View File

@ -204,7 +204,8 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi
virtual void remove_location_at_playhead_cursor () = 0;
virtual void set_show_measures (bool yn) = 0;
virtual bool show_measures () const = 0;
virtual void remove_tracks () = 0;
virtual Editing::MouseMode effective_mouse_mode () const = 0;
/** Import existing media */

View File

@ -852,12 +852,8 @@ RouteTimeAxisView::build_display_menu ()
items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Hide"), sigc::bind (sigc::mem_fun(_editor, &PublicEditor::hide_track_in_display), this, true)));
if (!Profile->get_sae()) {
items.push_back (MenuElem (_("Remove"), sigc::bind (sigc::mem_fun(*this, &RouteUI::remove_this_route), true)));
} else {
items.push_front (SeparatorElem());
items.push_front (MenuElem (_("Delete"), sigc::bind (sigc::mem_fun(*this, &RouteUI::remove_this_route), true)));
}
items.push_front (SeparatorElem());
items.push_front (MenuElem (_("Delete"), sigc::mem_fun(_editor, &PublicEditor::remove_tracks)));
}
void

View File

@ -1534,66 +1534,6 @@ RouteUI::set_color_from_route ()
return 0;
}
void
RouteUI::remove_this_route (bool apply_to_selection)
{
if (apply_to_selection) {
ARDOUR_UI::instance()->the_editor().get_selection().tracks.foreach_route_ui (boost::bind (&RouteUI::remove_this_route, _1, false));
} else {
if ((route()->is_master() || route()->is_monitor()) &&
!Config->get_allow_special_bus_removal()) {
MessageDialog msg (_("That would be bad news ...."),
false,
Gtk::MESSAGE_INFO,
Gtk::BUTTONS_OK);
msg.set_secondary_text (string_compose (_(
"Removing the master or monitor bus is such a bad idea\n\
that %1 is not going to allow it.\n\
\n\
If you really want to do this sort of thing\n\
edit your ardour.rc file to set the\n\
\"allow-special-bus-removal\" option to be \"yes\""), PROGRAM_NAME));
msg.present ();
msg.run ();
return;
}
vector<string> choices;
string prompt;
if (is_track()) {
prompt = string_compose (_("Do you really want to remove track \"%1\" ?\n\nYou may also lose the playlist used by this track.\n\n(This action cannot be undone, and the session file will be overwritten)"), _route->name());
} else {
prompt = string_compose (_("Do you really want to remove bus \"%1\" ?\n\n(This action cannot be undone, and the session file will be overwritten)"), _route->name());
}
choices.push_back (_("No, do nothing."));
choices.push_back (_("Yes, remove it."));
string title;
if (is_track()) {
title = _("Remove track");
} else {
title = _("Remove bus");
}
Choice prompter (title, prompt, choices);
if (prompter.run () == 1) {
Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), this));
}
}
}
gint
RouteUI::idle_remove_this_route (RouteUI *rui)
{
DisplaySuspender ds;
rui->_session->remove_route (rui->route());
return false;
}
/** @return true if this name should be used for the route, otherwise false */
bool
RouteUI::verify_new_route_name (const std::string& name)

View File

@ -187,9 +187,6 @@ class RouteUI : public virtual AxisView
int set_color_from_route ();
void remove_this_route (bool apply_to_selection = false);
static gint idle_remove_this_route (RouteUI *);
void route_rename();
virtual void property_changed (const PBD::PropertyChange&);