diff --git a/gtk2_ardour/route_group_dialog.cc b/gtk2_ardour/route_group_dialog.cc index fbbcf54fe7..84dc13ccd0 100644 --- a/gtk2_ardour/route_group_dialog.cc +++ b/gtk2_ardour/route_group_dialog.cc @@ -115,9 +115,9 @@ RouteGroupDialog::RouteGroupDialog (RouteGroup* g, bool creating_new) _share_monitoring.set_active (_group->is_monitoring()); if (_group->name ().empty()) { - _initial_name = "1"; + _initial_name = bump_name_abc (""); while (!unique_name (_initial_name)) { - _initial_name = bump_name_number (_initial_name); + _initial_name = bump_name_abc (_initial_name); } _name.set_text (_initial_name); update(); diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h index 22a99c758f..32c27fc26a 100644 --- a/libs/ardour/ardour/utils.h +++ b/libs/ardour/ardour/utils.h @@ -70,6 +70,7 @@ static inline float f_max(float x, float a) { LIBARDOUR_API std::string bump_name_once(const std::string& s, char delimiter); LIBARDOUR_API std::string bump_name_number(const std::string& s); +LIBARDOUR_API std::string bump_name_abc(const std::string& s); LIBARDOUR_API int cmp_nocase (const std::string& s, const std::string& s2); LIBARDOUR_API int cmp_nocase_utf8 (const std::string& s1, const std::string& s2); diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index 25b31f4984..4ecdd22c8c 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -232,6 +232,44 @@ ARDOUR::bump_name_number (const std::string& name) return newname; } +string +ARDOUR::bump_name_abc (const std::string& name) +{ + /* A, B, C, .. Z, A1, B1, .. Z1, A2 .. Z2, A3 .. */ + static char const* abc = _("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + if (name.empty ()) { + return {abc[0]}; + } + + /* check first char */ + char first = toupper (name[0]); + + char const* end = abc + strlen (abc); + char const* pos = std::find (abc, end, first); + + /* first char is not in the given set. Start over */ + if (pos == end) { + return {abc[0]}; + } + + ++pos; + if (pos != end) { + string rv = name; + rv[0] = *pos; + return rv; + } + + /* find number */ + size_t num = 0; + if (name.length () > 1) { + num = strtol (name.c_str() + 1, (char **)NULL, 10); + } + ++num; + + return string_compose ("%1%2", abc[0], num); +} + + XMLNode * ARDOUR::find_named_node (const XMLNode& node, string name) {