summaryrefslogtreecommitdiff
path: root/libs/gtkmm2ext
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2019-03-20 11:15:22 -0700
committerPaul Davis <paul@linuxaudiosystems.com>2019-03-20 11:15:22 -0700
commitdf29e57cb400243bf0cf435e78f0037cb47f5012 (patch)
tree1c5d4d22c6452b6e1e118776baae9c2b83430f07 /libs/gtkmm2ext
parented97a290db2c7c5e7bbc5ac3ac1a8917d13e22b5 (diff)
ActionManager::get_all_actions() no longer includes <Actions> in the paths it returns, part 1
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r--libs/gtkmm2ext/actions.cc58
-rw-r--r--libs/gtkmm2ext/bindings.cc8
-rw-r--r--libs/gtkmm2ext/gtk_ui.cc2
3 files changed, 26 insertions, 42 deletions
diff --git a/libs/gtkmm2ext/actions.cc b/libs/gtkmm2ext/actions.cc
index 700db236d1..69814f8728 100644
--- a/libs/gtkmm2ext/actions.cc
+++ b/libs/gtkmm2ext/actions.cc
@@ -203,29 +203,16 @@ ActionManager::uncheck_toggleaction (const string& n)
void
ActionManager::set_toggleaction_state (const string& n, bool s)
{
- char const * name = n.c_str ();
+ string::size_type pos = n.find ('/');
- const char *last_slash = strrchr (name, '/');
-
- if (last_slash == 0) {
- fatal << string_compose ("programmer error: %1 %2", "illegal toggle action name", name) << endmsg;
- throw MissingActionException (n);
+ if (pos == string::npos || pos == n.size() - 1) {
+ error << string_compose ("illegal action name \"%1\" passed to ActionManager::set_toggleaction_state()", n) << endmsg;
return;
}
- /* 10 = strlen ("<Actions>/") */
- size_t len = last_slash - (name + 10);
-
- char* group_name = new char[len+1];
- memcpy (group_name, name + 10, len);
- group_name[len] = '\0';
-
- const char* action_name = last_slash + 1;
- if (!set_toggleaction_state (group_name, action_name, s)) {
- error << string_compose (_("Unknown action name: %1/%2"), group_name, action_name) << endmsg;
+ if (!set_toggleaction_state (n.substr (0, pos).c_str(), n.substr (pos+1).c_str(), s)) {
+ error << string_compose (_("Unknown action name: %1/%2"), n.substr (0, pos), n.substr (pos+1)) << endmsg;
}
-
- delete [] group_name;
}
bool
@@ -533,33 +520,34 @@ ActionManager::get_all_actions (std::vector<std::string>& paths,
Glib::RefPtr<Action> act = a->second;
- paths.push_back (act->get_accel_path());
- labels.push_back (act->get_label());
- tooltips.push_back (act->get_tooltip());
- acts.push_back (act);
+ /* strip the GTK-added <Actions>/ from the front */
+ paths.push_back (act->get_accel_path().substr (10));
+ labels.push_back (act->get_label());
+ tooltips.push_back (act->get_tooltip());
+ acts.push_back (act);
- /* foreach binding */
+ /* foreach binding */
#if 0
- Bindings* bindings = (*map)->bindings();
+ Bindings* bindings = (*map)->bindings();
- if (bindings) {
+ if (bindings) {
- KeyboardKey key;
- Bindings::Operation op;
+ KeyboardKey key;
+ Bindings::Operation op;
- key = bindings->get_binding_for_action (*act, op);
+ key = bindings->get_binding_for_action (*act, op);
- if (key == KeyboardKey::null_key()) {
- keys.push_back (string());
- } else {
- keys.push_back (key.display_label());
- }
- } else {
+ if (key == KeyboardKey::null_key()) {
keys.push_back (string());
+ } else {
+ keys.push_back (key.display_label());
}
-#else
+ } else {
keys.push_back (string());
+ }
+#else
+ keys.push_back (string());
#endif
}
}
diff --git a/libs/gtkmm2ext/bindings.cc b/libs/gtkmm2ext/bindings.cc
index 7f821d6e54..9d036289f1 100644
--- a/libs/gtkmm2ext/bindings.cc
+++ b/libs/gtkmm2ext/bindings.cc
@@ -804,14 +804,10 @@ Bindings::save_all_bindings_as_html (ostream& ostr)
for (p = paths.begin(), k = keys.begin(), l = labels.begin(); p != paths.end(); ++k, ++p, ++l) {
- string print_path = *p;
- /* strip <Actions>/ from the start */
- print_path = print_path.substr (10);
-
if ((*k).empty()) {
- ostr << print_path << " ( " << *l << " ) " << "</br>" << endl;
+ ostr << *p << " ( " << *l << " ) " << "</br>" << endl;
} else {
- ostr << print_path << " ( " << *l << " ) " << " => " << *k << "</br>" << endl;
+ ostr << *p << " ( " << *l << " ) " << " => " << *k << "</br>" << endl;
}
}
}
diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc
index 0e28f150c3..444e7471e9 100644
--- a/libs/gtkmm2ext/gtk_ui.cc
+++ b/libs/gtkmm2ext/gtk_ui.cc
@@ -109,7 +109,7 @@ UI::UI (string application_name, string thread_name, int *argc, char ***argv)
errors = new TextViewer (800,600);
errors->text().set_editable (false);
errors->text().set_name ("ErrorText");
- errors->signal_unmap().connect (sigc::bind (sigc::ptr_fun (&ActionManager::uncheck_toggleaction), X_("<Actions>/Editor/toggle-log-window")));
+ errors->signal_unmap().connect (sigc::bind (sigc::ptr_fun (&ActionManager::uncheck_toggleaction), X_("Editor/toggle-log-window")));
Glib::set_application_name (application_name);