diff options
| author | Johan Dahlin <johan@src.gnome.org> | 2006-07-25 21:30:22 +0000 |
|---|---|---|
| committer | Johan Dahlin <johan@src.gnome.org> | 2006-07-25 21:30:22 +0000 |
| commit | 9b642f26cf275d1b3c1418c87e394526a66da3a6 (patch) | |
| tree | 4f8af8569c6eea4e75f86d4b22cbd5116a964b88 | |
| parent | e3bba3b12b7612193bcae379140c3793f0d671b6 (diff) | |
| download | pygobject-9b642f26cf275d1b3c1418c87e394526a66da3a6.tar.gz pygobject-9b642f26cf275d1b3c1418c87e394526a66da3a6.tar.xz pygobject-9b642f26cf275d1b3c1418c87e394526a66da3a6.zip | |
Add a macro to easily check the installed pygobject version.
* gobject/pygobject.h (init_pygobject_check): Add a macro to easily
check the installed pygobject version.
| -rw-r--r-- | ChangeLog | 3 | ||||
| -rw-r--r-- | gobject/pygobject.h | 24 |
2 files changed, 27 insertions, 0 deletions
@@ -1,5 +1,8 @@ 2006-07-25 Johan Dahlin <jdahlin@async.com.br> + * gobject/pygobject.h (init_pygobject_check): Add a macro to easily + check the installed pygobject version. + * gobject/pygflags.c (pyg_flags_add) * gobject/pygenum.c (pyg_enum_add): Duplicate the string before sending it to python. Fixes GCC warnings. diff --git a/gobject/pygobject.h b/gobject/pygobject.h index 3e928c7..6d82d34 100644 --- a/gobject/pygobject.h +++ b/gobject/pygobject.h @@ -293,6 +293,30 @@ struct _PyGObject_Functions *_PyGObject_API; } \ } G_STMT_END +#define init_pygobject_check(major, minor, micro) G_STMT_START { \ + init_pygobject(); \ + PyObject *gobject = PyImport_ImportModule("gobject"); \ + version = PyDict_GetItemString(mdict, "pygobject_version"); \ + if (!version) \ + version = PyDict_GetItemString(mdict, "pygtk_version"); \ + if (!version) { \ + PyErr_SetString(PyExc_ImportError, \ + "PyGObject version too old"); \ + return; \ + } \ + if (!PyArg_ParseTuple(version, "iii", \ + &found_major, &found_minor, &found_micro)) \ + return; \ + if (major > found_major || minor > found_minor || \ + micro > found_micro) { \ + PyErr_Format(PyExc_ImportError, \ + "PyGObject version too old, %d.%d.%d is required, " \ + "found %d.%d.%d.", major, minor, micro, \ + found_major, found_minor, found_micro); \ + return; \ + } \ +} G_STMT_END + #endif /* !_INSIDE_PYGOBJECT_ */ G_END_DECLS |
