]> Dogcows Code - chaz/openbox/commitdiff
split up the otk stuff into separate files.
authorDana Jansens <danakj@orodu.net>
Mon, 17 Feb 2003 21:25:52 +0000 (21:25 +0000)
committerDana Jansens <danakj@orodu.net>
Mon, 17 Feb 2003 21:25:52 +0000 (21:25 +0000)
wrap otk::Property properly with typemaps so that it is usable.
wrap otk::Timer properly so that you can use it with a python callback

23 files changed:
wrap/Makefile.am
wrap/ob.i
wrap/ob_callback.i [moved from wrap/callback.i with 95% similarity]
wrap/ob_client.i
wrap/ob_openbox.i
wrap/ob_screen.i
wrap/otk.i
wrap/otk_application.i [new file with mode: 0644]
wrap/otk_appwidget.i [new file with mode: 0644]
wrap/otk_button.i [new file with mode: 0644]
wrap/otk_font.i [new file with mode: 0644]
wrap/otk_label.i [new file with mode: 0644]
wrap/otk_point.i [new file with mode: 0644]
wrap/otk_property.i [new file with mode: 0644]
wrap/otk_rect.i [new file with mode: 0644]
wrap/otk_rendercolor.i [new file with mode: 0644]
wrap/otk_renderstyle.i [new file with mode: 0644]
wrap/otk_rendertexture.i [new file with mode: 0644]
wrap/otk_size.i [new file with mode: 0644]
wrap/otk_strut.i [new file with mode: 0644]
wrap/otk_timer.i [new file with mode: 0644]
wrap/otk_ustring.i [moved from wrap/ustring.i with 90% similarity]
wrap/otk_widget.i [new file with mode: 0644]

