summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-05-21 09:30:05 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-05-31 15:30:44 -0400
commit405fda66f708e61a933d88a3889916b6488cd9da (patch)
treed654ccfe5c928a8ee7d4a3dd7fa5943b84f43ec8
parent4cd6d52013dc60d65c2872d9d6e87e83e85cff95 (diff)
basics of printing bindings as HTML
-rw-r--r--libs/gtkmm2ext/bindings.cc101
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/bindings.h2
2 files changed, 103 insertions, 0 deletions
diff --git a/libs/gtkmm2ext/bindings.cc b/libs/gtkmm2ext/bindings.cc
index deac345418..155b2cf11c 100644
--- a/libs/gtkmm2ext/bindings.cc
+++ b/libs/gtkmm2ext/bindings.cc
@@ -676,6 +676,107 @@ Bindings::save (XMLNode& root)
root.add_child_nocopy (*releases);
}
+void
+Bindings::save_all_bindings_as_html (ostream& ostr)
+{
+ if (bindings.empty()) {
+ return;
+ }
+
+ ostr << "<http>\n<head>\n<title>";
+ ostr << PROGRAM_NAME;
+ ostr << "</title>\n</head>\n<body>\n";
+
+ for (list<Bindings*>::const_iterator b = bindings.begin(); b != bindings.end(); ++b) {
+ (*b)->save_as_html (ostr);
+ }
+
+ ostr << "</body>\n";
+ ostr << "</http>\n";
+}
+
+void
+Bindings::save_as_html (ostream& ostr) const
+{
+ ostr << "<h1 class=\"binding-set-name\">";
+ ostr << name();
+ ostr << "</h1>\n";
+
+ if (!press_bindings.empty() || !button_press_bindings.empty()) {
+
+ ostr << "<h2 class=\"action-title\">";
+ ostr << _("Press");
+ ostr << "</h2>\n";
+
+ if (!press_bindings.empty()) {
+
+ ostr << "<dl class=\"key-binding\">\n";
+
+ for (KeybindingMap::const_iterator k = press_bindings.begin(); k != press_bindings.end(); ++k) {
+ if (k->first.name().empty()) {
+ continue;
+ }
+
+ RefPtr<Action> action;
+
+ if (k->second.action) {
+ action = k->second.action;
+ } else {
+ if (_action_map) {
+ action = _action_map->find_action (k->second.action_name);
+ }
+ }
+
+ if (!action) {
+ continue;
+ }
+
+ ostr << "<dt class=\"key-name\">" << k->first.name() << "</dt>\n";
+ ostr << "<dd class=\"key-action\">" << action->get_label() << "</dd>\n";
+ }
+
+ ostr << "</dl>\n";
+ }
+ }
+
+ if (!release_bindings.empty() || !release_bindings.empty()) {
+
+ ostr << "<h2 class=\"action-title\">";
+ ostr << _("Release");
+ ostr << "</h2>\n";
+
+ if (!release_bindings.empty()) {
+ ostr << "<dl class=\"key-binding\">\n";
+
+ for (KeybindingMap::const_iterator k = release_bindings.begin(); k != release_bindings.end(); ++k) {
+
+ if (k->first.name().empty()) {
+ continue;
+ }
+
+ RefPtr<Action> action;
+
+ if (k->second.action) {
+ action = k->second.action;
+ } else {
+ if (_action_map) {
+ action = _action_map->find_action (k->second.action_name);
+ }
+ }
+
+ if (!action) {
+ continue;
+ }
+
+ ostr << "<dt class=\"key-name\">" << k->first.name() << "</dt>\n";
+ ostr << "<dd class=\"key-action\">" << action->get_label() << "</dd>\n";
+ }
+
+ ostr << "</dl>\n";
+ }
+ }
+}
+
bool
Bindings::load (XMLNode const& node)
{
diff --git a/libs/gtkmm2ext/gtkmm2ext/bindings.h b/libs/gtkmm2ext/gtkmm2ext/bindings.h
index f7437fa67b..c2a5215a68 100644
--- a/libs/gtkmm2ext/gtkmm2ext/bindings.h
+++ b/libs/gtkmm2ext/gtkmm2ext/bindings.h
@@ -180,6 +180,7 @@ class LIBGTKMM2EXT_API Bindings {
bool load (XMLNode const& node);
void load_operation (XMLNode const& node);
void save (XMLNode& root);
+ void save_as_html (std::ostream&) const;
/* GTK has the following position a Gtk::Action:
*
@@ -209,6 +210,7 @@ class LIBGTKMM2EXT_API Bindings {
static std::list<Bindings*> bindings;
static Bindings* get_bindings (std::string const& name, ActionMap&);
static void associate_all ();
+ static void save_all_bindings_as_html (std::ostream&);
static PBD::Signal1<void,Bindings*> BindingsChanged;