View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0016224 | Scribus | Scripter | public | 2020-08-23 05:23 | 2020-11-07 14:52 |
| Reporter | ale | Assigned To | ale | ||
| Priority | normal | Severity | feature | Reproducibility | N/A |
| Status | closed | Resolution | fixed | ||
| Product Version | 1.5.6.svn | ||||
| Summary | 0016224: scripter: add getNextLinkedFrame() and getPrevLinkedFrame() | ||||
| Description | get the name of the next frame in the chain. in the docstring i'm using the new signature i've suggested in 0016213 getLinkedTextFrame(page: str = None) -> str if you commit as is, i will modify all signatures to match the new pattern (which, as said, is the way python signatures are written nowadays) you can restore it to getLinkedTextFrame([\"name\"]) -> string\n\ if you don't like the proposition. | ||||
| Tags | No tags attached. | ||||
| Attached Files | next-in-chain.diff (3,469 bytes)
diff --git a/scribus/plugins/scriptplugin/cmdtext.cpp b/scribus/plugins/scriptplugin/cmdtext.cpp
index 6c3b6dcb9..d0e5cb536 100644
--- a/scribus/plugins/scriptplugin/cmdtext.cpp
+++ b/scribus/plugins/scriptplugin/cmdtext.cpp
@@ -267,6 +267,28 @@ PyObject *scribus_getfontfeatures(PyObject* /* self */, PyObject* args)
return PyUnicode_FromString(item->currentCharStyle().fontFeatures().toUtf8());
}
+PyObject *scribus_getlinkedtextframe(PyObject* /* self */, PyObject* args)
+{
+ char *Name = const_cast<char*>("");
+ if (!PyArg_ParseTuple(args, "|es", "utf-8", &Name))
+ return nullptr;
+ if (!checkHaveDocument())
+ return nullptr;
+ PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+ if (item == nullptr)
+ return nullptr;
+ if (!item->isTextFrame())
+ {
+ PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot get linked frames of non-text frame.","python error").toLocal8Bit().constData());
+ return nullptr;
+ }
+
+ if (item->nextInChain() != nullptr)
+ return PyUnicode_FromString(item->nextInChain()->itemName().toUtf8());
+
+ Py_RETURN_NONE;
+}
+
PyObject *scribus_getlinespace(PyObject* /* self */, PyObject* args)
{
char *Name = const_cast<char*>("");
@@ -1415,6 +1437,7 @@ void cmdtextdocwarnings()
<< scribus_getcolumns__doc__
<< scribus_getfont__doc__
<< scribus_getfontfeatures__doc__
+ << scribus_getlinkedtextframe__doc__
<< scribus_getfontsize__doc__
<< scribus_getframetext__doc__
<< scribus_getlinespace__doc__
diff --git a/scribus/plugins/scriptplugin/cmdtext.h b/scribus/plugins/scriptplugin/cmdtext.h
index 034aa126f..b1c302ae5 100644
--- a/scribus/plugins/scriptplugin/cmdtext.h
+++ b/scribus/plugins/scriptplugin/cmdtext.h
@@ -48,6 +48,18 @@ selected item is used.\n\
/*! Get fontfeatures */
PyObject *scribus_getfontfeatures(PyObject * /*self*/, PyObject* args);
+/*! docstring */
+PyDoc_STRVAR(scribus_getlinkedtextframe__doc__,
+QT_TR_NOOP("getLinkedTextFrame(page: str = None) -> str\n\
+\n\
+Return the next text frame in the chain or None\n\
+if it's the last frame in the chain.\n\
+\n\
+If \"name\" is not given the currently selected item is used.\n\
+"));
+/*! Get the name of the next frames in the chain */
+PyObject *scribus_getlinkedtextframe(PyObject * /*self*/, PyObject* args);
+
/*! docstring */
PyDoc_STRVAR(scribus_gettextcolor__doc__,
QT_TR_NOOP("getTextColor([\"name\"]) -> string\n\
diff --git a/scribus/plugins/scriptplugin/scriptplugin.cpp b/scribus/plugins/scriptplugin/scriptplugin.cpp
index aab82fa3b..afab3c345 100644
--- a/scribus/plugins/scriptplugin/scriptplugin.cpp
+++ b/scribus/plugins/scriptplugin/scriptplugin.cpp
@@ -358,6 +358,7 @@ PyMethodDef scribus_methods[] = {
{const_cast<char*>("getFillTransparency"), scribus_getfilltrans, METH_VARARGS, tr(scribus_getfilltrans__doc__)},
{const_cast<char*>("getFont"), scribus_getfont, METH_VARARGS, tr(scribus_getfont__doc__)},
{const_cast<char*>("getFontFeatures"), scribus_getfontfeatures, METH_VARARGS, tr(scribus_getfontfeatures__doc__)},
+ {const_cast<char*>("getLinkedTextFrame"), scribus_getlinkedtextframe, METH_VARARGS, tr(scribus_getlinkedtextframe__doc__)},
{const_cast<char*>("getFontNames"), (PyCFunction)scribus_fontnames, METH_NOARGS, tr(scribus_fontnames__doc__)},
{const_cast<char*>("getFontSize"), scribus_getfontsize, METH_VARARGS, tr(scribus_getfontsize__doc__)},
{const_cast<char*>("getFrameText"), scribus_getframetext, METH_VARARGS, tr(scribus_getframetext__doc__)},
| ||||
| Patch | Yes | ||||
|
|
For completeness, i would prefer having two different functions: getNextLinkedFrame() and getPrevLinkedFrame(). |
|
|
i'm not sure that it's so useful to know the prev chain. there could be use cases, but i think that we could better cover the "other" use cases with a function that returns the whole chain for the given frame. getTextFramesChain(itemName: str = None) -> List[str] p.s.: i've just noticed that i've made a copy paste error in the patch. it should be: getLinkedTextFrame(item: str = None) -> str (not "page: str") |
|
|
This is pending one of two things: - new patch that fixes the paste error and implements getNextLinkedFrame() and getPrevLinkedFrame() - we take your patch and make getNextLinkedFrame() and getPrevLinkedFrame() from them As we need to nail down 1.5.6, let us know which way you want to move Ale. thanks Craig |
|
|
I went for the second solution, and hence added getNextLinkedFrame() and getPrevLinkedFrame() to scripter. As a bonus, I have also added getFirstLinkedFrame() to get first frame in the chain, and getLastLinkedFrame() to get last frame in the chain. |
|
|
thanks |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2020-08-23 05:23 | ale | New Issue | |
| 2020-08-23 05:23 | ale | File Added: next-in-chain.diff | |
| 2020-08-23 05:50 | ale | Patch | No => Yes |
| 2020-09-14 16:19 | jghali | Note Added: 0048065 | |
| 2020-09-14 16:19 | jghali | Note Edited: 0048065 | |
| 2020-09-14 16:56 | ale | Note Added: 0048066 | |
| 2020-09-15 20:52 | cbradney | Note Added: 0048075 | |
| 2020-09-15 21:34 | jghali | Note Added: 0048076 | |
| 2020-09-15 21:34 | jghali | Summary | PATCH: scripter: add getLinkedTextFrame() => scripter: getNextLinkedFrame() and getPrevLinkedFrame() |
| 2020-09-15 21:34 | jghali | Note Edited: 0048076 | |
| 2020-09-15 21:34 | jghali | Assigned To | => ale |
| 2020-09-15 21:34 | jghali | Status | new => resolved |
| 2020-09-15 21:34 | jghali | Resolution | open => fixed |
| 2020-09-15 21:37 | jghali | Summary | scripter: getNextLinkedFrame() and getPrevLinkedFrame() => scripter: add getNextLinkedFrame() and getPrevLinkedFrame() |
| 2020-09-16 06:33 | ale | Note Added: 0048078 | |
| 2020-11-07 14:52 | cbradney | Status | resolved => closed |