0001-Add-script-method-getBaseLine-to-complement-setBaseL.patch (3,352 bytes)
From 7f560ad47e99ca194cd74045f27345fe31fa4560 Mon Sep 17 00:00:00 2001
From: Hugo Wetterberg <hugo@wetterberg.nu>
Date: Sun, 20 Oct 2024 13:07:36 +0200
Subject: [PATCH] Add script method getBaseLine() to complement setBaseLine()
---
scribus/plugins/scriptplugin/cmddoc.cpp | 12 ++++++++++++
scribus/plugins/scriptplugin/cmddoc.h | 11 +++++++++++
scribus/plugins/scriptplugin/scriptplugin.cpp | 1 +
3 files changed, 24 insertions(+)
diff --git a/scribus/plugins/scriptplugin/cmddoc.cpp b/scribus/plugins/scriptplugin/cmddoc.cpp
index a96f9230a..903c1c2e1 100644
--- a/scribus/plugins/scriptplugin/cmddoc.cpp
+++ b/scribus/plugins/scriptplugin/cmddoc.cpp
@@ -171,6 +171,17 @@ PyObject *scribus_setbaseline(PyObject* /* self */, PyObject* args)
Py_RETURN_NONE;
}
+PyObject *scribus_getbaseline(PyObject* /* self */)
+{
+ if (!checkHaveDocument())
+ return nullptr;
+
+ GuidesPrefs& guides = ScCore->primaryMainWindow()->doc->guidesPrefs();
+
+ return Py_BuildValue("(dd)",
+ guides.valueBaselineGrid,
+ guides.offsetBaselineGrid);
+}
PyObject *scribus_closedoc(PyObject* /* self */)
{
@@ -513,6 +524,7 @@ void cmddocdocwarnings()
<< scribus_savedoc__doc__
<< scribus_savedocas__doc__
<< scribus_setbaseline__doc__
+ << scribus_getbaseline__doc__
<< scribus_setbleeds__doc__
<< scribus_setdoctype__doc__
<< scribus_setinfo__doc__
diff --git a/scribus/plugins/scriptplugin/cmddoc.h b/scribus/plugins/scriptplugin/cmddoc.h
index fe77ef462..5017f1c1b 100644
--- a/scribus/plugins/scriptplugin/cmddoc.h
+++ b/scribus/plugins/scriptplugin/cmddoc.h
@@ -226,6 +226,17 @@ constants.\n\
/** Sets document baseline settings - grid and offset. */
PyObject *scribus_setbaseline(PyObject * /*self*/, PyObject* args);
+/*! docstring */
+PyDoc_STRVAR(scribus_getbaseline__doc__,
+QT_TR_NOOP("getBaseLine() -> (grid, offset)\n\
+\n\
+Gets the base line settings of the document, grid spacing(grid), grid offset(offset).\n\
+Values are given in the measurement units of the document - see UNIT_<type>\n\
+constants.\n\
+"));
+/** Sets document baseline settings - grid and offset. */
+PyObject *scribus_getbaseline(PyObject * /*self*/);
+
/*! docstring */
PyDoc_STRVAR(scribus_setunit__doc__,
QT_TR_NOOP("setUnit(type)\n\
diff --git a/scribus/plugins/scriptplugin/scriptplugin.cpp b/scribus/plugins/scriptplugin/scriptplugin.cpp
index c18f7c7bb..2791f9754 100644
--- a/scribus/plugins/scriptplugin/scriptplugin.cpp
+++ b/scribus/plugins/scriptplugin/scriptplugin.cpp
@@ -507,6 +507,7 @@ PyMethodDef scribus_methods[] = {
{ "sentToLayer", scribus_sendtolayer, METH_VARARGS, tr(scribus_sendtolayer__doc__)}, // Deprecated, alias to sentToLayer
{ "setActiveLayer", scribus_setactivelayer, METH_VARARGS, tr(scribus_setactivelayer__doc__)},
{ "setBaseLine", scribus_setbaseline, METH_VARARGS, tr(scribus_setbaseline__doc__)},
+ { "getBaseLine", (PyCFunction) scribus_getbaseline, METH_NOARGS, tr(scribus_getbaseline__doc__)},
{ "setBleeds", scribus_setbleeds, METH_VARARGS, tr(scribus_setbleeds__doc__)},
{ "setCellBottomBorder", scribus_setcellbottomborder, METH_VARARGS, tr(scribus_setcellbottomborder__doc__)},
{ "setCellBottomPadding", scribus_setcellbottompadding, METH_VARARGS, tr(scribus_setcellbottompadding__doc__)},
--
2.47.0