File: gtksourceview2.override

package info (click to toggle)
pygtksourceview 2.2.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,824 kB
  • ctags: 54
  • sloc: sh: 9,128; xml: 4,454; python: 299; makefile: 171; ansic: 26
file content (438 lines) | stat: -rw-r--r-- 12,548 bytes parent folder | download
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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
/* -*- C -*- */
%%
headers
#define NO_IMPORT_PYGOBJECT
#include "pygobject.h"

#include <gtksourceview/gtksourceview.h>
#include <gtksourceview/gtksourceview-typebuiltins.h>
#include <gtksourceview/gtksourcelanguagemanager.h>
#include <gtksourceview/gtksourcestyleschememanager.h>
#include <gtksourceview/gtksourcestyle.h>
#include <gtksourceview/gtksourcestylescheme.h>
#include <gtksourceview/gtksourcelanguage.h>
#include <gtksourceview/gtksourceiter.h>
#include <gtksourceview/gtksourcebuffer.h>
#include <gtksourceview/gtksourceprintcompositor.h>

static PyObject *
gslist_to_pylist_objs (const GSList *source)
{
    const GSList *iter;
    PyObject *dest = PyList_New (0);
    for (iter = source; iter != NULL; iter = iter->next)
    {
        PyObject *item = pygobject_new ((GObject *)iter->data);
        PyList_Append (dest, item);
        Py_DECREF (item);
    }
    return dest;
}

static PyObject *
strv_to_pylist (char **strv)
{
    gsize len, i;
    PyObject *list;

    len = strv ? g_strv_length (strv) : 0;
    list = PyList_New (len);

    for (i = 0; i < len; i++)
        PyList_SetItem (list, i, PyString_FromString (strv[i]));

    return list;
}

static gboolean
pylist_to_strv (PyObject *list,
                char   ***strvp)
{
    int i, len;
    char **ret;

    *strvp = NULL;

    if (list == Py_None)
        return TRUE;

    if (!PySequence_Check (list))
    {
        PyErr_Format (PyExc_TypeError, "argument must be a list or tuple of strings");
        return FALSE;
    }

    if ((len = PySequence_Size (list)) < 0)
        return FALSE;

    ret = g_new (char*, len + 1);
    for (i = 0; i <= len; ++i)
        ret[i] = NULL;

    for (i = 0; i < len; ++i)
    {
        PyObject *item = PySequence_GetItem (list, i);

        if (!item)
        {
            g_strfreev (ret);
            return FALSE;
        }

        if (!PyString_Check (item))
        {
            Py_DECREF (item);
            g_strfreev (ret);
            PyErr_Format (PyExc_TypeError, "argument must be a list of strings");
            return FALSE;
        }

        ret[i] = g_strdup (PyString_AsString (item));
        Py_DECREF (item);
    }

    *strvp = ret;
    return TRUE;
}

%%
modulename gtksourceview2

%%
import gobject.GObject as PyGObject_Type
import gtk.gdk.Pixbuf as PyGdkPixbuf_Type
import gtk.TextTagTable as PyGtkTextTagTable_Type
import gtk.TextView as PyGtkTextView_Type
import gtk.TextBuffer as PyGtkTextBuffer_Type
import gtk.TextMark as PyGtkTextMark_Type
import gtk.PrintContext as PyGtkPrintContext_Type

%%
ignore-glob
*_get_type
%%
override gtk_source_language_get_globs noargs
static PyObject *
_wrap_gtk_source_language_get_globs(PyGObject *self)
{
    gchar **globs;
    PyObject *ret;

    globs = gtk_source_language_get_globs (GTK_SOURCE_LANGUAGE (self->obj));
    ret = strv_to_pylist (globs);
    g_strfreev (globs);

    return ret;
}

%%
override gtk_source_language_get_mime_types noargs
static PyObject *
_wrap_gtk_source_language_get_mime_types(PyGObject *self)
{
    gchar **mime_types;
    PyObject *ret;

    mime_types = gtk_source_language_get_mime_types (GTK_SOURCE_LANGUAGE (self->obj));
    ret = strv_to_pylist (mime_types);
    g_strfreev (mime_types);

    return ret;
}

%%
override gtk_source_language_manager_get_language_ids noargs
static PyObject *
_wrap_gtk_source_language_manager_get_language_ids (PyGObject *self)
{
    PyObject *py_ret;
    const char * const *ret;

    ret = gtk_source_language_manager_get_language_ids (GTK_SOURCE_LANGUAGE_MANAGER (self->obj));
    py_ret = strv_to_pylist ((char**) ret);

    return py_ret;
}

