summaryrefslogtreecommitdiff
path: root/gtk2_ardour/route_group_dialog.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-06-30 18:25:11 +0200
committerRobin Gareus <robin@gareus.org>2014-06-30 18:33:05 +0200
commitbae86a2d908122d0bb54afcce82d2cf232268a8a (patch)
treedd02552b2e063fb877684d15d1ab4092ed45140b /gtk2_ardour/route_group_dialog.cc
parent26ba90815b7e0e5ce4823e6fe86edc795bb3e7b1 (diff)
Disallow empty names for Groups, automatically enumerate them
Diffstat (limited to 'gtk2_ardour/route_group_dialog.cc')
-rw-r--r--gtk2_ardour/route_group_dialog.cc18
1 files changed, 14 insertions, 4 deletions
diff --git a/gtk2_ardour/route_group_dialog.cc b/gtk2_ardour/route_group_dialog.cc
index f659a683d4..b4da3c19f3 100644
--- a/gtk2_ardour/route_group_dialog.cc
+++ b/gtk2_ardour/route_group_dialog.cc
@@ -88,6 +88,15 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new)
main_vbox->pack_start (*top_vbox, false, false);
+ 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();
+ }
+
_name.set_text (_group->name ());
_active.set_active (_group->is_active ());
@@ -181,14 +190,14 @@ RouteGroupDialog::do_run ()
return Gtk::RESPONSE_CANCEL;
}
- 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,
@@ -232,11 +241,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<RouteGroup*> route_groups = _group->session().route_groups ();
list<RouteGroup*>::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;
}