summaryrefslogtreecommitdiff
path: root/gtk2_ardour/utils.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-01-29 20:02:43 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-01-29 20:02:43 +0000
commit9e8082aad6645f67cb18ea608abb6a854fd268d0 (patch)
tree4b6c7cfe6e8171d26d4c33287bbb259ed252c8b8 /gtk2_ardour/utils.cc
parent433f2cfb437e189a5114338c70967815a6d9d02a (diff)
small change to region creation for make-mono-regions; add untested short_path(); fix double-redraws when canvas zoom/position changes
git-svn-id: svn://localhost/ardour2/trunk@1396 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/utils.cc')
-rw-r--r--gtk2_ardour/utils.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index 887494829e..238622ea38 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -547,3 +547,35 @@ 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 len = path.length();
+
+ if (len <= target_characters) {
+ return path;
+ }
+
+
+ slash = path.find_last_of ('/');
+
+ 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);
+ }
+
+ uint32_t so_far = (len - slash) + 4; // allow for .../
+ uint32_t space_for = target_characters - so_far;
+
+ if (slash < target_characters) {
+ return path;
+ }
+
+ string res = ".../";
+ res += path.substr (slash - space_for);
+
+ return res;
+}