aboutsummaryrefslogtreecommitdiffstats
path: root/src/epiphany.override
blob: 439ca3c2ea25755e9b79d185eba2be2816afda4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
/* -*- Mode: C; c-basic-offset: 4 -*-
 * Copyright (C) 2005 Adam Hooper <adamh@cvs.gnome.org>
 * Copyright (C) 2005 Christian Persch <chpe@cvs.gnome.org>
 * Copyright (C) 2005 Crispin Flowerday <gnome@flowerday.cx>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */
%%
headers
#include <Python.h>               
#include <pygobject.h>
#include <pygtk/pygtk.h>
#include "ephy-bookmarks.h"
#include "ephy-bookmarks-type-builtins.h"
#include "ephy-command-manager.h"
#include "ephy-cookie-manager.h"
#include "ephy-dialog.h"
#include "ephy-embed-event.h"
#include "ephy-embed-factory.h"
#include "ephy-embed.h"
#include "ephy-embed-persist.h"
#include "ephy-embed-prefs.h"
#include "ephy-embed-shell.h"
#include "ephy-embed-single.h"
#include "ephy-embed-type-builtins.h"
#include "ephy-extension.h"
#include "ephy-extensions-manager.h"
#include "ephy-history.h"
#include "ephy-lib-type-builtins.h"
#include "ephy-node-db.h"
#include "ephy-node.h"
#include "ephy-notebook.h"
#include "ephy-password-manager.h"
#include "ephy-permission-manager.h"
#include "ephy-session.h"
#include "ephy-shell.h"
#include "ephy-state.h"
#include "ephy-statusbar.h"
#include "ephy-tab.h"
#include "ephy-type-builtins.h"
#include "ephy-window.h"
#include "ephy-link.h"
#include "ephy-link-action.h"
#include "egg-toolbars-model.h"
#include "egg-editable-toolbar.h"
#include "ephy-toolbars-model.h"
#include "ephy-toolbar.h"
#include "ephy-bookmarksbar-model.h"
#include "ephy-bookmarksbar.h"
#include "ephy-search-entry.h"
#include "ephy-spinner.h"
#include "ephy-location-action.h"
#include "ephy-favicon-cache.h"
#include "eggtypebuiltins.h"

void pyepiphany_register_classes (PyObject *d); 
void pyepiphany_add_constants (PyObject *module, const gchar *strip_prefix);

static PyObject *
_helper_wrap_string_glist (GList *list)
{
    GList *tmp;
    PyObject *py_list;

    if ((py_list = PyList_New(0)) == NULL) {
        g_list_foreach(list, (GFunc)g_free, NULL);
        g_list_free(list);
        return NULL;
    }
    for (tmp = list; tmp != NULL; tmp = tmp->next) {
        PyObject *str_obj =  PyString_FromString ((char*)tmp->data);

        if (str_obj == NULL) {
            g_list_foreach(list, (GFunc)g_free, NULL);
            g_list_free(list);
            Py_DECREF(py_list);
            return NULL;
        }
        PyList_Append(py_list, str_obj);
        Py_DECREF(str_obj);
    }
    g_list_foreach(list, (GFunc)g_free, NULL);
    g_list_free(list);
    return py_list;
}

static PyObject *
_helper_wrap_gobject_glist (GList *list)
{
    PyObject *py_list;
    GList *tmp;

    if ((py_list = PyList_New(0)) == NULL) {
        return NULL;
    }
    for (tmp = list; tmp != NULL; tmp = tmp->next) {
        PyObject *py_obj = pygobject_new(G_OBJECT(tmp->data));

        if (py_obj == NULL) {
            Py_DECREF(py_list);
            return NULL;
        }
        PyList_Append(py_list, py_obj);
        Py_DECREF(py_obj);
    }
    return py_list;
}

static void
free_boxed_type (gpointer data, gpointer type)
{
    g_boxed_free (GPOINTER_TO_INT(type), data);
}


