summaryrefslogtreecommitdiffstats
path: root/src/extension/script/InkscapePython.cpp
diff options
context:
space:
mode:
authorBob Jamison <ishmalius@gmail.com>2007-04-14 15:52:31 +0000
committerishmal <ishmal@users.sourceforge.net>2007-04-14 15:52:31 +0000
commitb8e436d8fb9ec7996d50202ca3c51a3940fbc01e (patch)
treea856e6e6aa3338d79d7927ac60deaf91119f06d6 /src/extension/script/InkscapePython.cpp
parentfix typecasts (diff)
downloadinkscape-b8e436d8fb9ec7996d50202ca3c51a3940fbc01e.tar.gz
inkscape-b8e436d8fb9ec7996d50202ca3c51a3940fbc01e.zip
Change python binding mechanism
(bzr r2885)
Diffstat (limited to 'src/extension/script/InkscapePython.cpp')
-rw-r--r--src/extension/script/InkscapePython.cpp150
1 files changed, 120 insertions, 30 deletions
diff --git a/src/extension/script/InkscapePython.cpp b/src/extension/script/InkscapePython.cpp
index 49e6a11a2..f7cfe81db 100644
--- a/src/extension/script/InkscapePython.cpp
+++ b/src/extension/script/InkscapePython.cpp
@@ -4,7 +4,7 @@
* Authors:
* Bob Jamison <rjamison@titan.com>
*
- * Copyright (C) 2004 Authors
+ * Copyright (C) 2004-2007 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -16,57 +16,147 @@
#include <stdio.h>
+#include <CXX/Extensions.hxx>
+#include <CXX/Objects.hxx>
-#include "inkscape_py.py.h"
+#include <inkscape.h>
-/*
- * Generated by SWIG
- */
-extern "C" void init_inkscape_py(void);
+namespace Inkscape
+{
+namespace Extension
+{
+namespace Script
+{
-namespace Inkscape {
-namespace Extension {
-namespace Script {
+//########################################################################
+//# I N K S C A P E
+//########################################################################
-/*
- *
- */
-InkscapePython::InkscapePython()
+class PyDialogManager : public Py::PythonExtension<PyDialogManager>
{
-}
+public:
-/*
- *
- */
-InkscapePython::~InkscapePython()
+private:
+
+};
+
+
+
+class PyDesktop : public Py::PythonExtension<PyDesktop>
+{
+public:
+
+
+
+private:
+
+};
+
+
+
+class PyDocument : public Py::PythonExtension<PyDocument>
+{
+public:
+
+
+
+private:
+
+};
+
+
+
+class PyInkscape : public Py::PythonExtension<PyInkscape>
+{
+public:
+
+ PyInkscape()
+ {
+ inkscape = INKSCAPE;
+ }
+
+ virtual ~PyInkscape()
+ {
+ }
+
+
+ virtual Py::Object getattr(const char *name)
+ {
+ if (strcmp(name, "activeDesktop")==0)
+ {
+ }
+ else if (strcmp(name, "activeDocument")==0)
+ {
+ }
+ else if (strcmp(name, "dialogManager")==0)
+ {
+ }
+ return getattr_methods(name);
+ }
+
+ virtual Py::Object exit(const Py::Tuple &args)
+ {
+ //exit();
+ }
+
+ static void init_type()
+ {
+ behaviors().name("inkscape");
+ behaviors().doc("inkscape objects: activeDesktop activeDocument dialogManager");
+ behaviors().supportRepr();
+ behaviors().supportGetattr();
+
+ add_varargs_method("exit", &PyInkscape::exit,
+ "exit from the current application");
+ }
+
+private:
+
+ Inkscape::Application *inkscape;
+
+};
+
+
+
+
+//########################################################################
+//# M A I N
+//########################################################################
+
+
+bool InkscapePython::initialize()
{
+ if (initialized)
+ return true;
+
+ Py_Initialize();
+
+
+
+ initialized = true;
+ return true;
}
-static bool initialized = false;
/*
* Interpret an in-memory string
*/
bool InkscapePython::interpretScript(const Glib::ustring &script,
- Glib::ustring &output,
- Glib::ustring &error)
+ Glib::ustring &output, Glib::ustring &error)
{
- if (!initialized)
- {
- Py_Initialize();
- init_inkscape_py();
- initialized = true;
- }
+ if (!initialize())
+ return false;
+
char *codeStr = (char *)script.raw().c_str();
- PyRun_SimpleString(inkscape_module_script);
- PyRun_SimpleString("inkscape = _inkscape_py.getInkscape()\n");
- PyRun_SimpleString(codeStr);
+ //PyRun_SimpleString(inkscape_module_script);
+ //PyRun_SimpleString("inkscape = _inkscape_py.getInkscape()\n");
+ //PyRun_SimpleString(codeStr);
//## Check for errors
if (PyErr_Occurred())