%%
override gtk_source_language_manager_get_search_path noargs
static PyObject *
_wrap_gtk_source_language_manager_get_search_path(PyGObject *self)
{
    const char * const *ret;
    PyObject  *py_ret;

    ret = gtk_source_language_manager_get_search_path (GTK_SOURCE_LANGUAGE_MANAGER(self->obj));
    py_ret = strv_to_pylist ((char**) ret);

    return py_ret;
}

%%
override gtk_source_language_manager_set_search_path kwargs
static PyObject *
_wrap_gtk_source_language_manager_set_search_path (PyGObject *self, PyObject *args, PyObject *kwargs)
{
    static char *kwlist[] = { "dirs", NULL };
    PyObject *py_dirs;
    char **dirs;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:GtkSourceLanguageManager.set_search_path", kwlist, &py_dirs))
        return NULL;

    if (!pylist_to_strv (py_dirs, &dirs))
        return NULL;

    gtk_source_language_manager_set_search_path (GTK_SOURCE_LANGUAGE_MANAGER (self->obj), dirs);
    g_strfreev (dirs);

    Py_INCREF(Py_None);
    return Py_None;
}

%%
override gtk_source_style_scheme_manager_get_search_path noargs
static PyObject *
_wrap_gtk_source_style_scheme_manager_get_search_path(PyGObject *self)
{
    const char * const *ret;
    PyObject *py_ret;

    ret = gtk_source_style_scheme_manager_get_search_path (GTK_SOURCE_STYLE_SCHEME_MANAGER (self->obj));
    py_ret = strv_to_pylist ((char**) ret);

    return py_ret;
}

%%
override gtk_source_style_scheme_manager_set_search_path kwargs
static PyObject *
_wrap_gtk_source_style_scheme_manager_set_search_path(PyGObject *self, PyObject *args, PyObject *kwargs)
{
    static char *kwlist[] = { "dirs", NULL };
    PyObject *py_dirs;
    char **dirs;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:GtkSourceStyleSchemeManager.set_search_path", kwlist, &py_dirs))
        return NULL;

    if (!pylist_to_strv (py_dirs, &dirs))
        return NULL;

    gtk_source_style_scheme_manager_set_search_path (GTK_SOURCE_STYLE_SCHEME_MANAGER (self->obj), dirs);
    g_strfreev (dirs);

    Py_INCREF(Py_None);
    return Py_None;
}

%%
override gtk_source_style_scheme_manager_get_scheme_ids noargs
static PyObject *
_wrap_gtk_source_style_scheme_manager_get_scheme_ids (PyGObject *self)
{
    PyObject *py_ret;
    const char * const *ret;

    ret = gtk_source_style_scheme_manager_get_scheme_ids (GTK_SOURCE_STYLE_SCHEME_MANAGER (self->obj));
    py_ret = strv_to_pylist ((char**) ret);

    return py_ret;
}

%%
override gtk_source_style_scheme_get_authors noargs
static PyObject *
_wrap_gtk_source_style_scheme_get_authors (PyGObject *self)
{
    PyObject *py_ret;
    const char * const *ret;

    ret = gtk_source_style_scheme_get_authors (GTK_SOURCE_STYLE_SCHEME (self->obj));
    py_ret = strv_to_pylist ((char**) ret);

    return py_ret;
}

%%
override-slot GtkSourceLanguage.tp_new
static PyObject *
_wrap_gtk_source_language_tp_new(PyTypeObject *type)
{
    PyErr_SetString(PyExc_TypeError,
		    "cannot create instance of type `GtkSourceLanguage'");
    return NULL;
}

%%
override-slot GtkSourceStyleScheme.tp_new
static PyObject *
_wrap_gtk_source_style_scheme_tp_new(PyTypeObject *type)
{
    PyErr_SetString(PyExc_TypeError,
		    "cannot create instance of type `GtkSourceStyleScheme'");
    return NULL;
}

%%
override gtk_source_language_get_style_ids noargs
static PyObject *
_wrap_gtk_source_language_get_style_ids(PyGObject *self)
{
    gchar       **ret;
    PyObject    *py_ret;

    ret = gtk_source_language_get_style_ids(GTK_SOURCE_LANGUAGE(self->obj));
    py_ret = strv_to_pylist ((char**) ret);

    return py_ret;
}

%%
override gtk_source_buffer_get_source_marks_at_iter kwargs
static PyObject *
_wrap_gtk_source_buffer_get_source_marks_at_iter(PyGObject *self,
                                                 PyObject *args,
                                                 PyObject *kwargs)
{
    static char *kwlist[] = { "iter", "category", NULL };
    PyObject    *py_iter, *py_ret;
    gchar       *category;
    GtkTextIter *iter = NULL;
    GSList      *ret;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
                                     "Oz:GtkSourceBuffer.get_source_marks_at_iter",
                                     kwlist, &py_iter, &category))
        return NULL;

    if (pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER))
        iter = pyg_boxed_get(py_iter, GtkTextIter);
    else {
        PyErr_SetString(PyExc_TypeError, "iter should be a GtkTextIter");
        return NULL;
    }

    ret = gtk_source_buffer_get_source_marks_at_iter(GTK_SOURCE_BUFFER(self->obj),
                                                     iter, category);

    py_ret = gslist_to_pylist_objs (ret);

    return py_ret;
}

