From: Paul Davis Date: Mon, 20 Jun 2016 21:19:23 +0000 (-0400) Subject: some modest improvements in the html rendering of key bindings, plus use of normal... X-Git-Tag: 5.0-pre1~478 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;ds=sidebyside;h=10a4de155034ffce6b3bc97d0cf91ba8f8e99812;p=ardour.git some modest improvements in the html rendering of key bindings, plus use of normal modifier names --- diff --git a/libs/gtkmm2ext/bindings.cc b/libs/gtkmm2ext/bindings.cc index d06a3a28c1..3dbc3c0302 100644 --- a/libs/gtkmm2ext/bindings.cc +++ b/libs/gtkmm2ext/bindings.cc @@ -234,6 +234,51 @@ KeyboardKey::name () const return str; } +string +KeyboardKey::native_name () const +{ + int s = state(); + + string str; + + if (s & Keyboard::PrimaryModifier) { + str += Keyboard::primary_modifier_name (); + } + if (s & Keyboard::SecondaryModifier) { + if (!str.empty()) { + str += '-'; + } + str += Keyboard::secondary_modifier_name (); + } + if (s & Keyboard::TertiaryModifier) { + if (!str.empty()) { + str += '-'; + } + str += Keyboard::tertiary_modifier_name (); + } + if (s & Keyboard::Level4Modifier) { + if (!str.empty()) { + str += '-'; + } + str += Keyboard::level4_modifier_name (); + } + + if (!str.empty()) { + str += '-'; + } + + char const *gdk_name = gdk_keyval_name (key()); + + if (gdk_name) { + str += gdk_name; + } else { + /* fail! */ + return string(); + } + + return str; +} + bool KeyboardKey::make_key (const string& str, KeyboardKey& k) { @@ -683,30 +728,66 @@ Bindings::save_all_bindings_as_html (ostream& ostr) return; } - ostr << "\n\n"; + + ostr << "<html>\n<head>\n<title>"; ostr << PROGRAM_NAME; - ostr << "\n\n\n"; + ostr << "\n"; + + + ostr << "\n"; + + ostr << "\n\n"; + + ostr << "
\n"; for (list::const_iterator b = bindings.begin(); b != bindings.end(); ++b) { (*b)->save_as_html (ostr); } + ostr << "
\n"; ostr << "\n"; - ostr << "
\n"; + ostr << "\n"; } void Bindings::save_as_html (ostream& ostr) const { - ostr << "

"; - ostr << name(); - ostr << "

\n"; if (!press_bindings.empty() || !button_press_bindings.empty()) { - ostr << "

"; - ostr << _("Press"); - ostr << "

\n"; + ostr << "

"; + ostr << name(); + ostr << "

\n"; if (!press_bindings.empty()) { @@ -731,7 +812,7 @@ Bindings::save_as_html (ostream& ostr) const continue; } - ostr << "
" << k->first.name() << "
\n"; + ostr << "
" << k->first.native_name() << "
\n"; ostr << "
" << action->get_label() << "
\n"; } @@ -741,10 +822,6 @@ Bindings::save_as_html (ostream& ostr) const if (!release_bindings.empty() || !release_bindings.empty()) { - ostr << "

"; - ostr << _("Release"); - ostr << "

\n"; - if (!release_bindings.empty()) { ostr << "
\n"; diff --git a/libs/gtkmm2ext/gtkmm2ext/bindings.h b/libs/gtkmm2ext/gtkmm2ext/bindings.h index c2a5215a68..3462f102ea 100644 --- a/libs/gtkmm2ext/gtkmm2ext/bindings.h +++ b/libs/gtkmm2ext/gtkmm2ext/bindings.h @@ -43,6 +43,7 @@ class LIBGTKMM2EXT_API KeyboardKey } std::string name() const; + std::string native_name() const; static bool make_key (const std::string&, KeyboardKey&); std::string display_label() const;