r17560 by jainbasil - Added new Scripter2 code into main branch

scribus-commit scribus-commit at lists.scribus.net
Tue Jun 12 22:00:07 UTC 2012


Author: jainbasil
Date: Tue Jun 12 22:00:07 2012
New Revision: 17560

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17560
Log:
Added new Scripter2 code into main branch

Added:
    trunk/Scribus/scribus/plugins/scripter/api_color.cpp
    trunk/Scribus/scribus/plugins/scripter/api_color.h
    trunk/Scribus/scribus/plugins/scripter/api_imageexport.cpp
    trunk/Scribus/scribus/plugins/scripter/api_imageexport.h
    trunk/Scribus/scribus/plugins/scripter/api_layer.cpp
    trunk/Scribus/scribus/plugins/scripter/api_layer.h
    trunk/Scribus/scribus/plugins/scripter/api_printer.cpp
    trunk/Scribus/scribus/plugins/scripter/api_printer.h
    trunk/Scribus/scribus/plugins/scripter/api_textitem.cpp
    trunk/Scribus/scribus/plugins/scripter/api_textitem.h
    trunk/Scribus/scribus/plugins/scripter/utils.cpp
    trunk/Scribus/scribus/plugins/scripter/utils.h
Modified:
    trunk/Scribus/scribus/plugins/scripter/CMakeLists.txt
    trunk/Scribus/scribus/plugins/scripter/api_dialogs.h
    trunk/Scribus/scribus/plugins/scripter/api_document.cpp
    trunk/Scribus/scribus/plugins/scripter/api_document.h
    trunk/Scribus/scribus/plugins/scripter/api_item.cpp
    trunk/Scribus/scribus/plugins/scripter/api_item.h
    trunk/Scribus/scribus/plugins/scripter/api_page.cpp
    trunk/Scribus/scribus/plugins/scripter/api_page.h
    trunk/Scribus/scribus/plugins/scripter/api_window.cpp
    trunk/Scribus/scribus/plugins/scripter/api_window.h
    trunk/Scribus/scribus/plugins/scripter/python/autoload/about.spy
    trunk/Scribus/scribus/plugins/scripter/python/autoload/fullscreen.spy
    trunk/Scribus/scribus/plugins/scripter/python/autoload/help.spy
    trunk/Scribus/scribus/plugins/scripter/python/autoload/runfile.spy
    trunk/Scribus/scribus/plugins/scripter/python/autoload/sceditor.spy
    trunk/Scribus/scribus/plugins/scripter/python/init_scripter.py
    trunk/Scribus/scribus/plugins/scripter/python/sceditor/console.py
    trunk/Scribus/scribus/plugins/scripter/python/sceditor/mainwindow.py
    trunk/Scribus/scribus/plugins/scripter/python/sceditor/mainwindow.ui
    trunk/Scribus/scribus/plugins/scripter/python/sceditor/mainwindow_ui.py
    trunk/Scribus/scribus/plugins/scripter/python/sceditor/widget.py
    trunk/Scribus/scribus/plugins/scripter/python/scribusscript.py
    trunk/Scribus/scribus/plugins/scripter/python/scripter_hooks.py
    trunk/Scribus/scribus/plugins/scripter/pythonize.cpp
    trunk/Scribus/scribus/plugins/scripter/scripterimpl.cpp
    trunk/Scribus/scribus/plugins/scripter/scripterimpl.h

Modified: trunk/Scribus/scribus/plugins/scripter/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/plugins/scripter/CMakeLists.txt Tue Jun 12 22:00:07 2012
@@ -7,11 +7,17 @@
 scripter.h
 scripterimpl.h
 api_prefs.h
+api_imageitem.h
 api_item.h
+api_textitem.h
+api_printer.h
+api_imageexport.h
+api_layer.h
 api_page.h
 api_dialogs.h
 api_window.h
 api_document.h
+api_color.h
 )
 
 SET(SCRIPTER_PLUGIN_SOURCES
@@ -19,11 +25,18 @@
 scripterimpl.cpp
 pythonize.cpp
 api_prefs.cpp
+api_imageitem.cpp
 api_item.cpp
+api_textitem.cpp
+api_printer.cpp
+api_imageexport.cpp
+api_layer.cpp
 api_page.cpp
 api_dialogs.cpp
 api_window.cpp
 api_document.cpp
+api_color.cpp
+utils.cpp
 )
 
 

Modified: trunk/Scribus/scribus/plugins/scripter/api_dialogs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/api_dialogs.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/api_dialogs.h (original)
+++ trunk/Scribus/scribus/plugins/scripter/api_dialogs.h Tue Jun 12 22:00:07 2012
@@ -25,6 +25,7 @@
     Q_PROPERTY(QWidget* documentChecker READ documentChecker);
     Q_PROPERTY(QWidget* pages READ pages);
     Q_PROPERTY(QWidget* bookmarks READ bookmarks);
+    Q_PROPERTY(bool newDocument READ newDocument);
 public:
     DialogsAPI();
     virtual ~DialogsAPI();
@@ -105,6 +106,12 @@
     QWidget* bookmarks() {
         return (QWidget*)ScCore->primaryMainWindow()->bookmarkPalette;
     };
+    /** Scripter.dialogs.newDocument
+     *  Property
+     */
+    bool newDocument() {
+        return ScCore->primaryMainWindow()->slotFileNew();
+    };
 };
 
 #endif /*API_DIALOGS_H_*/

Modified: trunk/Scribus/scribus/plugins/scripter/api_document.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/api_document.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/api_document.cpp (original)
+++ trunk/Scribus/scribus/plugins/scripter/api_document.cpp Tue Jun 12 22:00:07 2012
@@ -4,22 +4,46 @@
 a copyright and/or license notice that predates the release of Scribus 1.3.2
 for which a new license (GPL+exception) is in place.
 */
+#include <QImageWriter>
+
 #include "api_document.h"
 #include "selection.h"
+#include "api_color.h"
+#include "api_layer.h"
+#include "api_imageexport.h"
+#include "api_printer.h"
+#include "api_textitem.h"
+#include "api_imageitem.h"
+#include "util.h"
+#include "utils.h"
+#include "pageitem_textframe.h"
+#include "undomanager.h"
 
 DocumentAPI::DocumentAPI() : QObject(COLLECTOR)
 {
-    qDebug() << "DocumentAPI loaded";
-    setObjectName("activeDocument"); // XXX: support other documents later
+	qDebug() << "DocumentAPI loaded";
+	setObjectName("document"); // XXX: support other documents later
 }
 
 
 
 DocumentAPI::~DocumentAPI()
 {
-    qDebug() << "DocumentAPI deleted";
-}
-
+	qDebug() << "DocumentAPI deleted";
+}
+
+/**
+ * Scripter.activeDocument.name
+ */
+QString DocumentAPI::getName()
+{
+	if (!check()) return NULL;
+	if (! ScCore->primaryMainWindow()->doc->hasName)
+	{
+		return QString("");
+	}
+	return ScCore->primaryMainWindow()->doc->DocName;
+}
 
 
 /**
@@ -29,9 +53,9 @@
  */
 bool DocumentAPI::available()
 {
-    if (ScCore->primaryMainWindow()->HaveDoc)
-        return true;
-    return false;
+	if (ScCore->primaryMainWindow()->HaveDoc)
+		return true;
+	return false;
 }
 
 
@@ -41,12 +65,12 @@
  */
 bool DocumentAPI::check()
 {
-    if (!available())
-    {
-        RAISE("Method call requires an open document, none found.");
-        return false;
-    }
-    return true;
+	if (!available())
+	{
+		RAISE("Method call requires an open document, none found.");
+		return false;
+	}
+	return true;
 }
 
 
@@ -60,16 +84,14 @@
  */
 void DocumentAPI::setModified(bool flag)
 {
-    if (!check()) return;
-    ScCore->primaryMainWindow()->doc->setModified(flag);
-}
-
-
+	if (!check()) return;
+	ScCore->primaryMainWindow()->doc->setModified(flag);
+}
 
 bool DocumentAPI::modified()
 {
-    if (!check()) return NULL;
-    return ScCore->primaryMainWindow()->doc->isModified();
+	if (!check()) return NULL;
+	return ScCore->primaryMainWindow()->doc->isModified();
 }
 
 
@@ -81,13 +103,42 @@
  */
 bool DocumentAPI::close()
 {
-    if (!check()) return NULL;
-    setModified(false);
-    bool ret = ScCore->primaryMainWindow()->slotFileClose();
-    qApp->processEvents();
-    return ret;
-}
-
+	if (!check()) return NULL;
+	setModified(false);
+	bool ret = ScCore->primaryMainWindow()->slotFileClose();
+	qApp->processEvents();
+	return ret;
+}
+
+/**
+ * Scripter.activeDocument.save()
+ *
+ * Saves the activeDocument
+ */
+bool DocumentAPI::save()
+{
+	if (!check()) return NULL;
+	bool ret = ScCore->primaryMainWindow()->slotFileSave();
+	qApp->processEvents();
+	return ret;
+}
+
+/**
+ * Scripter.activeDocument.saveAs(name)
+ *
+ * saves a document
+ */
+bool DocumentAPI::saveAs(QString name)
+{
+	if (!check()) return NULL;
+	bool ret = ScCore->primaryMainWindow()->DoFileSave(name);
+	if (!ret)
+	{
+		RAISE("Failed to save document.");
+		return NULL;
+	}
+	return true;
+}
 
 
 /**
@@ -96,7 +147,7 @@
  */
 int DocumentAPI::pageCount()
 {
-    return ScCore->primaryMainWindow()->doc->Pages->count();
+	return ScCore->primaryMainWindow()->doc->Pages->count();
 }
 
 
@@ -106,8 +157,9 @@
  * Property
  * Page object of active page in active Document
  */
