r14939 by jghali - #8965: add getObjectType([name]) -> string api
scribus-commit
scribus-commit at lists.scribus.net
Sat Mar 27 14:20:35 CET 2010
Revision: 14939
Author: jghali
Date: 2010-03-27T13:13:23.710340Z
Commit message: #8965: add getObjectType([name]) -> string api
Changeset:
M /branches/Version135/Scribus/scribus/plugins/scriptplugin/cmdgetprop.cpp
M /branches/Version135/Scribus/scribus/doc/fr/scripterapi-getobjprop.html
M /branches/Version135/Scribus/scribus/plugins/scriptplugin/cmdgetprop.h
M /branches/Version135/Scribus/scribus/doc/en/scripterapi-getobjprop.html
M /branches/Version135/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
Diffs:
Index: scribus/doc/en/scripterapi-getobjprop.html
===================================================================
--- scribus/doc/en/scripterapi-getobjprop.html (revision 14938)
+++ scribus/doc/en/scripterapi-getobjprop.html (revision 14939)
@@ -8,6 +8,10 @@
<dl>
+<dt><a name="-getObjectType"><strong>getObjectType</strong></a>(...)</dt>
+<dd><code>getObjectType(["name"]) -> 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"]) -> 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: scribus/doc/fr/scripterapi-getobjprop.html
===================================================================
--- scribus/doc/fr/scripterapi-getobjprop.html (revision 14938)
+++ scribus/doc/fr/scripterapi-getobjprop.html (revision 14939)
@@ -8,6 +8,11 @@
<dl>
+<dt><a name="-getObjectType"><strong>getObjectType</strong></a>(...)</dt>
+<dd><code><a href="#-getObjectType">getObjectType</a>(["nom"])
+-> chaîne</code>
+<p>Retourne le type de l'objet "nom" sous forme d'une chaîne de caractère. Si "nom" n'est pas fourni, l'élément sélectionné est utilisé. </p></dd>
+
<dt><a name="-getCornerRadius"><strong>getCornerRadius</strong></a>(...)</dt>
<dd><code><a href="#-getCornerRadius">getCornerRadius</a>(["nom"])
-> nombre entier</code>
Index: scribus/plugins/scriptplugin/cmdgetprop.cpp
===================================================================
--- scribus/plugins/scriptplugin/cmdgetprop.cpp (revision 14938)
+++ scribus/plugins/scriptplugin/cmdgetprop.cpp (revision 14939)
@@ -8,6 +8,44 @@
#include "cmdutil.h"
#include "scribuscore.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*>("");
@@ -294,5 +332,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 14938)
+++ scribus/plugins/scriptplugin/cmdgetprop.h (revision 14939)
@@ -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 14938)
+++ scribus/plugins/scriptplugin/scriptplugin.cpp (revision 14939)
@@ -353,6 +353,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