View Issue Details

IDProjectCategoryView StatusLast Update
0015489ScribusScripterpublic2019-06-04 20:56
ReporterIam_TJ Assigned Tojghali  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.5.4.svn 
Fixed in Version1.5.5.svn 
Summary0015489: scriptplugin: Add combinePolygons to API
DescriptionEnable scripting to combine polygons of selected objects as can be done via the GUI.
TagsNo tags attached.
PatchYes

Activities

Iam_TJ

2018-11-19 09:51

reporter  

0001-scriptplugin-Add-combinePolygons-to-API.patch (3,485 bytes)   
From edb43eb367433a4922acbc5f1485e01bbe3a308b Mon Sep 17 00:00:00 2001
From: TJ <hacker@iam.tj>
Date: Mon, 29 Oct 2018 15:47:26 +0000
Subject: [PATCH] scriptplugin: Add combinePolygons() to API

Signed-off-by: TJ <hacker@iam.tj>
---
 doc/en/scripterapi-manobj.html                |  4 ++++
 scribus/plugins/scriptplugin/cmdmani.cpp      | 11 +++++++++++
 scribus/plugins/scriptplugin/cmdmani.h        |  7 +++++++
 scribus/plugins/scriptplugin/scriptplugin.cpp |  2 ++
 4 files changed, 24 insertions(+)

diff --git a/doc/en/scripterapi-manobj.html b/doc/en/scripterapi-manobj.html
index 01370a953..006da6b83 100644
--- a/doc/en/scripterapi-manobj.html
+++ b/doc/en/scripterapi-manobj.html
@@ -8,6 +8,10 @@
 
 <dl>
 
+<dt><a name="-combinePolygons"><strong>combinePolygons()</strong></a></dt>
+<dd><code>combinePolygons()</code>
+<p>combines two or more selected polygons.</p></dd>
+
 <dt><a name="-copyObject"><strong>copyObject</strong>(...)</a></dt>
 <dd><code>copyObject(["name"]) -&gt; string</code>
 <p>copies the selected Object to the clipboard.</p></dd>
diff --git a/scribus/plugins/scriptplugin/cmdmani.cpp b/scribus/plugins/scriptplugin/cmdmani.cpp
index c31a21769..72ef35ecb 100644
--- a/scribus/plugins/scriptplugin/cmdmani.cpp
+++ b/scribus/plugins/scriptplugin/cmdmani.cpp
@@ -625,6 +625,17 @@ PyObject *scribus_flipobject(PyObject* /* self */, PyObject* args)
 	Py_RETURN_NONE;
 }
 
+PyObject *scribus_combinepolygons(PyObject * /* self */)
+{
+	if (!checkHaveDocument())
+		return nullptr;
+
+	ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
+	currentDoc->itemSelection_UniteItems(nullptr);
+
+	Py_RETURN_NONE;
+}
+
 /*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings
 with header files structure untouched (docstrings are kept near declarations)
 PV */
diff --git a/scribus/plugins/scriptplugin/cmdmani.h b/scribus/plugins/scriptplugin/cmdmani.h
index f580684ff..d8b8ecca9 100644
--- a/scribus/plugins/scriptplugin/cmdmani.h
+++ b/scribus/plugins/scriptplugin/cmdmani.h
@@ -271,4 +271,11 @@ If \"name\" is not given the currently selected item is used.\n\
 /*! Flip the object 2010/5/18.*/
 PyObject *scribus_flipobject(PyObject * /*self*/, PyObject* args);
 
+PyDoc_STRVAR(scribus_combinepolygons__doc__,
+QT_TR_NOOP("combinePolygons()\n\
+\n\
+Combine two or more selected Polygons\n\
+"));
+PyObject *scribus_combinepolygons(PyObject * /* self */);
+
 #endif
diff --git a/scribus/plugins/scriptplugin/scriptplugin.cpp b/scribus/plugins/scriptplugin/scriptplugin.cpp
index 0a18a3ede..cc85d251b 100644
--- a/scribus/plugins/scriptplugin/scriptplugin.cpp
+++ b/scribus/plugins/scriptplugin/scriptplugin.cpp
@@ -586,6 +586,8 @@ PyMethodDef scribus_methods[] = {
 	{const_cast<char*>("duplicateObject"), scribus_duplicateobject, METH_VARARGS, tr(scribus_duplicateobject__doc__)},
 	{const_cast<char*>("copyObject"), scribus_copyobject, METH_VARARGS, tr(scribus_copyobject__doc__)},
 	{const_cast<char*>("pasteObject"), scribus_pasteobject, METH_VARARGS, tr(scribus_pasteobject__doc__)},
+	// by Tj (hacker@iam.tj>
+	{const_cast<char*>("combinePolygons"), (PyCFunction)scribus_combinepolygons, METH_NOARGS, tr(scribus_combinepolygons__doc__)},
 	// Internal methods - Not for public use
 	{const_cast<char*>("retval"), (PyCFunction)scribus_retval, METH_VARARGS, const_cast<char*>("Scribus internal.")},
 	{const_cast<char*>("getval"), (PyCFunction)scribus_getval, METH_NOARGS, const_cast<char*>("Scribus internal.")},
-- 
2.17.1

jghali

2018-11-21 23:21

administrator   ~0045650

Applied thanks! I just added some error checking vs selected frame types.

Issue History

Date Modified Username Field Change
2018-11-19 09:51 Iam_TJ New Issue
2018-11-19 09:51 Iam_TJ File Added: 0001-scriptplugin-Add-combinePolygons-to-API.patch
2018-11-21 23:21 jghali Assigned To => jghali
2018-11-21 23:21 jghali Status new => resolved
2018-11-21 23:21 jghali Resolution open => fixed
2018-11-21 23:21 jghali Fixed in Version => 1.5.5.svn
2018-11-21 23:21 jghali Note Added: 0045650
2019-06-04 20:56 cbradney Status resolved => closed