Add initial support for defect #12:
[pywebkitgtk.git] / webkitmodule.c
blob88c58e9acc61d3dcadf1e5d984a830c1bf382e08
1 /*
2 * Copyright (C) 2006-2007, Red Hat, Inc.
3 * Copyright (C) 2007-2008 Jan Michael Alonzo <jmalonzo@unpluggable.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 #include <Python.h>
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
25 /* include this first, before NO_IMPORT_PYGOBJECT is defined */
26 #include <pygobject.h>
27 #include <pygtk/pygtk.h>
29 extern PyMethodDef pywebkit_functions[];
31 void pywebkit_register_classes (PyObject *d);
33 #ifdef HAVE_GJS
34 extern PyMethodDef pygjs_functions[];
35 void pygjs_register_classes (PyObject *d);
36 #endif
38 DL_EXPORT(void)
39 initwebkit(void)
41 PyObject *m, *d;
43 if (!pygobject_init(-1, -1, -1)) {
44 PyErr_Print();
45 Py_FatalError ("can't initialise module gobject");
48 init_pygtk();
50 /* webkit module */
51 m = Py_InitModule ("webkit", pywebkit_functions);
52 d = PyModule_GetDict (m);
53 pywebkit_register_classes (d);
55 #ifdef HAVE_GJS
56 /* webkit.gjs module */
57 m = Py_InitModule ("webkit.gjs", pygjs_functions);
58 d = PyModule_GetDict(m);
59 pygjs_register_classes (d);
60 #endif
62 if (PyErr_Occurred ()) {
63 PyErr_Print();
64 Py_FatalError ("can't initialise module webkit.gjs");