r15528 by craig - #9111: Add flipObject command to scripter

scribus-commit scribus-commit at lists.scribus.net
Wed Oct 13 00:28:39 CEST 2010


Author: craig
Date: Tue Oct 12 22:28:39 2010
New Revision: 15528

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15528
Log:
#9111: Add flipObject command to scripter

Modified:
    trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp
    trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.h
    trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15528&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp Tue Oct 12 22:28:39 2010
@@ -571,6 +571,45 @@
 //	return Py_None;
 	Py_RETURN_NONE;
 }
+PyObject *scribus_flipobject(PyObject* /* self */, PyObject* args)
+{
+	char *Name = const_cast<char*>("");
+	double h, v;
+	if (!PyArg_ParseTuple(args, "dd|es", &h, &v, "utf-8", &Name))
+		return NULL;
+	if(!checkHaveDocument())
+		return NULL;
+	PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+	if (item == NULL)
+		return NULL;
+	
+	// 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->SelectItemNr(item->ItemNr);
+
+	// flip
+	if (h == 1) {
+		ScCore->primaryMainWindow()->doc->itemSelection_FlipH();
+		}
+	if (v == 1) {
+		ScCore->primaryMainWindow()->doc->itemSelection_FlipV();
+		}
+	// Now restore the selection.
+	ScCore->primaryMainWindow()->view->Deselect();
+	if (hadOrigSelection)
+		*ScCore->primaryMainWindow()->doc->m_Selection=tempSelection;
+
+//	Py_INCREF(Py_None);
+//	return Py_None;
+	Py_RETURN_NONE;
+}
 
 /*! HACK: this removes "warning: 'blah' defined but not used" compiler warnings
 with header files structure untouched (docstrings are kept near declarations)
@@ -586,5 +625,6 @@
 	  << scribus_ungroupobj__doc__ << scribus_scalegroup__doc__
 	  << scribus_loadimage__doc__ << scribus_scaleimage__doc__
 	  << scribus_setimagescale__doc__ << scribus_lockobject__doc__
-	  << scribus_islocked__doc__ << scribus_setscaleimagetoframe__doc__ << scribus_setimagebrightness__doc__ << scribus_setimagegrayscale__doc__ << scribus_setimageoffset__doc__;
-}
+	  << scribus_islocked__doc__ << scribus_setscaleimagetoframe__doc__ << scribus_setimagebrightness__doc__ << scribus_setimagegrayscale__doc__ << scribus_setimageoffset__doc__
+	  << scribus_flipobject__doc__;
+}

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15528&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.h (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdmani.h Tue Oct 12 22:28:39 2010
@@ -252,4 +252,14 @@
 "));
 PyObject *scribus_setscaleimagetoframe(PyObject * /*self*/, PyObject* args, PyObject* kwargs);
 
+/*! docstring */
+PyDoc_STRVAR(scribus_flipobject__doc__,
+QT_TR_NOOP("flipObject(H,V,[\"name\"])\n\
+\n\
+Toggle the object \"name\" horizontal and/or vertical flip.\n\
+If \"name\" is not given the currently selected item is used.\n\
+"));
+/*! Flip the object 2010/5/18.*/
+PyObject *scribus_flipobject(PyObject * /*self*/, PyObject* args);
+
 #endif

Modified: trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15528&path=/trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp Tue Oct 12 22:28:39 2010
@@ -329,6 +329,7 @@
 	{const_cast<char*>("editMasterPage"), scribus_editmasterpage, METH_VARARGS, tr(scribus_editmasterpage__doc__)},
 	{const_cast<char*>("fileDialog"), (PyCFunction)scribus_filedia, METH_VARARGS|METH_KEYWORDS, tr(scribus_filedia__doc__)},
 	{const_cast<char*>("fileQuit"), scribus_filequit, METH_VARARGS, tr(scribus_filequit__doc__)},
+	{const_cast<char*>("flipObject"), scribus_flipobject, METH_VARARGS, tr(scribus_flipobject__doc__)},
 	{const_cast<char*>("getActiveLayer"), (PyCFunction)scribus_getactlayer, METH_NOARGS, tr(scribus_getactlayer__doc__)},
 	{const_cast<char*>("getAllObjects"), scribus_getallobj, METH_VARARGS, tr(scribus_getallobj__doc__)},
 	{const_cast<char*>("getAllStyles"), (PyCFunction)scribus_getstylenames, METH_NOARGS, tr(scribus_getstylenames__doc__)},




More information about the scribus-commit mailing list