View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0004014 | Scribus | Scripter | public | 2006-07-12 22:13 | 2006-07-24 20:45 |
| Reporter | Lysander | Assigned To | subik | ||
| Priority | normal | Severity | feature | Reproducibility | N/A |
| Status | closed | Resolution | fixed | ||
| Platform | Kubuntu 6.06 | OS | Linux | ||
| Product Version | 1.3.3 | ||||
| Fixed in Version | 1.3.3.3cvs | ||||
| Summary | 0004014: Litlle patch I wrote in order to add the function "duplicateObject" to the python API | ||||
| Description | I wrote a patch to add the Python function duplicateObject to the python API. It works so far for me and perhaps other people are interested in it! | ||||
| Tags | No tags attached. | ||||
| Attached Files | patch.txt (970 bytes)
in cmdobj.h add after line 245
/*! docstring */
PyDoc_STRVAR(scribus_duplicateobject__doc__,
QT_TR_NOOP("duplicateObject([\"name\"]) -> string\n\
\n\
creates a Duplicate of the selected Object (or Selection Group).\n\
"));
/**
Christian Hausknecht, 2006-07-12
duplicate an object
*/
PyObject *scribus_duplicateobject(PyObject * /* self */, PyObject *args);
in cmdobj.cpp add after line 596
/*
* added by Christian Hausknecht (christian.hausknecht@tu-clausthal.de)
*/
PyObject *scribus_duplicateobject(PyObject * /* self */, PyObject *args)
{
char* name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &name))
return NULL;
if(!checkHaveDocument())
return NULL;
// do the duplicate
ScMW->slotEditCopy();
ScMW->slotEditPaste();
Py_INCREF(Py_None);
return Py_None;
}
in scriptplugin.cpp 450
// by Christian Hausknecht
{const_cast<char*>("duplicateObject"), scribus_duplicateobject, METH_VARARGS, tr(scribus_duplicateobject__doc__)},
patch2.txt (663 bytes)
/*
* added by Christian Hausknecht (christian.hausknecht@tu-clausthal.de)
* line 596 - end in cmdobj.cpp
*/
PyObject *scribus_duplicateobject(PyObject * /* self */, PyObject *args)
{
char* name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &name)) {
return NULL;
}
if(!checkHaveDocument()) {
return NULL;
}
// Is there a special name given? Yes -> add this to selection
PageItem *i = GetUniqueItem(QString::fromUtf8(name));
if (i != NULL) {
ScMW->doc->m_Selection->clear();
ScMW->doc->m_Selection->addItem(i);
}
// do the duplicate
ScMW->slotEditCopy();
ScMW->slotEditPaste();
Py_INCREF(Py_None);
return Py_None;
}
patch3.txt (672 bytes)
/*
* added by Christian Hausknecht (christian.hausknecht@tu-clausthal.de)
* lines 596 - end in cmdobj.cpp
*/
PyObject *scribus_duplicateobject(PyObject * /* self */, PyObject *args)
{
char* name = const_cast<char*>("");
if (!PyArg_ParseTuple(args, "|es", "utf-8", &name)) {
return NULL;
}
if(!checkHaveDocument()) {
return NULL;
}
// Is there a special name given? Yes -> add this to selection
if (ItemExists(QString::fromUtf8(name))) {
ScMW->doc->m_Selection->clear();
ScMW->doc->m_Selection->addItem(GetUniqueItem(QString::fromUtf8(name)));
}
// do the duplicate
ScMW->slotEditCopy();
ScMW->slotEditPaste();
Py_INCREF(Py_None);
return Py_None;
}
| ||||
| Patch | |||||
|
|
Hello again, I probably forgot something in my code yesterday. I don't know if I have the time to add it today, as I am quite busy later on. So perhaps you wait a little to merge it with the official scribus code. Ciao, Christian |
|
|
ok, no prob |
|
|
OK, in patch2.txt you will find the brand new code for the duplicateobject function. Now it can also handle a given object per name! So imho it works now as all the rest of the Python functions! I hope you like it :-) Ciao, Christian |
|
|
I couldn't delete the patch2.txt I posted some hours ago. There was still a buggy behaviour I found. Now it should really work. It's in patch3.txt Ciao, Christian |
|
|
it's in 1333 and 134 cvs. I write one exception check for duplicateDocument('name_that_doesnt_exist') -> exception instead of silent procedure crash. Anyway there are some differences between the cvs trees, so you can checkout both to see what's new ;) thank you for this patch. p.s.: for next time: use diff (kdiff etc.) utility to create patch file easy to apply against existing sources. It will be helpful for inserting into existing code. |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2006-07-12 22:13 | Lysander | New Issue | |
| 2006-07-12 22:13 | Lysander | File Added: patch.txt | |
| 2006-07-12 22:14 | cbradney | Status | new => assigned |
| 2006-07-12 22:14 | cbradney | Assigned To | => subik |
| 2006-07-13 07:47 | Lysander | Note Added: 0011865 | |
| 2006-07-13 09:08 | subik | Note Added: 0011868 | |
| 2006-07-24 10:56 | Lysander | File Added: patch2.txt | |
| 2006-07-24 10:57 | Lysander | Note Added: 0011992 | |
| 2006-07-24 14:44 | Lysander | File Added: patch3.txt | |
| 2006-07-24 14:47 | Lysander | Note Added: 0011995 | |
| 2006-07-24 15:14 | subik | Status | assigned => resolved |
| 2006-07-24 15:14 | subik | Fixed in Version | => 1.3.3.3cvs |
| 2006-07-24 15:14 | subik | Resolution | open => fixed |
| 2006-07-24 15:14 | subik | Note Added: 0011996 | |
| 2006-07-24 20:44 | cbradney | Status | resolved => closed |