Add route dialog is never a transient window.
authornick_m <mainsbridge@gmail.com>
Wed, 11 Mar 2015 16:46:11 +0000 (03:46 +1100)
committernick_m <mainsbridge@gmail.com>
Wed, 11 Mar 2015 16:46:11 +0000 (03:46 +1100)
Fixes a hack where it's transient parent was used to give an order hint
(for the order key of any new tracks).
This commit adds a new combobox "insert_at" to let the user tell us
where they want new tracks to go.

gtk2_ardour/add_route_dialog.cc
gtk2_ardour/add_route_dialog.h
gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h

index 3b1cd47bfc17ec356fa1c62e90cb341085c2afc3..24e9ca81df0526ac0a664731d6be1b007d0995c2 100644 (file)
@@ -80,6 +80,12 @@ AddRouteDialog::AddRouteDialog ()
        track_bus_combo.append_text (_("Busses"));
        track_bus_combo.set_active (0);
 
+       insert_at_combo.append_text (_("Editor Selection"));
+       insert_at_combo.append_text (_("Mixer Selection"));
+       insert_at_combo.append_text (_("End"));
+
+       insert_at_combo.set_active (0);
+
        VBox* vbox = manage (new VBox);
        Gtk::Label* l;
 
@@ -151,6 +157,12 @@ AddRouteDialog::AddRouteDialog ()
        table2->attach (route_group_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
        ++n;
 
+       /* New route will be inserted at.. */
+       l = manage (new Label (_("Insert at:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
+       table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
+       table2->attach (insert_at_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       ++n;
+
        options_box->pack_start (*table2, false, true);
        vbox->pack_start (*options_box, false, true);
 
@@ -538,6 +550,20 @@ AddRouteDialog::group_changed ()
        }
 }
 
+AddRouteDialog::InsertAt
+AddRouteDialog::insert_at ()
+{
+       std::string str = insert_at_combo.get_active_text();
+
+       if (str == _("Editor Selection")) {
+               return EditorSelection;
+       } else if (str == _("Mixer Selection")){
+               return MixerSelection;
+       }
+
+       return End;
+}
+
 bool
 AddRouteDialog::channel_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
 {
index 3a5501e15fff7ef09bcdcd6241f1f32cab38bbe5..9f11528e58911ec845572228f4a3ce605e39a752 100644 (file)
@@ -67,6 +67,12 @@ class AddRouteDialog : public ArdourDialog
        
        ARDOUR::TrackMode mode();
        ARDOUR::RouteGroup* route_group ();
+       enum InsertAt {
+               EditorSelection,
+               MixerSelection,
+               End
+       };
+       InsertAt insert_at();
 
   private:
        Gtk::Entry name_template_entry;
@@ -80,6 +86,8 @@ class AddRouteDialog : public ArdourDialog
        Gtk::ComboBoxText mode_combo;
        Gtk::ComboBoxText route_group_combo;
        InstrumentSelector instrument_combo;
+       Gtk::Label insert_at_label;
+       Gtk::ComboBoxText insert_at_combo;
 
        std::vector<ARDOUR::TemplateInfo> route_templates;
 
index 8b8a7cdef2f09fa17f203c0d258a65811683ff7a..9ff0190918cadd8ae145212f0a3389d3904e55cf 100644 (file)
@@ -3424,7 +3424,7 @@ ARDOUR_UI::flush_trash ()
 }
 
 void
-ARDOUR_UI::setup_order_hint ()
+ARDOUR_UI::setup_order_hint (AddRouteDialog::InsertAt place)
 {
        uint32_t order_hint = 0;
 
@@ -3432,7 +3432,7 @@ ARDOUR_UI::setup_order_hint ()
          we want the new routes to have their order keys set starting from 
          the highest order key in the selection + 1 (if available).
        */
-       if (add_route_dialog->get_transient_for () == mixer->get_toplevel()) {
+       if (place == AddRouteDialog::MixerSelection) {
                for (RouteUISelection::iterator s = mixer->selection().routes.begin(); s != mixer->selection().routes.end(); ++s) {
                        if ((*s)->route()->order_key() > order_hint) {
                                order_hint = (*s)->route()->order_key();
@@ -3443,7 +3443,7 @@ ARDOUR_UI::setup_order_hint ()
                        order_hint++;
                }
 
-       } else {
+       } else if (place == AddRouteDialog::EditorSelection){
                for (TrackSelection::iterator s = editor->get_selection().tracks.begin(); s != editor->get_selection().tracks.end(); ++s) {
                        RouteTimeAxisView* tav = dynamic_cast<RouteTimeAxisView*> (*s);
                        if (tav && tav->route() && tav->route()->order_key() > order_hint) {
@@ -3454,28 +3454,34 @@ ARDOUR_UI::setup_order_hint ()
                if (!editor->get_selection().tracks.empty()) {
                        order_hint++;
                }
+       } else {
+               /** AddRouteDialog::End
+                * an order hint of '0' means place new routes at the end.
+                * do nothing
+                */
        }
 
        _session->set_order_hint (order_hint);
 
        /* create a gap in the existing route order keys to accomodate new routes.*/
+       if (order_hint != 0) {
+               boost::shared_ptr <RouteList> rd = _session->get_routes();
+               for (RouteList::iterator ri = rd->begin(); ri != rd->end(); ++ri) {
+                       boost::shared_ptr<Route> rt (*ri);
 
-       boost::shared_ptr <RouteList> rd = _session->get_routes();
-       for (RouteList::iterator ri = rd->begin(); ri != rd->end(); ++ri) {
-               boost::shared_ptr<Route> rt (*ri);
-                       
-               if (rt->is_monitor()) {
-                       continue;
-               }
+                       if (rt->is_monitor()) {
+                               continue;
+                       }
 
-               if (rt->order_key () >= order_hint) {
-                       rt->set_order_key (rt->order_key () + add_route_dialog->count());
+                       if (rt->order_key () >= order_hint) {
+                               rt->set_order_key (rt->order_key () + add_route_dialog->count());
+                       }
                }
        }
 }
 
 void
-ARDOUR_UI::add_route (Gtk::Window* float_window)
+ARDOUR_UI::add_route (Gtk::Window* /* ignored */)
 {
        int count;
 
@@ -3488,11 +3494,6 @@ ARDOUR_UI::add_route (Gtk::Window* float_window)
                return;
        }
 
-       if (float_window) {
-               add_route_dialog->unset_transient_for ();
-               add_route_dialog->set_transient_for (*float_window);
-       }
-
        ResponseType r = (ResponseType) add_route_dialog->run ();
 
        add_route_dialog->hide();
@@ -3509,7 +3510,7 @@ ARDOUR_UI::add_route (Gtk::Window* float_window)
                return;
        }
 
-       setup_order_hint();
+       setup_order_hint(add_route_dialog->insert_at());
 
        string template_path = add_route_dialog->track_template();
        DisplaySuspender ds;
index 0124d3c8f2bf203f3cf618799f7ba15918ef3fbc..66b6610f40c80a757973e9261e0aa03da91fd754 100644 (file)
@@ -609,7 +609,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
 
        void snapshot_session (bool switch_to_it);
        void rename_session ();
-       void setup_order_hint ();
+       void setup_order_hint (AddRouteDialog::InsertAt);
 
        int         create_mixer ();
        int         create_editor ();