r14343 by cbradney - #8597: Add getDocName to scripter

scribus-commit scribus-commit at lists.scribus.net
Wed Nov 25 00:05:41 CET 2009


Revision: 14343
Author: cbradney
Date: 2009-11-24T13:52:35.436838Z
Commit message: #8597: Add getDocName to scripter

Changeset: 
M  /branches/Version135/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp
M  /branches/Version135/Scribus/scribus/plugins/scriptplugin/cmddoc.h
M  /branches/Version135/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp

Diffs:
Index: scribus/plugins/scriptplugin/cmddoc.h
===================================================================
--- scribus/plugins/scriptplugin/cmddoc.h	(revision 14342)
+++ scribus/plugins/scriptplugin/cmddoc.h	(revision 14343)
@@ -142,6 +142,16 @@
 PyObject *scribus_savedoc(PyObject * /*self*/);
 
 /*! docstring */
+PyDoc_STRVAR(scribus_getdocname__doc__,
+QT_TR_NOOP("getDocName() -> string\n\
+\n\
+Returns the name the document was saved under.\n\
+If the document was not saved before the name is empty.\n\
+"));
+/** Saves active document with given name */
+PyObject *scribus_getdocname(PyObject * /*self*/);
+
+/*! docstring */
 PyDoc_STRVAR(scribus_savedocas__doc__,
 QT_TR_NOOP("saveDocAs(\"name\")\n\
 \n\
Index: scribus/plugins/scriptplugin/cmddoc.cpp
===================================================================
--- scribus/plugins/scriptplugin/cmddoc.cpp	(revision 14342)
+++ scribus/plugins/scriptplugin/cmddoc.cpp	(revision 14343)
@@ -169,6 +169,17 @@
 	Py_RETURN_NONE;
 }
 
+PyObject *scribus_getdocname(PyObject* /* self */)
+{
+	if(!checkHaveDocument())
+		return NULL;
+	if (! ScCore->primaryMainWindow()->doc->hasName)
+	{
+		return PyString_FromString("");
+	}
+	return PyString_FromString(ScCore->primaryMainWindow()->doc->DocName.toUtf8());
+}
+
 PyObject *scribus_savedocas(PyObject* /* self */, PyObject* args)
 {
 	char *Name;
@@ -363,5 +374,5 @@
 void cmddocdocwarnings()
 {
     QStringList s;
-    s << scribus_newdocument__doc__ << scribus_newdoc__doc__ <<  scribus_closedoc__doc__ << scribus_havedoc__doc__ << scribus_opendoc__doc__ << scribus_savedoc__doc__ << scribus_savedocas__doc__ << scribus_setinfo__doc__ <<scribus_setmargins__doc__ <<scribus_setunit__doc__ <<scribus_getunit__doc__ <<scribus_loadstylesfromfile__doc__ <<scribus_setdoctype__doc__ <<scribus_closemasterpage__doc__ <<scribus_masterpagenames__doc__ <<scribus_editmasterpage__doc__ <<scribus_createmasterpage__doc__ <<scribus_deletemasterpage__doc__;
+    s << scribus_newdocument__doc__ << scribus_newdoc__doc__ <<  scribus_closedoc__doc__ << scribus_havedoc__doc__ << scribus_opendoc__doc__ << scribus_savedoc__doc__ << scribus_getdocname__doc__ << scribus_savedocas__doc__ << scribus_setinfo__doc__ <<scribus_setmargins__doc__ <<scribus_setunit__doc__ <<scribus_getunit__doc__ <<scribus_loadstylesfromfile__doc__ <<scribus_setdoctype__doc__ <<scribus_closemasterpage__doc__ <<scribus_masterpagenames__doc__ <<scribus_editmasterpage__doc__ <<scribus_createmasterpage__doc__ <<scribus_deletemasterpage__doc__;
 }
Index: scribus/plugins/scriptplugin/scriptplugin.cpp
===================================================================
--- scribus/plugins/scriptplugin/scriptplugin.cpp	(revision 14342)
+++ scribus/plugins/scriptplugin/scriptplugin.cpp	(revision 14343)
@@ -403,6 +403,7 @@
 	{const_cast<char*>("replaceColor"), scribus_replcolor, METH_VARARGS, tr(scribus_replcolor__doc__)},
 	{const_cast<char*>("rotateObjectAbs"), scribus_rotobjabs, METH_VARARGS, tr(scribus_rotobjabs__doc__)},
 	{const_cast<char*>("rotateObject"), scribus_rotobjrel, METH_VARARGS, tr(scribus_rotobjrel__doc__)},
+	{const_cast<char*>("getDocName"), (PyCFunction)scribus_getdocname, METH_NOARGS, tr(scribus_getdocname__doc__)},
 	{const_cast<char*>("saveDocAs"), scribus_savedocas, METH_VARARGS, tr(scribus_savedocas__doc__)},
 	{const_cast<char*>("saveDoc"), (PyCFunction)scribus_savedoc, METH_NOARGS, tr(scribus_savedoc__doc__)},
 	{const_cast<char*>("savePageAsEPS"), scribus_savepageeps, METH_VARARGS, tr(scribus_savepageeps__doc__)},




More information about the scribus-commit mailing list