-QObject *DocumentAPI::activePage() {
-    return new PageAPI(this);
+QObject *DocumentAPI::activePage()
+{
+	return new ScribusPage(this);
 }
 
 
@@ -118,9 +170,34 @@
  */
 QObject *DocumentAPI::activeItem()
 {
-    if (ScCore->primaryMainWindow()->doc->m_Selection->count() == 0)
-        return NULL;
-    return ScCore->primaryMainWindow()->doc->m_Selection->itemAt(0);
+	if (ScCore->primaryMainWindow()->doc->m_Selection->count() == 0)
+		return NULL;
+	else
+	{
+		PageItem* item = ScCore->primaryMainWindow()->doc->m_Selection->itemAt(0);
+		if(item->asTextFrame())
+		{
+			ScribusTextItem *textItem = new ScribusTextItem(item->asTextFrame());
+			return textItem;
+		}
+		else if(item->asImageFrame())
+		{
+			ScribusImageItem *imageItem = new ScribusImageItem(item->asImageFrame());
+			return imageItem;
+		}
+		else
+		{
+			ScribusItem *otherItem = new ScribusItem(item);
+			return otherItem;
+		}
+	}
+}
+
+int DocumentAPI::selectionCount()
+{
+	if(!check())
+		RAISE("No document open.");
+	return ScCore->primaryMainWindow()->doc->m_Selection->count();
 }
 
 
@@ -131,12 +208,35 @@
  */
 QList<QVariant> DocumentAPI::selection()
 {
-    QList<QVariant> l;
-    Selection *sel = ScCore->primaryMainWindow()->doc->m_Selection;
-    for (int i=0; i < sel->count(); i++)
-        l.append(qVariantFromValue(
-                     (QObject *)sel->itemAt(i)));
-    return l;
+	QList<QVariant> l;
+	Selection *sel = ScCore->primaryMainWindow()->doc->m_Selection;
+	for (int i=0; i < sel->count(); i++)
+	{
+		/**
+		 * Checking whether it is a textframe. If yes, we are trying to cast 
+		 * it onto TextWrapper class, which can effectively perform all 
+		 * the text operations
+		 */
+		PageItem *item = sel->itemAt(i);
+		if (item->asTextFrame())
+		{
+			ScribusTextItem *textItem = new ScribusTextItem(item->asTextFrame());
+			l.append(qVariantFromValue((QObject *)(textItem)));
+		}
+		else if(item->asImageFrame())
+		{
+			ScribusImageItem *imageItem = new ScribusImageItem(item->asImageFrame());
+			l.append(qVariantFromValue((QObject *)(imageItem)));
+		}
+		else
+		{
+			ScribusItem *otherItem = new ScribusItem(item);
+			l.append(qVariantFromValue(
+			             (QObject *)(otherItem)
+			         ));
+		}
+	}
+	return l;
 }
 
 
@@ -147,9 +247,8 @@
  */
 QObject *DocumentAPI::dimensions()
 {
-    return new Dimensions(this);
-}
-
+	return new Dimensions(this);
+}
 
 /**
  * Scripter.activeDocument.items
@@ -158,22 +257,440 @@
  */
 QList<QVariant> DocumentAPI::items()
 {
-    QList<QVariant> l;
-    for (int i = 0; i<ScCore->primaryMainWindow()->doc->Items->count(); ++i)
-    {
-        l.append(qVariantFromValue(
-                     (QObject *)(ScCore->primaryMainWindow()->doc->Items->at(i))
-                 ));
-    }
-    return l;
-}
-
-
-Dimensions::Dimensions(QObject *parent) : QObject(COLLECTOR) {
-    qDebug() << "Dimensions created";
-}
-
-
+	QList<QVariant> l;
+	for (int i = 0; i<ScCore->primaryMainWindow()->doc->Items->count(); ++i)
+	{
+		PageItem *item = ScCore->primaryMainWindow()->doc->Items->at(i);
+		if (item->asTextFrame())
+		{
+			ScribusTextItem *textItem = new ScribusTextItem(item->asTextFrame());
+			l.append(qVariantFromValue((QObject *)(textItem)));
+		}
+		else if(item->asImageFrame())
+		{
+			ScribusImageItem *imageItem = new ScribusImageItem(item->asImageFrame());
+			l.append(qVariantFromValue((QObject *)(imageItem)));
+		}
+		else
+		{
+			ScribusItem *otherItem = new ScribusItem(item);
+			l.append(qVariantFromValue(
+			             (QObject *)(otherItem)
+			         ));
+		}
+	}
+	return l;
+}
+//FIXME is there a need to make these informations separate properties?
+//jainbasil
+
+
+void DocumentAPI::setInformation(QString author, QString title, QString desc)
+{
+	if (!check())
+		return;
+	ScCore->primaryMainWindow()->doc->documentInfo().setAuthor(author);
+	ScCore->primaryMainWindow()->doc->documentInfo().setTitle(title);
+	ScCore->primaryMainWindow()->doc->documentInfo().setComments(desc);
+	ScCore->primaryMainWindow()->slotDocCh();
+}
+
+
+QList<QVariant> DocumentAPI::layers()
+{
+	QList<QVariant> l;
+	for (int i = 0; i<ScCore->primaryMainWindow()->doc->Layers.count() ; ++i)
+	{
+		ScLayer *L = &(ScCore->primaryMainWindow()->doc->Layers[i]);
+		ScribusLayer *layer = new ScribusLayer(L);
+		l.append(qVariantFromValue((QObject *)(layer)));
+	}
+	return l;
+}
+
+QObject *DocumentAPI::newLayer(QString name)
+{
+	ScribusLayer *l = new ScribusLayer(ScCore->primaryMainWindow()->doc->Layers.newLayer(name));
+	return (QObject *)(l);
+}
+
+void DocumentAPI::removeLayer(QString name)
+{
+	if (ScCore->primaryMainWindow()->doc->Layers.count() == 1)
+	{
+		RAISE("Cannot remove the last layer.");
+	}
+	bool found = false;
+	for (int lam=0; lam < ScCore->primaryMainWindow()->doc->Layers.count(); ++lam)
+	{
+		if (ScCore->primaryMainWindow()->doc->Layers[lam].Name == name)
+		{
+			ScLayer it2 = ScCore->primaryMainWindow()->doc->Layers.at(lam);
+			int num2 = it2.ID;
+			if (!num2)
+			{
+				return;
+			}
+			ScCore->primaryMainWindow()->doc->removeLayer(num2);
+			ScCore->primaryMainWindow()->doc->Layers.removeLayerByID(num2);
+			ScCore->primaryMainWindow()->doc->setActiveLayer(0);
+			ScCore->primaryMainWindow()->changeLayer(0);
+			found = true;
+			break;
+		}
+	}
+	if (!found)
+	{
+		RAISE("Layer not found.");
+	}
+}
+
+QObject *DocumentAPI::getActiveLayer()
+{
+	for (int i = 0; i<ScCore->primaryMainWindow()->doc->Layers.count(); ++i)
+	{
+		if (ScCore->primaryMainWindow()->doc->Layers[i].Name == ScCore->primaryMainWindow()->doc->activeLayerName())
+		{
+			ScLayer *L = &(ScCore->primaryMainWindow()->doc->Layers[i]);
+			return new ScribusLayer(L);
+		}
+	}
+	return NULL;
+}
+
+QString DocumentAPI::getActiveLayerName()
+{
+	return ScCore->primaryMainWindow()->doc->activeLayerName();
+}
+
+void DocumentAPI::setActiveLayer(QString name)
+{
+	bool found = ScCore->primaryMainWindow()->doc->setActiveLayer(name);
+	if (found)
+		ScCore->primaryMainWindow()->changeLayer(ScCore->primaryMainWindow()->doc->activeLayer());
+	else
+		RAISE("Layer not found.");
+}
+
+/**
+ * Scripter.activeDocument.colors
+ * Property
+ * Colors of activeDocument
+ */
+QList<QVariant> DocumentAPI::colors()
+{
+	QList<QVariant> l;
+
+	ColorList names = ScCore->primaryMainWindow()->doc->PageColors;
+	ColorList::Iterator it;
+	for (it = names.begin(); it != names.end(); ++it)
+	{
+		ScColor *value = &(names[it.key()]);
+		ScColorWrapper *color = new ScColorWrapper(value, it.key());
+		l.append(qVariantFromValue((QObject *)(color)));
+	}
+	return l;
+}
+
+QObject *DocumentAPI::getColor(QString name)
+{
+	return new ScColorWrapper(&(ScCore->primaryMainWindow()->doc->PageColors[name]), name);
+}
+
+QObject *DocumentAPI::newColorCMYK(QString name, int c, int m, int y, int k)
+{
+	if (name.isEmpty())
+	{
+		RAISE("Cannot create a color with an empty name");
+	}
+	if (ScCore->primaryMainWindow()->doc->PageColors.contains(name))
+	{
+		ScCore->primaryMainWindow()->doc->PageColors.insert(name, ScColor(c, m, y, k));
+	}
+	else
+	{
+		ScCore->primaryMainWindow()->doc->PageColors[name].setColor(c, m, y, k);
+	}
+	return getColor(name);
+}
+
+QObject *DocumentAPI::newColorRGB(QString name, int r, int g, int b)
+{
+	if (name.isEmpty())
+	{
+		RAISE("Cannot create a color with an empty name");
+	}
+	if (ScCore->primaryMainWindow()->doc->PageColors.contains(name))
+	{
+		ScCore->primaryMainWindow()->doc->PageColors.insert(name, ScColor(r, g, b));
+	}
+	else
+	{
+		ScCore->primaryMainWindow()->doc->PageColors[name].setColorRGB(r, g, b);
+	}
+	return getColor(name);
+}
+
+QList<QVariant> DocumentAPI::supportedImageTypes()
+{
+	QList<QVariant> l;
+	QList<QByteArray> list = QImageWriter::supportedImageFormats();
+	for (QList<QByteArray>::Iterator it = list.begin(); it != list.end(); ++it)
+	{
+		l.append(QString((*it)).toLatin1().constData());
+	}
+	return l;
+}
+
+bool DocumentAPI::exportAsImages(QString dirName, QString type, double scale, double quality, double dpi, bool overwrite)
+{
+	std::vector<int> pageNs;
+	ImageExport *ie = new ImageExport(dirName, type, scale, quality, dpi, overwrite);
+	parsePagesString("*", &pageNs, ScCore->primaryMainWindow()->doc->DocPages.count());
+	bool result = ie->exportInterval(ScCore->primaryMainWindow()->doc, pageNs);
+	return result;
+}
+
+QObject* DocumentAPI::Printer()
+{
+	return new PrinterAPI();
+}
+
+QList<QVariant> DocumentAPI::masterPages()
+{
+	QList<QVariant> names;
+	if (!check())
+		return names;
+	QMap<QString,int>::const_iterator it(ScCore->primaryMainWindow()->doc->MasterNames.constBegin());
+	QMap<QString,int>::const_iterator itEnd(ScCore->primaryMainWindow()->doc->MasterNames.constEnd());
+	for (; it != itEnd; ++it)
+	{
+		names.append(it.key());
+	}
+	return names;
+}
+
+/**
+ * Scripter.activeDocument.createMasterPage(name)
+ */
+void DocumentAPI::createMasterPage(QString name)
+{
+	if (!check()) return;
+	if (ScCore->primaryMainWindow()->doc->MasterNames.contains(name))
+	{
+		RAISE("Master page already exists");
+		return;
+	}
+	ScCore->primaryMainWindow()->doc->addMasterPage(ScCore->primaryMainWindow()->doc->MasterPages.count(), name);
+}
+
+/**
+ * Scripter.activeDocument.deleteMasterPage(name)
+ */
+void DocumentAPI::deleteMasterPage(QString name)
+{
+	if (!check()) return;
+
+	if (!ScCore->primaryMainWindow()->doc->MasterNames.contains(name))
+	{
+		RAISE("Master page does not exist");
+		return;
+	}
+	if (name == "Normal")
+	{
+		RAISE("Can not delete the Normal master page");
+		return;
+	}
+	bool oldMode = ScCore->primaryMainWindow()->doc->masterPageMode();
+	ScCore->primaryMainWindow()->doc->setMasterPageMode(true);
+	ScCore->primaryMainWindow()->deletePage2(ScCore->primaryMainWindow()->doc->MasterNames[name]);
+	ScCore->primaryMainWindow()->doc->setMasterPageMode(oldMode);
+}
+
+void DocumentAPI::closeMasterPage(QString name)
+{
+	if (!check())
+		return;
+	ScCore->primaryMainWindow()->view->hideMasterPage();
+}
+
+void DocumentAPI::editMasterPage(QString name)
+{
+	if (!check())
+		return;
+	const QMap<QString,int>& masterNames(ScCore->primaryMainWindow()->doc->MasterNames);
+	const QMap<QString,int>::const_iterator it(masterNames.find(name));
+	if (it == masterNames.constEnd())
+	{
+		RAISE("Master page not found");
+		return;
+	}
+	ScCore->primaryMainWindow()->view->showMasterPage(*it);
+}
+
+void DocumentAPI::loadStylesFromFile(QString name)
+{
+	if (!check())
+		return;
+	ScCore->primaryMainWindow()->doc->loadStylesFromFile(name);
+}
+
+QObject* DocumentAPI::selectItem(QString name)
+{
+	if (!check())
+		RAISE("No document open");
+	PageItem *i = GetUniqueItem(name);
+	if (i == NULL)
+	{
+		RAISE("No item with this name");
+	}
+	ScCore->primaryMainWindow()->view->SelectItem(i);
+	return activeItem();
+}
+
+void DocumentAPI::deleteItem(QString name)
+{
+	if (name.isEmpty())
+	{
+		RAISE("name cannot be empty.");
+		return;
+	}
+	if (!check())
+		return;
+	PageItem *i = GetUniqueItem(name);
+	if (i == NULL)
+	{
+		RAISE("Unable to find the item.");
+		return;
+	}
+	ScCore->primaryMainWindow()->doc->m_Selection->clear();
+	ScCore->primaryMainWindow()->doc->m_Selection->addItem(i);
+	ScCore->primaryMainWindow()->doc->itemSelection_DeleteItem();
+}
+
+bool DocumentAPI::itemExists(QString name)
+{
+	if (name.isEmpty())
+	{
+		RAISE("Name cannot be empty");
+		return false;
+	}
+	if (!check())
+	{
+		RAISE("No active document");
+	}
+	if (ItemExists(name))
+		return true;
+	return false;
+}
+
+QList< QVariant > DocumentAPI::styles()
+{
+	QList<QVariant> styleList;
+	if (!check())
+		RAISE("No active document.");
+	for (int i=0; i < ScCore->primaryMainWindow()->doc->paragraphStyles().count(); ++i)
+	{
+		styleList.append(ScCore->primaryMainWindow()->doc->paragraphStyles()[i].name());
+	}
+	return styleList;
+}
+
+void DocumentAPI::deselectItems()
+{
+	if (!check())
+		return;
+	ScCore->primaryMainWindow()->view->Deselect();
+}
+
+QString DocumentAPI::groupItems(QList< QVariant > list)
+{
+	QString name;
+	if (!check())
+		RAISE("No document open");
+	if (list.isEmpty() && ScCore->primaryMainWindow()->doc->m_Selection->count() < 2)
+	{
+		RAISE("Need selection or argument list of items to group");
+	}
+	Selection *tempSelection=0;
+	Selection *finalSelection=0;
+	//uint ap = ScCore->primaryMainWindow()->doc->currentPage()->pageNr();
+	// If we were passed a list of items to group...
+	if (!list.isEmpty())
+	{
+		int len = list.length();
+		tempSelection = new Selection(ScCore->primaryMainWindow(), false);
+		for (int i = 0; i < len; i++)
+		{
+			// FIXME: We might need to explicitly get this string as utf8
+			// but as sysdefaultencoding is utf8 it should be a no-op to do
+			// so anyway.
+			name = list[i].toString();
+			PageItem *ic = GetUniqueItem(name);
+			if (ic == NULL)
+			{
+				delete tempSelection;
+				return NULL;
+			}
+			tempSelection->addItem(ic, true);
+		}
+		finalSelection=tempSelection;
+	}
+	else
+		finalSelection=ScCore->primaryMainWindow()->doc->m_Selection;
+	if (finalSelection->count() < 2)
+	{
+		// We can't very well group only one item
+		RAISE("Cannot group less than two items");
+		finalSelection=0;
+		delete tempSelection;
+		return NULL;
+	}
+
+	const PageItem* group = ScCore->primaryMainWindow()->doc->itemSelection_GroupObjects(false, false, finalSelection);
+	finalSelection=0;
+	delete tempSelection;
+
+	return (group ? group->itemName() : NULL);
+}
+
+void DocumentAPI::unGroupItems(QString name)
+{
+	if (!check())
+		RAISE("No document open");
+	PageItem *i = GetUniqueItem(name);
+	if (i == NULL)
+		RAISE("Item not found.");
+	ScCore->primaryMainWindow()->view->Deselect();
+	ScCore->primaryMainWindow()->view->SelectItem(i);
+	ScCore->primaryMainWindow()->UnGroupObj();
+}
+
+void DocumentAPI::scaleGroup(double factor, QString name)
+{
+	if (!check())
+		RAISE("No document open");
+	if (factor == 0.0)
+	{
+		RAISE("Cannot scale by 0%.");
+		return;
+	}
+	PageItem *i = GetUniqueItem(name);
+	if (i == NULL)
+		return;
+	ScCore->primaryMainWindow()->view->Deselect();
+	ScCore->primaryMainWindow()->view->SelectItem(i);
+//	int h = ScCore->primaryMainWindow()->view->frameResizeHandle;
+//	ScCore->primaryMainWindow()->view->frameResizeHandle = 1;
+	ScCore->primaryMainWindow()->view->startGroupTransaction(Um::Resize, "", Um::IResize);
+	ScCore->primaryMainWindow()->doc->scaleGroup(factor, factor);
+	ScCore->primaryMainWindow()->view->endGroupTransaction();
+}
+
+Dimensions::Dimensions(QObject *parent) : QObject(COLLECTOR)
+{
+	qDebug() << "Dimensions created";
+}
 
 /**
  * Scripter.activeDocument.dimensions.width
@@ -185,8 +702,6 @@
 	return ScCore->primaryMainWindow()->doc->pageWidth();
 }
 
-
-
 /**
  * Scripter.activeDocument.dimensions.height
  * Property
@@ -197,8 +712,6 @@
 	return ScCore->primaryMainWindow()->doc->pageHeight();
 }
 
-
-
 /**
  * Scripter.activeDocument.margins
  * Property
@@ -206,17 +719,13 @@
  */
 QObject *DocumentAPI::margins()
 {
-    return new Margins(this);
-}
-
-
+	return new Margins(this);
+}
 
 Margins::Margins(QObject *parent) : QObject(COLLECTOR)
 {
-    qDebug() << "Margins created";
-}
-
-
+	qDebug() << "Margins created";
+}
 
 /**
  * Scripter.activeDocument.margins.top
@@ -247,7 +756,8 @@
  * Property
  * right-margin of active document as double
  */
