summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-01-15 00:52:22 +0000
committerCarl Hetherington <carl@carlh.net>2010-01-15 00:52:22 +0000
commit43e8e880dc25a52b6a929b9c5eebfbe348c43e95 (patch)
treec14a1bd69d98091963b9ff0692a5e26d70bc166a /gtk2_ardour
parentbbb65d07d33160366533d9f2390f3f8d56fcb8e1 (diff)
Escape underscores in port matrix menus correctly so that track names etc. with underscores get displayed properly.
git-svn-id: svn://localhost/ardour2/branches/3.0@6491 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/port_matrix.cc12
-rw-r--r--gtk2_ardour/utils.cc18
-rw-r--r--gtk2_ardour/utils.h2
3 files changed, 28 insertions, 4 deletions
diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc
index 247d750534..209c4760f1 100644
--- a/gtk2_ardour/port_matrix.cc
+++ b/gtk2_ardour/port_matrix.cc
@@ -35,6 +35,7 @@
#include "port_matrix_component.h"
#include "i18n.h"
#include "gui_thread.h"
+#include "utils.h"
using namespace std;
using namespace Gtk;
@@ -393,7 +394,10 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t)
if (can_rename_channels (bc[dim].bundle)) {
- snprintf (buf, sizeof (buf), _("Rename '%s'..."), bc[dim].bundle->channel_name (bc[dim].channel).c_str());
+ snprintf (
+ buf, sizeof (buf), _("Rename '%s'..."),
+ escape_underscores (bc[dim].bundle->channel_name (bc[dim].channel)).c_str()
+ );
sub.push_back (
MenuElem (
buf,
@@ -445,7 +449,7 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t)
}
}
- items.push_back (MenuElem (bc[dim].bundle->name().c_str(), *m));
+ items.push_back (MenuElem (escape_underscores (bc[dim].bundle->name()).c_str(), *m));
need_separator = true;
}
@@ -807,7 +811,7 @@ PortMatrix::add_remove_option (Menu_Helpers::MenuList& m, boost::weak_ptr<Bundle
}
char buf [64];
- snprintf (buf, sizeof (buf), _("Remove '%s'"), b->channel_name (c).c_str());
+ snprintf (buf, sizeof (buf), _("Remove '%s'"), escape_underscores (b->channel_name (c)).c_str());
m.push_back (MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::remove_channel_proxy), w, c)));
}
@@ -822,6 +826,6 @@ PortMatrix::add_disassociate_option (Menu_Helpers::MenuList& m, boost::weak_ptr<
}
char buf [64];
- snprintf (buf, sizeof (buf), _("%s all from '%s'"), disassociation_verb().c_str(), b->channel_name (c).c_str());
+ snprintf (buf, sizeof (buf), _("%s all from '%s'"), disassociation_verb().c_str(), escape_underscores (b->channel_name (c)).c_str());
m.push_back (MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::disassociate_all_on_channel), w, c, d)));
}
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index 9aba168ef1..b8d7569414 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -1016,3 +1016,21 @@ pixbuf_from_ustring(const ustring& name, Pango::FontDescription* font, int clip_
return buf;
}
+
+/** Replace _ with __ in a string; for use with menu item text to make underscores displayed correctly */
+string
+escape_underscores (string const & s)
+{
+ string o;
+ string::size_type const N = s.length ();
+
+ for (string::size_type i = 0; i < N; ++i) {
+ if (s[i] == '_') {
+ o += "__";
+ } else {
+ o += s[i];
+ }
+ }
+
+ return o;
+}
diff --git a/gtk2_ardour/utils.h b/gtk2_ardour/utils.h
index e742e89cd5..9ee66729fc 100644
--- a/gtk2_ardour/utils.h
+++ b/gtk2_ardour/utils.h
@@ -95,4 +95,6 @@ Glib::RefPtr<Gdk::Pixbuf> pixbuf_from_ustring (const Glib::ustring& name,
void resize_window_to_proportion_of_monitor (Gtk::Window*, int, int);
+std::string escape_underscores (std::string const &);
+
#endif /* __ardour_gtk_utils_h__ */