[Gui] Introducing user edit mode

This commit is contained in:
0penBrain
2021-05-09 09:58:11 +02:00
parent bb434d3ff2
commit ef22c6ba1e
3 changed files with 108 additions and 0 deletions

View File

@@ -205,6 +205,18 @@ PyMethodDef Application::Methods[] = {
{"removeDocumentObserver", (PyCFunction) Application::sRemoveDocObserver, METH_VARARGS,
"removeDocumentObserver() -> None\n\n"
"Remove an added document observer."},
{"listUserEditModes", (PyCFunction) Application::sListUserEditModes, METH_VARARGS,
"listUserEditModes() -> list\n\n"
"List available user edit modes"},
{"getUserEditMode", (PyCFunction) Application::sGetUserEditMode, METH_VARARGS,
"getUserEditMode() -> string\n\n"
"Get current user edit mode"},
{"setUserEditMode", (PyCFunction) Application::sSetUserEditMode, METH_VARARGS,
"setUserEditMode(string=mode) -> Bool\n\n"
"Set user edit mode to 'mode', returns True if exists, false otherwise"},
{"reload", (PyCFunction) Application::sReload, METH_VARARGS,
"reload(name) -> doc\n\n"
@@ -1485,3 +1497,29 @@ PyObject* Application::sCoinRemoveAllChildren(PyObject * /*self*/, PyObject *arg
}PY_CATCH;
}
PyObject* Application::sListUserEditModes(PyObject * /*self*/, PyObject *args)
{
Py::List ret;
if (!PyArg_ParseTuple(args, ""))
return NULL;
for (auto const &uem : Instance->listUserEditModes()) {
ret.append(Py::String(uem.second));
}
return Py::new_reference_to(ret);
}
PyObject* Application::sGetUserEditMode(PyObject * /*self*/, PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
return Py::new_reference_to(Py::String(Instance->getUserEditModeName()));
}
PyObject* Application::sSetUserEditMode(PyObject * /*self*/, PyObject *args)
{
char *mode = "";
if (!PyArg_ParseTuple(args, "s", &mode))
return NULL;
bool ok = Instance->setUserEditMode(std::string(mode));
return Py::new_reference_to(Py::Boolean(ok));
}