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
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use Clipboard;
use Error;
use TargetList;
use TextChildAnchor;
use TextIter;
use TextMark;
use TextTag;
use TextTagTable;
use ffi;
use gdk;
use gdk_pixbuf;
use gdk_pixbuf_ffi;
use glib;
use glib::StaticType;
use glib::Value;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;

glib_wrapper! {
    /// You may wish to begin by reading the
    /// [text widget conceptual overview](https://developer.gnome.org/gtk3/stable/TextWidget.html)
    /// which gives an overview of all the objects and data
    /// types related to the text widget and how they work together.
    pub struct TextBuffer(Object<ffi::GtkTextBuffer, ffi::GtkTextBufferClass>);

    match fn {
        get_type => || ffi::gtk_text_buffer_get_type(),
    }
}

impl TextBuffer {
    /// Creates a new text buffer.
    /// ## `table`
    /// a tag table, or `None` to create a new one
    ///
    /// # Returns
    ///
    /// a new text buffer
    pub fn new<'a, P: Into<Option<&'a TextTagTable>>>(table: P) -> TextBuffer {
        assert_initialized_main_thread!();
        let table = table.into();
        let table = table.to_glib_none();
        unsafe {
            from_glib_full(ffi::gtk_text_buffer_new(table.0))
        }
    }
}

/// Trait containing all `TextBuffer` methods.
///
/// # Implementors
///
/// [`TextBuffer`](struct.TextBuffer.html)
pub trait TextBufferExt {
    /// Adds the mark at position `where_`. The mark must not be added to
    /// another buffer, and if its name is not `None` then there must not
    /// be another mark in the buffer with the same name.
    ///
    /// Emits the `TextBuffer::mark-set` signal as notification of the mark's
    /// initial placement.
    /// ## `mark`
    /// the mark to add
    /// ## `where_`
    /// location to place mark
    fn add_mark(&self, mark: &TextMark, where_: &TextIter);

    /// Adds `clipboard` to the list of clipboards in which the selection
    /// contents of `self` are available. In most cases, `clipboard` will be
    /// the `Clipboard` of type `GDK_SELECTION_PRIMARY` for a view of `self`.
    /// ## `clipboard`
    /// a `Clipboard`
    fn add_selection_clipboard(&self, clipboard: &Clipboard);

    /// Emits the “apply-tag” signal on `self`. The default
    /// handler for the signal applies `tag` to the given range.
    /// `start` and `end` do not have to be in order.
    /// ## `tag`
    /// a `TextTag`
    /// ## `start`
    /// one bound of range to be tagged
    /// ## `end`
    /// other bound of range to be tagged
    fn apply_tag(&self, tag: &TextTag, start: &TextIter, end: &TextIter);