static PyObject *
_helper_wrap_boxed_glist (GType type, GList *list)
{
    GList *tmp;
    PyObject *py_list;

    if ((py_list = PyList_New(0)) == NULL) {
        g_list_foreach(list, free_boxed_type, GINT_TO_POINTER(type));
        g_list_free(list);
        return NULL;
    }
    for (tmp = list; tmp != NULL; tmp = tmp->next) {
        PyObject *obj = pyg_boxed_new (type, tmp->data, FALSE, TRUE);
        PyList_Append(py_list, obj);
        Py_DECREF(obj);
    }
    g_list_free(list);
    return py_list;
}

static PyObject *
_helper_wrap_boxed_gptrarray (GType type, GPtrArray *list, gboolean own_ref, gboolean dealloc)
{
    PyObject *py_list;
    int i;

    if ((py_list = PyList_New(0)) == NULL) {
        return NULL;
    }
    for( i = 0; i < list->len; i++ ) {
        PyObject *obj = pyg_boxed_new (type, g_ptr_array_index(list,i), FALSE, own_ref);
        PyList_Append(py_list, obj);
        Py_DECREF(obj);
    }
    if (dealloc) g_ptr_array_free (list, TRUE);
    return py_list;
}

%%
modulename epiphany                     
%%
import gtk.Widget as PyGtkWidget_Type
import gtk.Bin as PyGtkBin_Type
import gtk.VBox as PyGtkVBox_Type
import gtk.Statusbar as PyGtkStatusbar_Type
import gtk.Notebook as PyGtkNotebook_Type
import gtk.Toolbar as PyGtkToolbar_Type
import gtk.Entry as PyGtkEntry_Type
import gtk.EventBox as PyGtkEventBox_Type
import gtk.Window as PyGtkWindow_Type
import gtk.Action as PyGtkAction_Type
import gtk.UIManager as PyGtkUIManager_Type
import gobject.GObject as PyGObject_Type 
%%
ignore-glob
  *_get_type
%%
ignore
  ephy_embed_event_get_dom_event
  ephy_tab_for_embed
  ephy_shell_error_quark
  ephy_shell_startup
  ephy_shell_get_dbus_service
