From df29e57cb400243bf0cf435e78f0037cb47f5012 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 20 Mar 2019 11:15:22 -0700 Subject: ActionManager::get_all_actions() no longer includes in the paths it returns, part 1 --- libs/gtkmm2ext/actions.cc | 58 ++++++++++++++++++---------------------------- libs/gtkmm2ext/bindings.cc | 8 ++----- libs/gtkmm2ext/gtk_ui.cc | 2 +- 3 files changed, 26 insertions(+), 42 deletions(-) (limited to 'libs/gtkmm2ext') 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 ("/") */ - 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& paths, Glib::RefPtr 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 / 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 / from the start */ - print_path = print_path.substr (10); - if ((*k).empty()) { - ostr << print_path << " ( " << *l << " ) " << "
" << endl; + ostr << *p << " ( " << *l << " ) " << "
" << endl; } else { - ostr << print_path << " ( " << *l << " ) " << " => " << *k << "
" << endl; + ostr << *p << " ( " << *l << " ) " << " => " << *k << "
" << 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_("/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); -- cgit v1.2.3