-double Margins::right() {
+double Margins::right()
+{
 	return ScCore->primaryMainWindow()->doc->margins()->Right;
 }
 
@@ -258,7 +768,8 @@
  * Property
  * top-margin of active document as double
  */
-double Margins::bottom() {
+double Margins::bottom()
+{
 	return ScCore->primaryMainWindow()->doc->margins()->Bottom;
 }
 
@@ -273,38 +784,38 @@
 
 void Margins::set(double lr, double tpr, double btr, double rr)
 {
-    MarginStruct margins(tpr, lr, btr, rr);
+	MarginStruct margins(tpr, lr, btr, rr);
 	ScCore->primaryMainWindow()->doc->resetPage(ScCore->primaryMainWindow()->doc->pagePositioning(), &margins);
-    ScCore->primaryMainWindow()->view->reformPages();
-    ScCore->primaryMainWindow()->doc->setModified(true);
-    ScCore->primaryMainWindow()->view->GotoPage(ScCore->primaryMainWindow()->doc->currentPageNumber());
-    ScCore->primaryMainWindow()->view->DrawNew();
+	ScCore->primaryMainWindow()->view->reformPages();
+	ScCore->primaryMainWindow()->doc->setModified(true);
+	ScCore->primaryMainWindow()->view->GotoPage(ScCore->primaryMainWindow()->doc->currentPageNumber());
+	ScCore->primaryMainWindow()->view->DrawNew();
 }
 
 
 
 void Margins::setTop(double value)
 {
-    set(left(), value, bottom(), right());
+	set(left(), value, bottom(), right());
 }
 
 
 
 void Margins::setLeft(double value)
 {
-    set(value, top(), bottom(), right());
+	set(value, top(), bottom(), right());
 }
 
 
 
 void Margins::setRight(double value)
 {
-    set(left(), top(), bottom(), value);
+	set(left(), top(), bottom(), value);
 }
 
 
 
 void Margins::setBottom(double value)
 {
-    set(left(), top(), value, right());
-}
+	set(left(), top(), value, right());
+}

Modified: trunk/Scribus/scribus/plugins/scripter/api_document.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/api_document.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/api_document.h (original)
+++ trunk/Scribus/scribus/plugins/scripter/api_document.h Tue Jun 12 22:00:07 2012
@@ -17,65 +17,146 @@
 
 class DocumentAPI : public QObject
 {
-    Q_OBJECT
-    Q_PROPERTY(bool available READ available);
-    Q_PROPERTY(QObject* margins READ margins);
-    Q_PROPERTY(bool modified READ modified WRITE setModified);
-    Q_PROPERTY(QObject* activePage READ activePage);
-    Q_PROPERTY(int pageCount READ pageCount);
-    Q_PROPERTY(QObject* activeItem READ activeItem);
-    Q_PROPERTY(QObject* dimensions READ dimensions);
-    Q_PROPERTY(QList<QVariant> items READ items);
-    Q_PROPERTY(QList<QVariant> selection READ selection);
+	Q_OBJECT
+	Q_PROPERTY(QString name READ getName);
+	Q_PROPERTY(bool available READ available);
+	Q_PROPERTY(QObject* margins READ margins);
+	Q_PROPERTY(bool modified READ modified WRITE setModified);
+	Q_PROPERTY(QObject* activePage READ activePage);
+	Q_PROPERTY(int pageCount READ pageCount);
+	Q_PROPERTY(QObject* activeItem READ activeItem);
+	Q_PROPERTY(QObject* dimensions READ dimensions);
+	Q_PROPERTY(QList<QVariant> items READ items);
+	Q_PROPERTY(QList<QVariant> selection READ selection);
+	Q_PROPERTY(int selectionCount READ selectionCount);
+	Q_PROPERTY(QList<QVariant> colors READ colors);
+	Q_PROPERTY(QList<QVariant> layers READ layers);
+	Q_PROPERTY(QList<QVariant> masterPages READ masterPages);
+	Q_PROPERTY(QList<QVariant> styles READ styles);
+
 public:
-    DocumentAPI();
-    virtual ~DocumentAPI();
+	DocumentAPI();
+	virtual ~DocumentAPI();
 
 public slots:
-    bool check();
-    bool close();
-    QList<QVariant> items();
+	bool check();
+	bool close();
+	bool save();
+	bool saveAs(QString name);
+	QList<QVariant> items(); //TODO move this to private section
+	QList<QVariant> layers(); //TODO move this to private section
+	void setInformation(QString author, QString title, QString desc);
+
+	/**
+	 * Layer functions related to activeDocument
+	 */
+	QObject *newLayer(QString name);
+	void removeLayer(QString name);
+	QObject *getActiveLayer();
+	QString getActiveLayerName();
+	void setActiveLayer(QString name);
+
+	/**
+	 * Color functions related to activeDocument
+	 */
+	QObject *newColorCMYK(QString name, int c, int m, int y, int k);
+	QObject *newColorRGB(QString name, int r, int g, int b);
+	QObject *getColor(QString name);
+	
+	/**
+	 * Export As Image
+	 */
+	QList<QVariant> supportedImageTypes();
+	bool exportAsImages(QString dirName, QString type, double scale, double quality, double dpi, bool overwrite);
+	
+	/**
+	 * Printer function
+	 */
+	QObject* Printer();
+	
+	/**
+	 * Master Pages
+	 */
+	QList<QVariant> masterPages();
+	void createMasterPage(QString name);
+	void deleteMasterPage(QString name);
+	void closeMasterPage(QString name);
+	void editMasterPage(QString name);
+	
+	/**
+	 * Styles
+	 */
+	void loadStylesFromFile(QString name);
+
+	/**
+	 * Selection
+	 */
+	void moveSelectionToFront()
+	{
+		ScCore->primaryMainWindow()->doc->sendItemSelectionToBack();
+	}
+	
+	void moveSelectionToBack()
+	{
+		ScCore->primaryMainWindow()->doc->sendItemSelectionToBack();
+	}
+	
+	/**
+	 * Methods on PageItems
+	 */
+	QObject* selectItem(QString name);
+	void deleteItem(QString name);
+	bool itemExists(QString name);
+	void deselectItems();
+	//methods related to grouped items
+	QString groupItems(QList<QVariant> list);
+	void unGroupItems(QString name);
+	void scaleGroup(double factor, QString name);
 
 private:
-    QObject *margins();
-    bool available();
-    bool modified();
-    void setModified(bool flag);
-    QObject *activePage();
-    int pageCount();
-    QList<QVariant> selection();
-    QObject *activeItem();
-    QObject *dimensions();
+	QObject *margins();
+	QString getName();
+	bool available();
+	bool modified();
+	void setModified(bool flag);
+	QObject *activePage();
+	int pageCount();
+	QList<QVariant> selection();
+	int selectionCount();
+	QObject *activeItem();
+	QObject *dimensions();
+	QList<QVariant> colors();
+	QList<QVariant> styles();
 };
 
 
 class Margins : public QObject
 {
-    Q_OBJECT
-    Q_PROPERTY(double top READ top WRITE setTop);
-    Q_PROPERTY(double left READ left WRITE setLeft);
-    Q_PROPERTY(double right READ right WRITE setRight);
-    Q_PROPERTY(double bottom READ bottom WRITE setBottom);
+	Q_OBJECT
+	Q_PROPERTY(double top READ top WRITE setTop);
+	Q_PROPERTY(double left READ left WRITE setLeft);
+	Q_PROPERTY(double right READ right WRITE setRight);
+	Q_PROPERTY(double bottom READ bottom WRITE setBottom);
 
 public:
-    Margins(QObject *parent);
-    virtual ~Margins()
-    {
-        qDebug() << "Margins deleted";
-    };
+	Margins(QObject *parent);
+	virtual ~Margins()
+	{
+		qDebug() << "Margins deleted";
+	};
 
 public slots:
-    void set(double lr, double tpr, double btr, double rr);
+	void set(double lr, double tpr, double btr, double rr);
 
 private:
-    double top();
-    void setTop(double value);
-    double left();
-    void setLeft(double value);
-    double right();
-    void setRight(double value);
-    double bottom();
-    void setBottom(double value);
+	double top();
+	void setTop(double value);
+	double left();
+	void setLeft(double value);
+	double right();
+	void setRight(double value);
+	double bottom();
+	void setBottom(double value);
 
 };
 
@@ -83,21 +164,21 @@
 
 class Dimensions : public QObject
 {
-    Q_OBJECT
-    Q_PROPERTY(double width READ width);
-    Q_PROPERTY(double height READ height);
+	Q_OBJECT
+	Q_PROPERTY(double width READ width);
+	Q_PROPERTY(double height READ height);
 
 public:
-    Dimensions(QObject *parent);
-    virtual ~Dimensions()
-    {
-        qDebug() << "Dimensions deleted";
-    };
+	Dimensions(QObject *parent);
+	virtual ~Dimensions()
+	{
+		qDebug() << "Dimensions deleted";
+	};
 
 private:
-    double width();
-    double height();
-    QList<QVariant> items;
+	double width();
+	double height();
+	QList<QVariant> items;
 };
 
 

Modified: trunk/Scribus/scribus/plugins/scripter/api_item.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/api_item.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/api_item.cpp (original)
+++ trunk/Scribus/scribus/plugins/scripter/api_item.cpp Tue Jun 12 22:00:07 2012
@@ -5,20 +5,384 @@
 for which a new license (GPL+exception) is in place.
 */
 #include "api_item.h"
-
-ItemAPI::ItemAPI(QObject *parent, const QString &name, int type, int number
-                ) : QObject(
-                            QApplication::instance()->findChild<ScripterImpl *>("Scripter"))
-{
-    qDebug() << "ItemAPI loaded";
-    setObjectName("Item");
-}
-
-
-
-ItemAPI::~ItemAPI()
-{
-    qDebug() << "ItemAPI deleted";
-}
-
-
+#include "utils.h"
+#include "undomanager.h"
+#include "selection.h"
+
+ScribusItem::ScribusItem(PageItem* it) : QObject(COLLECTOR)
+{
+	qDebug() << "ItemAPI loaded";
+	setObjectName("item");
+	item = it;
+}
+
+QString ScribusItem::itemName()
+{
+	return item->itemName();
+}
+
+void ScribusItem::setItemName(QString name)
+{
+	item->setItemName(name);
+}
+
+
+QString ScribusItem::fillColor()
+{
+	return item->fillColor();
+}
+
+void ScribusItem::setFillColor(QString color)
+{
+	item->setFillColor(color);
+}
+
+QString ScribusItem::lineColor()
+{
+	return item->lineColor();
+}
+
+void ScribusItem::setLineColor(QString color)
+{
+	item->setLineColor(color);
+}
+
+
+double ScribusItem::fillShade()
+{
+	return item->fillShade();
+}
+
+void ScribusItem::setFillShade(double value)
+{
+	item->setFillShade(value);
+}
+
+double ScribusItem::lineShade()
+{
+	return item->lineShade();
+}
+
+void ScribusItem::setLineShade(double value)
+{
+	item->setLineShade(value);
+}
+
+double ScribusItem::fillTransparency()
+{
+	return item->fillTransparency();
+}
+
+void ScribusItem::setFillTransparency(double value)
+{
+	item->setFillTransparency(value);
+}
+
+
+double ScribusItem::lineTransparency()
+{
+	return item->lineTransparency();
+}
+
+void ScribusItem::setLineTransparency(double value)
+{
+	item->setLineTransparency(value);
+}
+
+bool ScribusItem::locked()
+{
+	return item->locked();
+}
+
+void ScribusItem::setLocked(bool value)
+{
+	item->setLocked(value);
+}
+
+bool ScribusItem::sizeLocked()
+{
+	return item->sizeLocked();
+}
+
+void ScribusItem::setSizeLocked(bool value)
+{
+	item->setSizeLocked(value);
+}
+
+bool ScribusItem::imageFlippedV()
+{
+	return item->imageFlippedV();
+}
+
+void ScribusItem::setImageFlippedV(bool value)
+{
+	item->setImageFlippedV(value);
+}
+
+bool ScribusItem::imageFlippedH()
+{
+	return item->imageFlippedH();
+}
+
+void ScribusItem::setImageFlippedH(bool value)
+{
+	item->setImageFlippedH(value);
+}
+
+double ScribusItem::lineWidth()
+{
+	return item->lineWidth();
+}
+
+void ScribusItem::setLineWidth(double value)
+{
+	item->setLineWidth(value);
+}
+
+QString ScribusItem::customLineStyle()
+{
+	return item->customLineStyle();
+}
+
+void ScribusItem::setCustomLineStyle(QString name)
+{
+	item->setCustomLineStyle(name);
+}
+
+int ScribusItem::startArrowIndex()
+{
+	return item->startArrowIndex();
+}
+
+void ScribusItem::setStartArrowIndex(int value)
+{
+	item->setStartArrowIndex(value);
+}
+
+int ScribusItem::endArrowIndex()
+{
+	return item->endArrowIndex();
+}
+
+void ScribusItem::setEndArrowIndex(int value)
+{
+	item->setEndArrowIndex(value);
+}
+
+bool ScribusItem::printEnabled()
+{
+	return item->printEnabled();
+}
+
+void ScribusItem::setPrintEnabled(bool value)
+{
+	item->setPrintEnabled(value);
+}
+
+double ScribusItem::xPos()
+{
+	return item->xPos();
+}
+
+void ScribusItem::setXPos(double value)
+{
+	item->setXPos(value);
+}
+
+double ScribusItem::yPos()
+{
+	return item->yPos();
+}
+
+void ScribusItem::setYPos(double value)
+{
+	item->setYPos(value);
+}
+
+double ScribusItem::width()
+{
+	return item->width();
+}
+
+void ScribusItem::setWidth(double value)
+{
+	item->setWidth(value);
+}
+
+double ScribusItem::height()
+{
+	return item->height();
+}
+
+void ScribusItem::setHeight(double value)
+{
+	item->setHeight(value);
+}
+
+double ScribusItem::rotation()
+{
+	return item->rotation();
+}
+
+void ScribusItem::setRotation(double rotation)
+{
+	item->setRotation(rotation);
+}
+
+bool ScribusItem::reversed()
+{
+	return item->reversed();
+}
+
+void ScribusItem::setReversed(bool value)
+{
+	item->setReversed(value);
+}
+
+double ScribusItem::cornerRadius()
+{
+	return item->cornerRadius();
+}
+
+void ScribusItem::setCornerRadius(double value)
+{
+	item->setCornerRadius(value);
+}
+
+double ScribusItem::columnGap()
+{
+	return item->columnGap();
+}
+
+void ScribusItem::setColumnGap(double value)
+{
+	if (!checkHaveDocument())
+		RAISE("No document open");
+	if (value < 0.0)
+	{
+		RAISE("Column gap out of bounds, must be positive.");
+	}
+	item->ColGap = ValueToPoint(value);
+}
+
+int ScribusItem::columns()
+{
+	return item->columns();
+}
+
+void ScribusItem::setColumns(int value)
+{
+	if (!checkHaveDocument())
+		RAISE("No document open");
+	if (value < 1)
+	{
+		RAISE("Column count out of bounds, must be > 1.");
+	}
+	item->Cols = value;
+}
+
+
+/**
+ * Methods
+ */
+
+void ScribusItem::move(double dx, double dy)
+{
+	if (!checkHaveDocument())
+		return;
+	if (item==NULL)
+		return;
+	// Grab the old selection - but use it only where is there any
+	Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection);
+	bool hadOrigSelection = (tempSelection.count() != 0);
+
+	ScCore->primaryMainWindow()->doc->m_Selection->clear();
+	// Clear the selection
+	ScCore->primaryMainWindow()->view->Deselect();
+	// Select the item, which will also select its group if
+	// there is one.
+	ScCore->primaryMainWindow()->view->SelectItem(item);
+	// Move the item, or items
+	if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1)
+	{
+		ScCore->primaryMainWindow()->view->startGroupTransaction(Um::Move, "", Um::IMove);
+		ScCore->primaryMainWindow()->doc->moveGroup(ValueToPoint(dx), ValueToPoint(dy));
+		ScCore->primaryMainWindow()->view->endGroupTransaction();
+	}
+	else
+	{
+		ScCore->primaryMainWindow()->doc->MoveItem(ValueToPoint(dx), ValueToPoint(dy), item);
+	}
+	// Now restore the selection.
+	ScCore->primaryMainWindow()->view->Deselect();
+	if (hadOrigSelection)
+		*ScCore->primaryMainWindow()->doc->m_Selection=tempSelection;
+
+}
+
+void ScribusItem::moveAbs(double x, double y)
+{
+	if (!checkHaveDocument())
+		return;
+	if (item == NULL)
+		return;
+	// Grab the old selection - but use it only where is there any
+	Selection tempSelection(*ScCore->primaryMainWindow()->doc->m_Selection);
+	bool hadOrigSelection = (tempSelection.count() != 0);
+
+	// Clear the selection
+	ScCore->primaryMainWindow()->view->Deselect();
+	// Select the item, which will also select its group if
+	// there is one.
+	ScCore->primaryMainWindow()->view->SelectItem(item);
+	// Move the item, or items
+	if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1)
+	{
+		ScCore->primaryMainWindow()->view->startGroupTransaction(Um::Move, "", Um::IMove);
+		double x2, y2, w, h;
+		ScCore->primaryMainWindow()->doc->m_Selection->getGroupRect(&x2, &y2, &w, &h);
+		ScCore->primaryMainWindow()->doc->moveGroup(pageUnitXToDocX(x) - x2, pageUnitYToDocY(y) - y2);
+		ScCore->primaryMainWindow()->view->endGroupTransaction();
+	}
+	else
+		ScCore->primaryMainWindow()->doc->MoveItem(pageUnitXToDocX(x) - item->xPos(), pageUnitYToDocY(y) - item->yPos(), item);
+	// Now restore the selection.
+	ScCore->primaryMainWindow()->view->Deselect();
+	if (hadOrigSelection)
+		*ScCore->primaryMainWindow()->doc->m_Selection=tempSelection;
+}
+
+void ScribusItem::resize(double width, double height)
+{
+	if (!checkHaveDocument())
+		return;
+	if (item == NULL)
+		return;
+	ScCore->primaryMainWindow()->doc->SizeItem(ValueToPoint(width), ValueToPoint(height), item);
+}
+
+void ScribusItem::rotate(double rot)
+{
+	if (!checkHaveDocument())
+		return;
+	if (item == NULL)
+		return;
+	ScCore->primaryMainWindow()->doc->RotateItem(item->rotation() - rot, item);
+
+}
+void ScribusItem::rotateAbs(double rot)
+{
+	if (!checkHaveDocument())
+		return;
+	if (item == NULL)
+		return;
+	ScCore->primaryMainWindow()->doc->RotateItem(rot * -1.0, item);
+}
+
+
+ScribusItem::~ScribusItem()
+{
+	qDebug() << "ItemAPI deleted";
+}
+
+

