Add test for NetworkRequest
[pywebkitgtk.git] / webkit / webkit.override
blobb5cb5dd0467efb483210048f9da316540140d901
1 /* -*- Mode: C; c-basic-offset: 4 -*- */
2 /*
3  Copyright (C) 2006, Red Hat, Inc.
4  Copyright (C) 2007, One Laptop Per Child
5  Copyright (C) 2009, Jan Michael Alonzo <jmalonzo@gmail.com>
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  GNU General Public License for more details.
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 headers
24 #include <Python.h>
25 #define NO_IMPORT_PYGOBJECT
26 #define NO_IMPORT_PYGTK
27 #include <pygtk/pygtk.h>
28 #include <pygobject.h>
29 #include <webkit/webkit.h>
30 #include <JavaScriptCore/JSContextRef.h>
32 #include "javascriptcore/javascriptcore_types.h"
34 body
35 static PyObject *
36 _helper_wrap_gobject_glist (GList *list)
38     PyObject *py_list;
39     GList *tmp;
41     if ((py_list = PyList_New(0)) == NULL) {
42         return NULL;
43     }
44     for (tmp = list; tmp != NULL; tmp = tmp->next) {
45         PyObject *py_obj = pygobject_new(G_OBJECT(tmp->data));
47         if (py_obj == NULL) {
48             Py_DECREF(py_list);
49             return NULL;
50         }
51         
52         PyList_Append(py_list, py_obj);
53         Py_DECREF(py_obj);
54     }
56     return py_list;
59 modulename webkit
61 import gtk.Container as PyGtkContainer_Type
62 import gobject.GObject as PyGObject_Type
63 import gtk.PrintOperation as PyGtkPrintOperation_Type
65 ignore-glob
66   *_get_type
67   _*
69 ignore
70   webkit_network_request_get_type
71   webkit_web_back_forward_list_get_type
72   webkit_web_frame_get_type
73   webkit_web_history_item_get_type
74   webkit_web_inspector_get_type
75   webkit_web_view_get_type
76   webkit_web_settings_get_type
77   webkit_download_get_type
78   webkit_network_response_get_type
80 override webkit_web_frame_get_global_context noargs
81 static PyObject *
82 _wrap_webkit_web_frame_get_global_context (PyGObject *self)
84     JSGlobalContextRef ref;
86     ref = webkit_web_frame_get_global_context (WEBKIT_WEB_FRAME (self->obj));
88     return wrap_JSGlobalContextRef (ref);
91 override webkit_web_back_forward_list_get_back_list_with_limit
92 static PyObject *
93 _wrap_webkit_web_back_forward_list_get_back_list_with_limit (PyGObject *self, PyObject *args, PyObject *kwargs)
95     static char *kwlist[] = { "limit", NULL };
97     GList *list;
98     int limit;
99     
100     if (! PyArg_ParseTupleAndKeywords (args, kwargs, "i:WebBackForwardList.get_back_list_with_limit", kwlist, &limit))
101         return NULL;
102     
103     list = webkit_web_back_forward_list_get_back_list_with_limit(WEBKIT_WEB_BACK_FORWARD_LIST(self->obj),
104                                                                  limit);
105     return _helper_wrap_gobject_glist (list);
108 override webkit_web_back_forward_list_get_forward_list_with_limit
109 static PyObject *
110 _wrap_webkit_web_back_forward_list_get_forward_list_with_limit (PyGObject *self, PyObject *args, PyObject *kwargs)
112     static char *kwlist[] = { "limit", NULL };
114     GList *list;
115     int limit;
116     
117     if (! PyArg_ParseTupleAndKeywords (args, kwargs, "i:WebBackForwardList.get_forward_list_with_limit", kwlist, &limit))
118         return NULL;
120     list = webkit_web_back_forward_list_get_forward_list_with_limit(WEBKIT_WEB_BACK_FORWARD_LIST(self->obj),
121                                                                     limit);
122     return _helper_wrap_gobject_glist (list);
125 override webkit_web_navigation_action_set_reason kwargs
126 static PyObject *
127 _wrap_webkit_web_navigation_action_set_reason(PyGObject *self, PyObject *args, PyObject *kwargs)
129     static char *kwlist[] = { "reason", NULL };
130     PyObject *py_reason;
131     WebKitWebNavigationReason reason = 0;
133     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:WebKitWebNavigationAction.set_reason",
134                                      kwlist, &py_reason))
135         return NULL;
137     pyg_enum_get_value(WEBKIT_TYPE_WEB_NAVIGATION_REASON, py_reason, (gint*) &reason);
139     webkit_web_navigation_action_set_reason(WEBKIT_WEB_NAVIGATION_ACTION(self->obj), reason);
141     Py_INCREF(Py_None);
142     return Py_None;
145 override webkit_web_navigation_action_get_reason noargs
146 static PyObject *
147 _wrap_webkit_web_navigation_action_get_reason(PyGObject *self)
149     WebKitWebNavigationReason reason;
151     reason = webkit_web_navigation_action_get_reason(WEBKIT_WEB_NAVIGATION_ACTION(self->obj));
153     return Py_BuildValue("N", pyg_enum_from_gtype(WEBKIT_TYPE_WEB_NAVIGATION_REASON, reason));
156 override webkit_download_get_status noargs
157 static PyObject *
158 _wrap_webkit_download_get_status(PyGObject *self)
160     WebKitDownloadStatus status;
162     status = webkit_download_get_status(WEBKIT_DOWNLOAD(self->obj));
164     return Py_BuildValue("N", pyg_enum_from_gtype(WEBKIT_TYPE_DOWNLOAD_STATUS, status));
167 new-constructor WEBKIT_TYPE_HISTORY_ITEM
169 override webkit_web_history_item_new kwargs
170 static int
171 _wrap_webkit_web_history_item_new(PyGObject *self, PyObject *args, PyObject *kwargs)
173     static char *kwlist[] = {"uri", "title", NULL};
174     gchar *uri = NULL;
175     gchar *title = NULL;
177     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|zz:WebHistoryItem.__init__",
178                                     kwlist, &uri, &title))
179         return -1;
182     if (uri)
183         self->obj = (GObject *)webkit_web_history_item_new_with_data(uri, title);
184     else
185         self->obj = (GObject *)webkit_web_history_item_new();
187     if (!self->obj) {
188         PyErr_SetString(PyExc_RuntimeError,
189                         "count not create WebHistoryItem object");
190         return -1;
191     }
192     pygobject_register_wrapper((PyObject *)self);
193     return 0;
196 new-constructor WEBKIT_TYPE_NETWORK_RESPONSE
198 override webkit_network_response_new kwargs
199 static int
200 _wrap_webkit_network_response_new(PyGObject *self, PyObject* args, PyObject *kwargs)
202     static char *kwlist[] = {"uri", NULL };
203     gchar* uri = NULL;
205     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|z:NetworkResponse.__init__",
206                                      kwlist, &uri))
207         return -1;
209     if (uri)
210         self->obj = G_OBJECT(webkit_network_response_new(uri));
211     else
212         self->obj = G_OBJECT(webkit_network_response_new("about:blank"));
214     if (!self->obj) {
215         PyErr_SetString(PyExc_RuntimeError,
216                         "cannot create NetworkResponse object");
217         return -1;
218     }
219     pygobject_register_wrapper((PyObject *)self);
220     return 0;
223 new-constructor WEBKIT_TYPE_NETWORK_REQUEST
225 override webkit_network_request_new kwargs
226 static int
227 _wrap_webkit_network_request_new(PyGObject *self, PyObject* args, PyObject *kwargs)
229     static char *kwlist[] = {"uri", NULL };
230     gchar* uri = NULL;
232     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|z:NetworkRequest.__init__",
233                                      kwlist, &uri))
234         return -1;
236     if (uri)
237         self->obj = G_OBJECT(webkit_network_request_new(uri));
238     else
239         self->obj = G_OBJECT(webkit_network_request_new("about:blank"));
241     if (!self->obj) {
242         PyErr_SetString(PyExc_RuntimeError,
243                         "cannot create NetworkRequest object");
244         return -1;
245     }
246     pygobject_register_wrapper((PyObject *)self);
247     return 0;