Back to index

scribus-ng  1.3.4.dfsg+svn20071115
guiapp.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "guiapp.h"
00008 #include "cmdutil.h"
00009 #include "scribuscore.h"
00010 #include <qstring.h>
00011 #include <qcursor.h>
00012 
00013 PyObject *scribus_messagebartext(PyObject* /* self */, PyObject* args)
00014 {
00015        char *aText;
00016        if (!PyArg_ParseTuple(args, "es", "utf-8", &aText))
00017               return NULL;
00018        ScCore->primaryMainWindow()->setStatusBarInfoText(QString::fromUtf8(aText));
00019 //     Py_INCREF(Py_None);
00020 //     return Py_None;
00021        Py_RETURN_NONE;
00022 }
00023 
00024 PyObject *scribus_progressreset(PyObject* /* self */)
00025 {
00026        ScCore->primaryMainWindow()->mainWindowProgressBar->reset();
00027        qApp->processEvents();
00028 //     Py_INCREF(Py_None);
00029 //     return Py_None;
00030        Py_RETURN_NONE;
00031 }
00032 
00033 PyObject *scribus_progresssettotalsteps(PyObject* /* self */, PyObject* args)
00034 {
00035        int steps;
00036        if (!PyArg_ParseTuple(args, "i", &steps))
00037               return NULL;
00038        ScCore->primaryMainWindow()->mainWindowProgressBar->setTotalSteps(steps);
00039        ScCore->primaryMainWindow()->mainWindowProgressBar->setProgress(0);
00040        qApp->processEvents();
00041 //     Py_INCREF(Py_None);
00042 //     return Py_None;
00043        Py_RETURN_NONE;
00044 }
00045 
00046 PyObject *scribus_progresssetprogress(PyObject* /* self */, PyObject* args)
00047 {
00048        int position;
00049        if (!PyArg_ParseTuple(args, "i", &position))
00050               return NULL;
00051        if (position > ScCore->primaryMainWindow()->mainWindowProgressBar->totalSteps())
00052        {
00053               PyErr_SetString(PyExc_ValueError, QString("Tried to set progress > maximum progress"));
00054               return NULL;
00055        }
00056        ScCore->primaryMainWindow()->mainWindowProgressBar->setProgress(position);
00057        qApp->processEvents();
00058 //     Py_INCREF(Py_None);
00059 //     return Py_None;
00060        Py_RETURN_NONE;
00061 }
00062 
00063 
00064 PyObject *scribus_setcursor(PyObject* /* self */, PyObject* args)
00065 {
00066        char *aCursor;
00067        qDebug("WARNING! SetCursor() is not stable!");
00068        if (!PyArg_ParseTuple(args, "es", "ascii", &aCursor))
00069               return NULL;
00070        if (strcmp(aCursor, "wait") == 0)
00071               qApp->setOverrideCursor(Qt::WaitCursor);
00072        else
00073               qApp->restoreOverrideCursor();
00074 //     Py_INCREF(Py_None);
00075 //     return Py_None;
00076        Py_RETURN_NONE;
00077 }
00078 
00079 PyObject *scribus_docchanged(PyObject* /* self */, PyObject* args)
00080 {
00081        int aValue;
00082        if (!PyArg_ParseTuple(args, "i", &aValue))
00083               return NULL;
00084        if(!checkHaveDocument())
00085               return NULL;
00086        ScCore->primaryMainWindow()->slotDocCh(static_cast<bool>(aValue));
00087        /*
00088        if (aValue>0)
00089               ScCore->primaryMainWindow()->slotDocCh(true);
00090        else
00091               ScCore->primaryMainWindow()->slotDocCh(false);*/
00092 //     Py_INCREF(Py_None);
00093 //     return Py_None;
00094        Py_RETURN_NONE;
00095 }
00096 
00097 PyObject *scribus_zoomdocument(PyObject* /* self */, PyObject* args)
00098 {
00099        double zoomFactor;
00100        if (!PyArg_ParseTuple(args, "d", &zoomFactor))
00101               return NULL;
00102        if(!checkHaveDocument())
00103               return NULL;
00104        if (zoomFactor > 0.0 || zoomFactor == -100.0)
00105               ScCore->primaryMainWindow()->slotZoom(zoomFactor);
00106        else
00107        {
00108               PyErr_SetString(PyExc_ValueError, QString("The zoom factor should be greater than 0.0 or equal to -100.0. See help(zoomFactor)."));
00109               return NULL;
00110        }
00111 //     Py_INCREF(Py_None);
00112 //     return Py_None;
00113        Py_RETURN_NONE;
00114 }
00115 
00119 void guiappdocwarnings()
00120 {
00121     QStringList s;
00122     s << scribus_messagebartext__doc__ << scribus_progressreset__doc__ << scribus_progresssettotalsteps__doc__ << scribus_progresssetprogress__doc__ << scribus_setcursor__doc__ << scribus_docchanged__doc__ << scribus_zoomdocument__doc__;
00123 }