Modified: trunk/Scribus/scribus/plugins/scripter/api_item.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/api_item.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/api_item.h (original)
+++ trunk/Scribus/scribus/plugins/scripter/api_item.h Tue Jun 12 22:00:07 2012
@@ -13,15 +13,127 @@
 
 #include "scripterimpl.h"
 
-class ItemAPI : public QObject
+class ScribusItem : public QObject
 {
-    Q_OBJECT
+	Q_OBJECT
+	Q_PROPERTY(QString itemName READ itemName WRITE setItemName)
+	Q_PROPERTY(QString fillColor READ fillColor WRITE setFillColor)
+	Q_PROPERTY(QString lineColor READ lineColor WRITE setLineColor)
+	Q_PROPERTY(double fillShade READ fillShade WRITE setFillShade)
+	Q_PROPERTY(double lineShade READ lineShade WRITE setLineShade)
+	Q_PROPERTY(double fillTransparency READ fillTransparency WRITE setFillTransparency)
+	Q_PROPERTY(double lineTransparency READ lineTransparency WRITE setLineTransparency)
+	Q_PROPERTY(bool locked READ locked WRITE setLocked)
+	Q_PROPERTY(bool sizeLocked READ sizeLocked WRITE setSizeLocked)
+	Q_PROPERTY(bool flipVertical READ imageFlippedV WRITE setImageFlippedV)
+	Q_PROPERTY(bool flipHorizontal READ imageFlippedH WRITE setImageFlippedH)
+	Q_PROPERTY(double lineWidth READ lineWidth WRITE setLineWidth)
+	Q_PROPERTY(QString customLineStyle READ customLineStyle WRITE setCustomLineStyle)
+	Q_PROPERTY(int startArrowIndex READ startArrowIndex WRITE setStartArrowIndex)
+	Q_PROPERTY(int endArrowIndex READ endArrowIndex WRITE setEndArrowIndex)
+
+	Q_PROPERTY(bool printEnabled READ printEnabled WRITE setPrintEnabled)
+	Q_PROPERTY(double xPos READ xPos WRITE setXPos)
+	Q_PROPERTY(double yPos READ yPos WRITE setYPos)
+	Q_PROPERTY(double width READ width WRITE setWidth)
+	Q_PROPERTY(double height READ height WRITE setHeight)
+	Q_PROPERTY(double rotation READ rotation WRITE setRotation)
+	Q_PROPERTY(bool reversed READ reversed WRITE setReversed)
+	Q_PROPERTY(double cornerRadius READ cornerRadius WRITE setCornerRadius)
+	Q_PROPERTY(double columnGap READ columnGap WRITE setColumnGap)
+	Q_PROPERTY(int columns READ columns WRITE setColumns)
+
 public:
-    ItemAPI(QObject *parent, const QString &name, int type, int number);
-    virtual ~ItemAPI();
+	ScribusItem(PageItem *it);
+	virtual ~ScribusItem();
 
 public slots:
-    // XXX: put your methods here
+	void move(double dx, double dy);
+	void moveAbs(double x, double y);
+	void rotate(double rot);
+	void rotateAbs(double rot);
+	void resize(double width, double height);
+
+private:
+	PageItem *item;
+	
+	/**
+	 * Properties
+	 */
+	QString itemName();
+	void setItemName(QString name);
+	
+	QString fillColor();
+	void setFillColor(QString color);
+	
+	QString lineColor();
+	void setLineColor(QString color);
+	
+	double fillShade();
+	void setFillShade(double value);
+	
+	double lineShade();
+	void setLineShade(double value);
+	
+	double fillTransparency();
+	void setFillTransparency(double value);
+	
+	double lineTransparency();
+	void setLineTransparency(double value);
+	
+	bool locked();
+	void setLocked(bool value);
+	
+	bool sizeLocked();
+	void setSizeLocked(bool value);
+	
+	bool imageFlippedV();
+	void setImageFlippedV(bool value);
+	
+	bool imageFlippedH();
+	void setImageFlippedH(bool value);
+	
+	double lineWidth();
+	void setLineWidth(double value);
+	
+	QString customLineStyle();
+	void setCustomLineStyle(QString name);
+	
+	int startArrowIndex();
+	void setStartArrowIndex(int value);
+	
+	int endArrowIndex();
+	void setEndArrowIndex(int value);
+	
+	bool printEnabled();
+	void setPrintEnabled(bool value);
+	
+	double xPos();
+	void setXPos(double value);
+	
+	double yPos();
+	void setYPos(double value);
+	
+	double width();
+	void setWidth(double value);
+
+	double height();
+	void setHeight(double value);
+	
+	double rotation();
+	void setRotation(double rotation);
+	
+	bool reversed();
+	void setReversed(bool value);
+	
+	double cornerRadius();
+	void setCornerRadius(double value);
+	
+	double columnGap();
+	void setColumnGap(double value);
+	
+	int columns();
+	void setColumns(int value);
 };
 
 #endif /*API_ITEM_H_*/

Modified: trunk/Scribus/scribus/plugins/scripter/api_page.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/api_page.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/api_page.cpp (original)
+++ trunk/Scribus/scribus/plugins/scripter/api_page.cpp Tue Jun 12 22:00:07 2012
@@ -14,20 +14,23 @@
 #include "ui/propertiespalette.h"
 #include "ui/propertiespalette_text.h"
 #include "ui/propertiespalette_line.h"
