View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0008597 | Scribus | Scripter | public | 2009-11-24 22:29 | 2009-11-24 23:16 |
Reporter | tadi | Assigned To | cbradney | ||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Platform | Debian | OS | Linux | OS Version | sid |
Product Version | 1.5.0svn | ||||
Fixed in Version | 1.3.6svn | ||||
Summary | 0008597: Add getDocName function to scripter plugin. | ||||
Description | The attached patch adds the function getDocName() to the Scribus scripter-API document commands. The function returns the 'DocName' member of the doc-instance if 'hasName' is true. Otherwise it returns an empty string. That way a script can determine if a document was saved before. In case it wants to operate on a security copy of the current documnt it can prompt the user with a 'reasonable' save name. After the users reply it can use saveDocAs(newName) before continuing its (possible massive changing) operations on the document (Usefull for scripts that perform some document polishing and finishing tasks). | ||||
Tags | No tags attached. | ||||
Patch | |||||
2009-11-24 22:29
|
scribus-scripter-getDocName-command.patch (3,707 bytes)
diff -Nur Scribus.orig/scribus/plugins/scriptplugin/cmddoc.cpp Scribus/scribus/plugins/scriptplugin/cmddoc.cpp --- Scribus.orig/scribus/plugins/scriptplugin/cmddoc.cpp 2009-10-12 19:12:54.000000000 +0200 +++ Scribus/scribus/plugins/scriptplugin/cmddoc.cpp 2009-11-24 22:12:01.000000000 +0100 @@ -170,6 +170,17 @@ Py_RETURN_NONE; } +PyObject *scribus_getdocname(PyObject* /* self */) +{ + if(!checkHaveDocument()) + return NULL; + if (! ScCore->primaryMainWindow()->doc->hasName) + { + return PyString_FromString(""); + } + return PyString_FromString(ScCore->primaryMainWindow()->doc->DocName.toUtf8()); +} + PyObject *scribus_savedocas(PyObject* /* self */, PyObject* args) { char *Name; @@ -364,5 +375,5 @@ void cmddocdocwarnings() { QStringList s; - s << scribus_newdocument__doc__ << scribus_newdoc__doc__ << scribus_closedoc__doc__ << scribus_havedoc__doc__ << scribus_opendoc__doc__ << scribus_savedoc__doc__ << scribus_savedocas__doc__ << scribus_setinfo__doc__ <<scribus_setmargins__doc__ <<scribus_setunit__doc__ <<scribus_getunit__doc__ <<scribus_loadstylesfromfile__doc__ <<scribus_setdoctype__doc__ <<scribus_closemasterpage__doc__ <<scribus_masterpagenames__doc__ <<scribus_editmasterpage__doc__ <<scribus_createmasterpage__doc__ <<scribus_deletemasterpage__doc__; + s << scribus_newdocument__doc__ << scribus_newdoc__doc__ << scribus_closedoc__doc__ << scribus_havedoc__doc__ << scribus_opendoc__doc__ << scribus_savedoc__doc__ << scribus_getdocname__doc__ << scribus_savedocas__doc__ << scribus_setinfo__doc__ <<scribus_setmargins__doc__ <<scribus_setunit__doc__ <<scribus_getunit__doc__ <<scribus_loadstylesfromfile__doc__ <<scribus_setdoctype__doc__ <<scribus_closemasterpage__doc__ <<scribus_masterpagenames__doc__ <<scribus_editmasterpage__doc__ <<scribus_createmasterpage__doc__ <<scribus_deletemasterpage__doc__; } diff -Nur Scribus.orig/scribus/plugins/scriptplugin/cmddoc.h Scribus/scribus/plugins/scriptplugin/cmddoc.h --- Scribus.orig/scribus/plugins/scriptplugin/cmddoc.h 2007-09-30 14:27:02.000000000 +0200 +++ Scribus/scribus/plugins/scriptplugin/cmddoc.h 2009-11-24 22:11:55.000000000 +0100 @@ -142,6 +142,16 @@ PyObject *scribus_savedoc(PyObject * /*self*/); /*! docstring */ +PyDoc_STRVAR(scribus_getdocname__doc__, +QT_TR_NOOP("getDocName() -> string\n\ +\n\ +Returns the name the document was saved under.\n\ +If the document was not saved before the name is empty.\n\ +")); +/** Saves active document with given name */ +PyObject *scribus_getdocname(PyObject * /*self*/); + +/*! docstring */ PyDoc_STRVAR(scribus_savedocas__doc__, QT_TR_NOOP("saveDocAs(\"name\")\n\ \n\ diff -Nur Scribus.orig/scribus/plugins/scriptplugin/scriptplugin.cpp Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp --- Scribus.orig/scribus/plugins/scriptplugin/scriptplugin.cpp 2009-10-18 14:23:33.000000000 +0200 +++ Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp 2009-11-24 22:13:06.000000000 +0100 @@ -412,6 +412,7 @@ {const_cast<char*>("replaceColor"), scribus_replcolor, METH_VARARGS, tr(scribus_replcolor__doc__)}, {const_cast<char*>("rotateObjectAbs"), scribus_rotobjabs, METH_VARARGS, tr(scribus_rotobjabs__doc__)}, {const_cast<char*>("rotateObject"), scribus_rotobjrel, METH_VARARGS, tr(scribus_rotobjrel__doc__)}, + {const_cast<char*>("getDocName"), (PyCFunction)scribus_getdocname, METH_NOARGS, tr(scribus_getdocname__doc__)}, {const_cast<char*>("saveDocAs"), scribus_savedocas, METH_VARARGS, tr(scribus_savedocas__doc__)}, {const_cast<char*>("saveDoc"), (PyCFunction)scribus_savedoc, METH_NOARGS, tr(scribus_savedoc__doc__)}, {const_cast<char*>("savePageAsEPS"), scribus_savepageeps, METH_VARARGS, tr(scribus_savepageeps__doc__)}, |
|
Thanks! Committed to 1.5.0svn and it will go into 1.3.6svn soon too. |
Date Modified | Username | Field | Change |
---|---|---|---|
2009-11-24 22:29 | tadi | New Issue | |
2009-11-24 22:29 | tadi | File Added: scribus-scripter-getDocName-command.patch | |
2009-11-24 22:40 | christoph_s | Status | new => assigned |
2009-11-24 22:40 | christoph_s | Assigned To | => subik |
2009-11-24 22:43 | cbradney | Assigned To | subik => cbradney |
2009-11-24 22:44 | cbradney | Note Added: 0022881 | |
2009-11-24 22:44 | cbradney | Status | assigned => resolved |
2009-11-24 22:44 | cbradney | Fixed in Version | => 1.5.0svn |
2009-11-24 22:44 | cbradney | Resolution | open => fixed |
2009-11-24 23:09 | cbradney | Relationship added | has duplicate 0008536 |
2009-11-24 23:10 | cbradney | Fixed in Version | 1.5.0svn => 1.3.6svn |
2009-11-24 23:16 | cbradney | Status | resolved => closed |