r14714 by jghali - #8771: groupObjects() and group-naming Allow to manipulate groups in scripter after creating them

scribus-commit scribus-commit at lists.scribus.net
Sat Feb 13 16:40:43 CET 2010


Revision: 14714
Author: jghali
Date: 2010-02-13T15:34:56.864425Z
Commit message: #8771: groupObjects() and group-naming
Allow to manipulate groups in scripter after creating them

Changeset: 
M  /trunk/Scribus/doc/en/scripterapi-manobj.html
M  /trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp
M  /trunk/Scribus/doc/fr/scripterapi-manobj.html
M  /trunk/Scribus/scribus/scribusdoc.cpp
M  /trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.h
M  /trunk/Scribus/scribus/scribusdoc.h
M  /trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp

Diffs:
Index: doc/en/scripterapi-manobj.html
===================================================================
--- doc/en/scripterapi-manobj.html	(revision 14713)
+++ doc/en/scripterapi-manobj.html	(revision 14714)
@@ -13,8 +13,8 @@
 <p>creates a Duplicate of the selected Object (or Selection Group).</p></dd>
 
 <dt><a name="-groupObjects"><strong>groupObjects</strong></a>(...)</dt>
-<dd><code>groupObjects(list)</code>
-<p>Groups the objects named in "list" together. "list" must contain the names of the objects to be grouped. If "list" is not given the currently selected items are used.</p></dd>
+<dd><code>groupObjects(list) -&gt; string</code>
+<p>Groups the objects named in "list" together. "list" must contain the names of the objects to be grouped. If "list" is not given the currently selected items are used. Returns the group name for further referencing.</p></dd>
 
 <dt><a name="-isLocked"><strong>isLocked</strong></a>(...)</dt>
 <dd><code>isLocked(["name"]) -&gt; bool</code>
Index: doc/fr/scripterapi-manobj.html
===================================================================
--- doc/fr/scripterapi-manobj.html	(revision 14713)
+++ doc/fr/scripterapi-manobj.html	(revision 14714)
@@ -9,10 +9,10 @@
 <dl>
 
 <dt><a name="-groupObjects"><strong>groupObjects</strong></a>(...)</dt>
-<dd><code><a href="#-groupObjects">groupObjects</a>(liste)</code>
+<dd><code><a href="#-groupObjects">groupObjects</a>(liste)  -&gt; cha&icirc;ne</code>
 <p>Groupe les objets &eacute;num&eacute;r&eacute;s dans "liste". La "liste" doit contenir les noms des objets &agrave; grouper. 
 Si la "liste" n'est pas fournie, les &eacute;l&eacute;ments s&eacute;lectionn&eacute;s sont
-utilis&eacute;s.</p></dd>
+utilis&eacute;s. Retourne le nom du groupe cr&eacute;&eacute; pour utilisation ult&eacute;rieure.</p></dd>
 
 <dt><a name="-isLocked"><strong>isLocked</strong></a>(...)</dt>
 <dd><code><a href="#-isLocked">isLocked</a>(["nom"]) -&gt; bool&eacute;en</code>
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(revision 14713)
+++ scribus/scribusdoc.cpp	(revision 14714)
@@ -10556,14 +10556,14 @@
 
 
 
-void ScribusDoc::itemSelection_GroupObjects(bool changeLock, bool lock, Selection* customSelection)
+const PageItem * ScribusDoc::itemSelection_GroupObjects(bool changeLock, bool lock, Selection* customSelection)
 {
 		Selection* itemSelection = (customSelection!=0) ? customSelection : m_Selection;
 		if (itemSelection->count() < 1)
-			return;
+			return NULL;
 		int objectsLayer = itemSelection->objectsLayer();
 		if (objectsLayer == -1)
-			return;
+			return NULL;
 		PageItem *currItem;
 		PageItem* bb;
 		double x, y, w, h;
@@ -10707,6 +10707,7 @@
 			m_ScMW->scrActions["itemUngroup"]->setEnabled(true);
 		}
 		undoManager->action(this, ss, Um::SelectionGroup, Um::IGroup);
+		return groupItem;
 }
 
 void ScribusDoc::itemSelection_UnGroupObjects(Selection* customSelection)
