r14940 by jghali - #8965: add getObjectType([name]) -> string api

scribus-commit scribus-commit at lists.scribus.net
Sat Mar 27 14:21:05 CET 2010


Revision: 14940
Author: jghali
Date: 2010-03-27T13:14:02.815357Z
Commit message: #8965: add getObjectType([name]) -> string api

Changeset: 
M  /trunk/Scribus/scribus/plugins/scriptplugin/cmdgetprop.cpp
M  /trunk/Scribus/doc/en/scripterapi-getobjprop.html
M  /trunk/Scribus/scribus/plugins/scriptplugin/cmdgetprop.h
M  /trunk/Scribus/doc/fr/scripterapi-getobjprop.html
M  /trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp

Diffs:
Index: doc/en/scripterapi-getobjprop.html
===================================================================
--- doc/en/scripterapi-getobjprop.html	(revision 14939)
+++ doc/en/scripterapi-getobjprop.html	(revision 14940)
@@ -8,6 +8,10 @@
 
 <dl>
 
+<dt><a name="-getObjectType"><strong>getObjectType</strong></a>(...)</dt>
+<dd><code>getObjectType(["name"]) -&gt; string</code>
+<p>Get type of object "name" as a string. If "name" is not given the currently selected item is used.</p></dd>
+
 <dt><a name="-getCornerRadius"><strong>getCornerRadius</strong></a>(...)</dt>
 <dd><code>getCornerRadius(["name"]) -&gt; integer</code>
 <p>Returns the corner radius of the object "name". The radius is expressed in points. If "name" is not given the currently selected item is used.</p></dd>
Index: doc/fr/scripterapi-getobjprop.html
===================================================================
--- doc/fr/scripterapi-getobjprop.html	(revision 14939)
+++ doc/fr/scripterapi-getobjprop.html	(revision 14940)
@@ -8,6 +8,11 @@
 
 <dl>
 
+<dt><a name="-getObjectType"><strong>getObjectType</strong></a>(...)</dt>
+<dd><code><a href="#-getObjectType">getObjectType</a>(["nom"])
+-&gt; cha&icirc;ne</code>
+<p>Retourne le type de l'objet "nom" sous forme d'une cha&icirc;ne de caract&egrave;re. Si "nom" n'est pas fourni, l'&eacute;l&eacute;ment s&eacute;lectionn&eacute; est utilis&eacute;. </p></dd>
+
 <dt><a name="-getCornerRadius"><strong>getCornerRadius</strong></a>(...)</dt>
 <dd><code><a href="#-getCornerRadius">getCornerRadius</a>(["nom"])
 -&gt; nombre entier</code>
Index: scribus/plugins/scriptplugin/cmdgetprop.cpp
===================================================================
--- scribus/plugins/scriptplugin/cmdgetprop.cpp	(revision 14939)
+++ scribus/plugins/scriptplugin/cmdgetprop.cpp	(revision 14940)
@@ -9,6 +9,44 @@
 #include "scribuscore.h"
 #include "scribusdoc.h"
 
