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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
|
/* -*- Mode: C; c-basic-offset: 4 -*-
* pygtk- Python bindings for the GTK toolkit.
* Copyright (C) 1998-2003 James Henstridge
*
* gtktextview.override: overrides for the gtk.TextView object.
*
* 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
*/
%%
ignore-glob
gtk_text_view_new
%%
override gtk_text_view_get_visible_rect noargs
static PyObject *
_wrap_gtk_text_view_get_visible_rect(PyGObject *self)
{
GdkRectangle visible_rect;
gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(self->obj), &visible_rect);
return pyg_boxed_new(GDK_TYPE_RECTANGLE, &visible_rect, TRUE, TRUE);
}
%%
override gtk_text_view_buffer_to_window_coords kwargs
static PyObject *
_wrap_gtk_text_view_buffer_to_window_coords(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "win", "buffer_x", "buffer_y", NULL };
GtkTextWindowType win;
gint buffer_x, buffer_y, window_x = 0, window_y = 0;
PyObject *py_win;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"Oii:GtkTextView.buffer_to_window_coords",
kwlist, &py_win, &buffer_x, &buffer_y))
return NULL;
if (pyg_enum_get_value(GTK_TYPE_TEXT_WINDOW_TYPE, py_win, (gint *)&win))
return NULL;
gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(self->obj), win,
buffer_x, buffer_y,
&window_x, &window_y);
return Py_BuildValue("(ii)", window_x, window_y);
}
%%
override gtk_text_view_window_to_buffer_coords kwargs
static PyObject *
_wrap_gtk_text_view_window_to_buffer_coords(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "win", "window_x", "window_y", NULL };
GtkTextWindowType win;
gint window_x, window_y, buffer_x = 0, buffer_y = 0;
PyObject *py_win;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"Oii:GtkTextView.window_to_buffer_coords",
kwlist, &py_win, &window_x, &window_y))
return NULL;
if (pyg_enum_get_value(GTK_TYPE_TEXT_WINDOW_TYPE, py_win, (gint *)&win))
return NULL;
gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(self->obj), win,
window_x, window_y,
&buffer_x, &buffer_y);
return Py_BuildValue("(ii)", buffer_x, buffer_y);
}
%%
override gtk_text_view_get_iter_location kwargs
static PyObject *
_wrap_gtk_text_view_get_iter_location(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "iter", NULL };
PyObject *py_iter;
GdkRectangle location;
GtkTextIter *iter = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"O:GtkTextView.get_iter_location",
kwlist, &py_iter))
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;
}
gtk_text_view_get_iter_location(GTK_TEXT_VIEW(self->obj), iter, &location);
return pyg_boxed_new(GDK_TYPE_RECTANGLE, &location, TRUE, TRUE);
}
%%
override gtk_text_view_get_line_at_y kwargs
static PyObject *
_wrap_gtk_text_view_get_line_at_y(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "y", NULL };
GtkTextIter iter;
gint y, line_top;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"i:GtkTextView.get_line_at_y",
kwlist, &y))
return NULL;
gtk_text_view_get_line_at_y(GTK_TEXT_VIEW(self->obj),
&iter, y, &line_top);
return Py_BuildValue("(Ni)",
pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE),
line_top);
}
%%
override gtk_text_view_get_line_yrange kwargs
static PyObject *
_wrap_gtk_text_view_get_line_yrange(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "iter", NULL };
GtkTextIter *iter = NULL;
gint y = -1, height = -1;
PyObject *py_iter;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"O:GtkTextView.get_line_yrange",
kwlist, &py_iter))
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;
}
gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(self->obj),
iter, &y, &height);
return Py_BuildValue("(ii)", y, height);
}
%%
override gtk_text_view_get_iter_at_location kwargs
static PyObject *
_wrap_gtk_text_view_get_iter_at_location(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "x", "y", NULL };
GtkTextIter iter;
gint x, y;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"ii:GtkTextView.get_iter_at_location",
kwlist, &x, &y))
return NULL;
gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(self->obj),
&iter, x, y);
return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE);
}
%%
override gtk_text_view_set_border_window_size kwargs
static PyObject *
_wrap_gtk_text_view_set_border_window_size(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "type", "size", NULL };
PyObject *py_type = NULL;
int size;
GtkTextWindowType type;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"Oi:GtkTextView.set_border_window_size",
kwlist, &py_type, &size))
return NULL;
if (size < 0) {
PyErr_SetString(PyExc_ValueError, "size must be >= 0");
return NULL;
}
if (pyg_enum_get_value(GTK_TYPE_TEXT_WINDOW_TYPE, py_type, (gint *)&type))
return NULL;
switch (type)
{
case GTK_TEXT_WINDOW_LEFT:
case GTK_TEXT_WINDOW_RIGHT:
case GTK_TEXT_WINDOW_TOP:
case GTK_TEXT_WINDOW_BOTTOM:
gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(self->obj), type,
size);
break;
default:
PyErr_SetString(PyExc_ValueError, "type must be one of: "
"gtk.TEXT_WINDOW_LEFT, gtk.TEXT_WINDOW_RIGHT, "
"gtk.TEXT_WINDOW_TOP or gtk.TEXT_WINDOW_BOTTOM");
return NULL;
}
Py_INCREF(Py_None);
return Py_None;
}
%%
ignore gtk_text_iter_free
%%
override gtk_text_iter_copy noargs
static PyObject *
_wrap_gtk_text_iter_copy(PyGBoxed *self)
{
return pyg_boxed_new(GTK_TYPE_TEXT_ITER, pyg_boxed_get(self, GtkTextIter),
TRUE, TRUE);
}
%%
override gtk_text_iter_get_slice kwargs
static PyObject *
_wrap_gtk_text_iter_get_slice(PyGBoxed *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "end", NULL };
PyGBoxed *end;
gchar *text;
PyObject *pytext;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkTextIter.get_slice",
kwlist, &end))
return NULL;
if (!pyg_boxed_check(end, GTK_TYPE_TEXT_ITER)) {
PyErr_SetString(PyExc_TypeError, "end must be a GtkTextIter");
return NULL;
}
text = gtk_text_iter_get_slice(pyg_boxed_get(self, GtkTextIter),
pyg_boxed_get(end, GtkTextIter));
pytext = PyUnicode_DecodeUTF8(text, strlen(text), "strict");
g_free(text);
return pytext;
}
%%
override gtk_text_iter_get_text kwargs
static PyObject *
_wrap_gtk_text_iter_get_text(PyGBoxed *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "end", NULL };
PyGBoxed *end;
gchar *text;
PyObject *pytext;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkTextIter.get_text",
kwlist, &end))
return NULL;
if (!pyg_boxed_check(end, GTK_TYPE_TEXT_ITER)) {
PyErr_SetString(PyExc_TypeError, "end must be a GtkTextIter");
return NULL;
}
text = gtk_text_iter_get_text(pyg_boxed_get(self, GtkTextIter),
pyg_boxed_get(end, GtkTextIter));
pytext = PyUnicode_DecodeUTF8(text, strlen(text), "strict");
g_free(text);
return pytext;
}
%%
override gtk_text_iter_get_visible_slice kwargs
static PyObject *
_wrap_gtk_text_iter_get_visible_slice(PyGBoxed *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "end", NULL };
PyGBoxed *end;
gchar *text;
PyObject *pytext;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"O:GtkTextIter.get_visible_slice", kwlist,
&end))
return NULL;
if (!pyg_boxed_check(end, GTK_TYPE_TEXT_ITER)) {
PyErr_SetString(PyExc_TypeError, "end must be a GtkTextIter");
return NULL;
}
text = gtk_text_iter_get_visible_slice(pyg_boxed_get(self, GtkTextIter),
pyg_boxed_get(end, GtkTextIter));
pytext = PyUnicode_DecodeUTF8(text, strlen(text), "strict");
g_free(text);
return pytext;
}
%%
override gtk_text_iter_get_visible_text kwargs
static PyObject *
_wrap_gtk_text_iter_get_visible_text(PyGBoxed *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "end", NULL };
PyGBoxed *end;
gchar *text;
PyObject *pytext;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"O:GtkTextIter.get_visible_text", kwlist,
&end))
return NULL;
if (!pyg_boxed_check(end, GTK_TYPE_TEXT_ITER)) {
PyErr_SetString(PyExc_TypeError, "end must be a GtkTextIter");
return NULL;
}
text = gtk_text_iter_get_visible_text(pyg_boxed_get(self, GtkTextIter),
pyg_boxed_get(end, GtkTextIter));
pytext = PyUnicode_DecodeUTF8(text, strlen(text), "strict");
g_free(text);
return pytext;
}
%%
override gtk_text_iter_get_marks noargs
static PyObject *
_wrap_gtk_text_iter_get_marks(PyGBoxed *self)
{
GSList *ret, *tmp;
PyObject *pyret;
ret = gtk_text_iter_get_marks(pyg_boxed_get(self, GtkTextIter));
pyret = PyList_New(0);
for (tmp = ret; tmp != NULL; tmp = tmp->next) {
PyObject *mark = pygobject_new((GObject *)tmp->data);
PyList_Append(pyret, mark);
Py_DECREF(mark);
}
g_slist_free(ret);
return pyret;
}
%%
override gtk_text_iter_get_toggled_tags kwargs
static PyObject *
_wrap_gtk_text_iter_get_toggled_tags(PyGBoxed *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "toggled_on", NULL };
GSList *ret, *tmp;
int toggled_on;
PyObject *pyret;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"i:GtkTextIter.get_toggled_tags", kwlist,
&toggled_on))
return NULL;
ret = gtk_text_iter_get_toggled_tags(pyg_boxed_get(self, GtkTextIter),
toggled_on);
pyret = PyList_New(0);
for (tmp = ret; tmp != NULL; tmp = tmp->next) {
PyObject *tag = pygobject_new((GObject *)tmp->data);
PyList_Append(pyret, tag);
Py_DECREF(tag);
}
g_slist_free(ret);
return pyret;
}
%%
override gtk_text_iter_get_tags noargs
static PyObject *
_wrap_gtk_text_iter_get_tags(PyGBoxed *self)
{
GSList *ret, *tmp;
PyObject *pyret;
ret = gtk_text_iter_get_tags(pyg_boxed_get(self, GtkTextIter));
pyret = PyList_New(0);
for (tmp = ret; tmp != NULL; tmp = tmp->next) {
PyObject *tag = pygobject_new((GObject *)tmp->data);
PyList_Append(pyret, tag);
Py_DECREF(tag);
}
g_slist_free(ret);
return pyret;
}
%%
override gtk_text_iter_forward_search kwargs
static PyObject *
_wrap_gtk_text_iter_forward_search(PyGBoxed *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "str", "flags", "limit", NULL };
gchar *str;
PyObject *py_flags, *py_limit = Py_None;
GtkTextIter match_start, match_end, *limit = NULL;
GtkTextSearchFlags flags;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"sO|O:GtkTextIter.forward_search",
kwlist, &str, &py_flags, &py_limit))
return NULL;
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_text_iter_forward_search(pyg_boxed_get(self, GtkTextIter), 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_text_iter_backward_search kwargs
static PyObject *
_wrap_gtk_text_iter_backward_search(PyGBoxed *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "str", "flags", "limit", NULL };
gchar *str;
PyObject *py_flags, *py_limit = Py_None;
GtkTextIter match_start, match_end, *limit = NULL;
GtkTextSearchFlags flags;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"sO|O:GtkTextIter.backward_search",
kwlist, &str, &py_flags, &py_limit))
return NULL;
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_text_iter_backward_search(pyg_boxed_get(self, GtkTextIter), 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_text_buffer_insert_with_tags
static PyObject *
_wrap_gtk_text_buffer_insert_with_tags(PyGObject *self, PyObject *args)
{
PyObject *first, *py_iter;
gint len, i, text_len, start_offset;
gchar *text;
GtkTextIter *iter, start;
len = PyTuple_Size(args);
if (len < 2) {
PyErr_SetString(PyExc_TypeError,
"GtkTextBuffer.insert_with_tags requires at least 2 arguments");
return NULL;
}
first = PySequence_GetSlice(args, 0, 2);
if (!PyArg_ParseTuple(first, "Os#:GtkTextBuffer.insert_with_tags",
&py_iter, &text, &text_len)) {
Py_DECREF(first);
return NULL;
}
Py_DECREF(first);
if (!pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER)) {
PyErr_SetString(PyExc_TypeError, "iter must be a GtkTextIter");
return NULL;
}
iter = pyg_boxed_get(py_iter, GtkTextIter);
/* check types */
for (i = 2; i < len; i++) {
PyObject *item = PyTuple_GetItem(args, i);
if (!pygobject_check(item, &PyGtkTextTag_Type)) {
PyErr_SetString(PyExc_TypeError,
"additional argument must be a GtkTextTag");
return NULL;
}
}
start_offset = gtk_text_iter_get_offset(iter);
gtk_text_buffer_insert(GTK_TEXT_BUFFER(self->obj), iter, text, text_len);
gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(self->obj),
&start, start_offset);
for (i = 2; i < len; i++) {
PyObject *item = PyTuple_GetItem(args, i);
GtkTextTag *tag = GTK_TEXT_TAG(pygobject_get(item));
gtk_text_buffer_apply_tag(GTK_TEXT_BUFFER(self->obj), tag,&start,iter);
}
Py_INCREF(Py_None);
return Py_None;
}
%%
override gtk_text_buffer_insert_with_tags_by_name
static PyObject *
_wrap_gtk_text_buffer_insert_with_tags_by_name(PyGObject *self, PyObject *args)
{
PyObject *first, *py_iter;
gint len, i, text_len, start_offset;
gchar *text;
GtkTextIter *iter, start;
len = PyTuple_Size(args);
if (len < 2) {
PyErr_SetString(PyExc_TypeError,
"GtkTextBuffer.insert_with_tags_by_name "
"requires at least 2 arguments");
return NULL;
}
first = PySequence_GetSlice(args, 0, 2);
if (!PyArg_ParseTuple(first, "Os#:GtkTextBuffer.insert_with_tags_by_name",
&py_iter, &text, &text_len)) {
Py_DECREF(first);
return NULL;
}
Py_DECREF(first);
if (!pyg_boxed_check(py_iter, GTK_TYPE_TEXT_ITER)) {
PyErr_SetString(PyExc_TypeError, "iter must be a GtkTextIter");
return NULL;
}
iter = pyg_boxed_get(py_iter, GtkTextIter);
/* check types */
for (i = 2; i < len; i++) {
PyObject *item = PyTuple_GetItem(args, i);
if (!PyString_Check(item)) {
PyErr_SetString(PyExc_TypeError,
"additional argument must be a string");
return NULL;
}
}
start_offset = gtk_text_iter_get_offset(iter);
gtk_text_buffer_insert(GTK_TEXT_BUFFER(self->obj), iter, text, text_len);
gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(self->obj),
&start, start_offset);
for (i = 2; i < len; i++) {
PyObject *item = PyTuple_GetItem(args, i);
const gchar *tagname = PyString_AsString(item);
gtk_text_buffer_apply_tag_by_name(GTK_TEXT_BUFFER(self->obj),
tagname, &start, iter);
}
Py_INCREF(Py_None);
return Py_None;
}
%%
override gtk_text_buffer_create_tag kwargs
static PyObject *
_wrap_gtk_text_buffer_create_tag(PyGObject *self, PyObject *args, PyObject *kwargs)
{
gchar *tag_name = NULL;
GtkTextTag *tag;
GtkTextTagTable *table;
if (!PyArg_ParseTuple(args, "|z:GtkTextBuffer.create_tag",
&tag_name)) {
return NULL;
}
table = GTK_TEXT_TAG_TABLE(GTK_TEXT_BUFFER(self->obj)->tag_table);
if (tag_name && table && g_hash_table_lookup(table->hash, tag_name)) {
gchar buf[512];
g_snprintf(buf, sizeof(buf),
"A tag named '%s' is already in the tag table",
tag_name);
PyErr_SetString(PyExc_TypeError, buf);
return NULL;
}
tag = gtk_text_buffer_create_tag(GTK_TEXT_BUFFER(self->obj),
tag_name, NULL);
/* set tag properties if any */
if (kwargs) {
gint i = 0;
PyObject *prop, *val;
while (PyDict_Next(kwargs, &i, &prop, &val)) {
GParamSpec *pspec;
GValue value = { 0, };
gchar *prop_str = PyString_AsString(prop);
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS(tag),
prop_str);
if (!pspec) {
PyErr_Format(PyExc_TypeError,
"unsupported tag property `%s'",
prop_str);
/* XXX: Free tag? */
return NULL;
}
g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec));
if (pyg_value_from_pyobject(&value, val) < 0) {
PyErr_Format(PyExc_TypeError,
"could not convert tag property '%s' to correct type",
prop_str);
/* XXX: Free tag? */
return NULL;
}
g_object_set_property((GObject *)tag, prop_str, &value);
g_value_unset(&value);
}
}
return pygobject_new((GObject *)tag);
}
%%
override gtk_text_buffer_get_iter_at_line_offset kwargs
static PyObject *
_wrap_gtk_text_buffer_get_iter_at_line_offset(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "line_number", "char_offset", NULL };
GtkTextIter iter;
int line_number, char_offset;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GtkTextBuffer.get_iter_at_line_offset", kwlist, &line_number, &char_offset))
return NULL;
gtk_text_buffer_get_iter_at_line_offset(GTK_TEXT_BUFFER(self->obj), &iter,
line_number, char_offset);
return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE);
}
%%
override gtk_text_buffer_get_iter_at_line_index kwargs
static PyObject *
_wrap_gtk_text_buffer_get_iter_at_line_index(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "line_number", "byte_offset", NULL };
GtkTextIter iter;
int line_number, byte_offset;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GtkTextBuffer.get_iter_at_line_index", kwlist, &line_number, &byte_offset))
return NULL;
gtk_text_buffer_get_iter_at_line_index(GTK_TEXT_BUFFER(self->obj), &iter,
line_number, byte_offset);
return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE);
}
%%
override gtk_text_buffer_get_iter_at_offset kwargs
static PyObject *
_wrap_gtk_text_buffer_get_iter_at_offset(PyGObject *self, PyObject *args, PyObject *kwargs)
{
int char_offset;
static char *kwlist[] = { "char_offset", NULL };
GtkTextIter iter;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:GtkTextBuffer.get_iter_at_offset", kwlist, &char_offset))
return NULL;
gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(self->obj),
&iter, char_offset);
return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE);
}
%%
override gtk_text_buffer_get_iter_at_line kwargs
static PyObject *
_wrap_gtk_text_buffer_get_iter_at_line(PyGObject *self, PyObject *args, PyObject *kwargs)
{
int line_number;
static char *kwlist[] = { "line_number", NULL };
GtkTextIter iter;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:GtkTextBuffer.get_iter_at_line", kwlist, &line_number))
return NULL;
gtk_text_buffer_get_iter_at_line(GTK_TEXT_BUFFER(self->obj),
&iter, line_number);
return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE);
}
%%
override gtk_text_buffer_get_start_iter noargs
static PyObject *
_wrap_gtk_text_buffer_get_start_iter(PyGObject *self)
{
GtkTextIter iter;
gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(self->obj), &iter);
return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE);
}
%%
override gtk_text_buffer_get_end_iter noargs
static PyObject *
_wrap_gtk_text_buffer_get_end_iter(PyGObject *self)
{
GtkTextIter iter;
gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(self->obj), &iter);
return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE);
}
%%
override gtk_text_buffer_get_bounds noargs
static PyObject *
_wrap_gtk_text_buffer_get_bounds(PyGObject *self)
{
GtkTextIter start, end;
gtk_text_buffer_get_bounds(GTK_TEXT_BUFFER(self->obj), &start, &end);
return Py_BuildValue("(NN)",
pyg_boxed_new(GTK_TYPE_TEXT_ITER, &start, TRUE, TRUE),
pyg_boxed_new(GTK_TYPE_TEXT_ITER, &end, TRUE, TRUE));
}
%%
override gtk_text_buffer_get_iter_at_mark kwargs
static PyObject *
_wrap_gtk_text_buffer_get_iter_at_mark(PyGObject *self, PyObject *args, PyObject *kwargs)
{
PyGObject *mark;
static char *kwlist[] = { "mark", NULL };
GtkTextIter iter;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GtkTextBuffer.get_iter_at_mark", kwlist, &mark))
return NULL;
if (!pygobject_check(mark, &PyGtkTextMark_Type)) {
PyErr_SetString(PyExc_TypeError, "mark should be a GtkTextMark");
return NULL;
}
gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(self->obj), &iter,
GTK_TEXT_MARK(mark->obj));
return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE);
}
%%
override gtk_text_buffer_set_text kwargs
static PyObject *
_wrap_gtk_text_buffer_set_text(PyGObject *self, PyObject *args, PyObject *kwargs)
{
char *text;
static char *kwlist[] = { "text", "len", NULL };
int len, oldlen = -1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"s#|i:GtkTextBuffer.set_text", kwlist,
&text, &len, &oldlen)) {
return NULL;
}
if (oldlen > 0) {
if (oldlen > len) {
PyErr_SetString(PyExc_ValueError, "len greater than text length");
return NULL;
}
len = oldlen;
}
gtk_text_buffer_set_text(GTK_TEXT_BUFFER(self->obj), text, len);
Py_INCREF(Py_None);
return Py_None;
}
%%
override gtk_text_buffer_get_selection_bounds noargs
static PyObject *
_wrap_gtk_text_buffer_get_selection_bounds(PyGObject *self, PyObject *args)
{
GtkTextIter start, end;
if (!gtk_text_buffer_get_selection_bounds(GTK_TEXT_BUFFER(self->obj),
&start, &end)) {
return Py_BuildValue ("()");
}
return Py_BuildValue("(NN)",
pyg_boxed_new(GTK_TYPE_TEXT_ITER, &start, TRUE, TRUE),
pyg_boxed_new(GTK_TYPE_TEXT_ITER, &end, TRUE, TRUE));
}
%%
override gtk_text_buffer_insert kwargs
static PyObject *
_wrap_gtk_text_buffer_insert(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "iter", "text", "len", NULL };
PyObject *py_iter;
char *text;
int len, oldlen = -1;
GtkTextIter *iter = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Os#|i:GtkTextBuffer.insert",
kwlist, &py_iter, &text, &len, &oldlen)) {
return NULL;
}
if (oldlen > 0) {
if (oldlen > len) {
PyErr_SetString(PyExc_ValueError, "len greater than text length");
return NULL;
}
len = oldlen;
}
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;
}
gtk_text_buffer_insert(GTK_TEXT_BUFFER(self->obj), iter, text, len);
Py_INCREF(Py_None);
return Py_None;
}
%%
override gtk_text_buffer_insert_at_cursor kwargs
static PyObject *
_wrap_gtk_text_buffer_insert_at_cursor(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "text", "len", NULL };
char *text;
int len, oldlen = -1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"s#|i:GtkTextBuffer.insert_at_cursor",
kwlist, &text, &len, &oldlen)) {
return NULL;
}
if (oldlen > 0) {
if (oldlen > len) {
PyErr_SetString(PyExc_ValueError, "len greater than text length");
return NULL;
}
len = oldlen;
}
gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(self->obj), text, len);
Py_INCREF(Py_None);
return Py_None;
}
%%
override gtk_text_buffer_insert_interactive kwargs
static PyObject *
_wrap_gtk_text_buffer_insert_interactive(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "iter", "text", "default_editable", "len", NULL };
PyObject *py_iter;
char *text;
int len, default_editable, ret, oldlen = -1;
GtkTextIter *iter = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"Os#i|i:GtkTextBuffer.insert_interactive",
kwlist, &py_iter, &text, &len,
&default_editable, &oldlen)) {
return NULL;
}
if (oldlen > 0) {
if (oldlen > len) {
PyErr_SetString(PyExc_ValueError, "len greater than text length");
return NULL;
}
if (oldlen > len) {
PyErr_SetString(PyExc_ValueError, "len greater than text length");
return NULL;
}
len = oldlen;
}
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_text_buffer_insert_interactive(GTK_TEXT_BUFFER(self->obj), iter,
text, len, default_editable);
return PyBool_FromLong(ret);
}
%%
override gtk_text_buffer_insert_interactive_at_cursor kwargs
static PyObject *
_wrap_gtk_text_buffer_insert_interactive_at_cursor(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "text", "default_editable", "len", NULL };
char *text;
int len, default_editable, ret, oldlen = -1;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"s#i|i:GtkTextBuffer.insert_interactive_at_cursor",
kwlist, &text, &len, &default_editable, &oldlen)) {
return NULL;
}
if (oldlen > 0) {
len = oldlen;
}
ret = gtk_text_buffer_insert_interactive_at_cursor(GTK_TEXT_BUFFER(self->obj),
text, len, default_editable);
return PyBool_FromLong(ret);
}
%%
override gtk_text_buffer_get_iter_at_child_anchor kwargs
static PyObject *
_wrap_gtk_text_buffer_get_iter_at_child_anchor(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "anchor", NULL };
PyGObject *anchor;
GtkTextIter iter;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GtkTextBuffer.get_iter_at_child_anchor", kwlist, &PyGtkTextChildAnchor_Type, &anchor))
return NULL;
gtk_text_buffer_get_iter_at_child_anchor(GTK_TEXT_BUFFER(self->obj),
&iter,
GTK_TEXT_CHILD_ANCHOR(anchor->obj));
return pyg_boxed_new(GTK_TYPE_TEXT_ITER, &iter, TRUE, TRUE);
}
%%
override gtk_text_tag_table_add kwargs
static PyObject *
_wrap_gtk_text_tag_table_add(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "tag", NULL };
GtkTextTag *tag;
GtkTextTagTable *table;
PyGObject *pytag;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GtkTextTagTable.add",
kwlist, &PyGtkTextTag_Type, &pytag)) {
return NULL;
}
tag = GTK_TEXT_TAG(pytag->obj);
table = GTK_TEXT_TAG_TABLE(self->obj);
if (tag->table) {
gchar buf[512];
g_snprintf(buf, sizeof(buf),
"The tag is already in a tag table");
PyErr_SetString(PyExc_ValueError, buf);
return NULL;
}
if (tag->name && table && g_hash_table_lookup(table->hash, tag->name)) {
gchar buf[512];
g_snprintf(buf, sizeof(buf),
"A tag named '%s' is already in the tag table",
tag->name);
PyErr_SetString(PyExc_ValueError, buf);
return NULL;
}
gtk_text_tag_table_add(table, tag);
Py_INCREF(Py_None);
return Py_None;
}
%%
override gtk_text_tag_table_remove kwargs
static PyObject *
_wrap_gtk_text_tag_table_remove(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "tag", NULL };
GtkTextTag *tag;
GtkTextTagTable *table;
PyGObject *pytag;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"O!:GtkTextTagTable.remove",
kwlist, &PyGtkTextTag_Type, &pytag)) {
return NULL;
}
tag = GTK_TEXT_TAG(pytag->obj);
table = GTK_TEXT_TAG_TABLE(self->obj);
if (tag->table != table) {
gchar buf[512];
if (tag->name)
g_snprintf(buf, sizeof(buf),
"The tag named '%s' is not in the tag table",
tag->name);
else
g_snprintf(buf, sizeof(buf),
"The tag is not in the tag table");
PyErr_SetString(PyExc_ValueError, buf);
return NULL;
}
gtk_text_tag_table_remove(table, tag);
Py_INCREF(Py_None);
return Py_None;
}
%%
override-attr GtkTextAttributes.bg_color
static PyObject *
_wrap_gtk_text_attributes__get_bg_color(PyObject *self, void *closure)
{
GdkColor ret;
ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.bg_color;
/* pyg_boxed_new handles NULL checking */
return pyg_boxed_new(GDK_TYPE_COLOR, &ret, TRUE, TRUE);
}
%%
override-attr GtkTextAttributes.fg_color
static PyObject *
_wrap_gtk_text_attributes__get_fg_color(PyObject *self, void *closure)
{
GdkColor ret;
ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.fg_color;
/* pyg_boxed_new handles NULL checking */
return pyg_boxed_new(GDK_TYPE_COLOR, &ret, TRUE, TRUE);
}
%%
override-attr GtkTextAttributes.bg_stipple
static PyObject *
_wrap_gtk_text_attributes__get_bg_stipple(PyObject *self, void *closure)
{
GdkBitmap *ret;
ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.bg_stipple;
/* pygobject_new handles NULL checking */
return pygobject_new((GObject *)ret);
}
%%
override-attr GtkTextAttributes.fg_stipple
static PyObject *
_wrap_gtk_text_attributes__get_fg_stipple(PyObject *self, void *closure)
{
GdkBitmap *ret;
ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.fg_stipple;
/* pygobject_new handles NULL checking */
return pygobject_new((GObject *)ret);
}
%%
override-attr GtkTextAttributes.rise
static PyObject *
_wrap_gtk_text_attributes__get_rise(PyObject *self, void *closure)
{
int ret;
ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.rise;
return PyInt_FromLong(ret);
}
%%
override-attr GtkTextAttributes.underline
static PyObject *
_wrap_gtk_text_attributes__get_underline(PyObject *self, void *closure)
{
int ret;
ret = pyg_boxed_get(self, GtkTextAttributes)->appearance.underline;
return PyInt_FromLong(ret);
}
%%
override-attr GtkTextAttributes.strikethrough
static PyObject *
_wrap_gtk_text_attributes__get_strikethrough(PyObject *self, void *closure)
{
return PyBool_FromLong(pyg_boxed_get(self, GtkTextAttributes)->appearance.strikethrough);
}
%%
override-attr GtkTextAttributes.draw_bg
static PyObject *
_wrap_gtk_text_attributes__get_draw_bg(PyObject *self, void *closure)
{
return PyBool_FromLong(pyg_boxed_get(self, GtkTextAttributes)->appearance.draw_bg);
}
%%
override gtk_text_tag_table_foreach kwargs
static void
pygtk_text_tag_table_foreach_cb(GtkTextTag *tag, gpointer user_data)
{
PyGILState_STATE state;
PyObject *callback, *args, *ret;
state = PyGILState_Ensure();
callback = PyTuple_GetItem((PyObject *)user_data, 0);
args = Py_BuildValue("(NO)",
pygobject_new((GObject *)tag),
PyTuple_GetItem((PyObject *)user_data, 1));
ret = PyObject_CallObject(callback, args);
if (!ret)
PyErr_Print();
Py_XDECREF(ret);
PyGILState_Release(state);
}
static PyObject *
_wrap_gtk_text_tag_table_foreach(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "func", "data", NULL };
PyObject *func, *data, *py_data = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"O|O:GtkTextTagTable.foreach",
kwlist, &func, &py_data)) {
return NULL;
}
if (!PyCallable_Check(func)) {
PyErr_SetString(PyExc_TypeError, "func must be callable");
return NULL;
}
data = Py_BuildValue("(OO)", func, py_data);
gtk_text_tag_table_foreach(GTK_TEXT_TAG_TABLE(self->obj),
pygtk_text_tag_table_foreach_cb,
(gpointer)data);
Py_INCREF(Py_None);
return Py_None;
}
%%
override gtk_text_iter_forward_find_char kwargs
gboolean
pygtk_find_char_pred(gunichar ch, gpointer user_data)
{
PyGILState_STATE state;
PyObject *pred, *args, *pyret = Py_False;
gboolean ret;
state = PyGILState_Ensure();
#if !defined(Py_UNICODE_SIZE) || Py_UNICODE_SIZE == 2
if (ch > 0xffff) {
PyErr_SetString(PyExc_RuntimeError,
"character can not be represented in 16-bit unicode");
PyErr_Print();
return FALSE;
}
#endif
pred = PyTuple_GetItem((PyObject *)user_data, 0);
args = Py_BuildValue("(NO)", PyUnicode_FromUnicode((Py_UNICODE *)&ch, 1),
PyTuple_GetItem((PyObject *)user_data, 1));
pyret = PyObject_CallObject(pred, args);
if (!pyret)
PyErr_Print();
ret = (pyret == Py_True) ? TRUE : FALSE;
Py_XDECREF(pyret);
PyGILState_Release(state);
return ret;
}
static PyObject *
_wrap_gtk_text_iter_forward_find_char(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "pred", "user_data", "limit", NULL };
GtkTextIter *iter, *limit = NULL;
gboolean ret;
PyObject *pylimit = Py_None, *pred, *data, *pydata = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"O|OO:gtk.TextIter.forward_find_char",
kwlist, &pred, &pydata, &pylimit))
return NULL;
if (pylimit != Py_None) {
if (pyg_boxed_check(pylimit, GTK_TYPE_TEXT_ITER)) {
limit = pyg_boxed_get(pylimit, GtkTextIter);
} else {
PyErr_SetString(PyExc_TypeError,
"limit should be a gtk.TextIter or None");
return NULL;
}
}
if (!PyCallable_Check(pred)) {
PyErr_SetString(PyExc_TypeError, "pred must be callable");
return NULL;
}
data = Py_BuildValue("(OO)", pred, pydata);
iter = pyg_boxed_get(self, GtkTextIter);
ret = gtk_text_iter_forward_find_char(iter, pygtk_find_char_pred,
(gpointer)data, limit);
return PyBool_FromLong(ret);
}
%%
override gtk_text_iter_backward_find_char kwargs
static PyObject *
_wrap_gtk_text_iter_backward_find_char(PyGObject *self, PyObject *args,
PyObject *kwargs)
{
static char *kwlist[] = { "pred", "user_data", "limit", NULL };
GtkTextIter *iter, *limit = NULL;
gboolean ret;
PyObject *pylimit = Py_None, *pred, *data, *pydata = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"O|OO:gtk.TextIter.backward_find_char",
kwlist, &pred, &pydata, &pylimit))
return NULL;
if (pylimit != Py_None) {
if (pyg_boxed_check(pylimit, GTK_TYPE_TEXT_ITER)) {
limit = pyg_boxed_get(pylimit, GtkTextIter);
} else {
PyErr_SetString(PyExc_TypeError,
"limit should be a gtk.TextIter or None");
return NULL;
}
}
if (!PyCallable_Check(pred)) {
PyErr_SetString(PyExc_TypeError, "pred must be callable");
return NULL;
}
data = Py_BuildValue("(OO)", pred, pydata);
iter = pyg_boxed_get(self, GtkTextIter);
ret = gtk_text_iter_backward_find_char(iter, pygtk_find_char_pred,
(gpointer)data, limit);
return PyBool_FromLong(ret);
}
|