rationalize incorrect design for removing tracks.
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 6 Apr 2015 21:56:18 +0000 (17:56 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 6 Apr 2015 21:56:23 +0000 (17:56 -0400)
Still requires a way to make this work correctly from the mixer window

gtk2_ardour/editor.h
gtk2_ardour/editor_actions.cc
gtk2_ardour/editor_ops.cc
gtk2_ardour/mixer_strip.cc
gtk2_ardour/public_editor.h
gtk2_ardour/route_time_axis.cc
gtk2_ardour/route_ui.cc
gtk2_ardour/route_ui.h

index 2e2593dbf1c6d027b12d24b1561d21d7f0a51c28..7cfc6ff9ffd35886ca39bec9dcd71995d76ba7e2 100644 (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;
index 1e104c1fdde9f9c1cf5fc83e1692e62f6ddefab3..322a823ff2e35852acfa8c42338d15eb989dd823 100644 (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));
index 5ccf589ef340426eb9e0b41108545930a029bf97..116bc4571d28e2d3bd5ec78283c9a6f118cd6c50 100644 (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"
index 03d0cbad9231873a42b13db1731a1dece5dd96e9..ae5a0023c1cda12f1b98a1108dd488829cd04958 100644 (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
index a16ae9f05cb035844614e734ea2943c93226a993..1ee068f14157ec86d47fb5239a879eb2b36d3b7f 100644 (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 */
index bec98d8756f2ac85a8966eb1a98a0ec7afbe4798..2e3dee46265f634370b523daaaa3045f7c9989a4 100644 (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
index fc2472ed3738c6700d3d0e19df833edb4ca96438..9f1acf49ed6c6bdad4648d2c9308670e905c4982 100644 (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)
index 0da95cdc238fe4614d444b5e932d349c092432b3..98d66fef84304019ca090df389bafd51685db3ab 100644 (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&);