From de4fabf2f4541e22bd5b0604cf35ac52fd6a167d Mon Sep 17 00:00:00 2001 From: ale rimoldi Date: Sun, 25 Feb 2018 18:16:29 +0100 Subject: [PATCH] add the isexportable python API command --- scribus/plugins/scriptplugin/cmdmani.cpp | 37 ++++++++++++++++++- scribus/plugins/scriptplugin/cmdmani.h | 21 +++++++++++ scribus/plugins/scriptplugin/scriptplugin.cpp | 2 + 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/scribus/plugins/scriptplugin/cmdmani.cpp b/scribus/plugins/scriptplugin/cmdmani.cpp index c77e0bdfbf..9739270179 100644 --- a/scribus/plugins/scriptplugin/cmdmani.cpp +++ b/scribus/plugins/scriptplugin/cmdmani.cpp @@ -503,6 +503,39 @@ PyObject *scribus_deselect(PyObject* /* self */) Py_RETURN_NONE; } +PyObject *scribus_exportableobject(PyObject* /* self */, PyObject* args) +{ + char *name = const_cast(""); + if (!PyArg_ParseTuple(args, "|es", "utf-8", &name)) + return NULL; + if(!checkHaveDocument()) + return NULL; + PageItem *item = GetUniqueItem(QString::fromUtf8(name)); + if (item == NULL) + return NULL; + item->togglePrintEnabled(); + if (item->locked()) + return PyInt_FromLong(1); + return PyInt_FromLong(0); +} + +PyObject *scribus_isexportable(PyObject* /* self */, PyObject* args) +{ + char *name = const_cast(""); + if (!PyArg_ParseTuple(args, "|es", "utf-8", &name)) + return NULL; + // FIXME: Rather than toggling the lock, we should probably let the user set the lock state + // and instead provide a different function like toggleLock() + if(!checkHaveDocument()) + return NULL; + PageItem *item = GetUniqueItem(QString::fromUtf8(name)); + if (item == NULL) + return NULL; + if (item->printEnabled()) + return PyBool_FromLong(1); + return PyBool_FromLong(0); +} + PyObject *scribus_lockobject(PyObject* /* self */, PyObject* args) { char *name = const_cast(""); @@ -628,6 +661,8 @@ void cmdmanidocwarnings() << scribus_ungroupobj__doc__ << scribus_scalegroup__doc__ << scribus_loadimage__doc__ << scribus_scaleimage__doc__ << scribus_setimagescale__doc__ << scribus_lockobject__doc__ - << scribus_islocked__doc__ << scribus_setscaleimagetoframe__doc__ << scribus_setimagebrightness__doc__ << scribus_setimagegrayscale__doc__ << scribus_setimageoffset__doc__ + << scribus_islocked__doc__ + << scribus_exportablebject__doc__ << scribus_isexportable__doc__ << + scribus_setscaleimagetoframe__doc__ << scribus_setimagebrightness__doc__ << scribus_setimagegrayscale__doc__ << scribus_setimageoffset__doc__ << scribus_flipobject__doc__; } diff --git a/scribus/plugins/scriptplugin/cmdmani.h b/scribus/plugins/scriptplugin/cmdmani.h index cfef82da19..fbc53d2201 100644 --- a/scribus/plugins/scriptplugin/cmdmani.h +++ b/scribus/plugins/scriptplugin/cmdmani.h @@ -220,6 +220,27 @@ May raise WrongFrameTypeError if the target frame is not an image frame\n\ /*! Set Image Brightness. */ PyObject *scribus_setimagegrayscale(PyObject * /*self*/, PyObject* args); +/*! docstring */ +PyDoc_STRVAR(scribus_exportablebject__doc__, +QT_TR_NOOP("exportableObject([\"name\"]) -> bool\n\ +\n\ +Sets the object \"name\" as exportable if it's not (or viceversa).\n\ +If \"name\" is not given the currently selected item is used. Returns true\n\ +if exportable.\n\ +")); +/*! (Un)Lock the object 2004/7/10 pv.*/ +PyObject *scribus_exportableobject(PyObject * /*self*/, PyObject* args); + +/*! docstring */ +PyDoc_STRVAR(scribus_isexportable__doc__, +QT_TR_NOOP("isExportable([\"name\"]) -> bool\n\ +\n\ +Returns true if is the object \"name\" is exportable. If \"name\" is not given the\n\ +currently selected item is used.\n\ +")); +/*! Status of locking 2004/7/10 pv.*/ +PyObject *scribus_isexportable(PyObject * /*self*/, PyObject* args); + /*! docstring */ PyDoc_STRVAR(scribus_lockobject__doc__, QT_TR_NOOP("lockObject([\"name\"]) -> bool\n\ diff --git a/scribus/plugins/scriptplugin/scriptplugin.cpp b/scribus/plugins/scriptplugin/scriptplugin.cpp index a565acf768..463d9b5ac4 100644 --- a/scribus/plugins/scriptplugin/scriptplugin.cpp +++ b/scribus/plugins/scriptplugin/scriptplugin.cpp @@ -433,10 +433,12 @@ PyMethodDef scribus_methods[] = { {const_cast("isLayerLocked"), scribus_glayerlock, METH_VARARGS, tr(scribus_glayerlock__doc__)}, {const_cast("isLayerOutlined"), scribus_glayeroutline, METH_VARARGS, tr(scribus_glayeroutline__doc__)}, {const_cast("isLayerFlow"), scribus_glayerflow, METH_VARARGS, tr(scribus_glayerflow__doc__)}, + {const_cast("isExportable"), scribus_isexportable, METH_VARARGS, tr(scribus_isexportable__doc__)}, {const_cast("isLocked"), scribus_islocked, METH_VARARGS, tr(scribus_islocked__doc__)}, {const_cast("linkTextFrames"), scribus_linktextframes, METH_VARARGS, tr(scribus_linktextframes__doc__)}, {const_cast("loadImage"), scribus_loadimage, METH_VARARGS, tr(scribus_loadimage__doc__)}, {const_cast("loadStylesFromFile"), scribus_loadstylesfromfile, METH_VARARGS, tr(scribus_loadstylesfromfile__doc__)}, + {const_cast("exportableObject"), scribus_exportableobject, METH_VARARGS, tr(scribus_exportablebject__doc__)}, {const_cast("lockObject"), scribus_lockobject, METH_VARARGS, tr(scribus_lockobject__doc__)}, {const_cast("masterPageNames"), (PyCFunction)scribus_masterpagenames, METH_NOARGS, tr(scribus_masterpagenames__doc__)}, {const_cast("mergeTableCells"), scribus_mergetablecells, METH_VARARGS, tr(scribus_mergetablecells__doc__)},