View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0008771 | Scribus | Scripter | public | 2010-02-04 19:24 | 2010-02-14 10:16 |
Reporter | arvee | Assigned To | jghali | ||
Priority | normal | Severity | feature | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 1.5.0svn | ||||
Fixed in Version | 1.5.0svn | ||||
Summary | 0008771: groupObjects() and group-naming | ||||
Description | groupObjects() command has no way to specify the name of the group, and does not return the name of the created group. | ||||
Additional Information | groupObjects is defined as : groupObjects(list) -> void a better way would be: groupObjects(list [,"name"]) -> name | ||||
Tags | No tags attached. | ||||
Patch | |||||
2010-02-12 11:44
|
groupObjects.diff (4,263 bytes)
Index: scribus/scribusdoc.cpp =================================================================== --- scribus/scribusdoc.cpp (revision 14689) +++ scribus/scribusdoc.cpp (working copy) @@ -10553,14 +10553,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; @@ -10704,6 +10704,7 @@ m_ScMW->scrActions["itemUngroup"]->setEnabled(true); } undoManager->action(this, ss, Um::SelectionGroup, Um::IGroup); + return groupItem; } void ScribusDoc::itemSelection_UnGroupObjects(Selection* customSelection) Index: scribus/scribusdoc.h =================================================================== --- scribus/scribusdoc.h (revision 14689) +++ scribus/scribusdoc.h (working copy) @@ -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 14689) +++ scribus/plugins/scriptplugin/cmdmani.cpp (working copy) @@ -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 PyString_FromString(group->itemName().toUtf8()); } PyObject *scribus_ungroupobj(PyObject* /* self */, PyObject* args) Index: scribus/plugins/scriptplugin/cmdmani.h =================================================================== --- scribus/plugins/scriptplugin/cmdmani.h (revision 14689) +++ scribus/plugins/scriptplugin/cmdmani.h (working copy) @@ -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 groupname 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 14689) +++ scribus/plugins/scriptplugin/scriptplugin.cpp (working copy) @@ -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__)}, |
2010-02-12 11:45
|
test-grouping.py (767 bytes)
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys try: from scribus import * except ImportError: print "This script only runs from within Scribus." sys.exit(1) def main(): newDocument(PAPER_A4, (20,20,20,20), PORTRAIT, 1, UNIT_MILLIMETERS, NOFACINGPAGES, FIRSTPAGERIGHT, 1) zoomDocument(50) # create boxes box1 = createRect(0,0,140,140) box2 = createRect(0,0,120,120) box3 = createRect(0,0,100,100) # set box colors setFillColor("Cyan", box1) setFillColor("Green", box2) setFillColor("Red", box3) # group box 1 and 2 group = groupObjects([box1, box2, box3]) # show group name text1 = createText(50, 50, 100, 20) setText("Group created: " + group, text1) # move group moveObject(200,100,group) if __name__ == '__main__': main() |
|
patch and test-script added. groupObjects returns the name of the created group now. |
|
Committed with a slight modification! Thanks! |
Date Modified | Username | Field | Change |
---|---|---|---|
2010-02-04 19:24 | arvee | New Issue | |
2010-02-12 11:44 | arvee | File Added: groupObjects.diff | |
2010-02-12 11:45 | arvee | File Added: test-grouping.py | |
2010-02-12 11:45 | arvee | Note Added: 0023246 | |
2010-02-13 15:35 | jghali | Note Added: 0023257 | |
2010-02-13 15:35 | jghali | Status | new => resolved |
2010-02-13 15:35 | jghali | Fixed in Version | => 1.5.0svn |
2010-02-13 15:35 | jghali | Resolution | open => fixed |
2010-02-13 15:35 | jghali | Assigned To | => jghali |
2010-02-14 10:16 | cbradney | Status | resolved => closed |