Add template dropdown sensitivity
[ardour.git] / gtk2_ardour / add_route_dialog.cc
index bb74bef2c088ee877a67c76b8304da6a06ce3ef7..d937172093fe4baf0bdb6df2b3915d05a52b2358 100644 (file)
@@ -32,6 +32,8 @@
 #include "gtkmm2ext/utils.h"
 #include "gtkmm2ext/doi.h"
 
+#include "widgets/tooltips.h"
+
 #include "ardour/plugin_manager.h"
 #include "ardour/profile.h"
 #include "ardour/template_utils.h"
@@ -42,7 +44,6 @@
 #include "utils.h"
 #include "add_route_dialog.h"
 #include "route_group_dialog.h"
-#include "tooltips.h"
 #include "pbd/i18n.h"
 
 using namespace Gtk;
@@ -61,6 +62,7 @@ AddRouteDialog::AddRouteDialog ()
        , configuration_label (_("Configuration:"))
        , mode_label (_("Record Mode:"))
        , instrument_label (_("Instrument:"))
+       , name_edited_by_user (false)
 {
        set_name ("AddRouteDialog");
        set_skip_taskbar_hint (true);
@@ -172,7 +174,7 @@ AddRouteDialog::AddRouteDialog ()
                table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
                table2->attach (strict_io_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
 
-               ARDOUR_UI_UTILS::set_tooltip (strict_io_combo,
+               ArdourWidgets::set_tooltip (strict_io_combo,
                                _("With strict-i/o enabled, Effect Processors will not modify the number of channels on a track. The number of output channels will always match the number of input channels."));
                ++n;
        }
@@ -182,6 +184,8 @@ AddRouteDialog::AddRouteDialog ()
 
        get_vbox()->pack_start (*vbox, false, false);
 
+       name_template_entry.signal_insert_text ().connect (sigc::mem_fun (*this, &AddRouteDialog::name_template_entry_insertion));
+       name_template_entry.signal_delete_text ().connect (sigc::mem_fun (*this, &AddRouteDialog::name_template_entry_deletion));
        track_bus_combo.signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::track_type_chosen));
        channel_combo.signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::channel_combo_changed));
        channel_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::channel_separator));
@@ -194,10 +198,10 @@ AddRouteDialog::AddRouteDialog ()
           this dialog is shown, via ::on_show()
        */
 
-       add_button (Stock::CANCEL, RESPONSE_CANCEL);
-       add_button (Stock::ADD, RESPONSE_ACCEPT);
-       set_response_sensitive (RESPONSE_ACCEPT, true);
-       set_default_response (RESPONSE_ACCEPT);
+       add_button (_("Add and Close"), AddAndClose);
+       add_button (_("Add"), Add);
+       set_response_sensitive (AddAndClose, true);
+       set_default_response (AddAndClose);
 
        track_type_chosen ();
 }
@@ -206,6 +210,28 @@ AddRouteDialog::~AddRouteDialog ()
 {
 }
 
+void
+AddRouteDialog::on_response (int r)
+{
+       name_edited_by_user = false;
+       /* Don't call ArdourDialog::on_response() because that will
+          automatically hide the dialog.
+       */
+       Gtk::Dialog::on_response (r);
+}
+
+void
+AddRouteDialog::name_template_entry_insertion (Glib::ustring const &,int*)
+{
+       name_edited_by_user = true;
+}
+
+void
+AddRouteDialog::name_template_entry_deletion (int, int)
+{
+       name_edited_by_user = true;
+}
+
 void
 AddRouteDialog::channel_combo_changed ()
 {
@@ -234,6 +260,10 @@ AddRouteDialog::type_wanted() const
 void
 AddRouteDialog::maybe_update_name_template_entry ()
 {
+       if (name_edited_by_user) {
+               return;
+       }
+
        switch (type_wanted()) {
        case AudioTrack:
                name_template_entry.set_text (_("Audio"));
@@ -252,6 +282,7 @@ AddRouteDialog::maybe_update_name_template_entry ()
                name_template_entry.set_text (VCA::default_name_template());
                break;
        }
+       name_edited_by_user = false;
 }
 
 void
@@ -287,7 +318,7 @@ AddRouteDialog::track_type_chosen ()
                                           true, MESSAGE_INFO, BUTTONS_OK, true);
                        msg.set_position (WIN_POS_MOUSE);
                        msg.run ();
-               }
+               }
                channel_combo.set_sensitive (true);
                mode_combo.set_sensitive (true);
                instrument_combo.set_sensitive (true);
@@ -459,6 +490,7 @@ void
 AddRouteDialog::on_show ()
 {
        routes_spinner.grab_focus ();
+       name_edited_by_user = false;
 
        refill_channel_setups ();
        refill_route_groups ();