+/* getObjectType(name) */
+PyObject *scribus_getobjecttype(PyObject* /* self */, PyObject* args)
+{
+	char *Name = const_cast<char*>("");
+	PageItem *item = NULL;
+	QString result = "";
+
+	if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
+		return NULL;
+
+	if(!checkHaveDocument())
+		return NULL;
+
+	item = GetUniqueItem(QString::fromUtf8(Name));
+	if (item == NULL)
+		return NULL;
+
+	if (item->itemType() == PageItem::TextFrame) {
+		result = "TextFrame";
+	} else if (item->itemType() == PageItem::PathText) {
+		result = "PathText";
+	} else if (item->itemType() == PageItem::ImageFrame) {
+		result = "ImageFrame";
+	} else if (item->itemType() == PageItem::Line) {
+		result = "Line";
+	} else if (item->itemType() == PageItem::Polygon) {
+		result = "Polygon";
+	} else if (item->itemType() == PageItem::PolyLine) {
+		result = "Polyline";
+	} else if (item->itemType() == PageItem::LatexFrame) {
+		result = "LatexFrame";
+	} else if (item->itemType() == PageItem::Multiple) {
+		result = "Multiple";
+	}
+
+	return PyString_FromString(result.toUtf8());
+}
+
 PyObject *scribus_getfillcolor(PyObject* /* self */, PyObject* args)
 {
 	char *Name = const_cast<char*>("");
@@ -295,5 +333,14 @@
 void cmdgetpropdocwarnings()
 {
     QStringList s;
-    s << scribus_getfillcolor__doc__ <<scribus_getfilltrans__doc__ << scribus_getfillblend__doc__ << scribus_getlinecolor__doc__ << scribus_getlinetrans__doc__ << scribus_getlineblend__doc__ << scribus_getlinewidth__doc__ << scribus_getlineshade__doc__ <<scribus_getlinejoin__doc__ <<scribus_getlineend__doc__ <<scribus_getlinestyle__doc__ <<scribus_getfillshade__doc__ <<scribus_getcornerrad__doc__ <<scribus_getimgscale__doc__ <<scribus_getimgname__doc__ <<scribus_getposi__doc__ <<scribus_getsize__doc__ <<scribus_getrotation__doc__ <<  scribus_getallobj__doc__;
+    s << scribus_getobjecttype__doc__ << scribus_getfillcolor__doc__ 
+	  << scribus_getfilltrans__doc__ << scribus_getfillblend__doc__ 
+	  << scribus_getlinecolor__doc__ << scribus_getlinetrans__doc__ 
+	  << scribus_getlineblend__doc__ << scribus_getlinewidth__doc__ 
+	  << scribus_getlineshade__doc__ << scribus_getlinejoin__doc__ 
+	  << scribus_getlineend__doc__ << scribus_getlinestyle__doc__ 
+	  << scribus_getfillshade__doc__ << scribus_getcornerrad__doc__ 
+	  << scribus_getimgscale__doc__ << scribus_getimgname__doc__ 
+	  << scribus_getposi__doc__ << scribus_getsize__doc__ 
+	  << scribus_getrotation__doc__ <<  scribus_getallobj__doc__;
 }
Index: scribus/plugins/scriptplugin/cmdgetprop.h
===================================================================
--- scribus/plugins/scriptplugin/cmdgetprop.h	(revision 14939)
+++ scribus/plugins/scriptplugin/cmdgetprop.h	(revision 14940)
@@ -13,6 +13,15 @@
 /** Query-Functions */
 
 /*! docstring */
+PyDoc_STRVAR(scribus_getobjecttype__doc__,
+QT_TR_NOOP("getObjectType([\"name\"]) -> string\n\
+\n\
+Get type of object \"name\" as a string.\n\
+"));
+/** Get Object Type of name. */
+PyObject *scribus_getobjecttype(PyObject * /*self*/, PyObject* args);
+
+/*! docstring */
 PyDoc_STRVAR(scribus_getfillcolor__doc__,
 QT_TR_NOOP("getFillColor([\"name\"]) -> string\n\
 \n\
Index: scribus/plugins/scriptplugin/scriptplugin.cpp
===================================================================
--- scribus/plugins/scriptplugin/scriptplugin.cpp	(revision 14939)
+++ scribus/plugins/scriptplugin/scriptplugin.cpp	(revision 14940)
@@ -373,6 +373,7 @@
 	{const_cast<char*>("importPage"), scribus_importpage, METH_VARARGS, tr(scribus_importpage__doc__)},
 	{const_cast<char*>("getPosition"), scribus_getposi, METH_VARARGS, tr(scribus_getposi__doc__)},
 	{const_cast<char*>("getRotation"), scribus_getrotation, METH_VARARGS, tr(scribus_getrotation__doc__)},
+	{const_cast<char*>("getObjectType"), scribus_getobjecttype, METH_VARARGS, tr(scribus_getobjecttype__doc__)},
 	{const_cast<char*>("getSelectedObject"), scribus_getselobjnam, METH_VARARGS, tr(scribus_getselobjnam__doc__)},
 	{const_cast<char*>("getSize"), scribus_getsize, METH_VARARGS, tr(scribus_getsize__doc__)},
 	{const_cast<char*>("getTextColor"), scribus_getlinecolor, METH_VARARGS, tr(scribus_getlinecolor__doc__)},




More information about the scribus-commit mailing list