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
This commit is contained in:
Carl Hetherington 2010-01-15 00:52:22 +00:00
parent bbb65d07d3
commit 43e8e880dc
3 changed files with 28 additions and 4 deletions

View File

@ -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)));
}

View File

@ -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;
}

View File

@ -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__ */