13
0

ActionManager::get_all_actions() no longer includes <Actions> in the paths it returns, part 1

This commit is contained in:
Paul Davis 2019-03-20 11:15:22 -07:00
parent ed97a290db
commit df29e57cb4
3 changed files with 26 additions and 42 deletions

View File

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

View File

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

View File

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