From c3fe336dc5d8d0177dd85fb1c2c16cc084c4f08e Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Wed, 4 Sep 2019 16:57:45 +0800 Subject: [PATCH] Gui: add Gui.updateCommands() for manual command status update --- src/Gui/Application.h | 1 + src/Gui/ApplicationPy.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/Gui/Application.h b/src/Gui/Application.h index 29f279f37b..438b53b47f 100644 --- a/src/Gui/Application.h +++ b/src/Gui/Application.h @@ -252,6 +252,7 @@ public: static PyObject* sAddCommand (PyObject *self,PyObject *args); static PyObject* sListCommands (PyObject *self,PyObject *args); static PyObject* sIsCommandActive (PyObject *self,PyObject *args); + static PyObject* sUpdateCommands (PyObject *self,PyObject *args); static PyObject* sHide (PyObject *self,PyObject *args); // deprecated static PyObject* sShow (PyObject *self,PyObject *args); // deprecated diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index 4c8162a9f6..038a0fe161 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -144,6 +144,9 @@ PyMethodDef Application::Methods[] = { {"listCommands", (PyCFunction) Application::sListCommands, METH_VARARGS, "listCommands() -> list of strings\n\n" "Returns a list of all commands known to FreeCAD."}, + {"updateCommands()", (PyCFunction) Application::sUpdateCommands, METH_VARARGS, + "updateCommands()\n\n" + "Update all command active status"}, {"SendMsgToActiveView", (PyCFunction) Application::sSendActiveView, METH_VARARGS, "deprecated -- use class View"}, {"sendMsgToFocusView", (PyCFunction) Application::sSendFocusView, METH_VARARGS, @@ -1246,6 +1249,14 @@ PyObject* Application::sIsCommandActive(PyObject * /*self*/, PyObject *args) }PY_CATCH; } +PyObject* Application::sUpdateCommands(PyObject * /*self*/, PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return NULL; + + getMainWindow()->updateActions(); + Py_Return; +} PyObject* Application::sListCommands(PyObject * /*self*/, PyObject *args) {