Rev 22721 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
203 | Franz | 7 | #include "guiapp.h" |
647 | fschmid | 8 | #include "cmdutil.h" |
5781 | cbradney | 9 | #include "scribuscore.h" |
19093 | craig | 10 | #include "scribusview.h" |
16546 | jghali | 11 | |
12 | #include <QApplication> |
||
13 | #include <QCursor> |
||
14 | #include <QProgressBar> |
||
10223 | cbradney | 15 | #include <QString> |
203 | Franz | 16 | |
24091 | jghali | 17 | PyObject *scribus_statusmessage(PyObject* /* self */, PyObject* args) |
203 | Franz | 18 | { |
19 | char *aText; |
||
747 | subik | 20 | if (!PyArg_ParseTuple(args, "es", "utf-8", &aText)) |
22606 | craig | 21 | return nullptr; |
5781 | cbradney | 22 | ScCore->primaryMainWindow()->setStatusBarInfoText(QString::fromUtf8(aText)); |
8319 | fschmid | 23 | Py_RETURN_NONE; |
203 | Franz | 24 | } |
25 | |||
2790 | craig | 26 | PyObject *scribus_progressreset(PyObject* /* self */) |
203 | Franz | 27 | { |
5781 | cbradney | 28 | ScCore->primaryMainWindow()->mainWindowProgressBar->reset(); |
203 | Franz | 29 | qApp->processEvents(); |
8319 | fschmid | 30 | Py_RETURN_NONE; |
203 | Franz | 31 | } |
32 | |||
2790 | craig | 33 | PyObject *scribus_progresssettotalsteps(PyObject* /* self */, PyObject* args) |
203 | Franz | 34 | { |
35 | int steps; |
||
36 | if (!PyArg_ParseTuple(args, "i", &steps)) |
||
22606 | craig | 37 | return nullptr; |
9953 | cbradney | 38 | ScCore->primaryMainWindow()->mainWindowProgressBar->setMaximum(steps); |
39 | ScCore->primaryMainWindow()->mainWindowProgressBar->setValue(0); |
||
203 | Franz | 40 | qApp->processEvents(); |
8319 | fschmid | 41 | Py_RETURN_NONE; |
203 | Franz | 42 | } |
43 | |||
2790 | craig | 44 | PyObject *scribus_progresssetprogress(PyObject* /* self */, PyObject* args) |
203 | Franz | 45 | { |
46 | int position; |
||
47 | if (!PyArg_ParseTuple(args, "i", &position)) |
||
22606 | craig | 48 | return nullptr; |
9953 | cbradney | 49 | if (position > ScCore->primaryMainWindow()->mainWindowProgressBar->maximum()) |
720 | subik | 50 | { |
10598 | cbradney | 51 | PyErr_SetString(PyExc_ValueError, QString("Tried to set progress > maximum progress").toLocal8Bit().constData()); |
22606 | craig | 52 | return nullptr; |
720 | subik | 53 | } |
9953 | cbradney | 54 | ScCore->primaryMainWindow()->mainWindowProgressBar->setValue(position); |
203 | Franz | 55 | qApp->processEvents(); |
8319 | fschmid | 56 | Py_RETURN_NONE; |
203 | Franz | 57 | } |
58 | |||
59 | |||
2790 | craig | 60 | PyObject *scribus_setcursor(PyObject* /* self */, PyObject* args) |
203 | Franz | 61 | { |
62 | char *aCursor; |
||
411 | Franz | 63 | qDebug("WARNING! SetCursor() is not stable!"); |
900 | cbradney | 64 | if (!PyArg_ParseTuple(args, "es", "ascii", &aCursor)) |
22606 | craig | 65 | return nullptr; |
900 | cbradney | 66 | if (strcmp(aCursor, "wait") == 0) |
9380 | fschmid | 67 | qApp->changeOverrideCursor(Qt::WaitCursor); |
68 | // else |
||
69 | // qApp->restoreOverrideCursor(); |
||
8319 | fschmid | 70 | Py_RETURN_NONE; |
203 | Franz | 71 | } |
204 | Franz | 72 | |
2790 | craig | 73 | PyObject *scribus_docchanged(PyObject* /* self */, PyObject* args) |
204 | Franz | 74 | { |
75 | int aValue; |
||
76 | if (!PyArg_ParseTuple(args, "i", &aValue)) |
||
22606 | craig | 77 | return nullptr; |
22721 | jghali | 78 | if (!checkHaveDocument()) |
22606 | craig | 79 | return nullptr; |
5781 | cbradney | 80 | ScCore->primaryMainWindow()->slotDocCh(static_cast<bool>(aValue)); |
792 | subik | 81 | /* |
204 | Franz | 82 | if (aValue>0) |
5781 | cbradney | 83 | ScCore->primaryMainWindow()->slotDocCh(true); |
204 | Franz | 84 | else |
5781 | cbradney | 85 | ScCore->primaryMainWindow()->slotDocCh(false);*/ |
8319 | fschmid | 86 | Py_RETURN_NONE; |
204 | Franz | 87 | } |
243 | Franz | 88 | |
3926 | subik | 89 | PyObject *scribus_zoomdocument(PyObject* /* self */, PyObject* args) |
90 | { |
||
91 | double zoomFactor; |
||
92 | if (!PyArg_ParseTuple(args, "d", &zoomFactor)) |
||
22606 | craig | 93 | return nullptr; |
22721 | jghali | 94 | if (!checkHaveDocument()) |
22606 | craig | 95 | return nullptr; |
3926 | subik | 96 | if (zoomFactor > 0.0 || zoomFactor == -100.0) |
5781 | cbradney | 97 | ScCore->primaryMainWindow()->slotZoom(zoomFactor); |
3926 | subik | 98 | else |
99 | { |
||
10598 | cbradney | 100 | PyErr_SetString(PyExc_ValueError, QString("The zoom factor should be greater than 0.0 or equal to -100.0. See help(zoomFactor).").toLocal8Bit().constData()); |
22606 | craig | 101 | return nullptr; |
3926 | subik | 102 | } |
8319 | fschmid | 103 | Py_RETURN_NONE; |
3926 | subik | 104 | } |
6200 | subik | 105 | |
11281 | subik | 106 | /* |
107 | * Gives the possibility to scroll the document. |
||
108 | * 13.12.2007: Joachim Neu |
||
109 | */ |
||
110 | PyObject *scribus_scrolldocument(PyObject*,PyObject* args) |
||
111 | { |
||
112 | int moveX = 0, moveY = 0; |
||
22721 | jghali | 113 | if (!PyArg_ParseTuple(args, "ii", &moveX, &moveY)) |
22606 | craig | 114 | return nullptr; |
22721 | jghali | 115 | if (!checkHaveDocument()) |
22606 | craig | 116 | return nullptr; |
11281 | subik | 117 | ScCore->primaryMainWindow()->view->scrollBy(moveX,moveY); |
118 | Py_RETURN_NONE; |
||
119 | } |
||
120 | |||
6200 | subik | 121 | /*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings |
122 | with header files structure untouched (docstrings are kept near declarations) |
||
123 | PV */ |
||
124 | void guiappdocwarnings() |
||
125 | { |
||
20424 | jghali | 126 | QStringList s; |
24091 | jghali | 127 | s << scribus_docchanged__doc__ |
128 | << scribus_progressreset__doc__ |
||
129 | << scribus_progresssetprogress__doc__ |
||
130 | << scribus_progresssettotalsteps__doc__ |
||
131 | << scribus_scrolldocument__doc__ |
||
132 | << scribus_setcursor__doc__ |
||
133 | << scribus_statusmessage__doc__ |
||
134 | << scribus_zoomdocument__doc__; |
||
6200 | subik | 135 | } |