@@ -11586,3 +11587,4 @@
 }
 
 
+
Index: scribus/scribusdoc.h
===================================================================
--- scribus/scribusdoc.h	(revision 14713)
+++ scribus/scribusdoc.h	(revision 14714)
@@ -811,7 +811,7 @@
 	bool sendItemSelectionToBack();
 	bool bringItemSelectionToFront();
 
-	void itemSelection_GroupObjects  (bool changeLock, bool lock, Selection* customSelection=0);
+	const PageItem * itemSelection_GroupObjects  (bool changeLock, bool lock, Selection* customSelection=0);
 	void itemSelection_UnGroupObjects(Selection* customSelection=0);
 	void itemSelection_convertItemsTo(const PageItem::ItemType newType, Selection* restoredSelection=0, Selection* customSelection=0);
 
Index: scribus/plugins/scriptplugin/cmdmani.cpp
===================================================================
--- scribus/plugins/scriptplugin/cmdmani.cpp	(revision 14713)
+++ scribus/plugins/scriptplugin/cmdmani.cpp	(revision 14714)
@@ -257,10 +257,12 @@
 		delete tempSelection;
 		return NULL;
 	}
-	ScCore->primaryMainWindow()->doc->itemSelection_GroupObjects(false, false, finalSelection);
+
+	const PageItem* group = ScCore->primaryMainWindow()->doc->itemSelection_GroupObjects(false, false, finalSelection);
 	finalSelection=0;
 	delete tempSelection;
-	Py_RETURN_NONE;
+	
+	return (group ? PyString_FromString(group->itemName().toUtf8()) : NULL);
 }
 
 PyObject *scribus_ungroupobj(PyObject* /* self */, PyObject* args)
Index: scribus/plugins/scriptplugin/cmdmani.h
===================================================================
--- scribus/plugins/scriptplugin/cmdmani.h	(revision 14713)
+++ scribus/plugins/scriptplugin/cmdmani.h	(revision 14714)
@@ -110,11 +110,11 @@
 
 /*! docstring */
 PyDoc_STRVAR(scribus_groupobj__doc__,
-QT_TR_NOOP("groupObjects(list)\n\
+QT_TR_NOOP("groupObjects(list) -> string\n\
 \n\
 Groups the objects named in \"list\" together. \"list\" must contain the names\n\
 of the objects to be grouped. If \"list\" is not given the currently selected\n\
-items are used.\n\
+items are used. Returns the group name for further referencing.\n\
 "));
 /*! Group objects named in list. */
 PyObject *scribus_groupobj(PyObject * /*self*/, PyObject* args);
Index: scribus/plugins/scriptplugin/scriptplugin.cpp
===================================================================
--- scribus/plugins/scriptplugin/scriptplugin.cpp	(revision 14713)
+++ scribus/plugins/scriptplugin/scriptplugin.cpp	(revision 14714)
@@ -380,7 +380,7 @@
 	{const_cast<char*>("getVGuides"), (PyCFunction)scribus_getVguides, METH_NOARGS, tr(scribus_getVguides__doc__)},
 	{const_cast<char*>("getXFontNames"), (PyCFunction)scribus_xfontnames, METH_NOARGS, tr(scribus_xfontnames__doc__)},
 	{const_cast<char*>("gotoPage"), scribus_gotopage, METH_VARARGS, tr(scribus_gotopage__doc__)},
-	{const_cast<char*>("groupObjects"), scribus_groupobj, METH_VARARGS, tr(scribus_groupobj__doc__)},
+	{const_cast<char*>("groupObjects"), (PyCFunction)scribus_groupobj, METH_VARARGS, tr(scribus_groupobj__doc__)},
 	{const_cast<char*>("haveDoc"), (PyCFunction)scribus_havedoc, METH_NOARGS, tr(scribus_havedoc__doc__)},
 	{const_cast<char*>("placeSVG"), scribus_placesvg, METH_VARARGS, tr(scribus_placesvg__doc__)},
 	{const_cast<char*>("placeEPS"), scribus_placeeps, METH_VARARGS, tr(scribus_placeeps__doc__)},




More information about the scribus-commit mailing list