index d3e44edc3abb083716c102f822d205cf9f3ce2a6..3f90488273f58da550de4b37d05c26dbde100724 100644 (file)
@@ -41,9 +41,9 @@ otk.i: $(wildcard ../otk/*.hh)
 ob.i: $(addprefix ../src/,openbox.hh screen.hh client.hh python.hh frame.hh)
        @touch $@
 
-wrap_otk.cc: otk.i
+wrap_otk.cc: otk.i otk_point.i otk_rect.i otk_size.i otk_rendercolor.i otk_rendertexture.i otk_ustring.i otk_font.i otk_renderstyle.i otk_widget.i otk_label.i otk_button.i otk_appwidget.i otk_application.i otk_strut.i otk_property.i otk_timer.i
        $(SWIG) $(SWIG_PYTHON_OPT) $(filter -I%,$(CPPFLAGS)) -nodefault -o $@ $<
 
-wrap_ob.cc: ob.i callback.i ob_client.i ob_screen.i ob_openbox.i ob_frame.i ob_python.i
+wrap_ob.cc: ob.i ob_callback.i ob_client.i ob_screen.i ob_openbox.i ob_frame.i ob_python.i
        $(SWIG) $(SWIG_PYTHON_OPT) $(filter -I%,$(CPPFLAGS)) -nodefault -o $@ $<
 
index 8f3cb4e3b29c5978f973e80cde9ca0f8243c5d9d..b6c9461e7cd23adab3edcf7eb1b6ebb9d54a4edd 100644 (file)
--- a/wrap/ob.i
+++ b/wrap/ob.i
@@ -32,7 +32,7 @@ void send_client_msg(Window target, Atom type, Window about,
 %include "ob_client.i"
 %include "ob_frame.i"
 %include "ob_python.i"
-%include "callback.i"
+%include "ob_callback.i"
 
 // for Window etc
 %import "X11/X.h"
@@ -42,6 +42,7 @@ void send_client_msg(Window target, Atom type, Window about,
 #include "bindings.hh"
 #include "otk/display.hh"
 #include "otk/screeninfo.hh"
+#include "otk/util.hh"
 
 void set_reset_key(const std::string &key)
 {
similarity index 95%
rename from wrap/callback.i
rename to wrap/ob_callback.i
index b13a3e9d14167a0a55d2709273d7e6b952944345..776bdb2b5f83bd0bf8b3866e20f437e5fef7b8ba 100644 (file)
@@ -1,5 +1,7 @@
 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
 
+%module ob_callback
+
 %include "std_string.i"
 
 %{
@@ -121,7 +123,7 @@ bool mbind(const std::string &button, ob::MouseContext::MC context,
     PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
     return false;
   }
-  Py_INCREF(func);
+  Py_INCREF(func); // the func is never decreffed... XXX
   return true;
 }
 
@@ -136,7 +138,7 @@ bool ebind(ob::EventAction::EA action, PyObject *func)
     PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
     return false;
   }
-  Py_INCREF(func);
+  Py_INCREF(func); // the func is never decreffed... XXX
   return true;
 }
 
@@ -147,7 +149,7 @@ bool kgrab(int screen, PyObject *func)
     PyErr_SetString(PyExc_RuntimeError,"Unable to grab keybaord.");
     return false;
   }
-  Py_INCREF(func);
+  Py_INCREF(func); // the func is never decreffed... XXX
   return true;
 }
 
@@ -197,7 +199,7 @@ bool kbind(PyObject *keylist, ob::KeyContext::KC context, PyObject *func)
     PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
     return false;
   }
-  Py_INCREF(func);
+  Py_INCREF(func); // the func is never decreffed... XXX
   return true;
 }
 
index af861eddd5ea3585b94544c106a87c68810ff626..353db7e502858c687ce6a13270ca54e96ad6be49 100644 (file)
@@ -7,8 +7,8 @@
 #include "client.hh"
 %}
 
-%include "otk.i" // XXX otk_size.i!!!
-%include "ustring.i"
+%include "otk_size.i"
+%include "otk_ustring.i"
 %include "std_string.i"
 
 namespace ob {
index ed44380bb04029cfcf5fbe806fcf7164a4c7cef7..48cfa90513b36d68cdef58409227c70de6f64539 100644 (file)
@@ -31,4 +31,5 @@ namespace ob {
 
 }
 
+%import "../otk/eventdispatcher.hh"
 %include "openbox.hh"
index bbf7b57c02ba0d40190f73cfb38d098711bffb49..b182d2d701f7ec87405e295dbae07b36ed6cdb50 100644 (file)
 %}
 
 %include "ob_client.i"
-%include "otk.i" // XXX otk_rect.i!!!
-%include "ustring.i"
+%include "otk_rect.i"
+%include "otk_ustring.i"
+%include "otk_size.i"
+%include "std_vector.i"
+
+%typemap(python,out) const otk::Property::StringVect& {
+  otk::Property::StringVect *v = $1;
+  unsigned int s = v->size();
+  PyObject *l = PyList_New(s);
+
+  otk::Property::StringVect::const_iterator it = v->begin(), end = v->end();
+  for (unsigned int i = 0; i < s; ++i, ++it) {
+    PyObject *pdata = PyString_FromString(it->c_str());
+    PyList_SET_ITEM(l, i, pdata);
+  }
+  $result = l;
+}
 
 %typemap(python,out) std::list<ob::Client*> {
   unsigned int s = $1.size();
   $result = l;
 }
 
-%typemap(python,out) const otk::Property::StringVect& {
-  otk::Property::StringVect *v = $1;
+%typemap(python,out) const std::vector<otk::Rect>& {
+  std::vector<otk::Rect> *v = $1;
   unsigned int s = v->size();
   PyObject *l = PyList_New(s);
 
-  otk::Property::StringVect::const_iterator it = v->begin(), end = v->end();
+  std::vector<otk::Rect>::const_iterator it = v->begin(), end = v->end();
   for (unsigned int i = 0; i < s; ++i, ++it) {
-    PyObject *pdata = PyString_FromString(it->c_str());
+    PyObject *pdata = SWIG_NewPointerObj((void*)&(*it),SWIGTYPE_p_otk__Rect,0);
     PyList_SET_ITEM(l, i, pdata);
   }
   $result = l;
@@ -52,6 +67,18 @@ namespace ob {
     send_client_msg(root, otk::Property::atoms.net_current_desktop,
                     root, desktop);
   }
+
+  const otk::Size& size() {
+    return otk::display->screenInfo(self->number())->size();
+  }
+
+  const std::vector<otk::Rect> &xineramaAreas() {
+    return otk::display->screenInfo(self->number())->xineramaAreas();
+  }
+
+  Window rootWindow() {
+    return otk::display->screenInfo(self->number())->rootWindow();
+  }
 }
 
 %immutable Screen::clients;
index 4ff835a6a771c5de396301fd7b864a9e77a837ca..6611a9925dd2c51e8361912f4a00d74b78000fec 100644 (file)
@@ -2,79 +2,36 @@
 
 %module otk
 
-%{
-#include "otk.hh"
-%}
-
-%include "stl.i"
-%include "typemaps.i"
-//%include std_list.i
-%include "ustring.i"
+%import "eventhandler.hh"
+%import "eventdispatcher.hh"
+
+%include "otk_strut.i"
+%include "otk_point.i"
+%include "otk_size.i"
+%include "otk_rect.i"
+%include "otk_rendercolor.i"
+%include "otk_rendertexture.i"
+%include "otk_font.i"
+%include "otk_ustring.i"
+%include "otk_renderstyle.i"
+%include "otk_widget.i"
+%include "otk_label.i"
+%include "otk_button.i"
+%include "otk_application.i"
+%include "otk_appwidget.i"
+%include "otk_property.i"
+%include "otk_timer.i"
 
-%immutable otk::display;
 %immutable otk::Property::atoms;
 
-namespace otk {
-/*%rename(setValue_bool) Configuration::setValue(std::string const &,bool);
-%rename(setValue_unsigned) Configuration::setValue(const std::string &, unsigned int);
-%rename(setValue_long) Configuration::setValue(const std::string &, long);
-%rename(setValue_unsignedlong) Configuration::setValue(const std::string &, unsigned long);
-%rename(setValue_string) Configuration::setValue(const std::string &, const std::string &);
-%rename(setValue_charptr) Configuration::setValue(const std::string &, const char *);*/
-
-%rename(itostring_unsigned) itostring(unsigned int);
-%rename(itostring_long) itostring(long);
-%rename(itostring_unsigned_long) itostring(unsigned long);
-
-// these are needed for guile, but not needed for python!
-//%rename(equals) BColor::operator==;
-//%rename(equals) Rect::operator==;
-//%rename(equals) BTexture::operator==;
-//%ignore BColor::operator!=;
-//%ignore BTexture::operator!=;
-%ignore Rect::operator!=;
-%ignore Rect::operator|;
-%ignore Rect::operator|=;
-%ignore Rect::operator&;
-%ignore Rect::operator&=;
-//%ignore OBTimer::operator<;
 %ignore TimerLessThan;
 
-/*
-%rename(set_multi) OtkProperty::set(Window, Atoms, Atoms, unsigned long[], int);
-%rename(set_string) OtkProperty::set(Window, Atoms, StringType, const std::string &);
-%rename(set_string_multi) OtkProperty::set(Window, Atoms, StringType, const StringVect &);
-*/
-}
-
-%include "eventhandler.hh"
-%include "eventdispatcher.hh"
-%include "point.hh"
-%include "size.hh"
-%include "rect.hh"
-%include "rendercolor.hh"
-%include "rendertexture.hh"
-%include "font.hh"
-%include "renderstyle.hh"
-%include "widget.hh"
-%include "label.hh"
-%include "appwidget.hh"
-%include "application.hh"
-%include "button.hh"
-%include "display.hh"
-%include "rendercontrol.hh"
-%include "screeninfo.hh"
-%include "strut.hh"
-
-%apply unsigned long *OUTPUT { unsigned long *value };
-%include "property.hh"
 
 // for Window etc
 %import "X11/X.h"
 
 // globals
 %pythoncode %{
-display = cvar.display;
 atoms = cvar.Property_atoms;
 
 def style(screen):
diff --git a/wrap/otk_application.i b/wrap/otk_application.i
new file mode 100644 (file)
index 0000000..6878055
--- /dev/null
@@ -0,0 +1,13 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_application
+
+%{
+#include "config.h"
+#include "application.hh"
+%}
+
+%include "otk_widget.i"
+
+%import "../otk/eventdispatcher.hh"
+%include "application.hh"
diff --git a/wrap/otk_appwidget.i b/wrap/otk_appwidget.i
new file mode 100644 (file)
index 0000000..25de346
--- /dev/null
@@ -0,0 +1,20 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_appwidget
+
+%{
+#include "config.h"
+#include "appwidget.hh"
+%}
+
+%include "otk_widget.i"
+%include "otk_application.i"
+
+namespace otk {
+
+%ignore AppWidget::clientMessageHandler(const XClientMessageEvent &);
+
+
+}
+
+%include "appwidget.hh"
diff --git a/wrap/otk_button.i b/wrap/otk_button.i
new file mode 100644 (file)
index 0000000..e216160
--- /dev/null
@@ -0,0 +1,22 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_button
+
+%{
+#include "config.h"
+#include "button.hh"
+%}
+
+%include "otk_widget.i"
+%include "otk_ustring.i"
+%include "otk_font.i"
+%include "otk_renderstyle.i"
+
+namespace otk {
+
+%ignore Button::clickHandler(unsigned int);
+%ignore Button::styleChanged(const RenderStyle &);
+
+}
+
+%include "button.hh"
diff --git a/wrap/otk_font.i b/wrap/otk_font.i
new file mode 100644 (file)
index 0000000..797a153
--- /dev/null
@@ -0,0 +1,13 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_rendertexture
+
+%{
+#include "config.h"
+#include "font.hh"
+%}
+
+%include "otk_ustring.i"
+%include "std_string.i"
+
+%include "font.hh"
diff --git a/wrap/otk_label.i b/wrap/otk_label.i
new file mode 100644 (file)
index 0000000..ca85b89
--- /dev/null
@@ -0,0 +1,21 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_label
+
+%{
+#include "config.h"
+#include "label.hh"
+%}
+
+%include "otk_widget.i"
+%include "otk_ustring.i"
+%include "otk_font.i"
+%include "otk_renderstyle.i"
+
+namespace otk {
+
+%ignore Label::renderForeground(Surface &);
+
+}
+
+%include "label.hh"
diff --git a/wrap/otk_point.i b/wrap/otk_point.i
new file mode 100644 (file)
index 0000000..6e2fc6f
--- /dev/null
@@ -0,0 +1,10 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_point
+
+%{
+#include "config.h"
+#include "point.hh"
+%}
+
+%include "point.hh"
diff --git a/wrap/otk_property.i b/wrap/otk_property.i
new file mode 100644 (file)
index 0000000..118f8c5
--- /dev/null
@@ -0,0 +1,164 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_property
+
+%{
+#include "config.h"
+#include "property.hh"
+%}
+
+%include "otk_ustring.i"
+
+%typemap(python,in) const otk::Property::StringVect & (otk::Property::StringVect temp) {
+  if (PyList_Check($input)) {
+    int s = PyList_Size($input);
+    temp = otk::Property::StringVect(s);
+    for (int i = 0; i < s; ++i) {
+      PyObject *o = PyList_GetItem($input, i);
+      if (PyString_Check(o)) {
+        temp[i] = PyString_AsString(o);
+      } else {
+        SWIG_exception(SWIG_TypeError, "list of strings expected");
+      }
+    }
+    $1 = &temp;
+  } else {
+    SWIG_exception(SWIG_TypeError, "list expected");
+  }
+}
+
+%typemap(python,in) unsigned long value[] (unsigned long *temp) {
+  if (PyList_Check($input)) {
+    int s = PyList_Size($input);
+    temp = new unsigned long[s];
+    for (int i = 0; i < s; ++i) {
+      PyObject *o = PyList_GetItem($input, i);
+      if (PyInt_Check(o)) {
+        temp[i] = PyInt_AsLong(o);
+      } else if (PyLong_Check(o)) {
+        temp[i] = PyLong_AsLong(o);
+      } else {
+        SWIG_exception(SWIG_TypeError, "list of numbers expected");
+      }
+    }
+    $1 = temp;
+  } else {
+    SWIG_exception(SWIG_TypeError, "list expected");
+  }
+}
+
+%typemap(python,freearg) unsigned long value[] {
+  delete [] $1;
+}
+
+%typemap(python,in,numinputs=0) otk::ustring *value (otk::ustring temp) {
+  $1 = &temp;
+}
+
+%typemap(python,argout) otk::ustring *value {
+  PyObject *tuple;
+  int s;
+  if (PyTuple_Check($result)) {
+    s = PyTuple_Size($result);
+    _PyTuple_Resize(&$result, s + 1);
+    tuple = $result;
+  } else {
+    tuple = PyTuple_New(2);
+    PyTuple_SET_ITEM(tuple, 0, $result);
+    Py_INCREF($result);
+    s = 1;
+  }
+
+  PyTuple_SET_ITEM(tuple, s, PyString_FromString($1->c_str()));
+  $result = tuple;
+}
+
+%typemap(python,in,numinputs=0) unsigned long *value (unsigned long temp) {
+  $1 = &temp;
+}
+
+%typemap(python,argout) unsigned long *value {
+  PyObject *s = PyLong_FromLong(*$1);
+  $result = s;
+}
+
+%typemap(python,in) unsigned long *nelements (unsigned long temp) {
+  temp = (unsigned)PyLong_AsLong($input);
+  $1 = &temp;
+}
+
+%typemap(python,in,numinputs=0) unsigned long **value (unsigned long *temp) {
+  $1 = &temp;
+}
+
+%typemap(python,argout) (unsigned long *nelements, unsigned long **value) {
+  PyObject *tuple;
+  int s;
+  if (PyTuple_Check($result)) {
+    s = PyTuple_Size($result);
+    _PyTuple_Resize(&$result, s + 2);
+    tuple = $result;
+  } else {
+    tuple = PyTuple_New(3);
+    PyTuple_SET_ITEM(tuple, 0, $result);
+    Py_INCREF($result);
+    s = 1;
+  }
+
+  int sz = *$1;
+
+  PyTuple_SET_ITEM(tuple, s++, PyLong_FromLong(sz));
+  
+  PyObject *r = PyList_New(sz);
+  for (int i = 0; i < sz; ++i) {
+    PyList_SET_ITEM(r, i, PyLong_FromLong((*$2)[i]));
+  }
+  PyTuple_SET_ITEM(tuple, s, r);
+  $result = tuple;
+}
+
+%typemap(python,in,numinputs=0) StringVect *strings (StringVect temp) {
+  $1 = &temp;
+}
+
+%typemap(python,argout) (unsigned long *nelements, StringVect *strings) {
+  PyObject *tuple;
+  int s;
+  if (PyTuple_Check($result)) {
+    s = PyTuple_Size($result);
+    _PyTuple_Resize(&$result, s + 2);
+    tuple = $result;
+  } else {
+    tuple = PyTuple_New(3);
+    PyTuple_SET_ITEM(tuple, 0, $result);
+    Py_INCREF($result);
+    s = 1;
+  }
+
+  int sz = *$1;
+
+  PyTuple_SET_ITEM(tuple, s++, PyLong_FromLong(sz));
+  
+  PyObject *r = PyList_New(sz);
+  for (int i = 0; i < sz; ++i) {
+    PyList_SET_ITEM(r, i, PyString_FromString((*$2)[i].c_str()));
+  }
+  PyTuple_SET_ITEM(tuple, s, r);
+  $result = tuple;
+}
+
+namespace otk {
+
+%ignore Property::NUM_STRING_TYPE;
+%ignore Property::initialize();
+
+%rename(getNum) Property::get(Window, Atom, Atom, unsigned long*);
+%rename(getNums) Property::get(Window, Atom, Atom, unsigned long*,
+                               unsigned long**);
+%rename(getString) Property::get(Window, Atom, StringType, ustring*);
+%rename(getStrings) Property::get(Window, Atom, StringType, unsigned long*,
+                                  StringVect);
+
+}
+
+%include "property.hh"
diff --git a/wrap/otk_rect.i b/wrap/otk_rect.i
new file mode 100644 (file)
index 0000000..2ff54d9
--- /dev/null
@@ -0,0 +1,13 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_rect
+
+%{
+#include "config.h"
+#include "rect.hh"
+%}
+
+%include "otk_point.i"
+%include "otk_size.i"
+
+%include "rect.hh"
diff --git a/wrap/otk_rendercolor.i b/wrap/otk_rendercolor.i
new file mode 100644 (file)
index 0000000..04869ac
--- /dev/null
@@ -0,0 +1,17 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_rendercolor
+
+%{
+#include "config.h"
+#include "rendercolor.hh"
+%}
+
+namespace otk {
+
+%ignore RenderColor::initialize();
+%ignore RenderColor::destroy();
+
+}
+
+%include "rendercolor.hh"
diff --git a/wrap/otk_renderstyle.i b/wrap/otk_renderstyle.i
new file mode 100644 (file)
index 0000000..7bb4b52
--- /dev/null
@@ -0,0 +1,27 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_renderstyle
+
+%{
+#include "config.h"
+#include "renderstyle.hh"
+%}
+
+%include "std_string.i"
+%include "otk_rendercolor.i"
+%include "otk_rendertexture.i"
+%include "otk_font.i"
+
+namespace otk {
+
+%ignore StyleNotify;
+
+%ignore RenderStyle::initialize();
+%ignore RenderStyle::destroy();
+%ignore RenderStyle::registerNotify(int, StyleNotify*);
+%ignore RenderStyle::unregisterNotify(int, StyleNotify *);
+%ignore RenderStyle::~RenderStyle();
+
+}
+
+%include "renderstyle.hh"
diff --git a/wrap/otk_rendertexture.i b/wrap/otk_rendertexture.i
new file mode 100644 (file)
index 0000000..4d60f3f
--- /dev/null
@@ -0,0 +1,10 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_rendertexture
+
+%{
+#include "config.h"
+#include "rendertexture.hh"
+%}
+
+%include "rendertexture.hh"
diff --git a/wrap/otk_size.i b/wrap/otk_size.i
new file mode 100644 (file)
index 0000000..0b46844
--- /dev/null
@@ -0,0 +1,10 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_size
+
+%{
+#include "config.h"
+#include "size.hh"
+%}
+
+%include "size.hh"
diff --git a/wrap/otk_strut.i b/wrap/otk_strut.i
new file mode 100644 (file)
index 0000000..ae005e5
--- /dev/null
@@ -0,0 +1,10 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_strut
+
+%{
+#include "config.h"
+#include "strut.hh"
+%}
+
+%include "strut.hh"
diff --git a/wrap/otk_timer.i b/wrap/otk_timer.i
new file mode 100644 (file)
index 0000000..9f9eb77
--- /dev/null
@@ -0,0 +1,78 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_timer
+
+%{
+#include "config.h"
+#include "timer.hh"
+%}
+
+%{
+  struct PythonCallbackData {
+    PyObject *pyfunc;
+    void *data;
+  };
+  /*
+    Calls a python callback for the TimeoutHandler function type
+  */
+  static void PythonCallback(PythonCallbackData *calldata) {
+    PyObject *arglist, *result;
+      
+    arglist = Py_BuildValue("(O)", calldata->data);
+      
+    // call the callback
+    result = PyEval_CallObject((PyObject*)calldata->pyfunc, arglist);
+    if (!result || PyErr_Occurred()) {
+      // an exception occured in the script, display it
+      PyErr_Print();
+    }
+      
+    Py_XDECREF(result);
+    Py_DECREF(arglist);
+  }
+%}
+
+// Grab a Python function object as a Python object.
+%typemap(python,in) PyObject *func {
+  if (!PyCallable_Check($input)) {
+    PyErr_SetString(PyExc_TypeError, "Excepting a callable object.");
+    return NULL;
+  }
+  $1 = $input;
+}
+
+namespace otk {
+
+%ignore Timer::Timer(long, TimeoutHandler, void*);
+%ignore Timer::operator delete(void*);
+%ignore Timer::initialize();
+%ignore Timer::destroy();
+%ignore Timer::dispatchTimers(bool);
+%ignore Timer::nearestTimeout(struct timeval&);
+
+%extend Timer {
+  Timer(long, PyObject*, PyObject*);
+
+  // if you don't call stop() before the object disappears, the timer will
+  // keep firing forever
+  void stop() {
+    delete self;
+  }
+}
+
+}
+
+%{
+  static otk::Timer *new_otk_Timer(long delay,
+                                   PyObject *func, PyObject *data) {
+    PythonCallbackData *d = new PythonCallbackData;
+    d->pyfunc = func;
+    d->data = data;
+    return new otk::Timer(delay,
+                          (otk::Timer::TimeoutHandler)&PythonCallback, d);
+    // the PythonCallbackData is leaked.. XXX
+  }
+%}
+
+%include "timer.hh"
similarity index 90%
rename from wrap/ustring.i
rename to wrap/otk_ustring.i
index 06addfe26a7d2172d8fe24a7b0cbc0174f43fde9..fbd0cbfacd791de08dda717643bb9673c038de56 100644 (file)
@@ -1,11 +1,12 @@
-// SWIG typemaps for otk::ustring
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_rendertexture
 
 %{
 #include "otk/ustring.hh"
 %}
 
 namespace otk {
-
     class ustring;
 
     /* Overloading check */
@@ -36,5 +37,4 @@ namespace otk {
     %typemap(out) const ustring & {
         $result = PyString_FromString($1->c_str());
     }
-
 }
diff --git a/wrap/otk_widget.i b/wrap/otk_widget.i
new file mode 100644 (file)
index 0000000..a9f06b5
--- /dev/null
@@ -0,0 +1,35 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
+
+%module otk_widget
+
+%{
+#include "config.h"
+#include "widget.hh"
+%}
+
+%include "otk_rendercolor.i"
+
+%typemap(python,out) const std::list<Widget*>& {
+  std::list<Widget*> *v = $1;
+  unsigned int s = v->size();
+  PyObject *l = PyList_New(s);
+
+  std::list<Widget*>::const_iterator it = v->begin(), end = v->end();
+  for (unsigned int i = 0; i < s; ++i, ++it) {
+    PyObject *pdata = SWIG_NewPointerObj((void*)*it,SWIGTYPE_p_otk__Widget,0);
+    PyList_SET_ITEM(l, i, pdata);
+  }
+  $result = l;
+}
+
+namespace otk {
+
+%ignore Widget::exposeHandler(const XExposeEvent &);
+%ignore Widget::configureHandler(const XConfigureEvent &);
+%ignore Widget::styleChanged(const RenderStyle &);
+
+}
+
+%import "../otk/eventhandler.hh"
+%import "../otk/renderstyle.hh"
+%include "widget.hh"
This page took 0.049819 seconds and 4 git commands to generate.