gtk/auto/
text_buffer.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use gdk;
6use gdk_pixbuf;
7use gdk_pixbuf_sys;
8use glib::object::Cast;
9use glib::object::IsA;
10use glib::signal::connect_raw;
11use glib::signal::SignalHandlerId;
12use glib::translate::*;
13use glib::GString;
14use glib::StaticType;
15use glib::ToValue;
16use glib::Value;
17use glib_sys;
18use gobject_sys;
19use gtk_sys;
20use std::boxed::Box as Box_;
21use std::fmt;
22use std::mem;
23use std::mem::transmute;
24use std::ptr;
25use Clipboard;
26use Error;
27use TargetList;
28use TextChildAnchor;
29use TextIter;
30use TextMark;
31use TextTag;
32use TextTagTable;
33
34glib_wrapper! {
35    pub struct TextBuffer(Object<gtk_sys::GtkTextBuffer, gtk_sys::GtkTextBufferClass, TextBufferClass>);
36
37    match fn {
38        get_type => || gtk_sys::gtk_text_buffer_get_type(),
39    }
40}
41
42impl TextBuffer {
43    pub fn new<P: IsA<TextTagTable>>(table: Option<&P>) -> TextBuffer {
44        assert_initialized_main_thread!();
45        unsafe {
46            from_glib_full(gtk_sys::gtk_text_buffer_new(
47                table.map(|p| p.as_ref()).to_glib_none().0,
48            ))
49        }
50    }
51}
52
53pub struct TextBufferBuilder {
54    tag_table: Option<TextTagTable>,
55    text: Option<String>,
56}
57
58impl TextBufferBuilder {
59    pub fn new() -> Self {
60        Self {
61            tag_table: None,
62            text: None,
63        }
64    }
65
66    pub fn build(self) -> TextBuffer {
67        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
68        if let Some(ref tag_table) = self.tag_table {
69            properties.push(("tag-table", tag_table));
70        }
71        if let Some(ref text) = self.text {
72            properties.push(("text", text));
73        }
74        glib::Object::new(TextBuffer::static_type(), &properties)
75            .expect("object new")
76            .downcast()
77            .expect("downcast")
78    }
79
80    pub fn tag_table(mut self, tag_table: &TextTagTable) -> Self {
81        self.tag_table = Some(tag_table.clone());
82        self
83    }
84
85    pub fn text(mut self, text: &str) -> Self {
86        self.text = Some(text.to_string());
87        self
88    }
89}
90
91pub const NONE_TEXT_BUFFER: Option<&TextBuffer> = None;
92
93pub trait TextBufferExt: 'static {
94    fn add_mark<P: IsA<TextMark>>(&self, mark: &P, where_: &TextIter);
95
96    fn add_selection_clipboard(&self, clipboard: &Clipboard);
97
98    fn apply_tag<P: IsA<TextTag>>(&self, tag: &P, start: &TextIter, end: &TextIter);
99
100    fn apply_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter);
101
102    fn backspace(&self, iter: &mut TextIter, interactive: bool, default_editable: bool) -> bool;
103
104    fn begin_user_action(&self);
105
106    fn copy_clipboard(&self, clipboard: &Clipboard);
107
108    fn create_child_anchor(&self, iter: &mut TextIter) -> Option<TextChildAnchor>;
109
110    fn create_mark(
111        &self,
112        mark_name: Option<&str>,
113        where_: &TextIter,
114        left_gravity: bool,
115    ) -> Option<TextMark>;
116
117    //fn create_tag(&self, tag_name: Option<&str>, first_property_name: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option<TextTag>;
118
119    fn cut_clipboard(&self, clipboard: &Clipboard, default_editable: bool);
120
121    fn delete(&self, start: &mut TextIter, end: &mut TextIter);
122
123    fn delete_interactive(
124        &self,
125        start_iter: &mut TextIter,
126        end_iter: &mut TextIter,
127        default_editable: bool,
128    ) -> bool;
129
130    fn delete_mark<P: IsA<TextMark>>(&self, mark: &P);
131
132    fn delete_mark_by_name(&self, name: &str);
133
134    fn delete_selection(&self, interactive: bool, default_editable: bool) -> bool;
135
136    fn deserialize<P: IsA<TextBuffer>>(
137        &self,
138        content_buffer: &P,
139        format: &gdk::Atom,
140        iter: &mut TextIter,
141        data: &[u8],
142    ) -> Result<(), Error>;
143
144    fn deserialize_get_can_create_tags(&self, format: &gdk::Atom) -> bool;
145
146    fn deserialize_set_can_create_tags(&self, format: &gdk::Atom, can_create_tags: bool);
147
148    fn end_user_action(&self);
149
150    fn get_bounds(&self) -> (TextIter, TextIter);
151
152    fn get_char_count(&self) -> i32;
153
154    fn get_copy_target_list(&self) -> Option<TargetList>;
155
156    fn get_deserialize_formats(&self) -> Vec<gdk::Atom>;
157
158    fn get_end_iter(&self) -> TextIter;
159
160    fn get_has_selection(&self) -> bool;
161
162    fn get_insert(&self) -> Option<TextMark>;
163
164    fn get_iter_at_child_anchor<P: IsA<TextChildAnchor>>(&self, anchor: &P) -> TextIter;
165
166    fn get_iter_at_line(&self, line_number: i32) -> TextIter;
167
168    fn get_iter_at_line_index(&self, line_number: i32, byte_index: i32) -> TextIter;
169
170    fn get_iter_at_line_offset(&self, line_number: i32, char_offset: i32) -> TextIter;
171
172    fn get_iter_at_mark<P: IsA<TextMark>>(&self, mark: &P) -> TextIter;
173
174    fn get_iter_at_offset(&self, char_offset: i32) -> TextIter;
175
176    fn get_line_count(&self) -> i32;
177
178    fn get_mark(&self, name: &str) -> Option<TextMark>;
179
180    fn get_modified(&self) -> bool;
181
182    fn get_paste_target_list(&self) -> Option<TargetList>;
183
184    fn get_selection_bound(&self) -> Option<TextMark>;
185
186    fn get_selection_bounds(&self) -> Option<(TextIter, TextIter)>;
187
188    fn get_serialize_formats(&self) -> Vec<gdk::Atom>;
189
190    fn get_slice(
191        &self,
192        start: &TextIter,
193        end: &TextIter,
194        include_hidden_chars: bool,
195    ) -> Option<GString>;
196
197    fn get_start_iter(&self) -> TextIter;
198
199    fn get_tag_table(&self) -> Option<TextTagTable>;
200
201    fn get_text(
202        &self,
203        start: &TextIter,
204        end: &TextIter,
205        include_hidden_chars: bool,
206    ) -> Option<GString>;
207
208    fn insert(&self, iter: &mut TextIter, text: &str);
209
210    fn insert_at_cursor(&self, text: &str);
211
212    fn insert_child_anchor<P: IsA<TextChildAnchor>>(&self, iter: &mut TextIter, anchor: &P);
213
214    fn insert_interactive(&self, iter: &mut TextIter, text: &str, default_editable: bool) -> bool;
215
216    fn insert_interactive_at_cursor(&self, text: &str, default_editable: bool) -> bool;
217
218    #[cfg(any(feature = "v3_16", feature = "dox"))]
219    fn insert_markup(&self, iter: &mut TextIter, markup: &str);
220
221    fn insert_pixbuf(&self, iter: &mut TextIter, pixbuf: &gdk_pixbuf::Pixbuf);
222
223    fn insert_range(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter);
224
225    fn insert_range_interactive(
226        &self,
227        iter: &mut TextIter,
228        start: &TextIter,
229        end: &TextIter,
230        default_editable: bool,
231    ) -> bool;
232
233    //fn insert_with_tags<P: IsA<TextTag>>(&self, iter: &mut TextIter, text: &str, first_tag: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);
234
235    //fn insert_with_tags_by_name(&self, iter: &mut TextIter, text: &str, first_tag_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);
236
237    fn move_mark<P: IsA<TextMark>>(&self, mark: &P, where_: &TextIter);
238
239    fn move_mark_by_name(&self, name: &str, where_: &TextIter);
240
241    fn paste_clipboard(
242        &self,
243        clipboard: &Clipboard,
244        override_location: Option<&TextIter>,
245        default_editable: bool,
246    );
247
248    fn place_cursor(&self, where_: &TextIter);
249
250    //fn register_deserialize_format<P: Fn(&TextBuffer, &TextBuffer, &TextIter, &Vec<u8>, usize, bool, Option<&Error>) -> bool + 'static>(&self, mime_type: &str, function: P) -> Option<gdk::Atom>;
251
252    fn register_deserialize_tagset(&self, tagset_name: Option<&str>) -> gdk::Atom;
253
254    fn register_serialize_tagset(&self, tagset_name: Option<&str>) -> gdk::Atom;
255
256    fn remove_all_tags(&self, start: &TextIter, end: &TextIter);
257
258    fn remove_selection_clipboard(&self, clipboard: &Clipboard);
259
260    fn remove_tag<P: IsA<TextTag>>(&self, tag: &P, start: &TextIter, end: &TextIter);
261
262    fn remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter);
263
264    fn select_range(&self, ins: &TextIter, bound: &TextIter);
265
266    fn serialize<P: IsA<TextBuffer>>(
267        &self,
268        content_buffer: &P,
269        format: &gdk::Atom,
270        start: &TextIter,
271        end: &TextIter,
272    ) -> Vec<u8>;
273
274    fn set_modified(&self, setting: bool);
275
276    fn set_text(&self, text: &str);
277
278    fn unregister_deserialize_format(&self, format: &gdk::Atom);
279
280    fn unregister_serialize_format(&self, format: &gdk::Atom);
281
282    fn get_property_cursor_position(&self) -> i32;
283
284    fn connect_apply_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
285        &self,
286        f: F,
287    ) -> SignalHandlerId;
288
289    fn connect_begin_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
290
291    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
292
293    fn connect_delete_range<F: Fn(&Self, &TextIter, &TextIter) + 'static>(
294        &self,
295        f: F,
296    ) -> SignalHandlerId;
297
298    fn connect_end_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
299
300    fn connect_insert_child_anchor<F: Fn(&Self, &TextIter, &TextChildAnchor) + 'static>(
301        &self,
302        f: F,
303    ) -> SignalHandlerId;
304
305    fn connect_insert_pixbuf<F: Fn(&Self, &TextIter, &gdk_pixbuf::Pixbuf) + 'static>(
306        &self,
307        f: F,
308    ) -> SignalHandlerId;
309
310    fn connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>(&self, f: F) -> SignalHandlerId;
311
312    fn connect_mark_set<F: Fn(&Self, &TextIter, &TextMark) + 'static>(
313        &self,
314        f: F,
315    ) -> SignalHandlerId;
316
317    fn connect_modified_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
318
319    fn connect_paste_done<F: Fn(&Self, &Clipboard) + 'static>(&self, f: F) -> SignalHandlerId;
320
321    fn connect_remove_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
322        &self,
323        f: F,
324    ) -> SignalHandlerId;
325
326    fn connect_property_copy_target_list_notify<F: Fn(&Self) + 'static>(
327        &self,
328        f: F,
329    ) -> SignalHandlerId;
330
331    fn connect_property_cursor_position_notify<F: Fn(&Self) + 'static>(
332        &self,
333        f: F,
334    ) -> SignalHandlerId;
335
336    fn connect_property_has_selection_notify<F: Fn(&Self) + 'static>(
337        &self,
338        f: F,
339    ) -> SignalHandlerId;
340
341    fn connect_property_paste_target_list_notify<F: Fn(&Self) + 'static>(
342        &self,
343        f: F,
344    ) -> SignalHandlerId;
345
346    fn connect_property_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
347}
348
349impl<O: IsA<TextBuffer>> TextBufferExt for O {
350    fn add_mark<P: IsA<TextMark>>(&self, mark: &P, where_: &TextIter) {
351        unsafe {
352            gtk_sys::gtk_text_buffer_add_mark(
353                self.as_ref().to_glib_none().0,
354                mark.as_ref().to_glib_none().0,
355                where_.to_glib_none().0,
356            );
357        }
358    }
359
360    fn add_selection_clipboard(&self, clipboard: &Clipboard) {
361        unsafe {
362            gtk_sys::gtk_text_buffer_add_selection_clipboard(
363                self.as_ref().to_glib_none().0,
364                clipboard.to_glib_none().0,
365            );
366        }
367    }
368
369    fn apply_tag<P: IsA<TextTag>>(&self, tag: &P, start: &TextIter, end: &TextIter) {
370        unsafe {
371            gtk_sys::gtk_text_buffer_apply_tag(
372                self.as_ref().to_glib_none().0,
373                tag.as_ref().to_glib_none().0,
374                start.to_glib_none().0,
375                end.to_glib_none().0,
376            );
377        }
378    }
379
380    fn apply_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter) {
381        unsafe {
382            gtk_sys::gtk_text_buffer_apply_tag_by_name(
383                self.as_ref().to_glib_none().0,
384                name.to_glib_none().0,
385                start.to_glib_none().0,
386                end.to_glib_none().0,
387            );
388        }
389    }
390
391    fn backspace(&self, iter: &mut TextIter, interactive: bool, default_editable: bool) -> bool {
392        unsafe {
393            from_glib(gtk_sys::gtk_text_buffer_backspace(
394                self.as_ref().to_glib_none().0,
395                iter.to_glib_none_mut().0,
396                interactive.to_glib(),
397                default_editable.to_glib(),
398            ))
399        }
400    }
401
402    fn begin_user_action(&self) {
403        unsafe {
404            gtk_sys::gtk_text_buffer_begin_user_action(self.as_ref().to_glib_none().0);
405        }
406    }
407
408    fn copy_clipboard(&self, clipboard: &Clipboard) {
409        unsafe {
410            gtk_sys::gtk_text_buffer_copy_clipboard(
411                self.as_ref().to_glib_none().0,
412                clipboard.to_glib_none().0,
413            );
414        }
415    }
416
417    fn create_child_anchor(&self, iter: &mut TextIter) -> Option<TextChildAnchor> {
418        unsafe {
419            from_glib_none(gtk_sys::gtk_text_buffer_create_child_anchor(
420                self.as_ref().to_glib_none().0,
421                iter.to_glib_none_mut().0,
422            ))
423        }
424    }
425
426    fn create_mark(
427        &self,
428        mark_name: Option<&str>,
429        where_: &TextIter,
430        left_gravity: bool,
431    ) -> Option<TextMark> {
432        unsafe {
433            from_glib_none(gtk_sys::gtk_text_buffer_create_mark(
434                self.as_ref().to_glib_none().0,
435                mark_name.to_glib_none().0,
436                where_.to_glib_none().0,
437                left_gravity.to_glib(),
438            ))
439        }
440    }
441
442    //fn create_tag(&self, tag_name: Option<&str>, first_property_name: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option<TextTag> {
443    //    unsafe { TODO: call gtk_sys:gtk_text_buffer_create_tag() }
444    //}
445
446    fn cut_clipboard(&self, clipboard: &Clipboard, default_editable: bool) {
447        unsafe {
448            gtk_sys::gtk_text_buffer_cut_clipboard(
449                self.as_ref().to_glib_none().0,
450                clipboard.to_glib_none().0,
451                default_editable.to_glib(),
452            );
453        }
454    }
455
456    fn delete(&self, start: &mut TextIter, end: &mut TextIter) {
457        unsafe {
458            gtk_sys::gtk_text_buffer_delete(
459                self.as_ref().to_glib_none().0,
460                start.to_glib_none_mut().0,
461                end.to_glib_none_mut().0,
462            );
463        }
464    }
465
466    fn delete_interactive(
467        &self,
468        start_iter: &mut TextIter,
469        end_iter: &mut TextIter,
470        default_editable: bool,
471    ) -> bool {
472        unsafe {
473            from_glib(gtk_sys::gtk_text_buffer_delete_interactive(
474                self.as_ref().to_glib_none().0,
475                start_iter.to_glib_none_mut().0,
476                end_iter.to_glib_none_mut().0,
477                default_editable.to_glib(),
478            ))
479        }
480    }
481
482    fn delete_mark<P: IsA<TextMark>>(&self, mark: &P) {
483        unsafe {
484            gtk_sys::gtk_text_buffer_delete_mark(
485                self.as_ref().to_glib_none().0,
486                mark.as_ref().to_glib_none().0,
487            );
488        }
489    }
490
491    fn delete_mark_by_name(&self, name: &str) {
492        unsafe {
493            gtk_sys::gtk_text_buffer_delete_mark_by_name(
494                self.as_ref().to_glib_none().0,
495                name.to_glib_none().0,
496            );
497        }
498    }
499
500    fn delete_selection(&self, interactive: bool, default_editable: bool) -> bool {
501        unsafe {
502            from_glib(gtk_sys::gtk_text_buffer_delete_selection(
503                self.as_ref().to_glib_none().0,
504                interactive.to_glib(),
505                default_editable.to_glib(),
506            ))
507        }
508    }
509
510    fn deserialize<P: IsA<TextBuffer>>(
511        &self,
512        content_buffer: &P,
513        format: &gdk::Atom,
514        iter: &mut TextIter,
515        data: &[u8],
516    ) -> Result<(), Error> {
517        let length = data.len() as usize;
518        unsafe {
519            let mut error = ptr::null_mut();
520            let _ = gtk_sys::gtk_text_buffer_deserialize(
521                self.as_ref().to_glib_none().0,
522                content_buffer.as_ref().to_glib_none().0,
523                format.to_glib_none().0,
524                iter.to_glib_none_mut().0,
525                data.to_glib_none().0,
526                length,
527                &mut error,
528            );
529            if error.is_null() {
530                Ok(())
531            } else {
532                Err(from_glib_full(error))
533            }
534        }
535    }
536
537    fn deserialize_get_can_create_tags(&self, format: &gdk::Atom) -> bool {
538        unsafe {
539            from_glib(gtk_sys::gtk_text_buffer_deserialize_get_can_create_tags(
540                self.as_ref().to_glib_none().0,
541                format.to_glib_none().0,
542            ))
543        }
544    }
545
546    fn deserialize_set_can_create_tags(&self, format: &gdk::Atom, can_create_tags: bool) {
547        unsafe {
548            gtk_sys::gtk_text_buffer_deserialize_set_can_create_tags(
549                self.as_ref().to_glib_none().0,
550                format.to_glib_none().0,
551                can_create_tags.to_glib(),
552            );
553        }
554    }
555
556    fn end_user_action(&self) {
557        unsafe {
558            gtk_sys::gtk_text_buffer_end_user_action(self.as_ref().to_glib_none().0);
559        }
560    }
561
562    fn get_bounds(&self) -> (TextIter, TextIter) {
563        unsafe {
564            let mut start = TextIter::uninitialized();
565            let mut end = TextIter::uninitialized();
566            gtk_sys::gtk_text_buffer_get_bounds(
567                self.as_ref().to_glib_none().0,
568                start.to_glib_none_mut().0,
569                end.to_glib_none_mut().0,
570            );
571            (start, end)
572        }
573    }
574
575    fn get_char_count(&self) -> i32 {
576        unsafe { gtk_sys::gtk_text_buffer_get_char_count(self.as_ref().to_glib_none().0) }
577    }
578
579    fn get_copy_target_list(&self) -> Option<TargetList> {
580        unsafe {
581            from_glib_none(gtk_sys::gtk_text_buffer_get_copy_target_list(
582                self.as_ref().to_glib_none().0,
583            ))
584        }
585    }
586
587    fn get_deserialize_formats(&self) -> Vec<gdk::Atom> {
588        unsafe {
589            let mut n_formats = mem::uninitialized();
590            let ret = FromGlibContainer::from_glib_container_num(
591                gtk_sys::gtk_text_buffer_get_deserialize_formats(
592                    self.as_ref().to_glib_none().0,
593                    &mut n_formats,
594                ),
595                n_formats as usize,
596            );
597            ret
598        }
599    }
600
601    fn get_end_iter(&self) -> TextIter {
602        unsafe {
603            let mut iter = TextIter::uninitialized();
604            gtk_sys::gtk_text_buffer_get_end_iter(
605                self.as_ref().to_glib_none().0,
606                iter.to_glib_none_mut().0,
607            );
608            iter
609        }
610    }
611
612    fn get_has_selection(&self) -> bool {
613        unsafe {
614            from_glib(gtk_sys::gtk_text_buffer_get_has_selection(
615                self.as_ref().to_glib_none().0,
616            ))
617        }
618    }
619
620    fn get_insert(&self) -> Option<TextMark> {
621        unsafe {
622            from_glib_none(gtk_sys::gtk_text_buffer_get_insert(
623                self.as_ref().to_glib_none().0,
624            ))
625        }
626    }
627
628    fn get_iter_at_child_anchor<P: IsA<TextChildAnchor>>(&self, anchor: &P) -> TextIter {
629        unsafe {
630            let mut iter = TextIter::uninitialized();
631            gtk_sys::gtk_text_buffer_get_iter_at_child_anchor(
632                self.as_ref().to_glib_none().0,
633                iter.to_glib_none_mut().0,
634                anchor.as_ref().to_glib_none().0,
635            );
636            iter
637        }
638    }
639
640    fn get_iter_at_line(&self, line_number: i32) -> TextIter {
641        unsafe {
642            let mut iter = TextIter::uninitialized();
643            gtk_sys::gtk_text_buffer_get_iter_at_line(
644                self.as_ref().to_glib_none().0,
645                iter.to_glib_none_mut().0,
646                line_number,
647            );
648            iter
649        }
650    }
651
652    fn get_iter_at_line_index(&self, line_number: i32, byte_index: i32) -> TextIter {
653        unsafe {
654            let mut iter = TextIter::uninitialized();
655            gtk_sys::gtk_text_buffer_get_iter_at_line_index(
656                self.as_ref().to_glib_none().0,
657                iter.to_glib_none_mut().0,
658                line_number,
659                byte_index,
660            );
661            iter
662        }
663    }
664
665    fn get_iter_at_line_offset(&self, line_number: i32, char_offset: i32) -> TextIter {
666        unsafe {
667            let mut iter = TextIter::uninitialized();
668            gtk_sys::gtk_text_buffer_get_iter_at_line_offset(
669                self.as_ref().to_glib_none().0,
670                iter.to_glib_none_mut().0,
671                line_number,
672                char_offset,
673            );
674            iter
675        }
676    }
677
678    fn get_iter_at_mark<P: IsA<TextMark>>(&self, mark: &P) -> TextIter {
679        unsafe {
680            let mut iter = TextIter::uninitialized();
681            gtk_sys::gtk_text_buffer_get_iter_at_mark(
682                self.as_ref().to_glib_none().0,
683                iter.to_glib_none_mut().0,
684                mark.as_ref().to_glib_none().0,
685            );
686            iter
687        }
688    }
689
690    fn get_iter_at_offset(&self, char_offset: i32) -> TextIter {
691        unsafe {
692            let mut iter = TextIter::uninitialized();
693            gtk_sys::gtk_text_buffer_get_iter_at_offset(
694                self.as_ref().to_glib_none().0,
695                iter.to_glib_none_mut().0,
696                char_offset,
697            );
698            iter
699        }
700    }
701
702    fn get_line_count(&self) -> i32 {
703        unsafe { gtk_sys::gtk_text_buffer_get_line_count(self.as_ref().to_glib_none().0) }
704    }
705
706    fn get_mark(&self, name: &str) -> Option<TextMark> {
707        unsafe {
708            from_glib_none(gtk_sys::gtk_text_buffer_get_mark(
709                self.as_ref().to_glib_none().0,
710                name.to_glib_none().0,
711            ))
712        }
713    }
714
715    fn get_modified(&self) -> bool {
716        unsafe {
717            from_glib(gtk_sys::gtk_text_buffer_get_modified(
718                self.as_ref().to_glib_none().0,
719            ))
720        }
721    }
722
723    fn get_paste_target_list(&self) -> Option<TargetList> {
724        unsafe {
725            from_glib_none(gtk_sys::gtk_text_buffer_get_paste_target_list(
726                self.as_ref().to_glib_none().0,
727            ))
728        }
729    }
730
731    fn get_selection_bound(&self) -> Option<TextMark> {
732        unsafe {
733            from_glib_none(gtk_sys::gtk_text_buffer_get_selection_bound(
734                self.as_ref().to_glib_none().0,
735            ))
736        }
737    }
738
739    fn get_selection_bounds(&self) -> Option<(TextIter, TextIter)> {
740        unsafe {
741            let mut start = TextIter::uninitialized();
742            let mut end = TextIter::uninitialized();
743            let ret = from_glib(gtk_sys::gtk_text_buffer_get_selection_bounds(
744                self.as_ref().to_glib_none().0,
745                start.to_glib_none_mut().0,
746                end.to_glib_none_mut().0,
747            ));
748            if ret {
749                Some((start, end))
750            } else {
751                None
752            }
753        }
754    }
755
756    fn get_serialize_formats(&self) -> Vec<gdk::Atom> {
757        unsafe {
758            let mut n_formats = mem::uninitialized();
759            let ret = FromGlibContainer::from_glib_container_num(
760                gtk_sys::gtk_text_buffer_get_serialize_formats(
761                    self.as_ref().to_glib_none().0,
762                    &mut n_formats,
763                ),
764                n_formats as usize,
765            );
766            ret
767        }
768    }
769
770    fn get_slice(
771        &self,
772        start: &TextIter,
773        end: &TextIter,
774        include_hidden_chars: bool,
775    ) -> Option<GString> {
776        unsafe {
777            from_glib_full(gtk_sys::gtk_text_buffer_get_slice(
778                self.as_ref().to_glib_none().0,
779                start.to_glib_none().0,
780                end.to_glib_none().0,
781                include_hidden_chars.to_glib(),
782            ))
783        }
784    }
785
786    fn get_start_iter(&self) -> TextIter {
787        unsafe {
788            let mut iter = TextIter::uninitialized();
789            gtk_sys::gtk_text_buffer_get_start_iter(
790                self.as_ref().to_glib_none().0,
791                iter.to_glib_none_mut().0,
792            );
793            iter
794        }
795    }
796
797    fn get_tag_table(&self) -> Option<TextTagTable> {
798        unsafe {
799            from_glib_none(gtk_sys::gtk_text_buffer_get_tag_table(
800                self.as_ref().to_glib_none().0,
801            ))
802        }
803    }
804
805    fn get_text(
806        &self,
807        start: &TextIter,
808        end: &TextIter,
809        include_hidden_chars: bool,
810    ) -> Option<GString> {
811        unsafe {
812            from_glib_full(gtk_sys::gtk_text_buffer_get_text(
813                self.as_ref().to_glib_none().0,
814                start.to_glib_none().0,
815                end.to_glib_none().0,
816                include_hidden_chars.to_glib(),
817            ))
818        }
819    }
820
821    fn insert(&self, iter: &mut TextIter, text: &str) {
822        let len = text.len() as i32;
823        unsafe {
824            gtk_sys::gtk_text_buffer_insert(
825                self.as_ref().to_glib_none().0,
826                iter.to_glib_none_mut().0,
827                text.to_glib_none().0,
828                len,
829            );
830        }
831    }
832
833    fn insert_at_cursor(&self, text: &str) {
834        let len = text.len() as i32;
835        unsafe {
836            gtk_sys::gtk_text_buffer_insert_at_cursor(
837                self.as_ref().to_glib_none().0,
838                text.to_glib_none().0,
839                len,
840            );
841        }
842    }
843
844    fn insert_child_anchor<P: IsA<TextChildAnchor>>(&self, iter: &mut TextIter, anchor: &P) {
845        unsafe {
846            gtk_sys::gtk_text_buffer_insert_child_anchor(
847                self.as_ref().to_glib_none().0,
848                iter.to_glib_none_mut().0,
849                anchor.as_ref().to_glib_none().0,
850            );
851        }
852    }
853
854    fn insert_interactive(&self, iter: &mut TextIter, text: &str, default_editable: bool) -> bool {
855        let len = text.len() as i32;
856        unsafe {
857            from_glib(gtk_sys::gtk_text_buffer_insert_interactive(
858                self.as_ref().to_glib_none().0,
859                iter.to_glib_none_mut().0,
860                text.to_glib_none().0,
861                len,
862                default_editable.to_glib(),
863            ))
864        }
865    }
866
867    fn insert_interactive_at_cursor(&self, text: &str, default_editable: bool) -> bool {
868        let len = text.len() as i32;
869        unsafe {
870            from_glib(gtk_sys::gtk_text_buffer_insert_interactive_at_cursor(
871                self.as_ref().to_glib_none().0,
872                text.to_glib_none().0,
873                len,
874                default_editable.to_glib(),
875            ))
876        }
877    }
878
879    #[cfg(any(feature = "v3_16", feature = "dox"))]
880    fn insert_markup(&self, iter: &mut TextIter, markup: &str) {
881        let len = markup.len() as i32;
882        unsafe {
883            gtk_sys::gtk_text_buffer_insert_markup(
884                self.as_ref().to_glib_none().0,
885                iter.to_glib_none_mut().0,
886                markup.to_glib_none().0,
887                len,
888            );
889        }
890    }
891
892    fn insert_pixbuf(&self, iter: &mut TextIter, pixbuf: &gdk_pixbuf::Pixbuf) {
893        unsafe {
894            gtk_sys::gtk_text_buffer_insert_pixbuf(
895                self.as_ref().to_glib_none().0,
896                iter.to_glib_none_mut().0,
897                pixbuf.to_glib_none().0,
898            );
899        }
900    }
901
902    fn insert_range(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter) {
903        unsafe {
904            gtk_sys::gtk_text_buffer_insert_range(
905                self.as_ref().to_glib_none().0,
906                iter.to_glib_none_mut().0,
907                start.to_glib_none().0,
908                end.to_glib_none().0,
909            );
910        }
911    }
912
913    fn insert_range_interactive(
914        &self,
915        iter: &mut TextIter,
916        start: &TextIter,
917        end: &TextIter,
918        default_editable: bool,
919    ) -> bool {
920        unsafe {
921            from_glib(gtk_sys::gtk_text_buffer_insert_range_interactive(
922                self.as_ref().to_glib_none().0,
923                iter.to_glib_none_mut().0,
924                start.to_glib_none().0,
925                end.to_glib_none().0,
926                default_editable.to_glib(),
927            ))
928        }
929    }
930
931    //fn insert_with_tags<P: IsA<TextTag>>(&self, iter: &mut TextIter, text: &str, first_tag: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
932    //    unsafe { TODO: call gtk_sys:gtk_text_buffer_insert_with_tags() }
933    //}
934
935    //fn insert_with_tags_by_name(&self, iter: &mut TextIter, text: &str, first_tag_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
936    //    unsafe { TODO: call gtk_sys:gtk_text_buffer_insert_with_tags_by_name() }
937    //}
938
939    fn move_mark<P: IsA<TextMark>>(&self, mark: &P, where_: &TextIter) {
940        unsafe {
941            gtk_sys::gtk_text_buffer_move_mark(
942                self.as_ref().to_glib_none().0,
943                mark.as_ref().to_glib_none().0,
944                where_.to_glib_none().0,
945            );
946        }
947    }
948
949    fn move_mark_by_name(&self, name: &str, where_: &TextIter) {
950        unsafe {
951            gtk_sys::gtk_text_buffer_move_mark_by_name(
952                self.as_ref().to_glib_none().0,
953                name.to_glib_none().0,
954                where_.to_glib_none().0,
955            );
956        }
957    }
958
959    fn paste_clipboard(
960        &self,
961        clipboard: &Clipboard,
962        override_location: Option<&TextIter>,
963        default_editable: bool,
964    ) {
965        unsafe {
966            gtk_sys::gtk_text_buffer_paste_clipboard(
967                self.as_ref().to_glib_none().0,
968                clipboard.to_glib_none().0,
969                mut_override(override_location.to_glib_none().0),
970                default_editable.to_glib(),
971            );
972        }
973    }
974
975    fn place_cursor(&self, where_: &TextIter) {
976        unsafe {
977            gtk_sys::gtk_text_buffer_place_cursor(
978                self.as_ref().to_glib_none().0,
979                where_.to_glib_none().0,
980            );
981        }
982    }
983
984    //fn register_deserialize_format<P: Fn(&TextBuffer, &TextBuffer, &TextIter, &Vec<u8>, usize, bool, Option<&Error>) -> bool + 'static>(&self, mime_type: &str, function: P) -> Option<gdk::Atom> {
985    //    unsafe { TODO: call gtk_sys:gtk_text_buffer_register_deserialize_format() }
986    //}
987
988    fn register_deserialize_tagset(&self, tagset_name: Option<&str>) -> gdk::Atom {
989        unsafe {
990            from_glib_none(gtk_sys::gtk_text_buffer_register_deserialize_tagset(
991                self.as_ref().to_glib_none().0,
992                tagset_name.to_glib_none().0,
993            ))
994        }
995    }
996
997    fn register_serialize_tagset(&self, tagset_name: Option<&str>) -> gdk::Atom {
998        unsafe {
999            from_glib_none(gtk_sys::gtk_text_buffer_register_serialize_tagset(
1000                self.as_ref().to_glib_none().0,
1001                tagset_name.to_glib_none().0,
1002            ))
1003        }
1004    }
1005
1006    fn remove_all_tags(&self, start: &TextIter, end: &TextIter) {
1007        unsafe {
1008            gtk_sys::gtk_text_buffer_remove_all_tags(
1009                self.as_ref().to_glib_none().0,
1010                start.to_glib_none().0,
1011                end.to_glib_none().0,
1012            );
1013        }
1014    }
1015
1016    fn remove_selection_clipboard(&self, clipboard: &Clipboard) {
1017        unsafe {
1018            gtk_sys::gtk_text_buffer_remove_selection_clipboard(
1019                self.as_ref().to_glib_none().0,
1020                clipboard.to_glib_none().0,
1021            );
1022        }
1023    }
1024
1025    fn remove_tag<P: IsA<TextTag>>(&self, tag: &P, start: &TextIter, end: &TextIter) {
1026        unsafe {
1027            gtk_sys::gtk_text_buffer_remove_tag(
1028                self.as_ref().to_glib_none().0,
1029                tag.as_ref().to_glib_none().0,
1030                start.to_glib_none().0,
1031                end.to_glib_none().0,
1032            );
1033        }
1034    }
1035
1036    fn remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter) {
1037        unsafe {
1038            gtk_sys::gtk_text_buffer_remove_tag_by_name(
1039                self.as_ref().to_glib_none().0,
1040                name.to_glib_none().0,
1041                start.to_glib_none().0,
1042                end.to_glib_none().0,
1043            );
1044        }
1045    }
1046
1047    fn select_range(&self, ins: &TextIter, bound: &TextIter) {
1048        unsafe {
1049            gtk_sys::gtk_text_buffer_select_range(
1050                self.as_ref().to_glib_none().0,
1051                ins.to_glib_none().0,
1052                bound.to_glib_none().0,
1053            );
1054        }
1055    }
1056
1057    fn serialize<P: IsA<TextBuffer>>(
1058        &self,
1059        content_buffer: &P,
1060        format: &gdk::Atom,
1061        start: &TextIter,
1062        end: &TextIter,
1063    ) -> Vec<u8> {
1064        unsafe {
1065            let mut length = mem::uninitialized();
1066            let ret = FromGlibContainer::from_glib_full_num(
1067                gtk_sys::gtk_text_buffer_serialize(
1068                    self.as_ref().to_glib_none().0,
1069                    content_buffer.as_ref().to_glib_none().0,
1070                    format.to_glib_none().0,
1071                    start.to_glib_none().0,
1072                    end.to_glib_none().0,
1073                    &mut length,
1074                ),
1075                length as usize,
1076            );
1077            ret
1078        }
1079    }
1080
1081    fn set_modified(&self, setting: bool) {
1082        unsafe {
1083            gtk_sys::gtk_text_buffer_set_modified(
1084                self.as_ref().to_glib_none().0,
1085                setting.to_glib(),
1086            );
1087        }
1088    }
1089
1090    fn set_text(&self, text: &str) {
1091        let len = text.len() as i32;
1092        unsafe {
1093            gtk_sys::gtk_text_buffer_set_text(
1094                self.as_ref().to_glib_none().0,
1095                text.to_glib_none().0,
1096                len,
1097            );
1098        }
1099    }
1100
1101    fn unregister_deserialize_format(&self, format: &gdk::Atom) {
1102        unsafe {
1103            gtk_sys::gtk_text_buffer_unregister_deserialize_format(
1104                self.as_ref().to_glib_none().0,
1105                format.to_glib_none().0,
1106            );
1107        }
1108    }
1109
1110    fn unregister_serialize_format(&self, format: &gdk::Atom) {
1111        unsafe {
1112            gtk_sys::gtk_text_buffer_unregister_serialize_format(
1113                self.as_ref().to_glib_none().0,
1114                format.to_glib_none().0,
1115            );
1116        }
1117    }
1118
1119    fn get_property_cursor_position(&self) -> i32 {
1120        unsafe {
1121            let mut value = Value::from_type(<i32 as StaticType>::static_type());
1122            gobject_sys::g_object_get_property(
1123                self.to_glib_none().0 as *mut gobject_sys::GObject,
1124                b"cursor-position\0".as_ptr() as *const _,
1125                value.to_glib_none_mut().0,
1126            );
1127            value.get().unwrap()
1128        }
1129    }
1130
1131    fn connect_apply_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
1132        &self,
1133        f: F,
1134    ) -> SignalHandlerId {
1135        unsafe extern "C" fn apply_tag_trampoline<
1136            P,
1137            F: Fn(&P, &TextTag, &TextIter, &TextIter) + 'static,
1138        >(
1139            this: *mut gtk_sys::GtkTextBuffer,
1140            tag: *mut gtk_sys::GtkTextTag,
1141            start: *mut gtk_sys::GtkTextIter,
1142            end: *mut gtk_sys::GtkTextIter,
1143            f: glib_sys::gpointer,
1144        ) where
1145            P: IsA<TextBuffer>,
1146        {
1147            let f: &F = &*(f as *const F);
1148            f(
1149                &TextBuffer::from_glib_borrow(this).unsafe_cast(),
1150                &from_glib_borrow(tag),
1151                &from_glib_borrow(start),
1152                &from_glib_borrow(end),
1153            )
1154        }
1155        unsafe {
1156            let f: Box_<F> = Box_::new(f);
1157            connect_raw(
1158                self.as_ptr() as *mut _,
1159                b"apply-tag\0".as_ptr() as *const _,
1160                Some(transmute(apply_tag_trampoline::<Self, F> as usize)),
1161                Box_::into_raw(f),
1162            )
1163        }
1164    }
1165
1166    fn connect_begin_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1167        unsafe extern "C" fn begin_user_action_trampoline<P, F: Fn(&P) + 'static>(
1168            this: *mut gtk_sys::GtkTextBuffer,
1169            f: glib_sys::gpointer,
1170        ) where
1171            P: IsA<TextBuffer>,
1172        {
1173            let f: &F = &*(f as *const F);
1174            f(&TextBuffer::from_glib_borrow(this).unsafe_cast())
1175        }
1176        unsafe {
1177            let f: Box_<F> = Box_::new(f);
1178            connect_raw(
1179                self.as_ptr() as *mut _,
1180                b"begin-user-action\0".as_ptr() as *const _,
1181                Some(transmute(begin_user_action_trampoline::<Self, F> as usize)),
1182                Box_::into_raw(f),
1183            )
1184        }
1185    }
1186
1187    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1188        unsafe extern "C" fn changed_trampoline<P, F: Fn(&P) + 'static>(
1189            this: *mut gtk_sys::GtkTextBuffer,
1190            f: glib_sys::gpointer,
1191        ) where
1192            P: IsA<TextBuffer>,
1193        {
1194            let f: &F = &*(f as *const F);
1195            f(&TextBuffer::from_glib_borrow(this).unsafe_cast())
1196        }
1197        unsafe {
1198            let f: Box_<F> = Box_::new(f);
1199            connect_raw(
1200                self.as_ptr() as *mut _,
1201                b"changed\0".as_ptr() as *const _,
1202                Some(transmute(changed_trampoline::<Self, F> as usize)),
1203                Box_::into_raw(f),
1204            )
1205        }
1206    }
1207
1208    fn connect_delete_range<F: Fn(&Self, &TextIter, &TextIter) + 'static>(
1209        &self,
1210        f: F,
1211    ) -> SignalHandlerId {
1212        unsafe extern "C" fn delete_range_trampoline<P, F: Fn(&P, &TextIter, &TextIter) + 'static>(
1213            this: *mut gtk_sys::GtkTextBuffer,
1214            start: *mut gtk_sys::GtkTextIter,
1215            end: *mut gtk_sys::GtkTextIter,
1216            f: glib_sys::gpointer,
1217        ) where
1218            P: IsA<TextBuffer>,
1219        {
1220            let f: &F = &*(f as *const F);
1221            f(
1222                &TextBuffer::from_glib_borrow(this).unsafe_cast(),
1223                &from_glib_borrow(start),
1224                &from_glib_borrow(end),
1225            )
1226        }
1227        unsafe {
1228            let f: Box_<F> = Box_::new(f);
1229            connect_raw(
1230                self.as_ptr() as *mut _,
1231                b"delete-range\0".as_ptr() as *const _,
1232                Some(transmute(delete_range_trampoline::<Self, F> as usize)),
1233                Box_::into_raw(f),
1234            )
1235        }
1236    }
1237
1238    fn connect_end_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1239        unsafe extern "C" fn end_user_action_trampoline<P, F: Fn(&P) + 'static>(
1240            this: *mut gtk_sys::GtkTextBuffer,
1241            f: glib_sys::gpointer,
1242        ) where
1243            P: IsA<TextBuffer>,
1244        {
1245            let f: &F = &*(f as *const F);
1246            f(&TextBuffer::from_glib_borrow(this).unsafe_cast())
1247        }
1248        unsafe {
1249            let f: Box_<F> = Box_::new(f);
1250            connect_raw(
1251                self.as_ptr() as *mut _,
1252                b"end-user-action\0".as_ptr() as *const _,
1253                Some(transmute(end_user_action_trampoline::<Self, F> as usize)),
1254                Box_::into_raw(f),
1255            )
1256        }
1257    }
1258
1259    fn connect_insert_child_anchor<F: Fn(&Self, &TextIter, &TextChildAnchor) + 'static>(
1260        &self,
1261        f: F,
1262    ) -> SignalHandlerId {
1263        unsafe extern "C" fn insert_child_anchor_trampoline<
1264            P,
1265            F: Fn(&P, &TextIter, &TextChildAnchor) + 'static,
1266        >(
1267            this: *mut gtk_sys::GtkTextBuffer,
1268            location: *mut gtk_sys::GtkTextIter,
1269            anchor: *mut gtk_sys::GtkTextChildAnchor,
1270            f: glib_sys::gpointer,
1271        ) where
1272            P: IsA<TextBuffer>,
1273        {
1274            let f: &F = &*(f as *const F);
1275            f(
1276                &TextBuffer::from_glib_borrow(this).unsafe_cast(),
1277                &from_glib_borrow(location),
1278                &from_glib_borrow(anchor),
1279            )
1280        }
1281        unsafe {
1282            let f: Box_<F> = Box_::new(f);
1283            connect_raw(
1284                self.as_ptr() as *mut _,
1285                b"insert-child-anchor\0".as_ptr() as *const _,
1286                Some(transmute(
1287                    insert_child_anchor_trampoline::<Self, F> as usize,
1288                )),
1289                Box_::into_raw(f),
1290            )
1291        }
1292    }
1293
1294    fn connect_insert_pixbuf<F: Fn(&Self, &TextIter, &gdk_pixbuf::Pixbuf) + 'static>(
1295        &self,
1296        f: F,
1297    ) -> SignalHandlerId {
1298        unsafe extern "C" fn insert_pixbuf_trampoline<
1299            P,
1300            F: Fn(&P, &TextIter, &gdk_pixbuf::Pixbuf) + 'static,
1301        >(
1302            this: *mut gtk_sys::GtkTextBuffer,
1303            location: *mut gtk_sys::GtkTextIter,
1304            pixbuf: *mut gdk_pixbuf_sys::GdkPixbuf,
1305            f: glib_sys::gpointer,
1306        ) where
1307            P: IsA<TextBuffer>,
1308        {
1309            let f: &F = &*(f as *const F);
1310            f(
1311                &TextBuffer::from_glib_borrow(this).unsafe_cast(),
1312                &from_glib_borrow(location),
1313                &from_glib_borrow(pixbuf),
1314            )
1315        }
1316        unsafe {
1317            let f: Box_<F> = Box_::new(f);
1318            connect_raw(
1319                self.as_ptr() as *mut _,
1320                b"insert-pixbuf\0".as_ptr() as *const _,
1321                Some(transmute(insert_pixbuf_trampoline::<Self, F> as usize)),
1322                Box_::into_raw(f),
1323            )
1324        }
1325    }
1326
1327    fn connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>(&self, f: F) -> SignalHandlerId {
1328        unsafe extern "C" fn mark_deleted_trampoline<P, F: Fn(&P, &TextMark) + 'static>(
1329            this: *mut gtk_sys::GtkTextBuffer,
1330            mark: *mut gtk_sys::GtkTextMark,
1331            f: glib_sys::gpointer,
1332        ) where
1333            P: IsA<TextBuffer>,
1334        {
1335            let f: &F = &*(f as *const F);
1336            f(
1337                &TextBuffer::from_glib_borrow(this).unsafe_cast(),
1338                &from_glib_borrow(mark),
1339            )
1340        }
1341        unsafe {
1342            let f: Box_<F> = Box_::new(f);
1343            connect_raw(
1344                self.as_ptr() as *mut _,
1345                b"mark-deleted\0".as_ptr() as *const _,
1346                Some(transmute(mark_deleted_trampoline::<Self, F> as usize)),
1347                Box_::into_raw(f),
1348            )
1349        }
1350    }
1351
1352    fn connect_mark_set<F: Fn(&Self, &TextIter, &TextMark) + 'static>(
1353        &self,
1354        f: F,
1355    ) -> SignalHandlerId {
1356        unsafe extern "C" fn mark_set_trampoline<P, F: Fn(&P, &TextIter, &TextMark) + 'static>(
1357            this: *mut gtk_sys::GtkTextBuffer,
1358            location: *mut gtk_sys::GtkTextIter,
1359            mark: *mut gtk_sys::GtkTextMark,
1360            f: glib_sys::gpointer,
1361        ) where
1362            P: IsA<TextBuffer>,
1363        {
1364            let f: &F = &*(f as *const F);
1365            f(
1366                &TextBuffer::from_glib_borrow(this).unsafe_cast(),
1367                &from_glib_borrow(location),
1368                &from_glib_borrow(mark),
1369            )
1370        }
1371        unsafe {
1372            let f: Box_<F> = Box_::new(f);
1373            connect_raw(
1374                self.as_ptr() as *mut _,
1375                b"mark-set\0".as_ptr() as *const _,
1376                Some(transmute(mark_set_trampoline::<Self, F> as usize)),
1377                Box_::into_raw(f),
1378            )
1379        }
1380    }
1381
1382    fn connect_modified_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1383        unsafe extern "C" fn modified_changed_trampoline<P, F: Fn(&P) + 'static>(
1384            this: *mut gtk_sys::GtkTextBuffer,
1385            f: glib_sys::gpointer,
1386        ) where
1387            P: IsA<TextBuffer>,
1388        {
1389            let f: &F = &*(f as *const F);
1390            f(&TextBuffer::from_glib_borrow(this).unsafe_cast())
1391        }
1392        unsafe {
1393            let f: Box_<F> = Box_::new(f);
1394            connect_raw(
1395                self.as_ptr() as *mut _,
1396                b"modified-changed\0".as_ptr() as *const _,
1397                Some(transmute(modified_changed_trampoline::<Self, F> as usize)),
1398                Box_::into_raw(f),
1399            )
1400        }
1401    }
1402
1403    fn connect_paste_done<F: Fn(&Self, &Clipboard) + 'static>(&self, f: F) -> SignalHandlerId {
1404        unsafe extern "C" fn paste_done_trampoline<P, F: Fn(&P, &Clipboard) + 'static>(
1405            this: *mut gtk_sys::GtkTextBuffer,
1406            clipboard: *mut gtk_sys::GtkClipboard,
1407            f: glib_sys::gpointer,
1408        ) where
1409            P: IsA<TextBuffer>,
1410        {
1411            let f: &F = &*(f as *const F);
1412            f(
1413                &TextBuffer::from_glib_borrow(this).unsafe_cast(),
1414                &from_glib_borrow(clipboard),
1415            )
1416        }
1417        unsafe {
1418            let f: Box_<F> = Box_::new(f);
1419            connect_raw(
1420                self.as_ptr() as *mut _,
1421                b"paste-done\0".as_ptr() as *const _,
1422                Some(transmute(paste_done_trampoline::<Self, F> as usize)),
1423                Box_::into_raw(f),
1424            )
1425        }
1426    }
1427
1428    fn connect_remove_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
1429        &self,
1430        f: F,
1431    ) -> SignalHandlerId {
1432        unsafe extern "C" fn remove_tag_trampoline<
1433            P,
1434            F: Fn(&P, &TextTag, &TextIter, &TextIter) + 'static,
1435        >(
1436            this: *mut gtk_sys::GtkTextBuffer,
1437            tag: *mut gtk_sys::GtkTextTag,
1438            start: *mut gtk_sys::GtkTextIter,
1439            end: *mut gtk_sys::GtkTextIter,
1440            f: glib_sys::gpointer,
1441        ) where
1442            P: IsA<TextBuffer>,
1443        {
1444            let f: &F = &*(f as *const F);
1445            f(
1446                &TextBuffer::from_glib_borrow(this).unsafe_cast(),
1447                &from_glib_borrow(tag),
1448                &from_glib_borrow(start),
1449                &from_glib_borrow(end),
1450            )
1451        }
1452        unsafe {
1453            let f: Box_<F> = Box_::new(f);
1454            connect_raw(
1455                self.as_ptr() as *mut _,
1456                b"remove-tag\0".as_ptr() as *const _,
1457                Some(transmute(remove_tag_trampoline::<Self, F> as usize)),
1458                Box_::into_raw(f),
1459            )
1460        }
1461    }
1462
1463    fn connect_property_copy_target_list_notify<F: Fn(&Self) + 'static>(
1464        &self,
1465        f: F,
1466    ) -> SignalHandlerId {
1467        unsafe extern "C" fn notify_copy_target_list_trampoline<P, F: Fn(&P) + 'static>(
1468            this: *mut gtk_sys::GtkTextBuffer,
1469            _param_spec: glib_sys::gpointer,
1470            f: glib_sys::gpointer,
1471        ) where
1472            P: IsA<TextBuffer>,
1473        {
1474            let f: &F = &*(f as *const F);
1475            f(&TextBuffer::from_glib_borrow(this).unsafe_cast())
1476        }
1477        unsafe {
1478            let f: Box_<F> = Box_::new(f);
1479            connect_raw(
1480                self.as_ptr() as *mut _,
1481                b"notify::copy-target-list\0".as_ptr() as *const _,
1482                Some(transmute(
1483                    notify_copy_target_list_trampoline::<Self, F> as usize,
1484                )),
1485                Box_::into_raw(f),
1486            )
1487        }
1488    }
1489
1490    fn connect_property_cursor_position_notify<F: Fn(&Self) + 'static>(
1491        &self,
1492        f: F,
1493    ) -> SignalHandlerId {
1494        unsafe extern "C" fn notify_cursor_position_trampoline<P, F: Fn(&P) + 'static>(
1495            this: *mut gtk_sys::GtkTextBuffer,
1496            _param_spec: glib_sys::gpointer,
1497            f: glib_sys::gpointer,
1498        ) where
1499            P: IsA<TextBuffer>,
1500        {
1501            let f: &F = &*(f as *const F);
1502            f(&TextBuffer::from_glib_borrow(this).unsafe_cast())
1503        }
1504        unsafe {
1505            let f: Box_<F> = Box_::new(f);
1506            connect_raw(
1507                self.as_ptr() as *mut _,
1508                b"notify::cursor-position\0".as_ptr() as *const _,
1509                Some(transmute(
1510                    notify_cursor_position_trampoline::<Self, F> as usize,
1511                )),
1512                Box_::into_raw(f),
1513            )
1514        }
1515    }
1516
1517    fn connect_property_has_selection_notify<F: Fn(&Self) + 'static>(
1518        &self,
1519        f: F,
1520    ) -> SignalHandlerId {
1521        unsafe extern "C" fn notify_has_selection_trampoline<P, F: Fn(&P) + 'static>(
1522            this: *mut gtk_sys::GtkTextBuffer,
1523            _param_spec: glib_sys::gpointer,
1524            f: glib_sys::gpointer,
1525        ) where
1526            P: IsA<TextBuffer>,
1527        {
1528            let f: &F = &*(f as *const F);
1529            f(&TextBuffer::from_glib_borrow(this).unsafe_cast())
1530        }
1531        unsafe {
1532            let f: Box_<F> = Box_::new(f);
1533            connect_raw(
1534                self.as_ptr() as *mut _,
1535                b"notify::has-selection\0".as_ptr() as *const _,
1536                Some(transmute(
1537                    notify_has_selection_trampoline::<Self, F> as usize,
1538                )),
1539                Box_::into_raw(f),
1540            )
1541        }
1542    }
1543
1544    fn connect_property_paste_target_list_notify<F: Fn(&Self) + 'static>(
1545        &self,
1546        f: F,
1547    ) -> SignalHandlerId {
1548        unsafe extern "C" fn notify_paste_target_list_trampoline<P, F: Fn(&P) + 'static>(
1549            this: *mut gtk_sys::GtkTextBuffer,
1550            _param_spec: glib_sys::gpointer,
1551            f: glib_sys::gpointer,
1552        ) where
1553            P: IsA<TextBuffer>,
1554        {
1555            let f: &F = &*(f as *const F);
1556            f(&TextBuffer::from_glib_borrow(this).unsafe_cast())
1557        }
1558        unsafe {
1559            let f: Box_<F> = Box_::new(f);
1560            connect_raw(
1561                self.as_ptr() as *mut _,
1562                b"notify::paste-target-list\0".as_ptr() as *const _,
1563                Some(transmute(
1564                    notify_paste_target_list_trampoline::<Self, F> as usize,
1565                )),
1566                Box_::into_raw(f),
1567            )
1568        }
1569    }
1570
1571    fn connect_property_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1572        unsafe extern "C" fn notify_text_trampoline<P, F: Fn(&P) + 'static>(
1573            this: *mut gtk_sys::GtkTextBuffer,
1574            _param_spec: glib_sys::gpointer,
1575            f: glib_sys::gpointer,
1576        ) where
1577            P: IsA<TextBuffer>,
1578        {
1579            let f: &F = &*(f as *const F);
1580            f(&TextBuffer::from_glib_borrow(this).unsafe_cast())
1581        }
1582        unsafe {
1583            let f: Box_<F> = Box_::new(f);
1584            connect_raw(
1585                self.as_ptr() as *mut _,
1586                b"notify::text\0".as_ptr() as *const _,
1587                Some(transmute(notify_text_trampoline::<Self, F> as usize)),
1588                Box_::into_raw(f),
1589            )
1590        }
1591    }
1592}
1593
1594impl fmt::Display for TextBuffer {
1595    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1596        write!(f, "TextBuffer")
1597    }
1598}