split up the otk stuff into separate files.
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
This commit is contained in:
parent
1741bddecb
commit
4534151926
23 changed files with 530 additions and 79 deletions
|
@ -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 $@ $<
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
|
|
@ -31,4 +31,5 @@ namespace ob {
|
|||
|
||||
}
|
||||
|
||||
%import "../otk/eventdispatcher.hh"
|
||||
%include "openbox.hh"
|
||||
|
|
|
@ -10,8 +10,23 @@
|
|||
%}
|
||||
|
||||
%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();
|
||||
|
@ -25,14 +40,14 @@
|
|||
$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;
|
||||
|
|
79
wrap/otk.i
79
wrap/otk.i
|
@ -2,79 +2,36 @@
|
|||
|
||||
%module otk
|
||||
|
||||
%{
|
||||
#include "otk.hh"
|
||||
%}
|
||||
%import "eventhandler.hh"
|
||||
%import "eventdispatcher.hh"
|
||||
|
||||
%include "stl.i"
|
||||
%include "typemaps.i"
|
||||
//%include std_list.i
|
||||
%include "ustring.i"
|
||||
%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):
|
||||
|
|
13
wrap/otk_application.i
Normal file
13
wrap/otk_application.i
Normal file
|
@ -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"
|
20
wrap/otk_appwidget.i
Normal file
20
wrap/otk_appwidget.i
Normal file
|
@ -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"
|
22
wrap/otk_button.i
Normal file
22
wrap/otk_button.i
Normal file
|
@ -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"
|
13
wrap/otk_font.i
Normal file
13
wrap/otk_font.i
Normal file
|
@ -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"
|
21
wrap/otk_label.i
Normal file
21
wrap/otk_label.i
Normal file
|
@ -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"
|
10
wrap/otk_point.i
Normal file
10
wrap/otk_point.i
Normal file
|
@ -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"
|
164
wrap/otk_property.i
Normal file
164
wrap/otk_property.i
Normal file
|
@ -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"
|
13
wrap/otk_rect.i
Normal file
13
wrap/otk_rect.i
Normal file
|
@ -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"
|
17
wrap/otk_rendercolor.i
Normal file
17
wrap/otk_rendercolor.i
Normal file
|
@ -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"
|
27
wrap/otk_renderstyle.i
Normal file
27
wrap/otk_renderstyle.i
Normal file
|
@ -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"
|
10
wrap/otk_rendertexture.i
Normal file
10
wrap/otk_rendertexture.i
Normal file
|
@ -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"
|
10
wrap/otk_size.i
Normal file
10
wrap/otk_size.i
Normal file
|
@ -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"
|
10
wrap/otk_strut.i
Normal file
10
wrap/otk_strut.i
Normal file
|
@ -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"
|
78
wrap/otk_timer.i
Normal file
78
wrap/otk_timer.i
Normal file
|
@ -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"
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
35
wrap/otk_widget.i
Normal file
35
wrap/otk_widget.i
Normal file
|
@ -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"
|
Loading…
Reference in a new issue