Skip to content

Commit

Permalink
+ detect from Python whether a document is modified, give option to s…
Browse files Browse the repository at this point in the history
…uppress warning from SendMsgToActiveView
  • Loading branch information
wwmayer committed Feb 24, 2014
1 parent 49ba4de commit 83caf9d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/Gui/ApplicationPy.cpp
Expand Up @@ -405,12 +405,15 @@ PyObject* Application::sExport(PyObject * /*self*/, PyObject *args,PyObject * /*
PyObject* Application::sSendActiveView(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
{
char *psCommandStr;
if (!PyArg_ParseTuple(args, "s",&psCommandStr)) // convert args: Python->C
PyObject *suppress=Py_False;
if (!PyArg_ParseTuple(args, "s|O!",&psCommandStr,&PyBool_Type,&suppress)) // convert args: Python->C
return NULL; // NULL triggers exception

const char* ppReturn=0;
if (!Instance->sendMsgToActiveView(psCommandStr,&ppReturn))
Base::Console().Warning("Unknown view command: %s\n",psCommandStr);
if (!Instance->sendMsgToActiveView(psCommandStr,&ppReturn)) {
if (!PyObject_IsTrue(suppress))
Base::Console().Warning("Unknown view command: %s\n",psCommandStr);
}

// Print the return value to the output
if (ppReturn) {
Expand Down
8 changes: 7 additions & 1 deletion src/Gui/DocumentPy.xml
Expand Up @@ -106,5 +106,11 @@
</Documentation>
<Parameter Name="Document" Type="Object" />
</Attribute>
</PythonExport>
<Attribute Name="Modified" ReadOnly="true">
<Documentation>
<UserDocu>Returns True if the document is marked as modified, and False otherwse</UserDocu>
</Documentation>
<Parameter Name="Modified" Type="Boolean" />
</Attribute>
</PythonExport>
</GenerateModel>
5 changes: 5 additions & 0 deletions src/Gui/DocumentPyImp.cpp
Expand Up @@ -321,6 +321,11 @@ Py::Object DocumentPy::getDocument(void) const
}
}

Py::Boolean DocumentPy::getModified(void) const
{
return Py::Boolean(getDocumentPtr()->isModified());
}

PyObject *DocumentPy::getCustomAttributes(const char* attr) const
{
// Note: Here we want to return only a document object if its
Expand Down

0 comments on commit 83caf9d

Please sign in to comment.