1 /* -*- Mode: C; c-basic-offset: 4 -*- */
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
25 #define NO_IMPORT_PYGOBJECT
26 #include <pygtk/pygtk.h>
27 #include <pygobject.h>
28 #include <webkit/webkit.h>
29 #include <JavaScriptCore/JSContextRef.h>
31 #include "javascriptcore/javascriptcore_types.h"
35 _helper_wrap_gobject_glist (GList *list)
40 if ((py_list = PyList_New(0)) == NULL) {
43 for (tmp = list; tmp != NULL; tmp = tmp->next) {
44 PyObject *py_obj = pygobject_new(G_OBJECT(tmp->data));
51 PyList_Append(py_list, py_obj);
60 import gtk.Container as PyGtkContainer_Type
61 import gobject.GObject as PyGObject_Type
68 webkit_network_request_get_type
69 webkit_web_back_forward_list_get_type
70 webkit_web_frame_get_type
71 webkit_web_history_item_get_type
72 webkit_web_inspector_get_type
73 webkit_web_view_get_type
74 webkit_web_settings_get_type
75 webkit_download_get_type
77 override webkit_web_frame_get_global_context noargs
79 _wrap_webkit_web_frame_get_global_context (PyGObject *self)
81 JSGlobalContextRef ref;
83 ref = webkit_web_frame_get_global_context (WEBKIT_WEB_FRAME (self->obj));
85 return wrap_JSGlobalContextRef (ref);
88 override webkit_web_back_forward_list_get_back_list_with_limit
90 _wrap_webkit_web_back_forward_list_get_back_list_with_limit (PyGObject *self, PyObject *args, PyObject *kwargs)
92 static char *kwlist[] = { "limit", NULL };
97 if (! PyArg_ParseTupleAndKeywords (args, kwargs, "i:WebBackForwardList.get_back_list_with_limit", kwlist, &limit))
100 list = webkit_web_back_forward_list_get_back_list_with_limit(WEBKIT_WEB_BACK_FORWARD_LIST(self->obj),
102 return _helper_wrap_gobject_glist (list);
105 override webkit_web_back_forward_list_get_forward_list_with_limit
107 _wrap_webkit_web_back_forward_list_get_forward_list_with_limit (PyGObject *self, PyObject *args, PyObject *kwargs)
109 static char *kwlist[] = { "limit", NULL };
114 if (! PyArg_ParseTupleAndKeywords (args, kwargs, "i:WebBackForwardList.get_forward_list_with_limit", kwlist, &limit))
117 list = webkit_web_back_forward_list_get_forward_list_with_limit(WEBKIT_WEB_BACK_FORWARD_LIST(self->obj),
119 return _helper_wrap_gobject_glist (list);
122 override webkit_web_navigation_action_set_reason kwargs
124 _wrap_webkit_web_navigation_action_set_reason(PyGObject *self, PyObject *args, PyObject *kwargs)
126 static char *kwlist[] = { "reason", NULL };
128 WebKitWebNavigationReason reason = 0;
130 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:WebKitWebNavigationAction.set_reason",
134 pyg_enum_get_value(WEBKIT_TYPE_WEB_NAVIGATION_REASON, py_reason, (gint*) &reason);
136 webkit_web_navigation_action_set_reason(WEBKIT_WEB_NAVIGATION_ACTION(self->obj), reason);
142 override webkit_web_navigation_action_get_reason noargs
144 _wrap_webkit_web_navigation_action_get_reason(PyGObject *self)
146 WebKitWebNavigationReason reason;
148 reason = webkit_web_navigation_action_get_reason(WEBKIT_WEB_NAVIGATION_ACTION(self->obj));
150 return Py_BuildValue("N", pyg_enum_from_gtype(WEBKIT_TYPE_WEB_NAVIGATION_REASON, reason));
153 override webkit_download_get_status noargs
155 _wrap_webkit_download_get_status(PyGObject *self)
157 WebKitDownloadStatus status;
159 status = webkit_download_get_status(WEBKIT_DOWNLOAD(self->obj));
161 return Py_BuildValue("N", pyg_enum_from_gtype(WEBKIT_TYPE_DOWNLOAD_STATUS, status));
164 new-constructor WEBKIT_TYPE_HISTORY_ITEM
166 override webkit_web_history_item_new kwargs
168 _wrap_webkit_web_history_item_new(PyGObject *self, PyObject *args, PyObject *kwargs)
170 static char *kwlist[] = {"uri", "title", NULL};
174 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|zz:WebHistoryItem.__init__",
175 kwlist, &uri, &title))
180 self->obj = (GObject *)webkit_web_history_item_new_with_data(uri, title);
182 self->obj = (GObject *)webkit_web_history_item_new();
185 PyErr_SetString(PyExc_RuntimeError,
186 "count not create WebHistoryItem object");
189 pygobject_register_wrapper((PyObject *)self);