r24770 by craig - #16674: Add in getInfo() for getting doc info (Author, Title, Comments),

scribus-commit scribus-commit at lists.scribus.net
Wed Nov 10 21:21:16 UTC 2021


Author: craig
Date: Wed Nov 10 21:21:16 2021
New Revision: 24770

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24770
Log:
#16674: Add in getInfo() for getting doc info (Author, Title, Comments),
fix compilation issue for Python 2x for getLineSpacingMode()

Modified:
    trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp
    trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.h
    trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
    trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddoc.cpp
    trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddoc.h
    trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.h
    trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptplugin.cpp

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24770&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp	(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.cpp	Wed Nov 10 21:21:16 2021
@@ -270,6 +270,22 @@
 	Py_RETURN_NONE;
 }
 
+PyObject *scribus_getinfo(PyObject* /* self */)
+{
+	if (!checkHaveDocument())
+		return nullptr;
+	if (! ScCore->primaryMainWindow()->doc->hasName)
+	{
+		return PyUnicode_FromString("");
+	}
+
+	DocumentInformation& docInfo = ScCore->primaryMainWindow()->doc->documentInfo();
+	return Py_BuildValue("(sss)",
+				docInfo.author().toUtf8().data(),
+				docInfo.title().toUtf8().data(),
+				docInfo.comments().toUtf8().data());
+}
+
 PyObject *scribus_setunit(PyObject* /* self */, PyObject* args)
 {
 	int e;
@@ -483,6 +499,7 @@
 	  << scribus_deletemasterpage__doc__
 	  << scribus_editmasterpage__doc__ 
 	  << scribus_getdocname__doc__
+	  << scribus_getinfo__doc__
 	  << scribus_getmasterpage__doc__
 	  << scribus_getunit__doc__ 
 	  << scribus_havedoc__doc__

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24770&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.h	(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmddoc.h	Wed Nov 10 21:21:16 2021
@@ -182,6 +182,16 @@
 PyObject *scribus_setinfo(PyObject * /*self*/, PyObject* args);
 
 /*! docstring */
+PyDoc_STRVAR(scribus_getinfo__doc__,
+QT_TR_NOOP("getInfo() -> \"author\", \"info\", \"description\"\n\
+\n\
+Gets the document information. \"Author\", \"Info\", \"Description\" are\n\
+strings.\n\
+"));
+/** Gets document infos - author, title and description */
+PyObject *scribus_getinfo(PyObject * /*self*/);
+
+/*! docstring */
 PyDoc_STRVAR(scribus_setbleeds__doc__,
 QT_TR_NOOP("setBleeds(lr, rr, tr, br)\n\
 \n\

Modified: trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24770&path=/trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp	(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp	Wed Nov 10 21:21:16 2021
@@ -369,6 +369,7 @@
 	{const_cast<char*>("getImageFile"), scribus_getimagefile, METH_VARARGS, tr(scribus_getimagefile__doc__)},
 	{const_cast<char*>("getImageOffset"), scribus_getimageoffset, METH_VARARGS, tr(scribus_getimageoffset__doc__)},
 	{const_cast<char*>("getImageScale"), scribus_getimagescale, METH_VARARGS, tr(scribus_getimagescale__doc__)},
+	{const_cast<char*>("getInfo"), (PyCFunction)scribus_getinfo, METH_VARARGS, tr(scribus_getinfo__doc__)},
 	{const_cast<char*>("getLastLinkedFrame"), scribus_getlastlinkedframe, METH_VARARGS, tr(scribus_getlastlinkedframe__doc__)},
 	{const_cast<char*>("getLayerBlendmode"), scribus_getlayerblendmode, METH_VARARGS, tr(scribus_getlayerblendmode__doc__)},
 	{const_cast<char*>("getLayerTransparency"), scribus_getlayertransparency, METH_VARARGS, tr(scribus_getlayertransparency__doc__)},

Modified: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24770&path=/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddoc.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddoc.cpp	(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddoc.cpp	Wed Nov 10 21:21:16 2021
@@ -268,6 +268,22 @@
 	ScCore->primaryMainWindow()->slotDocCh();
 
 	Py_RETURN_NONE;
+}
+
+PyObject *scribus_getinfo(PyObject* /* self */)
+{
+	if (!checkHaveDocument())
+		return nullptr;
+	if (! ScCore->primaryMainWindow()->doc->hasName)
+	{
+		return PyUnicode_FromString("");
+	}
+
+	DocumentInformation& docInfo = ScCore->primaryMainWindow()->doc->documentInfo();
+	return Py_BuildValue("(sss)",
+				docInfo.author().toUtf8().data(),
+				docInfo.title().toUtf8().data(),
+				docInfo.comments().toUtf8().data());
 }
 
 PyObject *scribus_setunit(PyObject* /* self */, PyObject* args)

Modified: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24770&path=/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddoc.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddoc.h	(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmddoc.h	Wed Nov 10 21:21:16 2021
@@ -182,6 +182,16 @@
 PyObject *scribus_setinfo(PyObject * /*self*/, PyObject* args);
 
 /*! docstring */
+PyDoc_STRVAR(scribus_getinfo__doc__,
+QT_TR_NOOP("getInfo() -> \"author\", \"info\", \"description\"\n\
+\n\
+Gets the document information. \"Author\", \"Info\", \"Description\" are\n\
+strings.\n\
+"));
+/** Gets document infos - author, title and description */
+PyObject *scribus_getinfo(PyObject * /*self*/);
+
+/*! docstring */
 PyDoc_STRVAR(scribus_setbleeds__doc__,
 QT_TR_NOOP("setBleeds(lr, rr, tr, br)\n\
 \n\

Modified: trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24770&path=/trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.h	(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/cmdtext.h	Wed Nov 10 21:21:16 2021
@@ -198,6 +198,15 @@
 PyObject *scribus_getlinespacing(PyObject * /*self*/, PyObject* args);
 
 /*! docstring */
+PyDoc_STRVAR(scribus_getlinespacingmode__doc__,
+QT_TR_NOOP("getLineSpacingMode([\"name\"]) -> float\n\
+\n\
+Returns the line spacing mode of the text frame \"name\". If \"name\" is not given the currently selected item is used.\n\
+"));
+/*! Get line spacing mode*/
+PyObject *scribus_getlinespacingmode(PyObject * /*self*/, PyObject* args);
+
+/*! docstring */
 PyDoc_STRVAR(scribus_gettextdistances__doc__,
 QT_TR_NOOP("getTextDistances([\"name\"]) -> tuple\n\
 \n\
@@ -390,6 +399,7 @@
 \n\
 May throw ValueError if any of the distances are out of bounds (must be positive).\n\
 "));
+
 /*! Set text distances */
 PyObject *scribus_settextdistances(PyObject */*self*/, PyObject* args);
 

Modified: trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24770&path=/trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptplugin.cpp	(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/scriptplugin.cpp	Wed Nov 10 21:21:16 2021
@@ -369,6 +369,7 @@
 	{const_cast<char*>("getImageFile"), scribus_getimagefile, METH_VARARGS, tr(scribus_getimagefile__doc__)},
 	{const_cast<char*>("getImageOffset"), scribus_getimageoffset, METH_VARARGS, tr(scribus_getimageoffset__doc__)},
 	{const_cast<char*>("getImageScale"), scribus_getimagescale, METH_VARARGS, tr(scribus_getimagescale__doc__)},
+	{const_cast<char*>("getInfo"), (PyCFunction)scribus_getinfo, METH_VARARGS, tr(scribus_getinfo__doc__)},
 	{const_cast<char*>("getLastLinkedFrame"), scribus_getlastlinkedframe, METH_VARARGS, tr(scribus_getlastlinkedframe__doc__)},
 	{const_cast<char*>("getLayerBlendmode"), scribus_getlayerblendmode, METH_VARARGS, tr(scribus_getlayerblendmode__doc__)},
 	{const_cast<char*>("getLayerTransparency"), scribus_getlayertransparency, METH_VARARGS, tr(scribus_getlayertransparency__doc__)},




More information about the scribus-commit mailing list