    /// Calls `TextTagTableExt::lookup` on the buffer’s tag table to
    /// get a `TextTag`, then calls `TextBufferExt::apply_tag`.
    /// ## `name`
    /// name of a named `TextTag`
    /// ## `start`
    /// one bound of range to be tagged
    /// ## `end`
    /// other bound of range to be tagged
    fn apply_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter);

    /// Performs the appropriate action as if the user hit the delete
    /// key with the cursor at the position specified by `iter`. In the
    /// normal case a single character will be deleted, but when
    /// combining accents are involved, more than one character can
    /// be deleted, and when precomposed character and accent combinations
    /// are involved, less than one character will be deleted.
    ///
    /// Because the buffer is modified, all outstanding iterators become
    /// invalid after calling this function; however, the `iter` will be
    /// re-initialized to point to the location where text was deleted.
    /// ## `iter`
    /// a position in `self`
    /// ## `interactive`
    /// whether the deletion is caused by user interaction
    /// ## `default_editable`
    /// whether the buffer is editable by default
    ///
    /// # Returns
    ///
    /// `true` if the buffer was modified
    fn backspace(&self, iter: &mut TextIter, interactive: bool, default_editable: bool) -> bool;

    /// Called to indicate that the buffer operations between here and a
    /// call to `TextBufferExt::end_user_action` are part of a single
    /// user-visible operation. The operations between
    /// `TextBufferExt::begin_user_action` and
    /// `TextBufferExt::end_user_action` can then be grouped when creating
    /// an undo stack. `TextBuffer` maintains a count of calls to
    /// `TextBufferExt::begin_user_action` that have not been closed with
    /// a call to `TextBufferExt::end_user_action`, and emits the
    /// “begin-user-action” and “end-user-action” signals only for the
    /// outermost pair of calls. This allows you to build user actions
    /// from other user actions.
    ///
    /// The “interactive” buffer mutation functions, such as
    /// `TextBufferExt::insert_interactive`, automatically call begin/end
    /// user action around the buffer operations they perform, so there's
    /// no need to add extra calls if you user action consists solely of a
    /// single call to one of those functions.
    fn begin_user_action(&self);

    /// Copies the currently-selected text to a clipboard.
    /// ## `clipboard`
    /// the `Clipboard` object to copy to
    fn copy_clipboard(&self, clipboard: &Clipboard);

    /// This is a convenience function which simply creates a child anchor
    /// with `TextChildAnchor::new` and inserts it into the buffer
    /// with `TextBufferExt::insert_child_anchor`. The new anchor is
    /// owned by the buffer; no reference count is returned to
    /// the caller of `TextBufferExt::create_child_anchor`.
    /// ## `iter`
    /// location in the buffer
    ///
    /// # Returns
    ///
    /// the created child anchor
    fn create_child_anchor(&self, iter: &mut TextIter) -> Option<TextChildAnchor>;

    /// Creates a mark at position `where_`. If `mark_name` is `None`, the mark
    /// is anonymous; otherwise, the mark can be retrieved by name using
    /// `TextBufferExt::get_mark`. If a mark has left gravity, and text is
    /// inserted at the mark’s current location, the mark will be moved to
    /// the left of the newly-inserted text. If the mark has right gravity
    /// (`left_gravity` = `false`), the mark will end up on the right of
    /// newly-inserted text. The standard left-to-right cursor is a mark
    /// with right gravity (when you type, the cursor stays on the right
    /// side of the text you’re typing).
    ///
    /// The caller of this function does not own a
    /// reference to the returned `TextMark`, so you can ignore the
    /// return value if you like. Marks are owned by the buffer and go
    /// away when the buffer does.
    ///
    /// Emits the `TextBuffer::mark-set` signal as notification of the mark's
    /// initial placement.
    /// ## `mark_name`
    /// name for mark, or `None`
    /// ## `where_`
    /// location to place mark
    /// ## `left_gravity`
    /// whether the mark has left gravity
    ///
    /// # Returns
    ///
    /// the new `TextMark` object
    fn create_mark<'a, P: Into<Option<&'a str>>>(&self, mark_name: P, where_: &TextIter, left_gravity: bool) -> Option<TextMark>;

    //fn create_tag<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b str>>>(&self, tag_name: P, first_property_name: Q, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option<TextTag>;

    /// Copies the currently-selected text to a clipboard, then deletes
    /// said text if it’s editable.
    /// ## `clipboard`
    /// the `Clipboard` object to cut to
    /// ## `default_editable`
    /// default editability of the buffer
    fn cut_clipboard(&self, clipboard: &Clipboard, default_editable: bool);

    /// Deletes text between `start` and `end`. The order of `start` and `end`
    /// is not actually relevant; `TextBufferExt::delete` will reorder
    /// them. This function actually emits the “delete-range” signal, and
    /// the default handler of that signal deletes the text. Because the
    /// buffer is modified, all outstanding iterators become invalid after
    /// calling this function; however, the `start` and `end` will be
    /// re-initialized to point to the location where text was deleted.
    /// ## `start`
    /// a position in `self`
    /// ## `end`
    /// another position in `self`
    fn delete(&self, start: &mut TextIter, end: &mut TextIter);

    /// Deletes all editable text in the given range.
    /// Calls `TextBufferExt::delete` for each editable sub-range of
    /// [`start`,`end`). `start` and `end` are revalidated to point to
    /// the location of the last deleted range, or left untouched if
    /// no text was deleted.
    /// ## `start_iter`
    /// start of range to delete
    /// ## `end_iter`
    /// end of range
    /// ## `default_editable`
    /// whether the buffer is editable by default
    ///
    /// # Returns
    ///
    /// whether some text was actually deleted
    fn delete_interactive(&self, start_iter: &mut TextIter, end_iter: &mut TextIter, default_editable: bool) -> bool;

    /// Deletes `mark`, so that it’s no longer located anywhere in the
    /// buffer. Removes the reference the buffer holds to the mark, so if
    /// you haven’t called `gobject::ObjectExt::ref` on the mark, it will be freed. Even
    /// if the mark isn’t freed, most operations on `mark` become
    /// invalid, until it gets added to a buffer again with
    /// `TextBufferExt::add_mark`. Use `TextMarkExt::get_deleted` to
    /// find out if a mark has been removed from its buffer.
    /// The `TextBuffer::mark-deleted` signal will be emitted as notification after
    /// the mark is deleted.
    /// ## `mark`
    /// a `TextMark` in `self`
    fn delete_mark(&self, mark: &TextMark);

    /// Deletes the mark named `name`; the mark must exist. See
    /// `TextBufferExt::delete_mark` for details.
    /// ## `name`
    /// name of a mark in `self`
    fn delete_mark_by_name(&self, name: &str);

    /// Deletes the range between the “insert” and “selection_bound” marks,
    /// that is, the currently-selected text. If `interactive` is `true`,
    /// the editability of the selection will be considered (users can’t delete
    /// uneditable text).
    /// ## `interactive`
    /// whether the deletion is caused by user interaction
    /// ## `default_editable`
    /// whether the buffer is editable by default
    ///
    /// # Returns
    ///
    /// whether there was a non-empty selection to delete
    fn delete_selection(&self, interactive: bool, default_editable: bool) -> bool;

    /// This function deserializes rich text in format `format` and inserts
    /// it at `iter`.
    ///
    /// `formats` to be used must be registered using
    /// `TextBufferExt::register_deserialize_format` or
    /// `TextBufferExt::register_deserialize_tagset` beforehand.
    /// ## `content_buffer`
    /// the `TextBuffer` to deserialize into
    /// ## `format`
    /// the rich text format to use for deserializing
    /// ## `iter`
    /// insertion point for the deserialized text
    /// ## `data`
    /// data to deserialize
    /// ## `length`
    /// length of `data`
    ///
    /// # Returns
    ///
    /// `true` on success, `false` otherwise.
    fn deserialize(&self, content_buffer: &TextBuffer, format: &gdk::Atom, iter: &mut TextIter, data: &[u8]) -> Result<(), Error>;

    /// This functions returns the value set with
    /// `TextBufferExt::deserialize_set_can_create_tags`
    /// ## `format`
    /// a `gdk::Atom` representing a registered rich text format
    ///
    /// # Returns
    ///
    /// whether deserializing this format may create tags
    fn deserialize_get_can_create_tags(&self, format: &gdk::Atom) -> bool;

    /// Use this function to allow a rich text deserialization function to
    /// create new tags in the receiving buffer. Note that using this
    /// function is almost always a bad idea, because the rich text
    /// functions you register should know how to map the rich text format
    /// they handler to your text buffers set of tags.
    ///
    /// The ability of creating new (arbitrary!) tags in the receiving buffer
    /// is meant for special rich text formats like the internal one that
    /// is registered using `TextBufferExt::register_deserialize_tagset`,
    /// because that format is essentially a dump of the internal structure
    /// of the source buffer, including its tag names.
    ///
    /// You should allow creation of tags only if you know what you are
    /// doing, e.g. if you defined a tagset name for your application
    /// suite’s text buffers and you know that it’s fine to receive new
    /// tags from these buffers, because you know that your application can
    /// handle the newly created tags.
    /// ## `format`
    /// a `gdk::Atom` representing a registered rich text format
    /// ## `can_create_tags`
    /// whether deserializing this format may create tags
    fn deserialize_set_can_create_tags(&self, format: &gdk::Atom, can_create_tags: bool);

    /// Should be paired with a call to `TextBufferExt::begin_user_action`.
    /// See that function for a full explanation.
    fn end_user_action(&self);

    /// Retrieves the first and last iterators in the buffer, i.e. the
    /// entire buffer lies within the range [`start`,`end`).
    /// ## `start`
    /// iterator to initialize with first position in the buffer
    /// ## `end`
    /// iterator to initialize with the end iterator
    fn get_bounds(&self) -> (TextIter, TextIter);

    /// Gets the number of characters in the buffer; note that characters
    /// and bytes are not the same, you can’t e.g. expect the contents of
    /// the buffer in string form to be this many bytes long. The character
    /// count is cached, so this function is very fast.
    ///
    /// # Returns
    ///
    /// number of characters in the buffer
    fn get_char_count(&self) -> i32;

    /// This function returns the list of targets this text buffer can
    /// provide for copying and as DND source. The targets in the list are
    /// added with `info` values from the `TextBufferTargetInfo` enum,
    /// using `TargetList::add_rich_text_targets` and
    /// `TargetList::add_text_targets`.
    ///
    /// # Returns
    ///
    /// the `TargetList`
    fn get_copy_target_list(&self) -> Option<TargetList>;

    /// This function returns the rich text deserialize formats registered
    /// with `self` using `TextBufferExt::register_deserialize_format` or
    /// `TextBufferExt::register_deserialize_tagset`
    /// ## `n_formats`
    /// return location for the number of formats
    ///
    /// # Returns
    ///
    /// an array of
    ///  ``GdkAtoms`` representing the registered formats.
    fn get_deserialize_formats(&self) -> Vec<gdk::Atom>;

    /// Initializes `iter` with the “end iterator,” one past the last valid
    /// character in the text buffer. If dereferenced with
    /// `TextIter::get_char`, the end iterator has a character value of 0.
    /// The entire buffer lies in the range from the first position in
    /// the buffer (call `TextBufferExt::get_start_iter` to get
    /// character position 0) to the end iterator.
    /// ## `iter`
    /// iterator to initialize
    fn get_end_iter(&self) -> TextIter;

    /// Indicates whether the buffer has some text currently selected.
    ///
    /// # Returns
    ///
    /// `true` if the there is text selected
    fn get_has_selection(&self) -> bool;

    /// Returns the mark that represents the cursor (insertion point).
    /// Equivalent to calling `TextBufferExt::get_mark` to get the mark
    /// named “insert”, but very slightly more efficient, and involves less
    /// typing.
    ///
    /// # Returns
    ///
    /// insertion point mark
    fn get_insert(&self) -> Option<TextMark>;

    /// Obtains the location of `anchor` within `self`.
    /// ## `iter`
    /// an iterator to be initialized
    /// ## `anchor`
    /// a child anchor that appears in `self`
    fn get_iter_at_child_anchor(&self, anchor: &TextChildAnchor) -> TextIter;

    /// Initializes `iter` to the start of the given line. If `line_number` is greater
    /// than the number of lines in the `self`, the end iterator is returned.
    /// ## `iter`
    /// iterator to initialize
    /// ## `line_number`
    /// line number counting from 0
    fn get_iter_at_line(&self, line_number: i32) -> TextIter;

    /// Obtains an iterator pointing to `byte_index` within the given line.
    /// `byte_index` must be the start of a UTF-8 character. Note bytes, not
    /// characters; UTF-8 may encode one character as multiple bytes.
    ///
    /// Before the 3.20 version, it was not allowed to pass an invalid location.
    ///
    /// Since the 3.20 version, if `line_number` is greater than the number of lines
    /// in the `self`, the end iterator is returned. And if `byte_index` is off the
    /// end of the line, the iterator at the end of the line is returned.
    /// ## `iter`
    /// iterator to initialize
    /// ## `line_number`
    /// line number counting from 0
    /// ## `byte_index`
    /// byte index from start of line
    fn get_iter_at_line_index(&self, line_number: i32, byte_index: i32) -> TextIter;

    /// Obtains an iterator pointing to `char_offset` within the given line. Note
    /// characters, not bytes; UTF-8 may encode one character as multiple bytes.
    ///
    /// Before the 3.20 version, it was not allowed to pass an invalid location.
    ///
    /// Since the 3.20 version, if `line_number` is greater than the number of lines
    /// in the `self`, the end iterator is returned. And if `char_offset` is off the
    /// end of the line, the iterator at the end of the line is returned.
    /// ## `iter`
    /// iterator to initialize
    /// ## `line_number`
    /// line number counting from 0
    /// ## `char_offset`
    /// char offset from start of line
    fn get_iter_at_line_offset(&self, line_number: i32, char_offset: i32) -> TextIter;

    /// Initializes `iter` with the current position of `mark`.
    /// ## `iter`
    /// iterator to initialize
    /// ## `mark`
    /// a `TextMark` in `self`
    fn get_iter_at_mark(&self, mark: &TextMark) -> TextIter;

    /// Initializes `iter` to a position `char_offset` chars from the start
    /// of the entire buffer. If `char_offset` is -1 or greater than the number
    /// of characters in the buffer, `iter` is initialized to the end iterator,
    /// the iterator one past the last valid character in the buffer.
    /// ## `iter`
    /// iterator to initialize
    /// ## `char_offset`
    /// char offset from start of buffer, counting from 0, or -1
    fn get_iter_at_offset(&self, char_offset: i32) -> TextIter;

    /// Obtains the number of lines in the buffer. This value is cached, so
    /// the function is very fast.
    ///
    /// # Returns
    ///
    /// number of lines in the buffer
    fn get_line_count(&self) -> i32;

    /// Returns the mark named `name` in buffer `self`, or `None` if no such
    /// mark exists in the buffer.
    /// ## `name`
    /// a mark name
    ///
    /// # Returns
    ///
    /// a `TextMark`, or `None`
    fn get_mark(&self, name: &str) -> Option<TextMark>;

    /// Indicates whether the buffer has been modified since the last call
    /// to `TextBufferExt::set_modified` set the modification flag to
    /// `false`. Used for example to enable a “save” function in a text
    /// editor.
    ///
    /// # Returns
    ///
    /// `true` if the buffer has been modified
    fn get_modified(&self) -> bool;

    /// This function returns the list of targets this text buffer supports
    /// for pasting and as DND destination. The targets in the list are
    /// added with `info` values from the `TextBufferTargetInfo` enum,
    /// using `TargetList::add_rich_text_targets` and
    /// `TargetList::add_text_targets`.
    ///
    /// # Returns
    ///
    /// the `TargetList`
    fn get_paste_target_list(&self) -> Option<TargetList>;

    /// Returns the mark that represents the selection bound. Equivalent
    /// to calling `TextBufferExt::get_mark` to get the mark named
    /// “selection_bound”, but very slightly more efficient, and involves
    /// less typing.
    ///
    /// The currently-selected text in `self` is the region between the
    /// “selection_bound” and “insert” marks. If “selection_bound” and
    /// “insert” are in the same place, then there is no current selection.
    /// `TextBufferExt::get_selection_bounds` is another convenient function
    /// for handling the selection, if you just want to know whether there’s a
    /// selection and what its bounds are.
    ///
    /// # Returns
    ///
    /// selection bound mark
    fn get_selection_bound(&self) -> Option<TextMark>;

    /// Returns `true` if some text is selected; places the bounds
    /// of the selection in `start` and `end` (if the selection has length 0,
    /// then `start` and `end` are filled in with the same value).
    /// `start` and `end` will be in ascending order. If `start` and `end` are
    /// NULL, then they are not filled in, but the return value still indicates
    /// whether text is selected.
    /// ## `start`
    /// iterator to initialize with selection start
    /// ## `end`
    /// iterator to initialize with selection end
    ///
    /// # Returns
    ///
    /// whether the selection has nonzero length
    fn get_selection_bounds(&self) -> Option<(TextIter, TextIter)>;

    /// This function returns the rich text serialize formats registered
    /// with `self` using `TextBufferExt::register_serialize_format` or
    /// `TextBufferExt::register_serialize_tagset`
    /// ## `n_formats`
    /// return location for the number of formats
    ///
    /// # Returns
    ///
    /// an array of
    ///  ``GdkAtoms`` representing the registered formats.
    fn get_serialize_formats(&self) -> Vec<gdk::Atom>;

    /// Returns the text in the range [`start`,`end`). Excludes undisplayed
    /// text (text marked with tags that set the invisibility attribute) if
    /// `include_hidden_chars` is `false`. The returned string includes a
    /// 0xFFFC character whenever the buffer contains
    /// embedded images, so byte and character indexes into
    /// the returned string do correspond to byte
    /// and character indexes into the buffer. Contrast with
    /// `TextBufferExt::get_text`. Note that 0xFFFC can occur in normal
    /// text as well, so it is not a reliable indicator that a pixbuf or
    /// widget is in the buffer.
    /// ## `start`
    /// start of a range
    /// ## `end`
    /// end of a range
    /// ## `include_hidden_chars`
    /// whether to include invisible text
    ///
    /// # Returns
    ///
    /// an allocated UTF-8 string
    fn get_slice(&self, start: &TextIter, end: &TextIter, include_hidden_chars: bool) -> Option<String>;

    /// Initialized `iter` with the first position in the text buffer. This
    /// is the same as using `TextBufferExt::get_iter_at_offset` to get
    /// the iter at character offset 0.
    /// ## `iter`
    /// iterator to initialize
    fn get_start_iter(&self) -> TextIter;

    /// Get the `TextTagTable` associated with this buffer.
    ///
    /// # Returns
    ///
    /// the buffer’s tag table
    fn get_tag_table(&self) -> Option<TextTagTable>;

    /// Returns the text in the range [`start`,`end`). Excludes undisplayed
    /// text (text marked with tags that set the invisibility attribute) if
    /// `include_hidden_chars` is `false`. Does not include characters
    /// representing embedded images, so byte and character indexes into
    /// the returned string do not correspond to byte
    /// and character indexes into the buffer. Contrast with
    /// `TextBufferExt::get_slice`.
    /// ## `start`
    /// start of a range
    /// ## `end`
    /// end of a range
    /// ## `include_hidden_chars`
    /// whether to include invisible text
    ///
    /// # Returns
    ///
    /// an allocated UTF-8 string
    fn get_text(&self, start: &TextIter, end: &TextIter, include_hidden_chars: bool) -> Option<String>;

    /// Inserts `len` bytes of `text` at position `iter`. If `len` is -1,
    /// `text` must be nul-terminated and will be inserted in its
    /// entirety. Emits the “insert-text” signal; insertion actually occurs
    /// in the default handler for the signal. `iter` is invalidated when
    /// insertion occurs (because the buffer contents change), but the
    /// default signal handler revalidates it to point to the end of the
    /// inserted text.
    /// ## `iter`
    /// a position in the buffer
    /// ## `text`
    /// text in UTF-8 format
    /// ## `len`
    /// length of text in bytes, or -1
    fn insert(&self, iter: &mut TextIter, text: &str);

    /// Simply calls `TextBufferExt::insert`, using the current
    /// cursor position as the insertion point.
    /// ## `text`
    /// text in UTF-8 format
    /// ## `len`
    /// length of text, in bytes
    fn insert_at_cursor(&self, text: &str);

    /// Inserts a child widget anchor into the text buffer at `iter`. The
    /// anchor will be counted as one character in character counts, and
    /// when obtaining the buffer contents as a string, will be represented
    /// by the Unicode “object replacement character” 0xFFFC. Note that the
    /// “slice” variants for obtaining portions of the buffer as a string
    /// include this character for child anchors, but the “text” variants do
    /// not. E.g. see `TextBufferExt::get_slice` and
    /// `TextBufferExt::get_text`. Consider
    /// `TextBufferExt::create_child_anchor` as a more convenient
    /// alternative to this function. The buffer will add a reference to
    /// the anchor, so you can unref it after insertion.
    /// ## `iter`
    /// location to insert the anchor
    /// ## `anchor`
    /// a `TextChildAnchor`
    fn insert_child_anchor(&self, iter: &mut TextIter, anchor: &TextChildAnchor);

    /// Like `TextBufferExt::insert`, but the insertion will not occur if
    /// `iter` is at a non-editable location in the buffer. Usually you
    /// want to prevent insertions at ineditable locations if the insertion
    /// results from a user action (is interactive).
    ///
    /// `default_editable` indicates the editability of text that doesn't
    /// have a tag affecting editability applied to it. Typically the
    /// result of `TextViewExt::get_editable` is appropriate here.
    /// ## `iter`
    /// a position in `self`
    /// ## `text`
    /// some UTF-8 text
    /// ## `len`
    /// length of text in bytes, or -1
    /// ## `default_editable`
    /// default editability of buffer
    ///
    /// # Returns
    ///
    /// whether text was actually inserted
    fn insert_interactive(&self, iter: &mut TextIter, text: &str, default_editable: bool) -> bool;

    /// Calls `TextBufferExt::insert_interactive` at the cursor
    /// position.
    ///
    /// `default_editable` indicates the editability of text that doesn't
    /// have a tag affecting editability applied to it. Typically the
    /// result of `TextViewExt::get_editable` is appropriate here.
    /// ## `text`
    /// text in UTF-8 format
    /// ## `len`
    /// length of text in bytes, or -1
    /// ## `default_editable`
    /// default editability of buffer
    ///
    /// # Returns
    ///
    /// whether text was actually inserted
    fn insert_interactive_at_cursor(&self, text: &str, default_editable: bool) -> bool;

    /// Inserts the text in `markup` at position `iter`. `markup` will be inserted
    /// in its entirety and must be nul-terminated and valid UTF-8. Emits the
    /// `TextBuffer::insert-text` signal, possibly multiple times; insertion
    /// actually occurs in the default handler for the signal. `iter` will point
    /// to the end of the inserted text on return.
    ///
    /// Feature: `v3_16`
    ///
    /// ## `iter`
    /// location to insert the markup
    /// ## `markup`
    /// a nul-terminated UTF-8 string containing [Pango markup][PangoMarkupFormat]
    /// ## `len`
    /// length of `markup` in bytes, or -1
    #[cfg(any(feature = "v3_16", feature = "dox"))]
    fn insert_markup(&self, iter: &mut TextIter, markup: &str);

    /// Inserts an image into the text buffer at `iter`. The image will be
    /// counted as one character in character counts, and when obtaining
    /// the buffer contents as a string, will be represented by the Unicode
    /// “object replacement character” 0xFFFC. Note that the “slice”
    /// variants for obtaining portions of the buffer as a string include
    /// this character for pixbufs, but the “text” variants do
    /// not. e.g. see `TextBufferExt::get_slice` and
    /// `TextBufferExt::get_text`.
    /// ## `iter`
    /// location to insert the pixbuf
    /// ## `pixbuf`
    /// a `gdk_pixbuf::Pixbuf`
    fn insert_pixbuf(&self, iter: &mut TextIter, pixbuf: &gdk_pixbuf::Pixbuf);

    /// Copies text, tags, and pixbufs between `start` and `end` (the order
    /// of `start` and `end` doesn’t matter) and inserts the copy at `iter`.
    /// Used instead of simply getting/inserting text because it preserves
    /// images and tags. If `start` and `end` are in a different buffer from
    /// `self`, the two buffers must share the same tag table.
    ///
    /// Implemented via emissions of the insert_text and apply_tag signals,
    /// so expect those.
    /// ## `iter`
    /// a position in `self`
    /// ## `start`
    /// a position in a `TextBuffer`
    /// ## `end`
    /// another position in the same buffer as `start`
    fn insert_range(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter);

    /// Same as `TextBufferExt::insert_range`, but does nothing if the
    /// insertion point isn’t editable. The `default_editable` parameter
    /// indicates whether the text is editable at `iter` if no tags
    /// enclosing `iter` affect editability. Typically the result of
    /// `TextViewExt::get_editable` is appropriate here.
    /// ## `iter`
    /// a position in `self`
    /// ## `start`
    /// a position in a `TextBuffer`
    /// ## `end`
    /// another position in the same buffer as `start`
    /// ## `default_editable`
    /// default editability of the buffer
    ///
    /// # Returns
    ///
    /// whether an insertion was possible at `iter`
    fn insert_range_interactive(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter, default_editable: bool) -> bool;

    //fn insert_with_tags(&self, iter: &mut TextIter, text: &str, first_tag: &TextTag, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);

    //fn insert_with_tags_by_name(&self, iter: &mut TextIter, text: &str, first_tag_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);

    /// Moves `mark` to the new location `where_`. Emits the `TextBuffer::mark-set`
    /// signal as notification of the move.
    /// ## `mark`
    /// a `TextMark`
    /// ## `where_`
    /// new location for `mark` in `self`
    fn move_mark(&self, mark: &TextMark, where_: &TextIter);

    /// Moves the mark named `name` (which must exist) to location `where_`.
    /// See `TextBufferExt::move_mark` for details.
    /// ## `name`
    /// name of a mark
    /// ## `where_`
    /// new location for mark
    fn move_mark_by_name(&self, name: &str, where_: &TextIter);

    /// Pastes the contents of a clipboard. If `override_location` is `None`, the
    /// pasted text will be inserted at the cursor position, or the buffer selection
    /// will be replaced if the selection is non-empty.
    ///
    /// Note: pasting is asynchronous, that is, we’ll ask for the paste data and
    /// return, and at some point later after the main loop runs, the paste data will
    /// be inserted.
    /// ## `clipboard`
    /// the `Clipboard` to paste from
    /// ## `override_location`
    /// location to insert pasted text, or `None`
    /// ## `default_editable`
    /// whether the buffer is editable by default
    fn paste_clipboard<'a, P: Into<Option<&'a TextIter>>>(&self, clipboard: &Clipboard, override_location: P, default_editable: bool);

    /// This function moves the “insert” and “selection_bound” marks
    /// simultaneously. If you move them to the same place in two steps
    /// with `TextBufferExt::move_mark`, you will temporarily select a
    /// region in between their old and new locations, which can be pretty
    /// inefficient since the temporarily-selected region will force stuff
    /// to be recalculated. This function moves them as a unit, which can
    /// be optimized.
    /// ## `where_`
    /// where to put the cursor
    fn place_cursor(&self, where_: &TextIter);

    //fn register_deserialize_format(&self, mime_type: &str, function: /*Unknown conversion*//*Unimplemented*/TextBufferDeserializeFunc, user_data_destroy: /*Unknown conversion*//*Unimplemented*/DestroyNotify) -> Option<gdk::Atom>;

    /// This function registers GTK+’s internal rich text serialization
    /// format with the passed `self`. See
    /// `TextBufferExt::register_serialize_tagset` for details.
    /// ## `tagset_name`
    /// an optional tagset name, on `None`
    ///
    /// # Returns
    ///
    /// the `gdk::Atom` that corresponds to the
    ///  newly registered format’s mime-type.
    fn register_deserialize_tagset<'a, P: Into<Option<&'a str>>>(&self, tagset_name: P) -> gdk::Atom;

    //fn register_serialize_format(&self, mime_type: &str, function: /*Unknown conversion*//*Unimplemented*/TextBufferSerializeFunc, user_data_destroy: /*Unknown conversion*//*Unimplemented*/DestroyNotify) -> Option<gdk::Atom>;

    /// This function registers GTK+’s internal rich text serialization
    /// format with the passed `self`. The internal format does not comply
    /// to any standard rich text format and only works between `TextBuffer`
    /// instances. It is capable of serializing all of a text buffer’s tags
    /// and embedded pixbufs.
    ///
    /// This function is just a wrapper around
    /// `TextBufferExt::register_serialize_format`. The mime type used
    /// for registering is “application/x-gtk-text-buffer-rich-text”, or
    /// “application/x-gtk-text-buffer-rich-text;format=`tagset_name`” if a
    /// `tagset_name` was passed.
    ///
    /// The `tagset_name` can be used to restrict the transfer of rich text
    /// to buffers with compatible sets of tags, in order to avoid unknown
    /// tags from being pasted. It is probably the common case to pass an
    /// identifier != `None` here, since the `None` tagset requires the
    /// receiving buffer to deal with with pasting of arbitrary tags.
    /// ## `tagset_name`
    /// an optional tagset name, on `None`
    ///
    /// # Returns
    ///
    /// the `gdk::Atom` that corresponds to the
    ///  newly registered format’s mime-type.
    fn register_serialize_tagset<'a, P: Into<Option<&'a str>>>(&self, tagset_name: P) -> gdk::Atom;

    /// Removes all tags in the range between `start` and `end`. Be careful
    /// with this function; it could remove tags added in code unrelated to
    /// the code you’re currently writing. That is, using this function is
    /// probably a bad idea if you have two or more unrelated code sections
    /// that add tags.
    /// ## `start`
    /// one bound of range to be untagged
    /// ## `end`
    /// other bound of range to be untagged
    fn remove_all_tags(&self, start: &TextIter, end: &TextIter);

    /// Removes a `Clipboard` added with
    /// `TextBufferExt::add_selection_clipboard`.
    /// ## `clipboard`
    /// a `Clipboard` added to `self` by
    ///  `TextBufferExt::add_selection_clipboard`
    fn remove_selection_clipboard(&self, clipboard: &Clipboard);

    /// Emits the “remove-tag” signal. The default handler for the signal
    /// removes all occurrences of `tag` from the given range. `start` and
    /// `end` don’t have to be in order.
    /// ## `tag`
    /// a `TextTag`
    /// ## `start`
    /// one bound of range to be untagged
    /// ## `end`
    /// other bound of range to be untagged
    fn remove_tag(&self, tag: &TextTag, start: &TextIter, end: &TextIter);

    /// Calls `TextTagTableExt::lookup` on the buffer’s tag table to
    /// get a `TextTag`, then calls `TextBufferExt::remove_tag`.
    /// ## `name`
    /// name of a `TextTag`
    /// ## `start`
    /// one bound of range to be untagged
    /// ## `end`
    /// other bound of range to be untagged
    fn remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter);

    /// This function moves the “insert” and “selection_bound” marks
    /// simultaneously. If you move them in two steps
    /// with `TextBufferExt::move_mark`, you will temporarily select a
    /// region in between their old and new locations, which can be pretty
    /// inefficient since the temporarily-selected region will force stuff
    /// to be recalculated. This function moves them as a unit, which can
    /// be optimized.
    /// ## `ins`
    /// where to put the “insert” mark
    /// ## `bound`
    /// where to put the “selection_bound” mark
    fn select_range(&self, ins: &TextIter, bound: &TextIter);

    /// This function serializes the portion of text between `start`
    /// and `end` in the rich text format represented by `format`.
    ///
    /// `formats` to be used must be registered using
    /// `TextBufferExt::register_serialize_format` or
    /// `TextBufferExt::register_serialize_tagset` beforehand.
    /// ## `content_buffer`
    /// the `TextBuffer` to serialize
    /// ## `format`
    /// the rich text format to use for serializing
    /// ## `start`
    /// start of block of text to serialize
    /// ## `end`
    /// end of block of test to serialize
    /// ## `length`
    /// return location for the length of the serialized data
    ///
    /// # Returns
    ///
    /// the serialized
    ///  data, encoded as `format`
    fn serialize(&self, content_buffer: &TextBuffer, format: &gdk::Atom, start: &TextIter, end: &TextIter) -> Vec<u8>;

    /// Used to keep track of whether the buffer has been modified since the
    /// last time it was saved. Whenever the buffer is saved to disk, call
    /// gtk_text_buffer_set_modified (`self`, FALSE). When the buffer is modified,
    /// it will automatically toggled on the modified bit again. When the modified
    /// bit flips, the buffer emits the `TextBuffer::modified-changed` signal.
    /// ## `setting`
    /// modification flag setting
    fn set_modified(&self, setting: bool);

    /// Deletes current contents of `self`, and inserts `text` instead. If
    /// `len` is -1, `text` must be nul-terminated. `text` must be valid UTF-8.
    /// ## `text`
    /// UTF-8 text to insert
    /// ## `len`
    /// length of `text` in bytes
    fn set_text(&self, text: &str);

    /// This function unregisters a rich text format that was previously
    /// registered using `TextBufferExt::register_deserialize_format` or
    /// `TextBufferExt::register_deserialize_tagset`.
    /// ## `format`
    /// a `gdk::Atom` representing a registered rich text format.
    fn unregister_deserialize_format(&self, format: &gdk::Atom);

    /// This function unregisters a rich text format that was previously
    /// registered using `TextBufferExt::register_serialize_format` or
    /// `TextBufferExt::register_serialize_tagset`
    /// ## `format`
    /// a `gdk::Atom` representing a registered rich text format.
    fn unregister_serialize_format(&self, format: &gdk::Atom);

    fn get_property_cursor_position(&self) -> i32;

    /// The ::apply-tag signal is emitted to apply a tag to a
    /// range of text in a `TextBuffer`.
    /// Applying actually occurs in the default handler.
    ///
    /// Note that if your handler runs before the default handler it must not
    /// invalidate the `start` and `end` iters (or has to revalidate them).
    ///
    /// See also:
    /// `TextBufferExt::apply_tag`,
    /// `TextBufferExt::insert_with_tags`,
    /// `TextBufferExt::insert_range`.
    /// ## `tag`
    /// the applied tag
    /// ## `start`
    /// the start of the range the tag is applied to
    /// ## `end`
    /// the end of the range the tag is applied to
    fn connect_apply_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(&self, f: F) -> SignalHandlerId;

    /// The ::begin-user-action signal is emitted at the beginning of a single
    /// user-visible operation on a `TextBuffer`.
    ///
    /// See also:
    /// `TextBufferExt::begin_user_action`,
    /// `TextBufferExt::insert_interactive`,
    /// `TextBufferExt::insert_range_interactive`,
    /// `TextBufferExt::delete_interactive`,
    /// `TextBufferExt::backspace`,
    /// `TextBufferExt::delete_selection`.
    fn connect_begin_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    /// The ::changed signal is emitted when the content of a `TextBuffer`
    /// has changed.
    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    /// The ::delete-range signal is emitted to delete a range
    /// from a `TextBuffer`.
    ///
    /// Note that if your handler runs before the default handler it must not
    /// invalidate the `start` and `end` iters (or has to revalidate them).
    /// The default signal handler revalidates the `start` and `end` iters to
    /// both point to the location where text was deleted. Handlers
    /// which run after the default handler (see `g_signal_connect_after`)
    /// do not have access to the deleted text.
    ///
    /// See also: `TextBufferExt::delete`.
    /// ## `start`
    /// the start of the range to be deleted
    /// ## `end`
    /// the end of the range to be deleted
    fn connect_delete_range<F: Fn(&Self, &TextIter, &TextIter) + 'static>(&self, f: F) -> SignalHandlerId;

    /// The ::end-user-action signal is emitted at the end of a single
    /// user-visible operation on the `TextBuffer`.
    ///
    /// See also:
    /// `TextBufferExt::end_user_action`,
    /// `TextBufferExt::insert_interactive`,
    /// `TextBufferExt::insert_range_interactive`,
    /// `TextBufferExt::delete_interactive`,
    /// `TextBufferExt::backspace`,
    /// `TextBufferExt::delete_selection`,
    /// `TextBufferExt::backspace`.
    fn connect_end_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    /// The ::insert-child-anchor signal is emitted to insert a
    /// `TextChildAnchor` in a `TextBuffer`.
    /// Insertion actually occurs in the default handler.
    ///
    /// Note that if your handler runs before the default handler it must
    /// not invalidate the `location` iter (or has to revalidate it).
    /// The default signal handler revalidates it to be placed after the
    /// inserted `anchor`.
    ///
    /// See also: `TextBufferExt::insert_child_anchor`.
    /// ## `location`
    /// position to insert `anchor` in `textbuffer`
    /// ## `anchor`
    /// the `TextChildAnchor` to be inserted
    fn connect_insert_child_anchor<F: Fn(&Self, &TextIter, &TextChildAnchor) + 'static>(&self, f: F) -> SignalHandlerId;

    /// The ::insert-pixbuf signal is emitted to insert a `gdk_pixbuf::Pixbuf`
    /// in a `TextBuffer`. Insertion actually occurs in the default handler.
    ///
    /// Note that if your handler runs before the default handler it must not
    /// invalidate the `location` iter (or has to revalidate it).
    /// The default signal handler revalidates it to be placed after the
    /// inserted `pixbuf`.
    ///
    /// See also: `TextBufferExt::insert_pixbuf`.
    /// ## `location`
    /// position to insert `pixbuf` in `textbuffer`
    /// ## `pixbuf`
    /// the `gdk_pixbuf::Pixbuf` to be inserted
    fn connect_insert_pixbuf<F: Fn(&Self, &TextIter, &gdk_pixbuf::Pixbuf) + 'static>(&self, f: F) -> SignalHandlerId;

    /// The ::mark-deleted signal is emitted as notification
    /// after a `TextMark` is deleted.
    ///
    /// See also:
    /// `TextBufferExt::delete_mark`.
    /// ## `mark`
    /// The mark that was deleted
    fn connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>(&self, f: F) -> SignalHandlerId;

    /// The ::mark-set signal is emitted as notification
    /// after a `TextMark` is set.
    ///
    /// See also:
    /// `TextBufferExt::create_mark`,
    /// `TextBufferExt::move_mark`.
    /// ## `location`
    /// The location of `mark` in `textbuffer`
    /// ## `mark`
    /// The mark that is set
    fn connect_mark_set<F: Fn(&Self, &TextIter, &TextMark) + 'static>(&self, f: F) -> SignalHandlerId;

    /// The ::modified-changed signal is emitted when the modified bit of a
    /// `TextBuffer` flips.
    ///
    /// See also:
    /// `TextBufferExt::set_modified`.
    fn connect_modified_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    /// The paste-done signal is emitted after paste operation has been completed.
    /// This is useful to properly scroll the view to the end of the pasted text.
    /// See `TextBufferExt::paste_clipboard` for more details.
    /// ## `clipboard`
    /// the `Clipboard` pasted from
    fn connect_paste_done<F: Fn(&Self, &Clipboard) + 'static>(&self, f: F) -> SignalHandlerId;

    /// The ::remove-tag signal is emitted to remove all occurrences of `tag` from
    /// a range of text in a `TextBuffer`.
    /// Removal actually occurs in the default handler.
    ///
    /// Note that if your handler runs before the default handler it must not
    /// invalidate the `start` and `end` iters (or has to revalidate them).
    ///
    /// See also:
    /// `TextBufferExt::remove_tag`.
    /// ## `tag`
    /// the tag to be removed
    /// ## `start`
    /// the start of the range the tag is removed from
    /// ## `end`
    /// the end of the range the tag is removed from
    fn connect_remove_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_copy_target_list_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_cursor_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_has_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_paste_target_list_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_tag_table_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<TextBuffer> + IsA<glib::object::Object>> TextBufferExt for O {
    fn add_mark(&self, mark: &TextMark, where_: &TextIter) {
        unsafe {
            ffi::gtk_text_buffer_add_mark(self.to_glib_none().0, mark.to_glib_none().0, where_.to_glib_none().0);
        }
    }

    fn add_selection_clipboard(&self, clipboard: &Clipboard) {
        unsafe {
            ffi::gtk_text_buffer_add_selection_clipboard(self.to_glib_none().0, clipboard.to_glib_none().0);
        }
    }

    fn apply_tag(&self, tag: &TextTag, start: &TextIter, end: &TextIter) {
        unsafe {
            ffi::gtk_text_buffer_apply_tag(self.to_glib_none().0, tag.to_glib_none().0, start.to_glib_none().0, end.to_glib_none().0);
        }
    }

    fn apply_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter) {
        unsafe {
            ffi::gtk_text_buffer_apply_tag_by_name(self.to_glib_none().0, name.to_glib_none().0, start.to_glib_none().0, end.to_glib_none().0);
        }
    }

    fn backspace(&self, iter: &mut TextIter, interactive: bool, default_editable: bool) -> bool {
        unsafe {
            from_glib(ffi::gtk_text_buffer_backspace(self.to_glib_none().0, iter.to_glib_none_mut().0, interactive.to_glib(), default_editable.to_glib()))
        }
    }

    fn begin_user_action(&self) {
        unsafe {
            ffi::gtk_text_buffer_begin_user_action(self.to_glib_none().0);
        }
    }

    fn copy_clipboard(&self, clipboard: &Clipboard) {
        unsafe {
            ffi::gtk_text_buffer_copy_clipboard(self.to_glib_none().0, clipboard.to_glib_none().0);
        }
    }

    fn create_child_anchor(&self, iter: &mut TextIter) -> Option<TextChildAnchor> {
        unsafe {
            from_glib_none(ffi::gtk_text_buffer_create_child_anchor(self.to_glib_none().0, iter.to_glib_none_mut().0))
        }
    }

    fn create_mark<'a, P: Into<Option<&'a str>>>(&self, mark_name: P, where_: &TextIter, left_gravity: bool) -> Option<TextMark> {
        let mark_name = mark_name.into();
        let mark_name = mark_name.to_glib_none();
        unsafe {
            from_glib_none(ffi::gtk_text_buffer_create_mark(self.to_glib_none().0, mark_name.0, where_.to_glib_none().0, left_gravity.to_glib()))
        }
    }

    //fn create_tag<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b str>>>(&self, tag_name: P, first_property_name: Q, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option<TextTag> {
    //    unsafe { TODO: call ffi::gtk_text_buffer_create_tag() }
    //}

    fn cut_clipboard(&self, clipboard: &Clipboard, default_editable: bool) {
        unsafe {
            ffi::gtk_text_buffer_cut_clipboard(self.to_glib_none().0, clipboard.to_glib_none().0, default_editable.to_glib());
        }
    }

    fn delete(&self, start: &mut TextIter, end: &mut TextIter) {
        unsafe {
            ffi::gtk_text_buffer_delete(self.to_glib_none().0, start.to_glib_none_mut().0, end.to_glib_none_mut().0);
        }
    }

    fn delete_interactive(&self, start_iter: &mut TextIter, end_iter: &mut TextIter, default_editable: bool) -> bool {
        unsafe {
            from_glib(ffi::gtk_text_buffer_delete_interactive(self.to_glib_none().0, start_iter.to_glib_none_mut().0, end_iter.to_glib_none_mut().0, default_editable.to_glib()))
        }
    }

    fn delete_mark(&self, mark: &TextMark) {
        unsafe {
            ffi::gtk_text_buffer_delete_mark(self.to_glib_none().0, mark.to_glib_none().0);
        }
    }

    fn delete_mark_by_name(&self, name: &str) {
        unsafe {
            ffi::gtk_text_buffer_delete_mark_by_name(self.to_glib_none().0, name.to_glib_none().0);
        }
    }

    fn delete_selection(&self, interactive: bool, default_editable: bool) -> bool {
        unsafe {
            from_glib(ffi::gtk_text_buffer_delete_selection(self.to_glib_none().0, interactive.to_glib(), default_editable.to_glib()))
        }
    }

    fn deserialize(&self, content_buffer: &TextBuffer, format: &gdk::Atom, iter: &mut TextIter, data: &[u8]) -> Result<(), Error> {
        let length = data.len() as usize;
        unsafe {
            let mut error = ptr::null_mut();
            let _ = ffi::gtk_text_buffer_deserialize(self.to_glib_none().0, content_buffer.to_glib_none().0, format.to_glib_none().0, iter.to_glib_none_mut().0, data.to_glib_none().0, length, &mut error);
            if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
        }
    }

    fn deserialize_get_can_create_tags(&self, format: &gdk::Atom) -> bool {
        unsafe {
            from_glib(ffi::gtk_text_buffer_deserialize_get_can_create_tags(self.to_glib_none().0, format.to_glib_none().0))
        }
    }

    fn deserialize_set_can_create_tags(&self, format: &gdk::Atom, can_create_tags: bool) {
        unsafe {
            ffi::gtk_text_buffer_deserialize_set_can_create_tags(self.to_glib_none().0, format.to_glib_none().0, can_create_tags.to_glib());
        }
    }

    fn end_user_action(&self) {
        unsafe {
            ffi::gtk_text_buffer_end_user_action(self.to_glib_none().0);
        }
    }

    fn get_bounds(&self) -> (TextIter, TextIter) {
        unsafe {
            let mut start = TextIter::uninitialized();
            let mut end = TextIter::uninitialized();
            ffi::gtk_text_buffer_get_bounds(self.to_glib_none().0, start.to_glib_none_mut().0, end.to_glib_none_mut().0);
            (start, end)
        }
    }

    fn get_char_count(&self) -> i32 {
        unsafe {
            ffi::gtk_text_buffer_get_char_count(self.to_glib_none().0)
        }
    }

    fn get_copy_target_list(&self) -> Option<TargetList> {
        unsafe {
            from_glib_none(ffi::gtk_text_buffer_get_copy_target_list(self.to_glib_none().0))
        }
    }

    fn get_deserialize_formats(&self) -> Vec<gdk::Atom> {
        unsafe {
            let mut n_formats = mem::uninitialized();
            let ret = FromGlibContainer::from_glib_container_num(ffi::gtk_text_buffer_get_deserialize_formats(self.to_glib_none().0, &mut n_formats), n_formats as usize);
            ret
        }
    }

    fn get_end_iter(&self) -> TextIter {
        unsafe {
            let mut iter = TextIter::uninitialized();
            ffi::gtk_text_buffer_get_end_iter(self.to_glib_none().0, iter.to_glib_none_mut().0);
            iter
        }
    }

    fn get_has_selection(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_text_buffer_get_has_selection(self.to_glib_none().0))
        }
    }

    fn get_insert(&self) -> Option<TextMark> {
        unsafe {
            from_glib_none(ffi::gtk_text_buffer_get_insert(self.to_glib_none().0))
        }
    }

    fn get_iter_at_child_anchor(&self, anchor: &TextChildAnchor) -> TextIter {
        unsafe {
            let mut iter = TextIter::uninitialized();
            ffi::gtk_text_buffer_get_iter_at_child_anchor(self.to_glib_none().0, iter.to_glib_none_mut().0, anchor.to_glib_none().0);
            iter
        }
    }

    fn get_iter_at_line(&self, line_number: i32) -> TextIter {
        unsafe {
            let mut iter = TextIter::uninitialized();
            ffi::gtk_text_buffer_get_iter_at_line(self.to_glib_none().0, iter.to_glib_none_mut().0, line_number);
            iter
        }
    }

    fn get_iter_at_line_index(&self, line_number: i32, byte_index: i32) -> TextIter {
        unsafe {
            let mut iter = TextIter::uninitialized();
            ffi::gtk_text_buffer_get_iter_at_line_index(self.to_glib_none().0, iter.to_glib_none_mut().0, line_number, byte_index);
            iter
        }
    }

    fn get_iter_at_line_offset(&self, line_number: i32, char_offset: i32) -> TextIter {
        unsafe {
            let mut iter = TextIter::uninitialized();
            ffi::gtk_text_buffer_get_iter_at_line_offset(self.to_glib_none().0, iter.to_glib_none_mut().0, line_number, char_offset);
            iter
        }
    }

    fn get_iter_at_mark(&self, mark: &TextMark) -> TextIter {
        unsafe {
            let mut iter = TextIter::uninitialized();
            ffi::gtk_text_buffer_get_iter_at_mark(self.to_glib_none().0, iter.to_glib_none_mut().0, mark.to_glib_none().0);
            iter
        }
    }

    fn get_iter_at_offset(&self, char_offset: i32) -> TextIter {
        unsafe {
            let mut iter = TextIter::uninitialized();
            ffi::gtk_text_buffer_get_iter_at_offset(self.to_glib_none().0, iter.to_glib_none_mut().0, char_offset);
            iter
        }
    }

    fn get_line_count(&self) -> i32 {
        unsafe {
            ffi::gtk_text_buffer_get_line_count(self.to_glib_none().0)
        }
    }

    fn get_mark(&self, name: &str) -> Option<TextMark> {
        unsafe {
            from_glib_none(ffi::gtk_text_buffer_get_mark(self.to_glib_none().0, name.to_glib_none().0))
        }
    }

    fn get_modified(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_text_buffer_get_modified(self.to_glib_none().0))
        }
    }

    fn get_paste_target_list(&self) -> Option<TargetList> {
        unsafe {
            from_glib_none(ffi::gtk_text_buffer_get_paste_target_list(self.to_glib_none().0))
        }
    }

    fn get_selection_bound(&self) -> Option<TextMark> {
        unsafe {
            from_glib_none(ffi::gtk_text_buffer_get_selection_bound(self.to_glib_none().0))
        }
    }

    fn get_selection_bounds(&self) -> Option<(TextIter, TextIter)> {
        unsafe {
            let mut start = TextIter::uninitialized();
            let mut end = TextIter::uninitialized();
            let ret = from_glib(ffi::gtk_text_buffer_get_selection_bounds(self.to_glib_none().0, start.to_glib_none_mut().0, end.to_glib_none_mut().0));
            if ret { Some((start, end)) } else { None }
        }
    }

    fn get_serialize_formats(&self) -> Vec<gdk::Atom> {
        unsafe {
            let mut n_formats = mem::uninitialized();
            let ret = FromGlibContainer::from_glib_container_num(ffi::gtk_text_buffer_get_serialize_formats(self.to_glib_none().0, &mut n_formats), n_formats as usize);
            ret
        }
    }

    fn get_slice(&self, start: &TextIter, end: &TextIter, include_hidden_chars: bool) -> Option<String> {
        unsafe {
            from_glib_full(ffi::gtk_text_buffer_get_slice(self.to_glib_none().0, start.to_glib_none().0, end.to_glib_none().0, include_hidden_chars.to_glib()))
        }
    }

    fn get_start_iter(&self) -> TextIter {
        unsafe {
            let mut iter = TextIter::uninitialized();
            ffi::gtk_text_buffer_get_start_iter(self.to_glib_none().0, iter.to_glib_none_mut().0);
            iter
        }
    }

    fn get_tag_table(&self) -> Option<TextTagTable> {
        unsafe {
            from_glib_none(ffi::gtk_text_buffer_get_tag_table(self.to_glib_none().0))
        }
    }

    fn get_text(&self, start: &TextIter, end: &TextIter, include_hidden_chars: bool) -> Option<String> {
        unsafe {
            from_glib_full(ffi::gtk_text_buffer_get_text(self.to_glib_none().0, start.to_glib_none().0, end.to_glib_none().0, include_hidden_chars.to_glib()))
        }
    }

    fn insert(&self, iter: &mut TextIter, text: &str) {
        let len = text.len() as i32;
        unsafe {
            ffi::gtk_text_buffer_insert(self.to_glib_none().0, iter.to_glib_none_mut().0, text.to_glib_none().0, len);
        }
    }

    fn insert_at_cursor(&self, text: &str) {
        let len = text.len() as i32;
        unsafe {
            ffi::gtk_text_buffer_insert_at_cursor(self.to_glib_none().0, text.to_glib_none().0, len);
        }
    }

    fn insert_child_anchor(&self, iter: &mut TextIter, anchor: &TextChildAnchor) {
        unsafe {
            ffi::gtk_text_buffer_insert_child_anchor(self.to_glib_none().0, iter.to_glib_none_mut().0, anchor.to_glib_none().0);
        }
    }

    fn insert_interactive(&self, iter: &mut TextIter, text: &str, default_editable: bool) -> bool {
        let len = text.len() as i32;
        unsafe {
            from_glib(ffi::gtk_text_buffer_insert_interactive(self.to_glib_none().0, iter.to_glib_none_mut().0, text.to_glib_none().0, len, default_editable.to_glib()))
        }
    }

    fn insert_interactive_at_cursor(&self, text: &str, default_editable: bool) -> bool {
        let len = text.len() as i32;
        unsafe {
            from_glib(ffi::gtk_text_buffer_insert_interactive_at_cursor(self.to_glib_none().0, text.to_glib_none().0, len, default_editable.to_glib()))
        }
    }

    #[cfg(any(feature = "v3_16", feature = "dox"))]
    fn insert_markup(&self, iter: &mut TextIter, markup: &str) {
        let len = markup.len() as i32;
        unsafe {
            ffi::gtk_text_buffer_insert_markup(self.to_glib_none().0, iter.to_glib_none_mut().0, markup.to_glib_none().0, len);
        }
    }

    fn insert_pixbuf(&self, iter: &mut TextIter, pixbuf: &gdk_pixbuf::Pixbuf) {
        unsafe {
            ffi::gtk_text_buffer_insert_pixbuf(self.to_glib_none().0, iter.to_glib_none_mut().0, pixbuf.to_glib_none().0);
        }
    }

    fn insert_range(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter) {
        unsafe {
            ffi::gtk_text_buffer_insert_range(self.to_glib_none().0, iter.to_glib_none_mut().0, start.to_glib_none().0, end.to_glib_none().0);
        }
    }

    fn insert_range_interactive(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter, default_editable: bool) -> bool {
        unsafe {
            from_glib(ffi::gtk_text_buffer_insert_range_interactive(self.to_glib_none().0, iter.to_glib_none_mut().0, start.to_glib_none().0, end.to_glib_none().0, default_editable.to_glib()))
        }
    }

    //fn insert_with_tags(&self, iter: &mut TextIter, text: &str, first_tag: &TextTag, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
    //    unsafe { TODO: call ffi::gtk_text_buffer_insert_with_tags() }
    //}

    //fn insert_with_tags_by_name(&self, iter: &mut TextIter, text: &str, first_tag_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
    //    unsafe { TODO: call ffi::gtk_text_buffer_insert_with_tags_by_name() }
    //}

    fn move_mark(&self, mark: &TextMark, where_: &TextIter) {
        unsafe {
            ffi::gtk_text_buffer_move_mark(self.to_glib_none().0, mark.to_glib_none().0, where_.to_glib_none().0);
        }
    }

    fn move_mark_by_name(&self, name: &str, where_: &TextIter) {
        unsafe {
            ffi::gtk_text_buffer_move_mark_by_name(self.to_glib_none().0, name.to_glib_none().0, where_.to_glib_none().0);
        }
    }

    fn paste_clipboard<'a, P: Into<Option<&'a TextIter>>>(&self, clipboard: &Clipboard, override_location: P, default_editable: bool) {
        let override_location = override_location.into();
        unsafe {
            ffi::gtk_text_buffer_paste_clipboard(self.to_glib_none().0, clipboard.to_glib_none().0, mut_override(override_location.to_glib_none().0), default_editable.to_glib());
        }
    }

    fn place_cursor(&self, where_: &TextIter) {
        unsafe {
            ffi::gtk_text_buffer_place_cursor(self.to_glib_none().0, where_.to_glib_none().0);
        }
    }

    //fn register_deserialize_format(&self, mime_type: &str, function: /*Unknown conversion*//*Unimplemented*/TextBufferDeserializeFunc, user_data_destroy: /*Unknown conversion*//*Unimplemented*/DestroyNotify) -> Option<gdk::Atom> {
    //    unsafe { TODO: call ffi::gtk_text_buffer_register_deserialize_format() }
    //}

    fn register_deserialize_tagset<'a, P: Into<Option<&'a str>>>(&self, tagset_name: P) -> gdk::Atom {
        let tagset_name = tagset_name.into();
        let tagset_name = tagset_name.to_glib_none();
        unsafe {
            from_glib_none(ffi::gtk_text_buffer_register_deserialize_tagset(self.to_glib_none().0, tagset_name.0))
        }
    }

    //fn register_serialize_format(&self, mime_type: &str, function: /*Unknown conversion*//*Unimplemented*/TextBufferSerializeFunc, user_data_destroy: /*Unknown conversion*//*Unimplemented*/DestroyNotify) -> Option<gdk::Atom> {
    //    unsafe { TODO: call ffi::gtk_text_buffer_register_serialize_format() }
    //}

    fn register_serialize_tagset<'a, P: Into<Option<&'a str>>>(&self, tagset_name: P) -> gdk::Atom {
        let tagset_name = tagset_name.into();
        let tagset_name = tagset_name.to_glib_none();
        unsafe {
            from_glib_none(ffi::gtk_text_buffer_register_serialize_tagset(self.to_glib_none().0, tagset_name.0))
        }
    }

    fn remove_all_tags(&self, start: &TextIter, end: &TextIter) {
        unsafe {
            ffi::gtk_text_buffer_remove_all_tags(self.to_glib_none().0, start.to_glib_none().0, end.to_glib_none().0);
        }
    }

    fn remove_selection_clipboard(&self, clipboard: &Clipboard) {
        unsafe {
            ffi::gtk_text_buffer_remove_selection_clipboard(self.to_glib_none().0, clipboard.to_glib_none().0);
        }
    }

    fn remove_tag(&self, tag: &TextTag, start: &TextIter, end: &TextIter) {
        unsafe {
            ffi::gtk_text_buffer_remove_tag(self.to_glib_none().0, tag.to_glib_none().0, start.to_glib_none().0, end.to_glib_none().0);
        }
    }

    fn remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter) {
        unsafe {
            ffi::gtk_text_buffer_remove_tag_by_name(self.to_glib_none().0, name.to_glib_none().0, start.to_glib_none().0, end.to_glib_none().0);
        }
    }

    fn select_range(&self, ins: &TextIter, bound: &TextIter) {
        unsafe {
            ffi::gtk_text_buffer_select_range(self.to_glib_none().0, ins.to_glib_none().0, bound.to_glib_none().0);
        }
    }

    fn serialize(&self, content_buffer: &TextBuffer, format: &gdk::Atom, start: &TextIter, end: &TextIter) -> Vec<u8> {
        unsafe {
            let mut length = mem::uninitialized();
            let ret = FromGlibContainer::from_glib_full_num(ffi::gtk_text_buffer_serialize(self.to_glib_none().0, content_buffer.to_glib_none().0, format.to_glib_none().0, start.to_glib_none().0, end.to_glib_none().0, &mut length), length as usize);
            ret
        }
    }

    fn set_modified(&self, setting: bool) {
        unsafe {
            ffi::gtk_text_buffer_set_modified(self.to_glib_none().0, setting.to_glib());
        }
    }

    fn set_text(&self, text: &str) {
        let len = text.len() as i32;
        unsafe {
            ffi::gtk_text_buffer_set_text(self.to_glib_none().0, text.to_glib_none().0, len);
        }
    }

    fn unregister_deserialize_format(&self, format: &gdk::Atom) {
        unsafe {
            ffi::gtk_text_buffer_unregister_deserialize_format(self.to_glib_none().0, format.to_glib_none().0);
        }
    }

    fn unregister_serialize_format(&self, format: &gdk::Atom) {
        unsafe {
            ffi::gtk_text_buffer_unregister_serialize_format(self.to_glib_none().0, format.to_glib_none().0);
        }
    }

    fn get_property_cursor_position(&self) -> i32 {
        unsafe {
            let mut value = Value::from_type(<i32 as StaticType>::static_type());
            gobject_ffi::g_object_get_property(self.to_glib_none().0, "cursor-position".to_glib_none().0, value.to_glib_none_mut().0);
            value.get().unwrap()
        }
    }

    fn connect_apply_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "apply-tag",
                transmute(apply_tag_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_begin_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "begin-user-action",
                transmute(begin_user_action_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "changed",
                transmute(changed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_delete_range<F: Fn(&Self, &TextIter, &TextIter) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &TextIter, &TextIter) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "delete-range",
                transmute(delete_range_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_end_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "end-user-action",
                transmute(end_user_action_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_insert_child_anchor<F: Fn(&Self, &TextIter, &TextChildAnchor) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &TextIter, &TextChildAnchor) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "insert-child-anchor",
                transmute(insert_child_anchor_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_insert_pixbuf<F: Fn(&Self, &TextIter, &gdk_pixbuf::Pixbuf) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &TextIter, &gdk_pixbuf::Pixbuf) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "insert-pixbuf",
                transmute(insert_pixbuf_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &TextMark) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "mark-deleted",
                transmute(mark_deleted_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_mark_set<F: Fn(&Self, &TextIter, &TextMark) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &TextIter, &TextMark) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "mark-set",
                transmute(mark_set_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_modified_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "modified-changed",
                transmute(modified_changed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_paste_done<F: Fn(&Self, &Clipboard) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &Clipboard) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "paste-done",
                transmute(paste_done_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_remove_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "remove-tag",
                transmute(remove_tag_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_copy_target_list_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::copy-target-list",
                transmute(notify_copy_target_list_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_cursor_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::cursor-position",
                transmute(notify_cursor_position_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_has_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::has-selection",
                transmute(notify_has_selection_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_paste_target_list_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::paste-target-list",
                transmute(notify_paste_target_list_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_tag_table_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::tag-table",
                transmute(notify_tag_table_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::text",
                transmute(notify_text_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
}

unsafe extern "C" fn apply_tag_trampoline<P>(this: *mut ffi::GtkTextBuffer, tag: *mut ffi::GtkTextTag, start: *mut ffi::GtkTextIter, end: *mut ffi::GtkTextIter, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P, &TextTag, &TextIter, &TextIter) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(tag), &from_glib_borrow(start), &from_glib_borrow(end))
}

unsafe extern "C" fn begin_user_action_trampoline<P>(this: *mut ffi::GtkTextBuffer, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn changed_trampoline<P>(this: *mut ffi::GtkTextBuffer, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn delete_range_trampoline<P>(this: *mut ffi::GtkTextBuffer, start: *mut ffi::GtkTextIter, end: *mut ffi::GtkTextIter, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P, &TextIter, &TextIter) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(start), &from_glib_borrow(end))
}

unsafe extern "C" fn end_user_action_trampoline<P>(this: *mut ffi::GtkTextBuffer, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn insert_child_anchor_trampoline<P>(this: *mut ffi::GtkTextBuffer, location: *mut ffi::GtkTextIter, anchor: *mut ffi::GtkTextChildAnchor, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P, &TextIter, &TextChildAnchor) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(location), &from_glib_borrow(anchor))
}

unsafe extern "C" fn insert_pixbuf_trampoline<P>(this: *mut ffi::GtkTextBuffer, location: *mut ffi::GtkTextIter, pixbuf: *mut gdk_pixbuf_ffi::GdkPixbuf, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P, &TextIter, &gdk_pixbuf::Pixbuf) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(location), &from_glib_borrow(pixbuf))
}

unsafe extern "C" fn mark_deleted_trampoline<P>(this: *mut ffi::GtkTextBuffer, mark: *mut ffi::GtkTextMark, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P, &TextMark) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(mark))
}

unsafe extern "C" fn mark_set_trampoline<P>(this: *mut ffi::GtkTextBuffer, location: *mut ffi::GtkTextIter, mark: *mut ffi::GtkTextMark, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P, &TextIter, &TextMark) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(location), &from_glib_borrow(mark))
}

unsafe extern "C" fn modified_changed_trampoline<P>(this: *mut ffi::GtkTextBuffer, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn paste_done_trampoline<P>(this: *mut ffi::GtkTextBuffer, clipboard: *mut ffi::GtkClipboard, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P, &Clipboard) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(clipboard))
}

unsafe extern "C" fn remove_tag_trampoline<P>(this: *mut ffi::GtkTextBuffer, tag: *mut ffi::GtkTextTag, start: *mut ffi::GtkTextIter, end: *mut ffi::GtkTextIter, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P, &TextTag, &TextIter, &TextIter) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(tag), &from_glib_borrow(start), &from_glib_borrow(end))
}

unsafe extern "C" fn notify_copy_target_list_trampoline<P>(this: *mut ffi::GtkTextBuffer, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn notify_cursor_position_trampoline<P>(this: *mut ffi::GtkTextBuffer, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn notify_has_selection_trampoline<P>(this: *mut ffi::GtkTextBuffer, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn notify_paste_target_list_trampoline<P>(this: *mut ffi::GtkTextBuffer, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn notify_tag_table_trampoline<P>(this: *mut ffi::GtkTextBuffer, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn notify_text_trampoline<P>(this: *mut ffi::GtkTextBuffer, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<TextBuffer> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&TextBuffer::from_glib_borrow(this).downcast_unchecked())
}