%%
override ephy_tab_get_size noargs
static PyObject *
_wrap_ephy_tab_get_size(PyGObject *self)
{
    gint width;
    gint height;

    ephy_tab_get_size(EPHY_TAB(self->obj), &width, &height);
    return Py_BuildValue("(ii)", width, height);
}
%%
override ephy_embed_event_get_coords noargs
static PyObject *
_wrap_ephy_embed_event_get_coords(PyGObject *self)
{
    guint x, y;

    ephy_embed_event_get_coords (EPHY_EMBED_EVENT(self->obj), &x, &y);
    return Py_BuildValue("(ll)", x, y);
}
%%
override ephy_window_get_tabs noargs
static PyObject *
_wrap_ephy_window_get_tabs(PyGObject *self)
{
    GList *list;
    PyObject *py_list;

    list = ephy_window_get_tabs(EPHY_WINDOW (self->obj));

    py_list = _helper_wrap_gobject_glist (list);

    g_list_free(list);

    return py_list;
}
%%
override ephy_embed_shistory_get_nth kwargs
static PyObject*
_wrap_ephy_embed_shistory_get_nth (PyGObject *self,
                                   PyObject *args, PyObject *kwargs)
{
    static char *kwlist[] = {"nth", "is_relative", NULL}; 
    int nth, is_relative;
    char *url, *title;
    PyObject *py_url, *py_title;
    PyObject *py_list;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,    
                                     "ii:EphyEmbed.shistory_get_nth", kwlist,
                                     &nth, &is_relative)) {
        return NULL;
    }

    ephy_embed_shistory_get_nth (EPHY_EMBED (self->obj), nth, is_relative,
                                 &url, &title);

    if (!url || !title) {
        return Py_None;
    }

    if ((py_list = PyList_New(0)) == NULL) {
        g_free (url);
        g_free (title);
        return NULL;
    }

    py_url   = PyString_FromString (url);
    g_free (url);
    if (!py_url) {
        g_free (title);
        Py_DECREF(py_list);
        return NULL;
    }

    PyList_Append(py_list, py_url);
    Py_DECREF(py_url);

    py_title = PyString_FromString (title);
    g_free (title);

    if (!py_title) {
        Py_DECREF(py_list);
        return NULL;
    }

    PyList_Append(py_list, py_title);
    Py_DECREF(py_title);
    return py_list;
}
%%
override ephy_embed_get_go_up_list noargs
static PyObject*
_wrap_ephy_embed_get_go_up_list (PyGObject *self)
{
    GSList *list, *tmp;
    PyObject *py_list;

    list = ephy_embed_get_go_up_list (EPHY_EMBED (self->obj));

    if ((py_list = PyList_New(0)) == NULL) {
        g_slist_foreach(list, (GFunc)g_free, NULL);
        g_slist_free(list);
        return NULL;
    }
    for (tmp = list; tmp != NULL; tmp = tmp->next) {
        PyObject *str_obj =  PyString_FromString ((char*)tmp->data);

        if (str_obj == NULL) {
            g_slist_foreach(list, (GFunc)g_free, NULL);
            g_slist_free(list);
            Py_DECREF(py_list);
            return NULL;
        }
        PyList_Append(py_list, str_obj);
        Py_DECREF(str_obj);
    }
    g_slist_foreach(list, (GFunc)g_free, NULL);
    g_slist_free(list);
    return py_list;
}
%%
override ephy_embed_single_get_printer_list noargs
static PyObject*
_wrap_ephy_embed_single_get_printer_list (PyGObject *self)
{
    GList *list;

    list = ephy_embed_single_get_printer_list (EPHY_EMBED_SINGLE (self->obj));

    return _helper_wrap_string_glist (list);
}
%%
override ephy_embed_single_get_font_list kwargs
static PyObject*
_wrap_ephy_embed_single_get_font_list (PyGObject *self,
                                       PyObject *args, PyObject *kwargs)
{
    static char *kwlist[] = {"font_group", NULL}; 
    char *font_group;
    GList *list;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs, 
                                     "s:EphyEmbedSingle.get_font_list", kwlist, &font_group))
        return NULL;


    list = ephy_embed_single_get_font_list (EPHY_EMBED_SINGLE (self->obj), font_group);

    return _helper_wrap_string_glist (list);
}
%%
override ephy_embed_event_get_property kwargs
static PyObject*
_wrap_ephy_embed_event_get_property (PyGObject *self,
                                     PyObject *args, PyObject *kwargs)
{
    static char *kwlist[] = {"property", NULL}; 
    char *prop;
    const GValue *value;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs, 
                                     "s:EphyEmbedEvent.get_property", kwlist, &prop))
        return NULL;

    ephy_embed_event_get_property (EPHY_EMBED_EVENT (self->obj), prop, &value);

    return pyg_value_as_pyobject(value, TRUE);
}
%%
override ephy_password_manager_list_passwords noargs
static PyObject*
_wrap_ephy_password_manager_list_passwords (PyGObject *self)
{
    GList *list;

    list = ephy_password_manager_list_passwords (EPHY_PASSWORD_MANAGER (self->obj));

    return _helper_wrap_boxed_glist (EPHY_TYPE_PASSWORD_INFO, list);
}
%%
override ephy_cookie_manager_list_cookies noargs
static PyObject *
_wrap_ephy_cookie_manager_list_cookies(PyGObject *self)
{
    GList *list;

    list = ephy_cookie_manager_list_cookies(EPHY_COOKIE_MANAGER (self->obj));

    return _helper_wrap_boxed_glist (EPHY_TYPE_COOKIE, list);
}
%%
override ephy_node_get_children noargs
static PyObject *
_wrap_ephy_node_get_children (PyGObject *self)
{
    GPtrArray *list = ephy_node_get_children ((EphyNode *) (self->obj));

    return _helper_wrap_boxed_gptrarray (EPHY_TYPE_NODE, list, FALSE, FALSE);
}
%%
override ephy_session_get_windows noargs
static PyObject *
_wrap_ephy_session_get_windows (PyGObject *self)
{    
    GList *list;
    PyObject *py_list;

    list = ephy_session_get_windows (EPHY_SESSION (self->obj));

    py_list = _helper_wrap_gobject_glist (list);

    g_list_free(list);

    return py_list;
}