-
-
-
-PageAPI::PageAPI(QObject *parent) : QObject(COLLECTOR)
-{
-    qDebug() << "PageAPI loaded";
-    setObjectName("activePage");
-}
-
-
-
-PageAPI::~PageAPI()
-{
-    qDebug() << "PageAPI deleted";
+#include "scribuscore.h"
+#include "api_textitem.h"
+#include "api_imageitem.h"
+
+
+
+ScribusPage::ScribusPage(QObject *parent) : QObject(COLLECTOR)
+{
+	qDebug() << "PageAPI loaded";
+	setObjectName("page");
+}
+
+
+
+ScribusPage::~ScribusPage()
+{
+	qDebug() << "PageAPI deleted";
 }
 
 
@@ -37,12 +40,12 @@
  *
  * Removes the active page from the active document.
  */
-void PageAPI::remove()
-{
-    if ( ScCore->primaryMainWindow()->doc->Pages->count() > 1  )
-        ScCore->primaryMainWindow()->DeletePage2(number());
-    else
-        RAISE("No pages left to remove");
+void ScribusPage::remove()
+{
+	if (ScCore->primaryMainWindow()->doc->Pages->count() > 1)
+		ScCore->primaryMainWindow()->deletePage2(number());
+	else
+		RAISE("No pages left to remove");
 }
 
 
@@ -52,9 +55,9 @@
  * Property
  * location of active page as int value (read-only)
  */
-int PageAPI::position()
-{
-    return ScCore->primaryMainWindow()->doc->locationOfPage(number());
+int ScribusPage::position()
+{
+	return ScCore->primaryMainWindow()->doc->locationOfPage(number());
 }
 
 
@@ -64,22 +67,22 @@
  * Property
  * int value of active page number >= 1
  */
-int PageAPI::number()
-{
-    return ScCore->primaryMainWindow()->doc->currentPageNumber() + 1;
-}
-
-
-
-void PageAPI::setNumber(int value)
-{
-    value--;
-    if ((value < 0) || (value > static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count())-1))
-    {
-        RAISE("Page number out of range.");
-        return;
-    }
-    ScCore->primaryMainWindow()->view->GotoPage(value);
+int ScribusPage::number()
+{
+	return ScCore->primaryMainWindow()->doc->currentPageNumber() + 1;
+}
+
+
+
+void ScribusPage::setNumber(int value)
+{
+	value--;
+	if ((value < 0) || (value > static_cast<int>(ScCore->primaryMainWindow()->doc->Pages->count())-1))
+	{
+		RAISE("Page number out of range.");
+		return;
+	}
+	ScCore->primaryMainWindow()->view->GotoPage(value);
 }
 
 
@@ -89,28 +92,33 @@
  * Property
  * List of Item objects of active page
  */
-QList<QVariant> PageAPI::items()
-{
-    QList<QVariant> l;
-    int num = number() - 1;
-    for (int i = 0; i<ScCore->primaryMainWindow()->doc->Items->count(); ++i)
-    {
-        if (num == ScCore->primaryMainWindow()->doc->Items->at(i)->OwnPage)
-        {
-            /*
-             new ItemAPI(this,
-                             ScCore->primaryMainWindow()->doc->Items->at(i)->itemName(),
-                             ScCore->primaryMainWindow()->doc->Items->at(i)->itemType(),
-                             ScCore->primaryMainWindow()->doc->Items->at(i)->ItemNr
-                            );
-            */
-            l.append(qVariantFromValue(
-                         (QObject *)(ScCore->primaryMainWindow()->doc->Items->at(i))
-                     ));
-
-        }
-    }
-    return l;
+QList<QVariant> ScribusPage::items()
+{
+	QList<QVariant> l;
+	int num = number() - 1;
+	for (int i = 0; i<ScCore->primaryMainWindow()->doc->Items->count(); ++i)
+	{
+		if (num == ScCore->primaryMainWindow()->doc->Items->at(i)->OwnPage)
+		{
+			PageItem *item = ScCore->primaryMainWindow()->doc->Items->at(i);
+			/**
+			 * Checking whether it is a textframe. If yes, we are trying to cast
+			 * it onto TextWrapper class, which can effectively perform all
+			 * the text operations
+			 */
+			if (item->asTextFrame())
+			{
+				l.append(qVariantFromValue((QObject *)(new ScribusTextItem(item->asTextFrame()))));
+			}
+			else
+			{
+				l.append(qVariantFromValue(
+				             (QObject *)(new ScribusItem(item))
+				         ));
+			}
+		}
+	}
+	return l;
 }
 
 
@@ -120,27 +128,36 @@
  * Property
  * List of selected Item objects on active page of active document
  */
-QList<QVariant> PageAPI::selection()
-{
-    QList<QVariant> l;
-    int num = number() - 1;
-    Selection *sel = ScCore->primaryMainWindow()->doc->m_Selection;
-    for (int i=0; i < sel->count(); i++)
-    {
-        PageItem *item = sel->itemAt(i);
-        if (num == item->OwnPage)
-            l.append(qVariantFromValue((QObject *)item));
-    }
-    return l;
+QList<QVariant> ScribusPage::selection()
+{
+	QList<QVariant> l;
+	int num = number() - 1;
+	Selection *sel = ScCore->primaryMainWindow()->doc->m_Selection;
+	for (int i=0; i < sel->count(); i++)
+	{
+		PageItem *item = sel->itemAt(i);
+		if (num == item->OwnPage)
+		{
+			if (item->asTextFrame())
+			{
+				l.append(qVariantFromValue((QObject*)(new ScribusTextItem(item->asTextFrame()))));
+			}
+			else
+			{
+				l.append(qVariantFromValue((QObject*)(new ScribusItem(item))));
+			}
+		}
+	}
+	return l;
 }
 
 
 // copied from scripter/cmdutil.cpp
 /// Convert an X co-ordinate part in page units to a document co-ordinate
 /// in system units.
-double pageXtoDocX(double x)
-{
-    return x + ScCore->primaryMainWindow()->doc->currentPage()->xOffset();
+double ScribusPage::pageXtoDocX(double x)
+{
+	return x + ScCore->primaryMainWindow()->doc->currentPage()->xOffset();
 }
 
 
@@ -149,25 +166,23 @@
 /// in system units. The document co-ordinates have their origin somewere
 /// up and left of the first page, where page co-ordinates have their
 /// origin on the top left of the current page.
-double pageYtoDocY(double y)
-{
-    return y + ScCore->primaryMainWindow()->doc->currentPage()->yOffset();
-}
-
-
-
-QObject *PageAPI::newItem(const PageItem::ItemType itemType,
+double ScribusPage::pageYtoDocY(double y)
+{
+	return y + ScCore->primaryMainWindow()->doc->currentPage()->yOffset();
+}
+
+PageItem *ScribusPage::newItem(const PageItem::ItemType itemType,
                           const PageItem::ItemFrameType frameType,
                           const double x, const double y, const double width,
                           const double height, const double w,
                           const QString& fill, const QString& outline)
 {
-    int i = ScCore->primaryMainWindow()->doc->itemAdd(
-                itemType, frameType,
-                pageXtoDocX(x), pageYtoDocY(y),
-                width, height,
-                w, fill, outline, true);
-    return ScCore->primaryMainWindow()->doc->Items->at(i);
+	int i = ScCore->primaryMainWindow()->doc->itemAdd(
+	            itemType, frameType,
+	            pageXtoDocX(x), pageYtoDocY(y),
+	            width, height,
+	            w, fill, outline, true);
+	return ScCore->primaryMainWindow()->doc->Items->at(i);
 }
 
 
@@ -180,13 +195,14 @@
  * height is a double
  * returns Item object
  */
-QObject *PageAPI::newRectangle(double x, double y, double width, double height)
-{
-    return newItem(
-               PageItem::Polygon, PageItem::Rectangle, x, y, width, height,
-               ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineWidth,
-               ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeFillColor,
-               ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineColor);
+QObject *ScribusPage::newRectangle(double x, double y, double width, double height)
+{
+	PageItem *item = newItem(
+	           PageItem::Polygon, PageItem::Rectangle, x, y, width, height,
+	           ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineWidth,
+	           ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeFillColor,
+	           ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineColor);
+	return new ScribusItem(item);
 }
 
 
@@ -199,13 +215,14 @@
  * height is a double
  * returns Item object
  */
-QObject *PageAPI::newEllipse(double x, double y, double width, double height)
-{
-    return newItem(
-               PageItem::Polygon, PageItem::Ellipse, x, y, width, height,
-               ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineWidth,
-               ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeFillColor,
-               ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineColor);
+QObject *ScribusPage::newEllipse(double x, double y, double width, double height)
+{
+	PageItem *item = newItem(
+	           PageItem::Polygon, PageItem::Ellipse, x, y, width, height,
+	           ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineWidth,
+	           ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeFillColor,
+	           ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineColor);
+	return new ScribusItem(item);
 }
 
 
@@ -218,15 +235,16 @@
  * height is a double
  * returns Item object
  */
-QObject *PageAPI::newImage(double x, double y, double width, double height)
-{
-    return newItem(
-               PageItem::ImageFrame, PageItem::Unspecified, x, y, width, height,
-               1,
-               // @xxx: ale
-               // ScCore->primaryMainWindow()->doc->toolSettings.dBrushPict,
-               ScCore->primaryMainWindow()->doc->itemToolPrefs().imageFillColor,
-               CommonStrings::None);
+QObject *ScribusPage::newImage(double x, double y, double width, double height)
+{
+	PageItem *item = newItem(
+	           PageItem::ImageFrame, PageItem::Unspecified, x, y, width, height,
+	           1,
+	           // @xxx: ale
+	           // ScCore->primaryMainWindow()->doc->toolSettings.dBrushPict,
+	           ScCore->primaryMainWindow()->doc->itemToolPrefs().imageFillColor,
+	           CommonStrings::None);
+	return new ScribusImageItem(item->asImageFrame());
 }
 
 
@@ -239,13 +257,14 @@
  * height is a double
  * returns Item object
  */
-QObject *PageAPI::newText(double x, double y, double width, double height)
-{
-    return newItem(
-               PageItem::TextFrame, PageItem::Unspecified, x, y, width, height,
-               ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineWidth,
-               CommonStrings::None,
-               ScCore->primaryMainWindow()->doc->itemToolPrefs().textFont);
+QObject *ScribusPage::newText(double x, double y, double width, double height)
+{
+	PageItem *item = newItem(
+	           PageItem::TextFrame, PageItem::Unspecified, x, y, width, height,
+	           ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineWidth,
+	           CommonStrings::None,
+	           ScCore->primaryMainWindow()->doc->itemToolPrefs().textFont);
+	return new ScribusTextItem(item->asTextFrame());
 }
 
 
@@ -258,45 +277,46 @@
  * height is a double
  * returns Item object
  */
-QObject *PageAPI::newLine(double x, double y, double width, double height)
-{
-    PageItem *item = (PageItem*)newItem(
-                         PageItem::Line, PageItem::Unspecified, x, y, width, height,
-                         ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineWidth,
-                         ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeFillColor,
-                         ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineColor);
-    item->setRotation(xy2Deg(width-x, height-y));
-    item->setWidthHeight(sqrt(pow(x-width, 2.0) + pow(y-height, 2.0)), 1.0);
-    item->Sizing = false;
-    item->updateClip();
-    return item;
+QObject *ScribusPage::newLine(double x, double y, double width, double height)
+{
+	PageItem *item = (PageItem*)newItem(
+	                     PageItem::Line, PageItem::Unspecified, x, y, width, height,
+	                     ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineWidth,
+	                     ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeFillColor,
+	                     ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineColor);
+	item->setRotation(xy2Deg(width-x, height-y));
+	item->setWidthHeight(sqrt(pow(x-width, 2.0) + pow(y-height, 2.0)), 1.0);
+	item->Sizing = false;
+	item->updateClip();
+	return new ScribusItem(item);
 }
 
 // XXX: newPolyLine, bezierline
 
 
-void PageAPI::placeImage(const int formatid, const QString & filename, const double x, const double y)
-{
-    const FileFormat * fmt = LoadSavePlugin::getFormatById(formatid);
-    if ( fmt )
-    {
-        fmt->loadFile(filename,
-                      LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive|LoadSavePlugin::lfScripted);
-        if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1)
-        {
-            double x2, y2, w, h;
-            ScCore->primaryMainWindow()->doc->m_Selection->getGroupRect(
-                &x2, &y2, &w, &h);
-            ScCore->primaryMainWindow()->view->startGroupTransaction();
-            ScCore->primaryMainWindow()->doc->moveGroup(
-                pageXtoDocX(x) - x2, pageYtoDocY(y) - y2);
-            ScCore->primaryMainWindow()->view->endGroupTransaction();
-            ScCore->primaryMainWindow()->propertiesPalette->updateColorList();
-            ScCore->primaryMainWindow()->propertiesPalette->textPal->paraStyleCombo->updateFormatList();
-            ScCore->primaryMainWindow()->propertiesPalette->textPal->charStyleCombo->updateFormatList();
-            ScCore->primaryMainWindow()->propertiesPalette->linePal->updateLineStyles();
-        }
-    } else RAISE("Format plug-in not loaded.");
+void ScribusPage::placeImage(const int formatid, const QString & filename, const double x, const double y)
+{
+	const FileFormat * fmt = LoadSavePlugin::getFormatById(formatid);
+	if (fmt)
+	{
+		fmt->loadFile(filename,
+		              LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive|LoadSavePlugin::lfScripted);
+		if (ScCore->primaryMainWindow()->doc->m_Selection->count() > 1)
+		{
+			double x2, y2, w, h;
+			ScCore->primaryMainWindow()->doc->m_Selection->getGroupRect(
+			    &x2, &y2, &w, &h);
+			ScCore->primaryMainWindow()->view->startGroupTransaction();
+			ScCore->primaryMainWindow()->doc->moveGroup(
+			    pageXtoDocX(x) - x2, pageYtoDocY(y) - y2);
+			ScCore->primaryMainWindow()->view->endGroupTransaction();
+			ScCore->primaryMainWindow()->propertiesPalette->updateColorList();
+			ScCore->primaryMainWindow()->propertiesPalette->textPal->paraStyleCombo->updateFormatList();
+			ScCore->primaryMainWindow()->propertiesPalette->textPal->charStyleCombo->updateFormatList();
+			ScCore->primaryMainWindow()->propertiesPalette->linePal->updateLineStyles();
+		}
+	}
+	else RAISE("Format plug-in not loaded.");
 }
 
 
@@ -310,9 +330,9 @@
  * y is double
  * import vector graphics at given position on active page
  */
-void PageAPI::placeSVG(const QString & filename, const double x, const double y)
-{
-    placeImage(FORMATID_SVGIMPORT, filename, x, y);
+void ScribusPage::placeSVG(const QString & filename, const double x, const double y)
+{
+	placeImage(FORMATID_SVGIMPORT, filename, x, y);
 }
 
 
@@ -324,9 +344,9 @@
  * y is double
  * import vector graphics at given position on active page
  */
-void PageAPI::placeODG(const QString & filename, const double x, const double y)
-{
-    placeImage(FORMATID_ODGIMPORT, filename, x, y);
+void ScribusPage::placeODG(const QString & filename, const double x, const double y)
+{
+	placeImage(FORMATID_ODGIMPORT, filename, x, y);
 }
 
 
@@ -338,9 +358,9 @@
  * y is double
  * import vector graphics at given position on active page
  */
-void PageAPI::placeEPS(const QString & filename, const double x, const double y)
-{
-    placeImage(FORMATID_PSIMPORT, filename, x, y);
+void ScribusPage::placeEPS(const QString & filename, const double x, const double y)
+{
+	placeImage(FORMATID_PSIMPORT, filename, x, y);
 }
 
 
@@ -352,7 +372,29 @@
  * y is double
  * import vector graphics at given position on active page
  */
-void PageAPI::placeSXD(const QString & filename, const double x, const double y)
-{
-    placeImage(FORMATID_SXDIMPORT, filename, x, y);
-}
+void ScribusPage::placeSXD(const QString & filename, const double x, const double y)
+{
+	placeImage(FORMATID_SXDIMPORT, filename, x, y);
+}
+
+
+/**
+ *  Scripter.activeDocument.activePage.savePageAsEPS(filename)
+ * filename is QString
+ */
+void ScribusPage::savePageAsEPS(const QString &filename)
+{
+	QString epsError;
+	bool ret = ScCore->primaryMainWindow()->DoSaveAsEps(filename, epsError);
+	if (!ret)
+		RAISE("Failed to save as EPS");
+}
+
+/**
+ * Scripter.activeDocument.activePage.type
+ * Returns 0 if LeftPage, 1 if Middle Page, 2 for Right Page
+ */
+int ScribusPage::type()
+{
+	return ScCore->primaryMainWindow()->doc->locationOfPage(number());
+}

Modified: trunk/Scribus/scribus/plugins/scripter/api_page.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/api_page.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/api_page.h (original)
+++ trunk/Scribus/scribus/plugins/scripter/api_page.h Tue Jun 12 22:00:07 2012
@@ -14,45 +14,48 @@
 #include "scripterimpl.h"
 
 
-class PageAPI : public QObject
+class ScribusPage : public QObject
 {
-    Q_OBJECT
-    Q_PROPERTY(int number READ number WRITE setNumber);
-    Q_PROPERTY(int position READ position);
-    Q_PROPERTY(QList<QVariant> items READ items);
-    Q_PROPERTY(QList<QVariant> selection READ selection);
+	Q_OBJECT
+	Q_PROPERTY(int number READ number WRITE setNumber);
+	Q_PROPERTY(int position READ position);
+	Q_PROPERTY(QList<QVariant> items READ items);
+	Q_PROPERTY(QList<QVariant> selection READ selection);
+	Q_PROPERTY(int type READ type);
 public:
-    PageAPI(QObject *parent);
-    virtual ~PageAPI();
+	ScribusPage(QObject *parent);
+	virtual ~ScribusPage();
 
 
 public slots:
-    void remove();
-    QObject *newRectangle(double x, double y, double width, double height);
-    QObject *newEllipse(double x, double y, double width, double height);
-    QObject *newImage(double x, double y, double width, double height);
-    QObject *newText(double x, double y, double width, double height);
-    QObject *newLine(double x, double y, double width, double height);
-    void placeSVG(const QString & filename, const double x, const double y);
-    void placeODG(const QString & filename, const double x, const double y);
-    void placeEPS(const QString & filename, const double x, const double y);
-    void placeSXD(const QString & filename, const double x, const double y);
+	void remove();
+	QObject *newRectangle(double x, double y, double width, double height);
+	QObject *newEllipse(double x, double y, double width, double height);
+	QObject *newImage(double x, double y, double width, double height);
+	QObject *newText(double x, double y, double width, double height);
+	QObject *newLine(double x, double y, double width, double height);
+	void placeSVG(const QString & filename, const double x, const double y);
+	void placeODG(const QString & filename, const double x, const double y);
+	void placeEPS(const QString & filename, const double x, const double y);
+	void placeSXD(const QString & filename, const double x, const double y);
+	void savePageAsEPS(const QString & filename);
 
 private:
-    int position();
-    int number();
-    void setNumber(int value);
-    QList<QVariant> items();
-    QList<QVariant> selection();
-    QObject *newItem(const PageItem::ItemType itemType,
-                     const PageItem::ItemFrameType frameType,
-                     const double x, const double y, const double width,
-                     const double height, const double w,
-                     const QString& fill, const QString& outline);
-    void placeImage(const int formatid, const QString & filename, const double x, const double y);
+	int position();
+	int number();
+	void setNumber(int value);
+	QList<QVariant> items();
+	QList<QVariant> selection();
+	PageItem *newItem(const PageItem::ItemType itemType,
+	                 const PageItem::ItemFrameType frameType,
+	                 const double x, const double y, const double width,
+	                 const double height, const double w,
+	                 const QString& fill, const QString& outline);
+	void placeImage(const int formatid, const QString & filename, const double x, const double y);
+
+	bool isMasterPage;
+	int type();
+	double pageYtoDocY(double y);
+	double pageXtoDocX(double x); 
 };
-
-double pageYtoDocY(double y);
-double pageXtoDocX(double x);
-
 #endif /*API_PAGE_H_*/

Modified: trunk/Scribus/scribus/plugins/scripter/api_window.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/api_window.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/api_window.cpp (original)
+++ trunk/Scribus/scribus/plugins/scripter/api_window.cpp Tue Jun 12 22:00:07 2012
@@ -7,16 +7,16 @@
 #include "api_window.h"
 #include "canvas.h"
 
-WindowAPI::WindowAPI() : QObject(COLLECTOR)
+ScribusWindow::ScribusWindow() : QObject(COLLECTOR)
 {
     qDebug() << "WindowAPI loaded";
     // XXX: support other windows later
-    setObjectName("activeWindow");
+    setObjectName("window");
 }
 
 
 
-WindowAPI::~WindowAPI()
+ScribusWindow::~ScribusWindow()
 {
     qDebug() << "WindowAPI deleted";
 }
@@ -29,7 +29,7 @@
  *
  * -100.0 is special value to see the whole page.
  */
-void WindowAPI::setZoom(double factor)
+void ScribusWindow::setZoom(double factor)
 {
     if (factor > 0.0 || factor == -100.0)
         ScCore->primaryMainWindow()->slotZoom(factor);
@@ -39,7 +39,7 @@
 
 
 
-double WindowAPI::zoom()
+double ScribusWindow::zoom()
 {
     // XXX: better use the following?
     // ScCore->primaryMainWindow()->view->m_canvas->scale()/Prefs->DisScale*100
@@ -57,7 +57,7 @@
  *
  * scrolls the visible view to (x, y)
  */
-void WindowAPI::scroll(int x, int y)
+void ScribusWindow::scroll(int x, int y)
 {
     ScCore->primaryMainWindow()->view->scrollBy(x, y);
 }
@@ -69,7 +69,7 @@
  *
  * forces a complete redraw of the view
  */
-void WindowAPI::update()
+void ScribusWindow::update()
 {
     ScCore->primaryMainWindow()->view->DrawNew();
 }
@@ -86,14 +86,14 @@
  * After that you can redraw the complete view with
  * ->Scripter.activeWindow.update()
  */
-void WindowAPI::setRedraw(bool flag)
+void ScribusWindow::setRedraw(bool flag)
 {
     ScCore->primaryMainWindow()->doc->DoDrawing = flag;
 }
 
 
 
-bool WindowAPI::redraw()
+bool ScribusWindow::redraw()
 {
     return ScCore->primaryMainWindow()->doc->DoDrawing;
 }

Modified: trunk/Scribus/scribus/plugins/scripter/api_window.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/api_window.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/api_window.h (original)
+++ trunk/Scribus/scribus/plugins/scripter/api_window.h Tue Jun 12 22:00:07 2012
@@ -13,15 +13,15 @@
 
 #include "scripterimpl.h"
 
-class WindowAPI : public QObject
+class ScribusWindow : public QObject
 {
     Q_OBJECT
     Q_PROPERTY(double zoom READ zoom WRITE setZoom);
     Q_PROPERTY(bool redraw READ redraw WRITE setRedraw);
 
 public:
-    WindowAPI();
-    virtual ~WindowAPI();
+    ScribusWindow();
+    virtual ~ScribusWindow();
 
 public slots:
     // XXX: relative or absolute scrolling?

Modified: trunk/Scribus/scribus/plugins/scripter/python/autoload/fullscreen.spy
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/python/autoload/fullscreen.spy
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/python/autoload/fullscreen.spy (original)
+++ trunk/Scribus/scribus/plugins/scripter/python/autoload/fullscreen.spy Tue Jun 12 22:00:07 2012
@@ -1,6 +1,7 @@
 ## name = fullscreen
 ## title = Toggle fullscreen
 ## shortcut = Ctrl+r,f
+## menu = Scripter
 
 mainWin = Scripter.dialogs.mainWindow
 if mainWin.fullScreen:

Modified: trunk/Scribus/scribus/plugins/scripter/python/autoload/help.spy
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/python/autoload/help.spy
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/python/autoload/help.spy (original)
+++ trunk/Scribus/scribus/plugins/scripter/python/autoload/help.spy Tue Jun 12 22:00:07 2012
@@ -4,7 +4,7 @@
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 
-URL = "http://scripterng.blogspot.com"
+URL = "http://jainbasil.net/scribus/scripter2"
 
 if not QDesktopServices.openUrl(QUrl(URL)):
     import webbrowser

Modified: trunk/Scribus/scribus/plugins/scripter/python/autoload/runfile.spy
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/python/autoload/runfile.spy
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/python/autoload/runfile.spy (original)
+++ trunk/Scribus/scribus/plugins/scripter/python/autoload/runfile.spy Tue Jun 12 22:00:07 2012
@@ -2,6 +2,7 @@
 ## shortcut = Esc,t
 ## shortcut = Ctrl+r,t
 ## subroutine = run
+## menu = Scripter
 import os
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *

Modified: trunk/Scribus/scribus/plugins/scripter/python/autoload/sceditor.spy
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/python/autoload/sceditor.spy
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/python/autoload/sceditor.spy (original)
+++ trunk/Scribus/scribus/plugins/scripter/python/autoload/sceditor.spy Tue Jun 12 22:00:07 2012
@@ -1,5 +1,6 @@
 ## title = Script &Editor and Console
 ## shortcut = Ctrl+r,e
+## menu = Scripter
 
 import sceditor
 sceditor.launch(Scripter.dialogs.mainWindow.qt)

Modified: trunk/Scribus/scribus/plugins/scripter/python/init_scripter.py
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/python/init_scripter.py
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/python/init_scripter.py (original)
+++ trunk/Scribus/scribus/plugins/scripter/python/init_scripter.py Tue Jun 12 22:00:07 2012
@@ -59,6 +59,8 @@
         self.setObjectName("Menu")
         self.popup = QMenu(i18n("Scripter"))
         MenuHooks().insertMenuAfter("E&xtras", self.popup)
+        self.scriptsMenu = QMenu(i18n("Scripts"))
+        MenuHooks().appendItem(self.popup, self.scriptsMenu)
         self._load_entries()
 
 

Modified: trunk/Scribus/scribus/plugins/scripter/python/sceditor/console.py
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/python/sceditor/console.py
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/python/sceditor/console.py (original)
+++ trunk/Scribus/scribus/plugins/scripter/python/sceditor/console.py Tue Jun 12 22:00:07 2012
@@ -6,7 +6,7 @@
 from PyQt4.QtGui import QTextCursor, qApp, QApplication, QPlainTextEdit
 
 
-from sceditor.highlighter import PythonHighlighter,  QtScriptHighlighter
+from highlighter import PythonHighlighter,  QtScriptHighlighter
 
 
 
@@ -296,6 +296,9 @@
         return self.inter.push(line)
 
 
+    def clear(self):
+	doc = self.document()
+	doc.setPlainText(self.ps1)
 
 
 

Modified: trunk/Scribus/scribus/plugins/scripter/python/sceditor/mainwindow.py
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/python/sceditor/mainwindow.py
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/python/sceditor/mainwindow.py (original)
+++ trunk/Scribus/scribus/plugins/scripter/python/sceditor/mainwindow.py Tue Jun 12 22:00:07 2012
@@ -1,13 +1,13 @@
 from PyQt4.QtCore import pyqtSignature, Qt
-from PyQt4.QtGui import QMainWindow, QSplitter, QTabWidget, QApplication
-
-from sceditor.widget import PythonEditorWidget,  QtScriptEditorWidget
-from sceditor.console import PythonConsole, QtScriptConsole
-from sceditor.mainwindow_ui import Ui_ScriptEditor
+from PyQt4.QtGui import QMainWindow, QSplitter, QTabWidget, QApplication, QFileDialog, QMessageBox, QCloseEvent
+
+from widget import PythonEditorWidget,  QtScriptEditorWidget, SaveDialog
+from console import PythonConsole, QtScriptConsole
+from mainwindow_ui import Ui_ScriptEditor
 
 
 import traceback
-
+import os
 
 template_py = """\
 # -*- coding: utf-8 -*-
@@ -34,11 +34,47 @@
         self.editors = []
         self.on_actionNewPython_triggered()
 
+    @pyqtSignature("")
+    def closeEvent(self, event):
+	while(self.editors.__len__()):
+	    edit = self.edit_tab.currentWidget()
+            if edit:
+	        if(edit.isModified()):
+		    saveBox = SaveDialog("You have unsaved script. Save it now?")
+		    prompt = saveBox.exec_()
+		    if(prompt == QMessageBox.Save):
+			event.ignore()
+		        self.save(True)
+		    elif(prompt == QMessageBox.Cancel):
+		        event.ignore()
+			return
+		    elif(prompt == QMessageBox.Discard):
+		        event.accept()
+                i = self.edit_tab.indexOf(edit)
+                self.edit_tab.removeTab(i)
+                self.editors.remove(edit)
+	event.accept()
+
+	
 
     @pyqtSignature("")
     def on_actionExit_triggered(self):
-        self.close()
-
+	while(self.editors.__len__()):
+	    edit = self.edit_tab.currentWidget()
+            if edit:
+	        if(edit.isModified()):
+		    saveBox = SaveDialog("You have unsaved script. Save it now?")
+		    prompt = saveBox.exec_()
+		    if(prompt == QMessageBox.Save):
+		        self.save(True)
+		    elif(prompt == QMessageBox.Cancel):
+		        return
+		    elif(prompt == QMessageBox.Discard):
+		        pass
+		i = self.edit_tab.indexOf(edit)
+                self.edit_tab.removeTab(i)
+                self.editors.remove(edit)
+	self.close()
 
     @pyqtSignature("")
     def on_actionNewPython_triggered(self):
@@ -67,10 +103,71 @@
     def on_actionClose_triggered(self):
         edit = self.edit_tab.currentWidget()
         if edit:
+	    if(edit.isModified()):
+		saveBox = SaveDialog("Do you want to save this Script?")
+		prompt = saveBox.exec_()
+		if(prompt == QMessageBox.Save):
+		    self.save(True)
+		elif(prompt == QMessageBox.Cancel):
+		    return
+		elif(prompt == QMessageBox.Discard):
+		    pass
             i = self.edit_tab.indexOf(edit)
             self.edit_tab.removeTab(i)
             self.editors.remove(edit)
+
         
+    @pyqtSignature("")
+    def on_actionClear_triggered(self):
+        #edit = self.edit_tab.currentWidget()
+	#edit.setPlainText(template_py)
+	self.py_console.clear()
+
+
+    @pyqtSignature("")
+    def on_actionSave_As_triggered(self):
+	self.save()
+
+
+    @pyqtSignature("")
+    def on_actionSave_triggered(self):
+	self.save(True)
+
+
+    #Path of the script file in each tab will be stored in tabToolTip
+    def save(self, Update = False):
+        edit = self.edit_tab.currentWidget()
+	contents = str(edit.toPlainText())
+	if((Update == False) or (self.edit_tab.tabText(self.edit_tab.currentIndex()) == "Python") ):
+	    #Save in its first invocation and Save As will enter  
+	    filename = QFileDialog.getSaveFileName(self, "Save File", "", "*.spy")
+	    fil = open(filename , 'w')
+	    if(filename and self.edit_tab.tabText(self.edit_tab.currentIndex()) == "Python"):
+		#Script hasn't been saved before and user specifies a valid filename
+	        self.edit_tab.setTabToolTip(self.edit_tab.currentIndex(), filename+'.spy')
+	        self.edit_tab.setTabText(self.edit_tab.currentIndex(), os.path.basename(str(filename+'.spy')))
+	else:
+	    #filename = self.edit_tab.tabText(self.edit_tab.currentIndex())
+	    filename = self.edit_tab.tabToolTip(self.edit_tab.currentIndex())
+	    fil = open( filename , 'w')
+	fil.write(contents)	
+	fil.close()
+	edit.setModified(False)
+
+
+    @pyqtSignature("")
+    def on_actionOpen_triggered(self):
+	filename = QFileDialog.getOpenFileName(self,"Open File","","*.spy")
+	try:
+	    fil = open(filename , 'r')
+	except IOError:
+	    return
+	code = fil.read()
+	edit = self.edit_tab.currentWidget()
+	self.edit_tab.setTabText(self.edit_tab.currentIndex(), os.path.basename(str(filename)))
+	self.edit_tab.setTabToolTip(self.edit_tab.currentIndex(), filename)
+	edit.setPlainText(code)
+	fil.close()
 
 
     @pyqtSignature("")

Modified: trunk/Scribus/scribus/plugins/scripter/python/sceditor/mainwindow.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/python/sceditor/mainwindow.ui
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/python/sceditor/mainwindow.ui (original)
+++ trunk/Scribus/scribus/plugins/scripter/python/sceditor/mainwindow.ui Tue Jun 12 22:00:07 2012
@@ -1,7 +1,8 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>ScriptEditor</class>
- <widget class="QMainWindow" name="ScriptEditor" >
-  <property name="geometry" >
+ <widget class="QMainWindow" name="ScriptEditor">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
@@ -9,104 +10,131 @@
     <height>449</height>
    </rect>
   </property>
-  <property name="windowTitle" >
+  <property name="windowTitle">
    <string>Script Editor</string>
   </property>
-  <widget class="QWidget" name="centralwidget" >
-   <property name="geometry" >
-    <rect>
-     <x>0</x>
-     <y>28</y>
-     <width>624</width>
-     <height>397</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QMenuBar" name="menubar" >
-   <property name="geometry" >
+  <widget class="QWidget" name="centralwidget"/>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
     <rect>
      <x>0</x>
      <y>0</y>
      <width>624</width>
-     <height>28</height>
+     <height>25</height>
     </rect>
    </property>
-   <widget class="QMenu" name="menuFile" >
-    <property name="title" >
+   <widget class="QMenu" name="menuFile">
+    <property name="title">
      <string>&File</string>
     </property>
-    <widget class="QMenu" name="menu_New" >
-     <property name="title" >
+    <widget class="QMenu" name="menu_New">
+     <property name="title">
       <string>&New</string>
      </property>
-     <addaction name="actionNewPython" />
-     <addaction name="actionNewQtScript" />
+     <addaction name="actionNewPython"/>
+     <addaction name="actionNewQtScript"/>
     </widget>
-    <addaction name="menu_New" />
-    <addaction name="actionClose" />
-    <addaction name="separator" />
-    <addaction name="actionExit" />
+    <addaction name="menu_New"/>
+    <addaction name="actionOpen"/>
+    <addaction name="actionSave"/>
+    <addaction name="actionSave_As"/>
+    <addaction name="actionClose"/>
+    <addaction name="separator"/>
+    <addaction name="actionExit"/>
    </widget>
-   <widget class="QMenu" name="menuRun" >
-    <property name="title" >
+   <widget class="QMenu" name="menuRun">
+    <property name="title">
      <string>&Run</string>
     </property>
-    <addaction name="actionRun" />
-    <addaction name="actionRunConsole" />
+    <addaction name="actionRun"/>
+    <addaction name="actionRunConsole"/>
+    <addaction name="actionClear"/>
    </widget>
-   <addaction name="menuFile" />
-   <addaction name="menuRun" />
+   <addaction name="menuFile"/>
+   <addaction name="menuRun"/>
   </widget>
-  <widget class="QStatusBar" name="statusbar" >
-   <property name="geometry" >
-    <rect>
-     <x>0</x>
-     <y>425</y>
-     <width>624</width>
-     <height>24</height>
-    </rect>
-   </property>
-  </widget>
-  <action name="actionClose" >
-   <property name="text" >
+  <widget class="QStatusBar" name="statusbar"/>
+  <action name="actionClose">
+   <property name="text">
     <string>&Close</string>
    </property>
-   <property name="shortcut" >
+   <property name="shortcut">
     <string>Ctrl+W</string>
    </property>
   </action>
-  <action name="actionExit" >
-   <property name="text" >
+  <action name="actionExit">
+   <property name="text">
     <string>&Exit</string>
    </property>
   </action>
-  <action name="actionRun" >
-   <property name="text" >
+  <action name="actionRun">
+   <property name="text">
     <string>&Run</string>
    </property>
-   <property name="shortcut" >
+   <property name="shortcut">
     <string>Ctrl+R</string>
    </property>
   </action>
-  <action name="actionRunConsole" >
-   <property name="text" >
+  <action name="actionRunConsole">
+   <property name="text">
     <string>Run script in &console</string>
    </property>
-   <property name="shortcut" >
+   <property name="shortcut">
     <string>Ctrl+C</string>
    </property>
   </action>
-  <action name="actionNewPython" >
-   <property name="text" >
+  <action name="actionNewPython">
+   <property name="text">
     <string>Python</string>
    </property>
-   <property name="shortcut" >
+   <property name="shortcut">
     <string>Ctrl+N</string>
    </property>
   </action>
-  <action name="actionNewQtScript" >
-   <property name="text" >
+  <action name="actionNewQtScript">
+   <property name="text">
     <string>QtScript</string>
+   </property>
+  </action>
+  <action name="actionClear">
+   <property name="text">
+    <string>Clear</string>
+   </property>
+   <property name="toolTip">
+    <string>Clear The Console</string>
+   </property>
+  </action>
+  <action name="actionSave_As">
+   <property name="text">
+    <string>Save &As</string>
+   </property>
+   <property name="toolTip">
+    <string>Save the  script</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+A</string>
+   </property>
+  </action>
+  <action name="actionOpen">
+   <property name="text">
+    <string>&Open</string>
+   </property>
+   <property name="toolTip">
+    <string>Open a script</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+O</string>
+   </property>
+  </action>
+  <action name="actionSave">
+   <property name="text">
+    <string>&Save</string>
+   </property>
+   <property name="toolTip">
+    <string>Save the current script</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+S</string>
    </property>
   </action>
  </widget>

Modified: trunk/Scribus/scribus/plugins/scripter/python/sceditor/mainwindow_ui.py
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/python/sceditor/mainwindow_ui.py
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/python/sceditor/mainwindow_ui.py (original)
+++ trunk/Scribus/scribus/plugins/scripter/python/sceditor/mainwindow_ui.py Tue Jun 12 22:00:07 2012
@@ -2,55 +2,70 @@
 
 # Form implementation generated from reading ui file 'mainwindow.ui'
 #
-# Created: Sat Jun 14 05:22:25 2008
-#      by: PyQt4 UI code generator 4.4.2
+# Created: Fri Aug 19 22:47:33 2011
+#      by: PyQt4 UI code generator 4.8.3
 #
 # WARNING! All changes made in this file will be lost!
 
 from PyQt4 import QtCore, QtGui
 
+try:
+    _fromUtf8 = QtCore.QString.fromUtf8
+except AttributeError:
+    _fromUtf8 = lambda s: s
+
 class Ui_ScriptEditor(object):
     def setupUi(self, ScriptEditor):
-        ScriptEditor.setObjectName("ScriptEditor")
-        ScriptEditor.resize(624,449)
+        ScriptEditor.setObjectName(_fromUtf8("ScriptEditor"))
+        ScriptEditor.resize(624, 449)
         self.centralwidget = QtGui.QWidget(ScriptEditor)
-        self.centralwidget.setGeometry(QtCore.QRect(0,28,624,397))
-        self.centralwidget.setObjectName("centralwidget")
+        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
         ScriptEditor.setCentralWidget(self.centralwidget)
         self.menubar = QtGui.QMenuBar(ScriptEditor)
-        self.menubar.setGeometry(QtCore.QRect(0,0,624,28))
-        self.menubar.setObjectName("menubar")
+        self.menubar.setGeometry(QtCore.QRect(0, 0, 624, 25))
+        self.menubar.setObjectName(_fromUtf8("menubar"))
         self.menuFile = QtGui.QMenu(self.menubar)
-        self.menuFile.setObjectName("menuFile")
+        self.menuFile.setObjectName(_fromUtf8("menuFile"))
         self.menu_New = QtGui.QMenu(self.menuFile)
-        self.menu_New.setObjectName("menu_New")
+        self.menu_New.setObjectName(_fromUtf8("menu_New"))
         self.menuRun = QtGui.QMenu(self.menubar)
-        self.menuRun.setObjectName("menuRun")
+        self.menuRun.setObjectName(_fromUtf8("menuRun"))
         ScriptEditor.setMenuBar(self.menubar)
         self.statusbar = QtGui.QStatusBar(ScriptEditor)
-        self.statusbar.setGeometry(QtCore.QRect(0,425,624,24))
-        self.statusbar.setObjectName("statusbar")
+        self.statusbar.setObjectName(_fromUtf8("statusbar"))
         ScriptEditor.setStatusBar(self.statusbar)
         self.actionClose = QtGui.QAction(ScriptEditor)
-        self.actionClose.setObjectName("actionClose")
+        self.actionClose.setObjectName(_fromUtf8("actionClose"))
         self.actionExit = QtGui.QAction(ScriptEditor)
-        self.actionExit.setObjectName("actionExit")
+        self.actionExit.setObjectName(_fromUtf8("actionExit"))
         self.actionRun = QtGui.QAction(ScriptEditor)
-        self.actionRun.setObjectName("actionRun")
+        self.actionRun.setObjectName(_fromUtf8("actionRun"))
         self.actionRunConsole = QtGui.QAction(ScriptEditor)
-        self.actionRunConsole.setObjectName("actionRunConsole")
+        self.actionRunConsole.setObjectName(_fromUtf8("actionRunConsole"))
         self.actionNewPython = QtGui.QAction(ScriptEditor)
-        self.actionNewPython.setObjectName("actionNewPython")
+        self.actionNewPython.setObjectName(_fromUtf8("actionNewPython"))
         self.actionNewQtScript = QtGui.QAction(ScriptEditor)
-        self.actionNewQtScript.setObjectName("actionNewQtScript")
+        self.actionNewQtScript.setObjectName(_fromUtf8("actionNewQtScript"))
+        self.actionClear = QtGui.QAction(ScriptEditor)
+        self.actionClear.setObjectName(_fromUtf8("actionClear"))
+        self.actionSave_As = QtGui.QAction(ScriptEditor)
+        self.actionSave_As.setObjectName(_fromUtf8("actionSave_As"))
+        self.actionOpen = QtGui.QAction(ScriptEditor)
+        self.actionOpen.setObjectName(_fromUtf8("actionOpen"))
+        self.actionSave = QtGui.QAction(ScriptEditor)
+        self.actionSave.setObjectName(_fromUtf8("actionSave"))
         self.menu_New.addAction(self.actionNewPython)
         self.menu_New.addAction(self.actionNewQtScript)
         self.menuFile.addAction(self.menu_New.menuAction())
+        self.menuFile.addAction(self.actionOpen)
+        self.menuFile.addAction(self.actionSave)
+        self.menuFile.addAction(self.actionSave_As)
         self.menuFile.addAction(self.actionClose)
         self.menuFile.addSeparator()
         self.menuFile.addAction(self.actionExit)
         self.menuRun.addAction(self.actionRun)
         self.menuRun.addAction(self.actionRunConsole)
+        self.menuRun.addAction(self.actionClear)
         self.menubar.addAction(self.menuFile.menuAction())
         self.menubar.addAction(self.menuRun.menuAction())
 
@@ -72,14 +87,15 @@
         self.actionNewPython.setText(QtGui.QApplication.translate("ScriptEditor", "Python", None, QtGui.QApplication.UnicodeUTF8))
         self.actionNewPython.setShortcut(QtGui.QApplication.translate("ScriptEditor", "Ctrl+N", None, QtGui.QApplication.UnicodeUTF8))
         self.actionNewQtScript.setText(QtGui.QApplication.translate("ScriptEditor", "QtScript", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionClear.setText(QtGui.QApplication.translate("ScriptEditor", "Clear", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionClear.setToolTip(QtGui.QApplication.translate("ScriptEditor", "Clear The Console", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSave_As.setText(QtGui.QApplication.translate("ScriptEditor", "Save &As", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSave_As.setToolTip(QtGui.QApplication.translate("ScriptEditor", "Save the  script", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSave_As.setShortcut(QtGui.QApplication.translate("ScriptEditor", "Ctrl+A", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionOpen.setText(QtGui.QApplication.translate("ScriptEditor", "&Open", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionOpen.setToolTip(QtGui.QApplication.translate("ScriptEditor", "Open a script", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionOpen.setShortcut(QtGui.QApplication.translate("ScriptEditor", "Ctrl+O", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSave.setText(QtGui.QApplication.translate("ScriptEditor", "&Save", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSave.setToolTip(QtGui.QApplication.translate("ScriptEditor", "Save the current script", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSave.setShortcut(QtGui.QApplication.translate("ScriptEditor", "Ctrl+S", None, QtGui.QApplication.UnicodeUTF8))
 
-
-if __name__ == "__main__":
-    import sys
-    app = QtGui.QApplication(sys.argv)
-    ScriptEditor = QtGui.QMainWindow()
-    ui = Ui_ScriptEditor()
-    ui.setupUi(ScriptEditor)
-    ScriptEditor.show()
-    sys.exit(app.exec_())
-

Modified: trunk/Scribus/scribus/plugins/scripter/python/sceditor/widget.py
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/python/sceditor/widget.py
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/python/sceditor/widget.py (original)
+++ trunk/Scribus/scribus/plugins/scripter/python/sceditor/widget.py Tue Jun 12 22:00:07 2012
@@ -15,12 +15,12 @@
 from PyQt4.QtCore import QCoreApplication, QLine, Qt, SIGNAL
 from PyQt4.QtGui import (QTextCursor, QBrush, QFont, QPainter, QVBoxLayout, 
                          QApplication, QKeyEvent, QTextBlockUserData, QPen, QPlainTextEdit, 
-                         QHBoxLayout, QPalette, QColor, QFrame, QWidget)
-
-from sceditor.indenter import PythonCodeIndenter
-from sceditor.assist import AutoComplete, CallTip
-
-from sceditor.highlighter import PythonHighlighter,  QtScriptHighlighter
+                         QHBoxLayout, QPalette, QColor, QFrame, QWidget, QMessageBox)
+
+from indenter import PythonCodeIndenter
+from assist import AutoComplete, CallTip
+
+from highlighter import PythonHighlighter,  QtScriptHighlighter
 
 
 
@@ -428,10 +428,14 @@
         self.view.document().setPlainText(text)
         self.view.setModified(False)
 
+    def isModified(self):
+        return self.view.document().isModified()
 
     def toPlainText(self):
         return unicode(self.view.document().toPlainText())
 
+    def setModified(self, flag):
+        self.view.document().setModified(flag)
 
 class PythonEditorWidget(EditorWidget):
     pass
@@ -441,6 +445,15 @@
     def __init__(self,  parent):
         QPlainTextEdit.__init__(self,  parent)
         self.highlighter = QtScriptHighlighter(self)
+
+class SaveDialog(QMessageBox):
+
+    def __init__(self, msg):
+	QMessageBox.__init__(self)
+	self.setWindowTitle("Save")
+	self.setText(msg)
+	self.setStandardButtons(QMessageBox.Save |QMessageBox.Discard | QMessageBox.Cancel)
+	self.setDefaultButton(QMessageBox.Save)
 
 
 if __name__ == "__main__":

Modified: trunk/Scribus/scribus/plugins/scripter/python/scribusscript.py
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/python/scribusscript.py
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/python/scribusscript.py (original)
+++ trunk/Scribus/scribus/plugins/scripter/python/scribusscript.py Tue Jun 12 22:00:07 2012
@@ -111,7 +111,7 @@
         Item("description"),
         Item("icon"),
         #Item("category"),
-        Item("menu", "Scripter"),
+        Item("menu"),
         #Item("context_menu"),
         Item("shortcut"),
         Item("filename"),

Modified: trunk/Scribus/scribus/plugins/scripter/python/scripter_hooks.py
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/python/scripter_hooks.py
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/python/scripter_hooks.py (original)
+++ trunk/Scribus/scribus/plugins/scripter/python/scripter_hooks.py Tue Jun 12 22:00:07 2012
@@ -36,6 +36,12 @@
             menu = action.menu()
             if menu:
                 yield menu
+                
+    def iter_inner_menus(self, menu):
+        for action in menu.actions():
+            menu = action.menu()
+            if menu:
+                yield menu
 
 
     def findMenu(self, title):
@@ -52,6 +58,9 @@
         for menu in self.iter_menus():
             if menu.title() == title:
                 return menu
+            for innerMenu in self.iter_inner_menus(menu):
+                if innerMenu.title() == title:
+                    return innerMenu
 
 
     def actionForMenu(self, menu):

Modified: trunk/Scribus/scribus/plugins/scripter/pythonize.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/pythonize.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/pythonize.cpp (original)
+++ trunk/Scribus/scribus/plugins/scripter/pythonize.cpp Tue Jun 12 22:00:07 2012
@@ -122,7 +122,7 @@
 
     int res = PyRun_SimpleString (line);
 
-    delete[] line;
+    delete line;
     return res == 0;
 }
 

Modified: trunk/Scribus/scribus/plugins/scripter/scripterimpl.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/scripterimpl.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/scripterimpl.cpp (original)
+++ trunk/Scribus/scribus/plugins/scripter/scripterimpl.cpp Tue Jun 12 22:00:07 2012
@@ -23,57 +23,59 @@
 
 
 
-ScripterImpl::~ScripterImpl() {
-    qDebug() << "destructor";
-    Q_ASSERT(python);
-    delete python;
-    //Q_ASSERT(collected);
-    //delete collected;
-    _instance = NULL;
-    qDebug() << "Scripter deleted";
+ScripterImpl::~ScripterImpl()
+{
+	qDebug() << "destructor";
+	Q_ASSERT(python);
+	delete python;
+	//Q_ASSERT(collected);
+	//delete collected;
+	_instance = NULL;
+	qDebug() << "Scripter deleted";
 };
 
 
 
 ScripterImpl *ScripterImpl::instance()
 {
-    //return QApplication::instance()->findChild<ScripterImpl *>("Scripter");
-    return _instance;
+	//return QApplication::instance()->findChild<ScripterImpl *>("Scripter");
+	return _instance;
 }
 
 
 bool ScripterImpl::init()
 {
-    collected = new QObject(this);
-    collected->setObjectName(QString("internal_garbage_collector"));
-    new PreferencesAPI();
-    new DialogsAPI();
-    python = new Pythonize();
-    Q_CHECK_PTR(python);
-    path = ScPaths::instance().libDir() + "plugins/scripter/";
-    //qRegisterMetaType< QList<QVariant*> >("QList<QVariant*>");
-    QString init_py = path + "init_scripter.py";
-    bool ok = runScript(init_py);
-    return ok;
-}
-
-
-
-bool ScripterImpl::runScript(const QString & filename) {
-    qDebug()  <<  "Running" << filename;
-    if (!python->runScript(filename.toLocal8Bit().data()))
-    {
-        qDebug()  << "Running" << filename << "failed";
-        return false;
-    }
-    return true;
+	collected = new QObject(this);
+	collected->setObjectName(QString("internal_garbage_collector"));
+	new PreferencesAPI();
+	new DialogsAPI();
+	python = new Pythonize();
+	Q_CHECK_PTR(python);
+	path = ScPaths::instance().libDir() + "plugins/scripter/";
+	//qRegisterMetaType< QList<QVariant*> >("QList<QVariant*>");
+	QString init_py = path + "init_scripter.py";
+	bool ok = runScript(init_py);
+	return ok;
+}
+
+
+
+bool ScripterImpl::runScript(const QString & filename)
+{
+	qDebug()  <<  "Running" << filename;
+	if (!python->runScript(filename.toLocal8Bit().data()))
+	{
+		qDebug()  << "Running" << filename << "failed";
+		return false;
+	}
+	return true;
 }
 
 
 bool ScripterImpl::cleanup()
 {
-    QString clean_py = path + "cleanup_scripter.py";
-    return runScript(clean_py);
+	QString clean_py = path + "cleanup_scripter.py";
+	return runScript(clean_py);
 }
 
 
@@ -89,18 +91,18 @@
 QObject *ScripterImpl::fromVariant(const QVariant& v)
 {
 
-    if (qVariantCanConvert< QWidget* >(v))
-    {
-        QObject* obj = qvariant_cast< QWidget* >(v);
-        return obj;
-    }
-    else if (qVariantCanConvert< QObject* >(v))
-    {
-        QObject* obj = qvariant_cast< QObject* >(v);
-        return obj;
-    }
-    else
-        return 0;
+	if (qVariantCanConvert< QWidget* >(v))
+	{
+		QObject* obj = qvariant_cast< QWidget* >(v);
+		return obj;
+	}
+	else if (qVariantCanConvert< QObject* >(v))
+	{
+		QObject* obj = qvariant_cast< QObject* >(v);
+		return obj;
+	}
+	else
+		return 0;
 }
 
 
@@ -111,13 +113,13 @@
  */
 QObject *ScripterImpl::openDocument(const QString & filename)
 {
-    bool ret = ScCore->primaryMainWindow()->loadDoc(filename);
-    if (!ret)
-    {
-        RAISE("Failed to open " + filename);
-        return NULL;
-    }
-    return activeDocument();
+	bool ret = ScCore->primaryMainWindow()->loadDoc(filename);
+	if (!ret)
+	{
+		RAISE("Failed to open " + filename);
+		return NULL;
+	}
+	return activeDocument();
 }
 
 
@@ -127,11 +129,12 @@
  * Property
  * returns a Document object if a document is open
  */
-QObject *ScripterImpl::activeDocument() {
-    if (ScCore->primaryMainWindow()->HaveDoc)
-        return new DocumentAPI();
-    else
-        return NULL;
+QObject *ScripterImpl::activeDocument()
+{
+	if (ScCore->primaryMainWindow()->HaveDoc)
+		return new DocumentAPI();
+	else
+		return NULL;
 }
 
 
@@ -140,11 +143,75 @@
  * Property
  * returns a Window object if a window is open
  */
-QObject *ScripterImpl::activeWindow() {
-    if (ScCore->primaryMainWindow()->HaveDoc)
-        return new WindowAPI();
-    else
-        return NULL;
+QObject *ScripterImpl::activeWindow()
+{
+	if (ScCore->primaryMainWindow()->HaveDoc)
+		return new ScribusWindow();
+	else
+		return NULL;
+}
+
+/**
+ * Scripter.colors
+ * Property
+ * returns a color object
+ */
+QList<QVariant> ScripterImpl::colors()
+{
+	QList<QVariant> l;
+
+	ColorList names = PrefsManager::instance()->colorSet();
+	ColorList::Iterator it;
+	for (it = names.begin(); it != names.end(); ++it)
+	{
+		ScColor *value = &(names[it.key()]);
+		ScColorWrapper *color = new ScColorWrapper(value, it.key());
+		l.append(qVariantFromValue((QObject *)(color)));
+	}
+	return l;
+}
+
+QList< QVariant > ScripterImpl::fontInfo()
+{
+	int cc2 = 0;
+	SCFontsIterator it2(PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts);
+	for ( ; it2.hasNext() ; it2.next())
+	{
+		if (it2.current().usable())
+			cc2++;
+	}
+	QList<QVariant> l;
+	SCFontsIterator it(PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts);
+	int cc = 0;
+	for ( ; it.hasNext() ; it.next())
+	{
+		if (it.current().usable())
+		{
+			l.append(it.currentKey());
+			cc++;
+		}
+	}
+	return l;
+}
+
+QList<QVariant> ScripterImpl::xFontInfo()
+{
+	QList<QVariant> l;
+	SCFontsIterator it(PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts);
+	int cc = 0;
+	QList<QVariant> row;
+	for ( ; it.hasNext() ; it.next())
+	{
+		row.append(it.currentKey());
+		row.append(it.current().family());
+		row.append(it.current().psName());
+		row.append(it.current().subset());
+		row.append(it.current().embedPs());
+		row.append(it.current().fontFilePath());
+		l.append(row);
+		cc++;
+	}
+	return l;
 }
 
 /**
@@ -171,43 +238,43 @@
     int orientation, int firstPageNr, int unit, int pagesType,
     int facingPages, int firstPageOrder, int numPages)
 {
-    if (numPages <= 0)
-        numPages = 1;
-    if (pagesType == 0)
-    {
-        facingPages = 0;
-        firstPageOrder = 0;
-    }
-    else
-        facingPages = 1;
-    // checking the bounds
-    if (pagesType < firstPageOrder)
-    {
-        RAISE("firstPageOrder is bigger than allowed.");
-        return NULL;
-    }
-    if (orientation == 1)
-    {
-        double x = pageWidth;
-        pageWidth = pageHeight;
-        pageHeight = x;
-    }
-    bool ret = ScCore->primaryMainWindow()->doFileNew(
-                   pageWidth, pageHeight, topMargin, leftMargin,
-                   rightMargin, bottomMargin,
-                   // XXX: add later?
-                   // autoframes. It's disabled in python
-                   // columnDistance, numberCols, autoframes,
-                   0, 1, false,
-                   pagesType, unit, firstPageOrder,
-                   orientation, firstPageNr, "Custom", true, numPages);
-    if (!ret)
-    {
-        RAISE("Page creation failed");
-        return NULL;
-    }
-    ScCore->primaryMainWindow()->doc->setPageSetFirstPage(pagesType, firstPageOrder);
-    return activeDocument();
+	if (numPages <= 0)
+		numPages = 1;
+	if (pagesType == 0)
+	{
+		facingPages = 0;
+		firstPageOrder = 0;
+	}
+	else
+		facingPages = 1;
+	// checking the bounds
+	if (pagesType < firstPageOrder)
+	{
+		RAISE("firstPageOrder is bigger than allowed.");
+		return NULL;
+	}
+	if (orientation == 1)
+	{
+		double x = pageWidth;
+		pageWidth = pageHeight;
+		pageHeight = x;
+	}
+	bool ret = ScCore->primaryMainWindow()->doFileNew(
+	               pageWidth, pageHeight, topMargin, leftMargin,
+	               rightMargin, bottomMargin,
+	               // XXX: add later?
+	               // autoframes. It's disabled in python
+	               // columnDistance, numberCols, autoframes,
+	               0, 1, false,
+	               pagesType, unit, firstPageOrder,
+	               orientation, firstPageNr, "Custom", true, numPages);
+	if (!ret)
+	{
+		RAISE("Page creation failed");
+		return NULL;
+	}
+	ScCore->primaryMainWindow()->doc->setPageSetFirstPage(pagesType, firstPageOrder);
+	return activeDocument();
 }
 
 
@@ -219,9 +286,13 @@
  */
 void ScripterImpl::addToMainWindowMenu(ScribusMainWindow *mainwin)
 {
-    emit createMenu(mainwin);
-}
-
+	emit createMenu(mainwin);
+}
+
+QString ScripterImpl::language()
+{
+	return ScCore->getGuiLanguage();
+}
 
 
 /*
@@ -231,17 +302,17 @@
  */
 bool ScripterImpl::test()
 {
-    bool ok;
-    QString code = QInputDialog::getText(
-                       0, tr("Scripter"), tr("Please enter a Python command:"), QLineEdit::Normal,
-                       "import scripterconsole; scripterconsole.show_console()", &ok);
-    if (ok && !code.isEmpty())
-    {
-        bool success = python->runString(code.toUtf8().data());
-        if (!success)
-            qDebug() << "python->runString(..) failed";
-    }
-    return true;
+	bool ok;
+	QString code = QInputDialog::getText(
+	                   0, tr("Scripter"), tr("Please enter a Python command:"), QLineEdit::Normal,
+	                   "import scripterconsole; scripterconsole.show_console()", &ok);
+	if (ok && !code.isEmpty())
+	{
+		bool success = python->runString(code.toUtf8().data());
+		if (!success)
+			qDebug() << "python->runString(..) failed";
+	}
+	return true;
 }
 
 
@@ -254,12 +325,12 @@
  */
 void ScripterImpl::aboutScripter()
 {
-    QMessageBox::information(
-        0, //(QWidget*)doc->scMW(),
-        tr("Scribus - Scripter Plugin"),
-        tr("If you see this box, Scripter probably works :)"),
-        QMessageBox::Ok|QMessageBox::Default|QMessageBox::Escape,
-        QMessageBox::NoButton);
+	QMessageBox::information(
+	    0, //(QWidget*)doc->scMW(),
+	    tr("Scribus - Scripter Plugin"),
+	    tr("If you see this box, Scripter probably works :)"),
+	    QMessageBox::Ok|QMessageBox::Default|QMessageBox::Escape,
+	    QMessageBox::NoButton);
 }
 
 

Modified: trunk/Scribus/scribus/plugins/scripter/scripterimpl.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17560&path=/trunk/Scribus/scribus/plugins/scripter/scripterimpl.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scripter/scripterimpl.h (original)
+++ trunk/Scribus/scribus/plugins/scripter/scripterimpl.h Tue Jun 12 22:00:07 2012
@@ -16,11 +16,14 @@
 #include "scribuscore.h"
 #include "scpaths.h"
 #include "api_prefs.h"
-#include "api_item.h"
+#include "api_printer.h"
+#include "api_imageexport.h"
+#include "api_layer.h"
 #include "api_page.h"
 #include "api_dialogs.h"
 #include "api_window.h"
 #include "api_document.h"
+#include "api_color.h"
 
 // XXX make this INTO method inside a new util.cpp
 #define RAISE(msg) QApplication::instance()->setProperty("MIKRO_EXCEPTION", QVariant(msg))
@@ -34,50 +37,59 @@
 
 class ScripterImpl : public QObject
 {
-    Q_OBJECT
-    Q_PROPERTY(QObject* collector READ collector);
-    Q_PROPERTY(QObject* activeDocument READ activeDocument);
-    Q_PROPERTY(QObject* activeWindow READ activeWindow);
+	Q_OBJECT
+	Q_PROPERTY(QObject* collector READ collector);
+	Q_PROPERTY(QString language READ language);
+	Q_PROPERTY(QObject* activeDocument READ activeDocument);
+	Q_PROPERTY(QObject* activeWindow READ activeWindow);
+	Q_PROPERTY(QList<QVariant> colors READ colors);
+	Q_PROPERTY(QList<QVariant> fontInfo READ fontInfo);
+	Q_PROPERTY(QList<QVariant> extendedFontInfo READ xFontInfo);
 
 public:
-    ScripterImpl();
-    ~ScripterImpl();
-    static ScripterImpl *instance();
-    bool init();
-    bool cleanup();
-    void addToMainWindowMenu(ScribusMainWindow *mainwin);
-    QObject *collector()  {
-        return collected;
-    };
+	ScripterImpl();
+	~ScripterImpl();
+	static ScripterImpl *instance();
+	bool init();
+	bool cleanup();
+	void addToMainWindowMenu(ScribusMainWindow *mainwin);
+	QObject *collector()
+	{
+		return collected;
+	};
 
 public slots:
-    void aboutScripter();
-    QObject *openDocument(const QString & filename);
-    QObject *newDocument(
-        double topMargin, double bottomMargin,
-        double leftMargin, double rightMargin,
-        double pageWidth, double pageHeight,
-        int orientation, int firstPageNr, int unit, int pagesType,
-        int facingPages, int firstPageOrder, int numPages);
-    QObject *fromVariant(const QVariant& v);
-    bool test();
+	void aboutScripter();
+	QObject *openDocument(const QString & filename);
+	QObject *newDocument(
+	    double topMargin, double bottomMargin,
+	    double leftMargin, double rightMargin,
+	    double pageWidth, double pageHeight,
+	    int orientation, int firstPageNr, int unit, int pagesType,
+	    int facingPages, int firstPageOrder, int numPages);
+	QObject *fromVariant(const QVariant& v);
+	bool test();
 
 signals:
-    void createMenu(QMainWindow *mainwin);
+	void createMenu(QMainWindow *mainwin);
 
 private:
-    /*
-      collected is used for dumb garbage collection.
-      Use it as a parent to make sure that your object gets deleted
-      inside the scripting environment if it is not needed anymore.
-     */
-    QObject *collected;
-    Pythonize *python;
-    static ScripterImpl *_instance;
-    QString path;
-    bool runScript(const QString & filename);
-    QObject *activeDocument();
-    QObject *activeWindow();
+	/*
+	  collected is used for dumb garbage collection.
+	  Use it as a parent to make sure that your object gets deleted
+	  inside the scripting environment if it is not needed anymore.
+	 */
+	QObject *collected;
+	Pythonize *python;
+	static ScripterImpl *_instance;
+	QString path;
+	bool runScript(const QString & filename);
+	QString language();
+	QObject *activeDocument();
+	QObject *activeWindow();
+	QList<QVariant> colors();
+	QList<QVariant> fontInfo();
+	QList<QVariant> xFontInfo();
 };
 
 #endif




More information about the scribus-commit mailing list