X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Froute_group_dialog.cc;h=9221a67948964e5d683c0c732fd2adb3ed26b630;hb=898764c5137a5d7dfe63cde93bc4ef3ed86dd5bf;hp=0919a715ae5760782ec1b001629be8d0eaa613b9;hpb=ce08ec0de0b0b077d9b28533c23886607991d144;p=ardour.git diff --git a/gtk2_ardour/route_group_dialog.cc b/gtk2_ardour/route_group_dialog.cc index 0919a715ae..9221a67948 100644 --- a/gtk2_ardour/route_group_dialog.cc +++ b/gtk2_ardour/route_group_dialog.cc @@ -34,6 +34,7 @@ using namespace Gtk; using namespace ARDOUR; +using namespace ARDOUR_UI_UTILS; using namespace std; using namespace PBD; @@ -52,7 +53,6 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new) , _share_color (_("Color")) , _share_monitoring (_("Monitoring")) { - set_modal (true); set_skip_taskbar_hint (true); set_resizable (true); set_name (N_("RouteGroupDialog")); @@ -84,10 +84,9 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new) hbox->pack_start (*l, false, false); hbox->pack_start (_color, false, false); top_vbox->pack_start (*hbox, false, false); - + main_vbox->pack_start (*top_vbox, false, false); - _name.set_text (_group->name ()); _active.set_active (_group->is_active ()); Gdk::Color c; @@ -96,13 +95,11 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new) VBox* options_box = manage (new VBox); options_box->set_spacing (6); - + l = manage (new Label (_("Sharing"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false )); l->set_use_markup (); options_box->pack_start (*l, false, true); - _name.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Dialog::response), RESPONSE_OK)); - _gain.set_active (_group->is_gain()); _relative.set_active (_group->is_relative()); _mute.set_active (_group->is_mute()); @@ -113,6 +110,18 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new) _share_color.set_active (_group->is_color()); _share_monitoring.set_active (_group->is_monitoring()); + if (_group->name ().empty()) { + _initial_name = "1"; + while (!unique_name (_initial_name)) { + _initial_name = bump_name_number (_initial_name); + } + _name.set_text (_initial_name); + update(); + } else { + _name.set_text (_initial_name); + } + + _name.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Dialog::response), RESPONSE_OK)); _name.signal_changed().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); _active.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); _color.signal_color_set().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); @@ -125,7 +134,7 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new) _route_active.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); _share_color.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); _share_monitoring.signal_toggled().connect (sigc::mem_fun (*this, &RouteGroupDialog::update)); - + gain_toggled (); Table* table = manage (new Table (11, 4, false)); @@ -175,19 +184,19 @@ RouteGroupDialog::do_run () { while (1) { int const r = run (); - if (r == Gtk::RESPONSE_CANCEL) { - /* cancel, so just bail now */ - return Gtk::RESPONSE_CANCEL; + + if (r != Gtk::RESPONSE_OK) { + return true; } - if (unique_name ()) { + if (unique_name (_name.get_text())) { /* not cancelled and the name is ok, so all is well */ return false; } _group->set_name (_initial_name); MessageDialog msg ( - _("A route group of this name already exists. Please use a different name."), + _("The group name is not unique. Please use a different name."), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, @@ -197,7 +206,7 @@ RouteGroupDialog::do_run () msg.run (); } - /* NOTREACHED */ + abort(); /* NOTREACHED */ return false; } @@ -219,7 +228,7 @@ RouteGroupDialog::update () plist.add (Properties::monitoring, _share_monitoring.get_active()); _group->apply_changes (plist); - + GroupTabs::set_group_color (_group, gdk_color_to_rgba (_color.get_color ())); } @@ -231,11 +240,12 @@ RouteGroupDialog::gain_toggled () /** @return true if the current group's name is unique accross the session */ bool -RouteGroupDialog::unique_name () const +RouteGroupDialog::unique_name (std::string const name) const { + if (name.empty()) return false; // do not allow empty name, empty means unset. list route_groups = _group->session().route_groups (); list::iterator i = route_groups.begin (); - while (i != route_groups.end() && ((*i)->name() != _name.get_text() || *i == _group)) { + while (i != route_groups.end() && ((*i)->name() != name || *i == _group)) { ++i; }