%%
override gtk_source_buffer_get_source_marks_at_line kwargs
static PyObject *
_wrap_gtk_source_buffer_get_source_marks_at_line(PyGObject *self,
                                                 PyObject *args,
                                                 PyObject *kwargs)
{
    static char *kwlist[] = { "line", "category", NULL };
    PyObject    *py_ret;
    gint        line;
    gchar       *category;
    GSList      *ret;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
                                     "iz:GtkSourceBuffer.get_source_marks_at_line",
                                     kwlist, &line, &category))
        return NULL;

    ret = gtk_source_buffer_get_source_marks_at_line(GTK_SOURCE_BUFFER(self->obj),
                                                     line, category);

    py_ret = gslist_to_pylist_objs (ret);

    return py_ret;
} 	 

%%
override gtk_source_iter_backward_search kwargs
static PyObject *
_wrap_gtk_source_iter_backward_search(PyObject *self, PyObject *args,
                                      PyObject *kwargs)
{
    static char *kwlist[] = { "iter", "str", "flags", "limit", NULL };
    gchar *str;
    PyObject *py_flags, *py_iter, *py_limit = Py_None;
    GtkTextIter match_start, match_end, *iter = NULL, *limit = NULL;
    GtkSourceSearchFlags flags;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
                                    "OsO|O:gtksourceview2.iter_backward_search",
                                    kwlist, &py_iter, &str, &py_flags,
                                    &py_limit))
        return NULL;

    if (pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER))
        iter = pyg_boxed_get(py_iter, GtkTextIter);

    if (pyg_boxed_check(py_limit, GTK_TYPE_TEXT_ITER))
        limit = pyg_boxed_get(py_limit, GtkTextIter);

    else if (py_limit != Py_None) {
        PyErr_SetString(PyExc_TypeError,"limit must be a GtkTextIter or None");
        return NULL;
    }

    if (pyg_flags_get_value(GTK_TYPE_TEXT_SEARCH_FLAGS, py_flags,
                            (gint *)&flags))
        return NULL;

    if (gtk_source_iter_backward_search(iter, str, flags, &match_start,
                                        &match_end, limit))
        return Py_BuildValue("(NN)",
                             pyg_boxed_new(GTK_TYPE_TEXT_ITER, &match_start,
                                           TRUE, TRUE),
                             pyg_boxed_new(GTK_TYPE_TEXT_ITER, &match_end,
                                           TRUE, TRUE));

    Py_INCREF(Py_None);
    return Py_None;
}

%%
override gtk_source_iter_forward_search kwargs
static PyObject *
_wrap_gtk_source_iter_forward_search(PyObject *self, PyObject *args,
                                      PyObject *kwargs)
{
    static char *kwlist[] = { "iter", "str", "flags", "limit", NULL };
    gchar *str;
    PyObject *py_flags, *py_iter, *py_limit = Py_None;
    GtkTextIter match_start, match_end, *iter = NULL, *limit = NULL;
    GtkSourceSearchFlags flags;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
                                    "OsO|O:gtksourceview2.iter_forward_search",
                                    kwlist, &py_iter, &str, &py_flags,
                                    &py_limit))
        return NULL;

    if (pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER))
        iter = pyg_boxed_get(py_iter, GtkTextIter);

    if (pyg_boxed_check(py_limit, GTK_TYPE_TEXT_ITER))
        limit = pyg_boxed_get(py_limit, GtkTextIter);

    else if (py_limit != Py_None) {
        PyErr_SetString(PyExc_TypeError,"limit must be a GtkTextIter or None");
        return NULL;
    }

    if (pyg_flags_get_value(GTK_TYPE_TEXT_SEARCH_FLAGS, py_flags,
                            (gint *)&flags))
        return NULL;

    if (gtk_source_iter_forward_search(iter, str, flags, &match_start,
                                        &match_end, limit))
        return Py_BuildValue("(NN)",
                             pyg_boxed_new(GTK_TYPE_TEXT_ITER, &match_start,
                                           TRUE, TRUE),
                             pyg_boxed_new(GTK_TYPE_TEXT_ITER, &match_end,
                                           TRUE, TRUE));

    Py_INCREF(Py_None);
    return Py_None;
}