r14974 by cbradney - Backport setImageOffset to 1.3.7svn

scribus-commit scribus-commit at lists.scribus.net
Thu Apr 15 23:20:30 CEST 2010


Revision: 14974
Author: cbradney
Date: 2010-04-15T21:15:42.056976Z
Commit message: Backport setImageOffset to 1.3.7svn

Changeset: 
M  /branches/Version135/Scribus/scribus/plugins/scriptplugin/cmdmani.cpp
M  /branches/Version135/Scribus/scribus/plugins/scriptplugin/cmdmani.h
M  /branches/Version135/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp

Diffs:
Index: scribus/plugins/scriptplugin/cmdmani.cpp
===================================================================
--- scribus/plugins/scriptplugin/cmdmani.cpp	(revision 14973)
+++ scribus/plugins/scriptplugin/cmdmani.cpp	(revision 14974)
@@ -81,6 +81,49 @@
 	Py_RETURN_NONE;
 }
 
+PyObject *scribus_setimageoffset(PyObject* /* self */, PyObject* args)
+{
+        char *Name = const_cast<char*>("");
+        double x, y;
+        if (!PyArg_ParseTuple(args, "dd|es", &x, &y, "utf-8", &Name))
+                return NULL;
+        if(!checkHaveDocument())
+                return NULL;
+        PageItem *item = GetUniqueItem(QString::fromUtf8(Name));
+        if (item == NULL)
+                return NULL;
+        if (! item->asImageFrame())
+        {
+                PyErr_SetString(ScribusException, QObject::tr("Specified item not an image frame.","python error").toLocal8Bit().constData());
+                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);
+
+        // offset
+        ScCore->primaryMainWindow()->doc->itemSelection_SetImageOffset(x, y); //CB why when this is done above?
+        ScCore->primaryMainWindow()->doc->updatePic();
+        
+        // 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;
+}
+
+
 PyObject *scribus_moveobjrel(PyObject* /* self */, PyObject* args)
 {
 	char *Name = const_cast<char*>("");
@@ -442,5 +485,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_islocked__doc__ << scribus_setscaleimagetoframe__doc__
+	  << scribus_setimageoffset__doc__ ;
 }
Index: scribus/plugins/scriptplugin/cmdmani.h
===================================================================
--- scribus/plugins/scriptplugin/cmdmani.h	(revision 14973)
+++ scribus/plugins/scriptplugin/cmdmani.h	(revision 14974)
@@ -182,6 +182,19 @@
 PyObject *scribus_setimagescale(PyObject * /*self*/, PyObject* args);
 
 /*! docstring */
+PyDoc_STRVAR(scribus_setimageoffset__doc__,
+QT_TR_NOOP("setImageOffset(x, y [, \"name\"])\n\
+\n\
+Sets the internal offset of the picture in the image frame \"name\".\n\
+If \"name\" is not given the currently selected item is used.\n\
+\n\
+May raise WrongFrameTypeError if the target frame is not an image frame\n\
+"));
+/*! Scale Image. */
+PyObject *scribus_setimageoffset(PyObject * /*self*/, PyObject* args);
+
+
+/*! docstring */
 PyDoc_STRVAR(scribus_lockobject__doc__,
 QT_TR_NOOP("lockObject([\"name\"]) -> bool\n\
 \n\
Index: scribus/plugins/scriptplugin/scriptplugin.cpp
===================================================================
--- scribus/plugins/scriptplugin/scriptplugin.cpp	(revision 14973)
+++ scribus/plugins/scriptplugin/scriptplugin.cpp	(revision 14974)
@@ -412,6 +412,7 @@
 	{const_cast<char*>("scaleGroup"), scribus_scalegroup, METH_VARARGS, tr(scribus_scalegroup__doc__)},
 	{const_cast<char*>("scaleImage"), scribus_scaleimage, METH_VARARGS, tr(scribus_scaleimage__doc__)},
 	{const_cast<char*>("setImageScale"), scribus_setimagescale, METH_VARARGS, tr(scribus_setimagescale__doc__)},
+	{const_cast<char*>("setImageOffset"), scribus_setimageoffset, METH_VARARGS, tr(scribus_setimageoffset__doc__)},
 	{const_cast<char*>("selectionCount"), (PyCFunction)scribus_selcount, METH_NOARGS, tr(scribus_selcount__doc__)},
 	{const_cast<char*>("selectObject"), scribus_selectobj, METH_VARARGS, tr(scribus_selectobj__doc__)},
 	{const_cast<char*>("selectText"), scribus_selecttext, METH_VARARGS, tr(scribus_selecttext__doc__)},




More information about the scribus-commit mailing list