diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-01-31 18:51:33 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-01-31 18:51:33 +0000 |
commit | df1c4dddc39d1cc5132501afb94bbabb9935cc32 (patch) | |
tree | 41ea78314c31f174d0da099c36f76b4c553a2287 /gtk2_ardour/utils.cc | |
parent | 1ab5012af74371379a5a35c3c43ecf05ed91645e (diff) |
remove ardour_message.{cc,h}; JACK latency menu now shows correct settings at startup and changes are handled correctly; export range markers doesn't start with /path/to/export.wav, just /path/to; hopefully improve ruler scrolling a little; fixed up short_path() implementation ; fix for export unsetting JACK freewheel too soon ; use ISO 8061 timestamps for snapshot default names
git-svn-id: svn://localhost/ardour2/trunk@1400 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/utils.cc')
-rw-r--r-- | gtk2_ardour/utils.cc | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index 238622ea38..f978324ab2 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -547,35 +547,55 @@ key_is_legal_for_numeric_entry (guint keyval) return false; } + ustring short_path (ustring path, uint32_t target_characters) { - ustring::size_type slash; + ustring::size_type last_sep; ustring::size_type len = path.length(); - + const char separator = '/'; + if (len <= target_characters) { return path; } + if ((last_sep = path.find_last_of (separator)) == ustring::npos) { - slash = path.find_last_of ('/'); + /* just a filename, but its too long anyway */ - if (len - slash > target_characters) { - /* even the filename itself is too long, so just return it - its - the best we can do - */ - return path.substr (slash); + if (target_characters > 3) { + return path.substr (0, target_characters - 3) + ustring ("..."); + } else { + /* stupid caller, just hand back the whole thing */ + return path; + } + } + + if (len - last_sep >= target_characters) { + + /* even the filename itself is too long */ + + if (target_characters > 3) { + return path.substr (last_sep+1, target_characters - 3) + ustring ("..."); + } else { + /* stupid caller, just hand back the whole thing */ + return path; + } } - uint32_t so_far = (len - slash) + 4; // allow for .../ + uint32_t so_far = (len - last_sep); uint32_t space_for = target_characters - so_far; - - if (slash < target_characters) { - return path; - } - string res = ".../"; - res += path.substr (slash - space_for); - - return res; + if (space_for >= 3) { + ustring res = "..."; + res += path.substr (last_sep - space_for); + return res; + } else { + /* remove part of the end */ + ustring res = "..."; + res += path.substr (last_sep - space_for, len - last_sep + space_for - 3); + res += "..."; + return res; + + } } |