Skip to main content

gtk4/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 crate::{TextChildAnchor, TextIter, TextMark, TextTag, TextTagTable, ffi};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// Stores text and attributes for display in a [`TextView`][crate::TextView].
16    ///
17    /// You may wish to begin by reading the
18    /// [text widget conceptual overview](section-text-widget.html),
19    /// which gives an overview of all the objects and data types
20    /// related to the text widget and how they work together.
21    ///
22    /// GtkTextBuffer can support undoing changes to the buffer
23    /// content, see [`TextBufferExt::set_enable_undo()`][crate::prelude::TextBufferExt::set_enable_undo()].
24    ///
25    /// ## Properties
26    ///
27    ///
28    /// #### `can-redo`
29    ///  Denotes that the buffer can reapply the last undone action.
30    ///
31    /// Readable
32    ///
33    ///
34    /// #### `can-undo`
35    ///  Denotes that the buffer can undo the last applied action.
36    ///
37    /// Readable
38    ///
39    ///
40    /// #### `cursor-position`
41    ///  The position of the insert mark.
42    ///
43    /// This is an offset from the beginning of the buffer.
44    /// It is useful for getting notified when the cursor moves.
45    ///
46    /// Readable
47    ///
48    ///
49    /// #### `enable-undo`
50    ///  Denotes if support for undoing and redoing changes to the buffer is allowed.
51    ///
52    /// Readable | Writable
53    ///
54    ///
55    /// #### `has-selection`
56    ///  Whether the buffer has some text currently selected.
57    ///
58    /// Readable
59    ///
60    ///
61    /// #### `tag-table`
62    ///  The GtkTextTagTable for the buffer.
63    ///
64    /// Readable | Writable | Construct Only
65    ///
66    ///
67    /// #### `text`
68    ///  The text content of the buffer.
69    ///
70    /// Without child widgets and images,
71    /// see [`TextBufferExt::text()`][crate::prelude::TextBufferExt::text()] for more information.
72    ///
73    /// Readable | Writable
74    ///
75    /// ## Signals
76    ///
77    ///
78    /// #### `apply-tag`
79    ///  Emitted to apply a tag to a range of text in a [`TextBuffer`][crate::TextBuffer].
80    ///
81    /// Applying actually occurs in the default handler.
82    ///
83    /// Note that if your handler runs before the default handler
84    /// it must not invalidate the @start and @end iters (or has to
85    /// revalidate them).
86    ///
87    /// See also:
88    /// [`TextBufferExt::apply_tag()`][crate::prelude::TextBufferExt::apply_tag()],
89    /// [`TextBufferExtManual::insert_with_tags()`][crate::prelude::TextBufferExtManual::insert_with_tags()],
90    /// [`TextBufferExt::insert_range()`][crate::prelude::TextBufferExt::insert_range()].
91    ///
92    ///
93    ///
94    ///
95    /// #### `begin-user-action`
96    ///  Emitted at the beginning of a single user-visible
97    /// operation on a [`TextBuffer`][crate::TextBuffer].
98    ///
99    /// See also:
100    /// [`TextBufferExt::begin_user_action()`][crate::prelude::TextBufferExt::begin_user_action()],
101    /// [`TextBufferExt::insert_interactive()`][crate::prelude::TextBufferExt::insert_interactive()],
102    /// [`TextBufferExt::insert_range_interactive()`][crate::prelude::TextBufferExt::insert_range_interactive()],
103    /// [`TextBufferExt::delete_interactive()`][crate::prelude::TextBufferExt::delete_interactive()],
104    /// [`TextBufferExt::backspace()`][crate::prelude::TextBufferExt::backspace()],
105    /// [`TextBufferExt::delete_selection()`][crate::prelude::TextBufferExt::delete_selection()].
106    ///
107    ///
108    ///
109    ///
110    /// #### `changed`
111    ///  Emitted when the content of a [`TextBuffer`][crate::TextBuffer] has changed.
112    ///
113    ///
114    ///
115    ///
116    /// #### `delete-range`
117    ///  Emitted to delete a range from a [`TextBuffer`][crate::TextBuffer].
118    ///
119    /// Note that if your handler runs before the default handler
120    /// it must not invalidate the @start and @end iters (or has
121    /// to revalidate them). The default signal handler revalidates
122    /// the @start and @end iters to both point to the location
123    /// where text was deleted. Handlers which run after the default
124    /// handler (see g_signal_connect_after()) do not have access to
125    /// the deleted text.
126    ///
127    /// See also: [`TextBufferExt::delete()`][crate::prelude::TextBufferExt::delete()].
128    ///
129    ///
130    ///
131    ///
132    /// #### `end-user-action`
133    ///  Emitted at the end of a single user-visible
134    /// operation on the [`TextBuffer`][crate::TextBuffer].
135    ///
136    /// See also:
137    /// [`TextBufferExt::end_user_action()`][crate::prelude::TextBufferExt::end_user_action()],
138    /// [`TextBufferExt::insert_interactive()`][crate::prelude::TextBufferExt::insert_interactive()],
139    /// [`TextBufferExt::insert_range_interactive()`][crate::prelude::TextBufferExt::insert_range_interactive()],
140    /// [`TextBufferExt::delete_interactive()`][crate::prelude::TextBufferExt::delete_interactive()],
141    /// [`TextBufferExt::backspace()`][crate::prelude::TextBufferExt::backspace()],
142    /// [`TextBufferExt::delete_selection()`][crate::prelude::TextBufferExt::delete_selection()],
143    /// [`TextBufferExt::backspace()`][crate::prelude::TextBufferExt::backspace()].
144    ///
145    ///
146    ///
147    ///
148    /// #### `insert-child-anchor`
149    ///  Emitted to insert a [`TextChildAnchor`][crate::TextChildAnchor] in a [`TextBuffer`][crate::TextBuffer].
150    ///
151    /// Insertion actually occurs in the default handler.
152    ///
153    /// Note that if your handler runs before the default handler
154    /// it must not invalidate the @location iter (or has to
155    /// revalidate it). The default signal handler revalidates
156    /// it to be placed after the inserted @anchor.
157    ///
158    /// See also: [`TextBufferExt::insert_child_anchor()`][crate::prelude::TextBufferExt::insert_child_anchor()].
159    ///
160    ///
161    ///
162    ///
163    /// #### `insert-paintable`
164    ///  Emitted to insert a [`gdk::Paintable`][crate::gdk::Paintable] in a [`TextBuffer`][crate::TextBuffer].
165    ///
166    /// Insertion actually occurs in the default handler.
167    ///
168    /// Note that if your handler runs before the default handler
169    /// it must not invalidate the @location iter (or has to
170    /// revalidate it). The default signal handler revalidates
171    /// it to be placed after the inserted @paintable.
172    ///
173    /// See also: [`TextBufferExt::insert_paintable()`][crate::prelude::TextBufferExt::insert_paintable()].
174    ///
175    ///
176    ///
177    ///
178    /// #### `insert-text`
179    ///  Emitted to insert text in a [`TextBuffer`][crate::TextBuffer].
180    ///
181    /// Insertion actually occurs in the default handler.
182    ///
183    /// Note that if your handler runs before the default handler
184    /// it must not invalidate the @location iter (or has to
185    /// revalidate it). The default signal handler revalidates
186    /// it to point to the end of the inserted text.
187    ///
188    /// See also: [`TextBufferExt::insert()`][crate::prelude::TextBufferExt::insert()],
189    /// [`TextBufferExt::insert_range()`][crate::prelude::TextBufferExt::insert_range()].
190    ///
191    ///
192    ///
193    ///
194    /// #### `mark-deleted`
195    ///  Emitted as notification after a [`TextMark`][crate::TextMark] is deleted.
196    ///
197    /// See also: [`TextBufferExt::delete_mark()`][crate::prelude::TextBufferExt::delete_mark()].
198    ///
199    ///
200    ///
201    ///
202    /// #### `mark-set`
203    ///  Emitted as notification after a [`TextMark`][crate::TextMark] is set.
204    ///
205    /// See also:
206    /// [`TextBufferExt::create_mark()`][crate::prelude::TextBufferExt::create_mark()],
207    /// [`TextBufferExt::move_mark()`][crate::prelude::TextBufferExt::move_mark()].
208    ///
209    ///
210    ///
211    ///
212    /// #### `modified-changed`
213    ///  Emitted when the modified bit of a [`TextBuffer`][crate::TextBuffer] flips.
214    ///
215    /// See also: [`TextBufferExt::set_modified()`][crate::prelude::TextBufferExt::set_modified()].
216    ///
217    ///
218    ///
219    ///
220    /// #### `paste-done`
221    ///  Emitted after paste operation has been completed.
222    ///
223    /// This is useful to properly scroll the view to the end
224    /// of the pasted text. See [`TextBufferExt::paste_clipboard()`][crate::prelude::TextBufferExt::paste_clipboard()]
225    /// for more details.
226    ///
227    ///
228    ///
229    ///
230    /// #### `redo`
231    ///  Emitted when a request has been made to redo the
232    /// previously undone operation.
233    ///
234    ///
235    ///
236    ///
237    /// #### `remove-tag`
238    ///  Emitted to remove all occurrences of @tag from a range
239    /// of text in a [`TextBuffer`][crate::TextBuffer].
240    ///
241    /// Removal actually occurs in the default handler.
242    ///
243    /// Note that if your handler runs before the default handler
244    /// it must not invalidate the @start and @end iters (or has
245    /// to revalidate them).
246    ///
247    /// See also: [`TextBufferExt::remove_tag()`][crate::prelude::TextBufferExt::remove_tag()].
248    ///
249    ///
250    ///
251    ///
252    /// #### `undo`
253    ///  Emitted when a request has been made to undo the
254    /// previous operation or set of operations that have
255    /// been grouped together.
256    ///
257    ///
258    ///
259    /// # Implements
260    ///
261    /// [`TextBufferExt`][trait@crate::prelude::TextBufferExt], [`trait@glib::ObjectExt`], [`TextBufferExtManual`][trait@crate::prelude::TextBufferExtManual]
262    #[doc(alias = "GtkTextBuffer")]
263    pub struct TextBuffer(Object<ffi::GtkTextBuffer, ffi::GtkTextBufferClass>);
264
265    match fn {
266        type_ => || ffi::gtk_text_buffer_get_type(),
267    }
268}
269
270impl TextBuffer {
271    pub const NONE: Option<&'static TextBuffer> = None;
272
273    /// Creates a new text buffer.
274    /// ## `table`
275    /// a tag table, or [`None`] to create a new one
276    ///
277    /// # Returns
278    ///
279    /// a new text buffer
280    #[doc(alias = "gtk_text_buffer_new")]
281    pub fn new(table: Option<&TextTagTable>) -> TextBuffer {
282        assert_initialized_main_thread!();
283        unsafe { from_glib_full(ffi::gtk_text_buffer_new(table.to_glib_none().0)) }
284    }
285
286    // rustdoc-stripper-ignore-next
287    /// Creates a new builder-pattern struct instance to construct [`TextBuffer`] objects.
288    ///
289    /// This method returns an instance of [`TextBufferBuilder`](crate::builders::TextBufferBuilder) which can be used to create [`TextBuffer`] objects.
290    pub fn builder() -> TextBufferBuilder {
291        TextBufferBuilder::new()
292    }
293}
294
295impl Default for TextBuffer {
296    fn default() -> Self {
297        glib::object::Object::new::<Self>()
298    }
299}
300
301// rustdoc-stripper-ignore-next
302/// A [builder-pattern] type to construct [`TextBuffer`] objects.
303///
304/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
305#[must_use = "The builder must be built to be used"]
306pub struct TextBufferBuilder {
307    builder: glib::object::ObjectBuilder<'static, TextBuffer>,
308}
309
310impl TextBufferBuilder {
311    fn new() -> Self {
312        Self {
313            builder: glib::object::Object::builder(),
314        }
315    }
316
317    /// Denotes if support for undoing and redoing changes to the buffer is allowed.
318    pub fn enable_undo(self, enable_undo: bool) -> Self {
319        Self {
320            builder: self.builder.property("enable-undo", enable_undo),
321        }
322    }
323
324    /// The GtkTextTagTable for the buffer.
325    pub fn tag_table(self, tag_table: &TextTagTable) -> Self {
326        Self {
327            builder: self.builder.property("tag-table", tag_table.clone()),
328        }
329    }
330
331    /// The text content of the buffer.
332    ///
333    /// Without child widgets and images,
334    /// see [`TextBufferExt::text()`][crate::prelude::TextBufferExt::text()] for more information.
335    pub fn text(self, text: impl Into<glib::GString>) -> Self {
336        Self {
337            builder: self.builder.property("text", text.into()),
338        }
339    }
340
341    // rustdoc-stripper-ignore-next
342    /// Build the [`TextBuffer`].
343    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
344    pub fn build(self) -> TextBuffer {
345        assert_initialized_main_thread!();
346        self.builder.build()
347    }
348}
349
350/// Trait containing all [`struct@TextBuffer`] methods.
351///
352/// # Implementors
353///
354/// [`TextBuffer`][struct@crate::TextBuffer]
355pub trait TextBufferExt: IsA<TextBuffer> + 'static {
356    /// Adds the mark at position @where_.
357    ///
358    /// The mark must not be added to another buffer, and if its name
359    /// is not [`None`] then there must not be another mark in the buffer
360    /// with the same name.
361    ///
362    /// Emits the [`mark-set`][struct@crate::TextBuffer#mark-set] signal as notification
363    /// of the mark's initial placement.
364    /// ## `mark`
365    /// the mark to add
366    /// ## `where_`
367    /// location to place mark
368    #[doc(alias = "gtk_text_buffer_add_mark")]
369    fn add_mark(&self, mark: &impl IsA<TextMark>, where_: &TextIter) {
370        unsafe {
371            ffi::gtk_text_buffer_add_mark(
372                self.as_ref().to_glib_none().0,
373                mark.as_ref().to_glib_none().0,
374                where_.to_glib_none().0,
375            );
376        }
377    }
378
379    /// Adds @clipboard to the list of clipboards in which the selection
380    /// contents of @self are available.
381    ///
382    /// In most cases, @clipboard will be the [`gdk::Clipboard`][crate::gdk::Clipboard] returned by
383    /// [`WidgetExt::primary_clipboard()`][crate::prelude::WidgetExt::primary_clipboard()] for a view of @self.
384    /// ## `clipboard`
385    /// a [`gdk::Clipboard`][crate::gdk::Clipboard]
386    #[doc(alias = "gtk_text_buffer_add_selection_clipboard")]
387    fn add_selection_clipboard(&self, clipboard: &gdk::Clipboard) {
388        unsafe {
389            ffi::gtk_text_buffer_add_selection_clipboard(
390                self.as_ref().to_glib_none().0,
391                clipboard.to_glib_none().0,
392            );
393        }
394    }
395
396    ///  signal on @self.
397    ///
398    /// The default handler for the signal applies
399    /// @tag to the given range. @start and @end do
400    /// not have to be in order.
401    /// ## `tag`
402    /// a [`TextTag`][crate::TextTag]
403    /// ## `start`
404    /// one bound of range to be tagged
405    /// ## `end`
406    /// other bound of range to be tagged
407    #[doc(alias = "gtk_text_buffer_apply_tag")]
408    fn apply_tag(&self, tag: &impl IsA<TextTag>, start: &TextIter, end: &TextIter) {
409        unsafe {
410            ffi::gtk_text_buffer_apply_tag(
411                self.as_ref().to_glib_none().0,
412                tag.as_ref().to_glib_none().0,
413                start.to_glib_none().0,
414                end.to_glib_none().0,
415            );
416        }
417    }
418
419    /// s
420    /// tag table to get a [`TextTag`][crate::TextTag], then calls
421    /// [`apply_tag()`][Self::apply_tag()].
422    /// ## `name`
423    /// name of a named [`TextTag`][crate::TextTag]
424    /// ## `start`
425    /// one bound of range to be tagged
426    /// ## `end`
427    /// other bound of range to be tagged
428    #[doc(alias = "gtk_text_buffer_apply_tag_by_name")]
429    fn apply_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter) {
430        unsafe {
431            ffi::gtk_text_buffer_apply_tag_by_name(
432                self.as_ref().to_glib_none().0,
433                name.to_glib_none().0,
434                start.to_glib_none().0,
435                end.to_glib_none().0,
436            );
437        }
438    }
439
440    /// Performs the appropriate action as if the user hit the delete
441    /// key with the cursor at the position specified by @iter.
442    ///
443    /// In the normal case a single character will be deleted, but when
444    /// combining accents are involved, more than one character can
445    /// be deleted, and when precomposed character and accent combinations
446    /// are involved, less than one character will be deleted.
447    ///
448    /// Because the buffer is modified, all outstanding iterators become
449    /// invalid after calling this function; however, the @iter will be
450    /// re-initialized to point to the location where text was deleted.
451    /// ## `iter`
452    /// a position in @self
453    /// ## `interactive`
454    /// whether the deletion is caused by user interaction
455    /// ## `default_editable`
456    /// whether the buffer is editable by default
457    ///
458    /// # Returns
459    ///
460    /// [`true`] if the buffer was modified
461    #[doc(alias = "gtk_text_buffer_backspace")]
462    fn backspace(&self, iter: &mut TextIter, interactive: bool, default_editable: bool) -> bool {
463        unsafe {
464            from_glib(ffi::gtk_text_buffer_backspace(
465                self.as_ref().to_glib_none().0,
466                iter.to_glib_none_mut().0,
467                interactive.into_glib(),
468                default_editable.into_glib(),
469            ))
470        }
471    }
472
473    /// Denotes the beginning of an action that may not be undone.
474    ///
475    /// This will cause any previous operations in the undo/redo queue
476    /// to be cleared.
477    ///
478    /// This should be paired with a call to
479    /// [`end_irreversible_action()`][Self::end_irreversible_action()] after the irreversible
480    /// action has completed.
481    ///
482    /// You may nest calls to gtk_text_buffer_begin_irreversible_action()
483    /// and gtk_text_buffer_end_irreversible_action() pairs.
484    #[doc(alias = "gtk_text_buffer_begin_irreversible_action")]
485    fn begin_irreversible_action(&self) {
486        unsafe {
487            ffi::gtk_text_buffer_begin_irreversible_action(self.as_ref().to_glib_none().0);
488        }
489    }
490
491    ///  buffer mutation functions, such as
492    /// [`insert_interactive()`][Self::insert_interactive()], automatically call
493    /// begin/end user action around the buffer operations they perform,
494    /// so there's no need to add extra calls if you user action consists
495    /// solely of a single call to one of those functions.
496    #[doc(alias = "gtk_text_buffer_begin_user_action")]
497    fn begin_user_action(&self) {
498        unsafe {
499            ffi::gtk_text_buffer_begin_user_action(self.as_ref().to_glib_none().0);
500        }
501    }
502
503    /// Copies the currently-selected text to a clipboard.
504    /// ## `clipboard`
505    /// the [`gdk::Clipboard`][crate::gdk::Clipboard] object to copy to
506    #[doc(alias = "gtk_text_buffer_copy_clipboard")]
507    fn copy_clipboard(&self, clipboard: &gdk::Clipboard) {
508        unsafe {
509            ffi::gtk_text_buffer_copy_clipboard(
510                self.as_ref().to_glib_none().0,
511                clipboard.to_glib_none().0,
512            );
513        }
514    }
515
516    /// Creates and inserts a child anchor.
517    ///
518    /// This is a convenience function which simply creates a child anchor
519    /// with [`TextChildAnchor::new()`][crate::TextChildAnchor::new()] and inserts it into the buffer
520    /// with [`insert_child_anchor()`][Self::insert_child_anchor()].
521    ///
522    /// The new anchor is owned by the buffer; no reference count is
523    /// returned to the caller of this function.
524    /// ## `iter`
525    /// location in the buffer
526    ///
527    /// # Returns
528    ///
529    /// the created child anchor
530    #[doc(alias = "gtk_text_buffer_create_child_anchor")]
531    fn create_child_anchor(&self, iter: &mut TextIter) -> TextChildAnchor {
532        unsafe {
533            from_glib_none(ffi::gtk_text_buffer_create_child_anchor(
534                self.as_ref().to_glib_none().0,
535                iter.to_glib_none_mut().0,
536            ))
537        }
538    }
539
540    /// re typing).
541    ///
542    /// The caller of this function does not own a
543    /// reference to the returned [`TextMark`][crate::TextMark], so you can ignore the
544    /// return value if you like. Marks are owned by the buffer and go
545    /// away when the buffer does.
546    ///
547    /// Emits the [`mark-set`][struct@crate::TextBuffer#mark-set] signal as notification
548    /// of the mark's initial placement.
549    /// ## `mark_name`
550    /// name for mark
551    /// ## `where_`
552    /// location to place mark
553    /// ## `left_gravity`
554    /// whether the mark has left gravity
555    ///
556    /// # Returns
557    ///
558    /// the new [`TextMark`][crate::TextMark] object
559    #[doc(alias = "gtk_text_buffer_create_mark")]
560    fn create_mark(
561        &self,
562        mark_name: Option<&str>,
563        where_: &TextIter,
564        left_gravity: bool,
565    ) -> TextMark {
566        unsafe {
567            from_glib_none(ffi::gtk_text_buffer_create_mark(
568                self.as_ref().to_glib_none().0,
569                mark_name.to_glib_none().0,
570                where_.to_glib_none().0,
571                left_gravity.into_glib(),
572            ))
573        }
574    }
575
576    /// s editable.
577    /// ## `clipboard`
578    /// the [`gdk::Clipboard`][crate::gdk::Clipboard] object to cut to
579    /// ## `default_editable`
580    /// default editability of the buffer
581    #[doc(alias = "gtk_text_buffer_cut_clipboard")]
582    fn cut_clipboard(&self, clipboard: &gdk::Clipboard, default_editable: bool) {
583        unsafe {
584            ffi::gtk_text_buffer_cut_clipboard(
585                self.as_ref().to_glib_none().0,
586                clipboard.to_glib_none().0,
587                default_editable.into_glib(),
588            );
589        }
590    }
591
592    ///  signal, and
593    /// the default handler of that signal deletes the text. Because the
594    /// buffer is modified, all outstanding iterators become invalid after
595    /// calling this function; however, the @start and @end will be
596    /// re-initialized to point to the location where text was deleted.
597    /// ## `start`
598    /// a position in @self
599    /// ## `end`
600    /// another position in @self
601    #[doc(alias = "gtk_text_buffer_delete")]
602    fn delete(&self, start: &mut TextIter, end: &mut TextIter) {
603        unsafe {
604            ffi::gtk_text_buffer_delete(
605                self.as_ref().to_glib_none().0,
606                start.to_glib_none_mut().0,
607                end.to_glib_none_mut().0,
608            );
609        }
610    }
611
612    /// Deletes all editable text in the given range.
613    ///
614    /// Calls [`delete()`][Self::delete()] for each editable
615    /// sub-range of [@start,@end). @start and @end are revalidated
616    /// to point to the location of the last deleted range, or left
617    /// untouched if no text was deleted.
618    /// ## `start_iter`
619    /// start of range to delete
620    /// ## `end_iter`
621    /// end of range
622    /// ## `default_editable`
623    /// whether the buffer is editable by default
624    ///
625    /// # Returns
626    ///
627    /// whether some text was actually deleted
628    #[doc(alias = "gtk_text_buffer_delete_interactive")]
629    fn delete_interactive(
630        &self,
631        start_iter: &mut TextIter,
632        end_iter: &mut TextIter,
633        default_editable: bool,
634    ) -> bool {
635        unsafe {
636            from_glib(ffi::gtk_text_buffer_delete_interactive(
637                self.as_ref().to_glib_none().0,
638                start_iter.to_glib_none_mut().0,
639                end_iter.to_glib_none_mut().0,
640                default_editable.into_glib(),
641            ))
642        }
643    }
644
645    /// t freed, most operations on @mark become
646    /// invalid, until it gets added to a buffer again with
647    /// [`add_mark()`][Self::add_mark()]. Use [`TextMarkExt::is_deleted()`][crate::prelude::TextMarkExt::is_deleted()]
648    /// to find out if a mark has been removed from its buffer.
649    ///
650    /// The [`mark-deleted`][struct@crate::TextBuffer#mark-deleted] signal will be emitted as
651    /// notification after the mark is deleted.
652    /// ## `mark`
653    /// a [`TextMark`][crate::TextMark] in @self
654    #[doc(alias = "gtk_text_buffer_delete_mark")]
655    fn delete_mark(&self, mark: &impl IsA<TextMark>) {
656        unsafe {
657            ffi::gtk_text_buffer_delete_mark(
658                self.as_ref().to_glib_none().0,
659                mark.as_ref().to_glib_none().0,
660            );
661        }
662    }
663
664    /// Deletes the mark named @name; the mark must exist.
665    ///
666    /// See [`delete_mark()`][Self::delete_mark()] for details.
667    /// ## `name`
668    /// name of a mark in @self
669    #[doc(alias = "gtk_text_buffer_delete_mark_by_name")]
670    fn delete_mark_by_name(&self, name: &str) {
671        unsafe {
672            ffi::gtk_text_buffer_delete_mark_by_name(
673                self.as_ref().to_glib_none().0,
674                name.to_glib_none().0,
675            );
676        }
677    }
678
679    /// t delete uneditable text).
680    /// ## `interactive`
681    /// whether the deletion is caused by user interaction
682    /// ## `default_editable`
683    /// whether the buffer is editable by default
684    ///
685    /// # Returns
686    ///
687    /// whether there was a non-empty selection to delete
688    #[doc(alias = "gtk_text_buffer_delete_selection")]
689    fn delete_selection(&self, interactive: bool, default_editable: bool) -> bool {
690        unsafe {
691            from_glib(ffi::gtk_text_buffer_delete_selection(
692                self.as_ref().to_glib_none().0,
693                interactive.into_glib(),
694                default_editable.into_glib(),
695            ))
696        }
697    }
698
699    /// Denotes the end of an action that may not be undone.
700    ///
701    /// This will cause any previous operations in the undo/redo
702    /// queue to be cleared.
703    ///
704    /// This should be called after completing modifications to the
705    /// text buffer after [`begin_irreversible_action()`][Self::begin_irreversible_action()]
706    /// was called.
707    ///
708    /// You may nest calls to gtk_text_buffer_begin_irreversible_action()
709    /// and gtk_text_buffer_end_irreversible_action() pairs.
710    #[doc(alias = "gtk_text_buffer_end_irreversible_action")]
711    fn end_irreversible_action(&self) {
712        unsafe {
713            ffi::gtk_text_buffer_end_irreversible_action(self.as_ref().to_glib_none().0);
714        }
715    }
716
717    /// Ends a user-visible operation.
718    ///
719    /// Should be paired with a call to
720    /// [`begin_user_action()`][Self::begin_user_action()].
721    /// See that function for a full explanation.
722    #[doc(alias = "gtk_text_buffer_end_user_action")]
723    fn end_user_action(&self) {
724        unsafe {
725            ffi::gtk_text_buffer_end_user_action(self.as_ref().to_glib_none().0);
726        }
727    }
728
729    /// Retrieves the first and last iterators in the buffer, i.e. the
730    /// entire buffer lies within the range [@start,@end).
731    ///
732    /// # Returns
733    ///
734    ///
735    /// ## `start`
736    /// iterator to initialize with first position in the buffer
737    ///
738    /// ## `end`
739    /// iterator to initialize with the end iterator
740    #[doc(alias = "gtk_text_buffer_get_bounds")]
741    #[doc(alias = "get_bounds")]
742    fn bounds(&self) -> (TextIter, TextIter) {
743        unsafe {
744            let mut start = TextIter::uninitialized();
745            let mut end = TextIter::uninitialized();
746            ffi::gtk_text_buffer_get_bounds(
747                self.as_ref().to_glib_none().0,
748                start.to_glib_none_mut().0,
749                end.to_glib_none_mut().0,
750            );
751            (start, end)
752        }
753    }
754
755    /// Gets whether there is a redoable action in the history.
756    ///
757    /// # Returns
758    ///
759    /// [`true`] if there is a redoable action
760    #[doc(alias = "gtk_text_buffer_get_can_redo")]
761    #[doc(alias = "get_can_redo")]
762    #[doc(alias = "can-redo")]
763    fn can_redo(&self) -> bool {
764        unsafe {
765            from_glib(ffi::gtk_text_buffer_get_can_redo(
766                self.as_ref().to_glib_none().0,
767            ))
768        }
769    }
770
771    /// Gets whether there is an undoable action in the history.
772    ///
773    /// # Returns
774    ///
775    /// [`true`] if there is an undoable action
776    #[doc(alias = "gtk_text_buffer_get_can_undo")]
777    #[doc(alias = "get_can_undo")]
778    #[doc(alias = "can-undo")]
779    fn can_undo(&self) -> bool {
780        unsafe {
781            from_glib(ffi::gtk_text_buffer_get_can_undo(
782                self.as_ref().to_glib_none().0,
783            ))
784        }
785    }
786
787    /// t e.g.
788    /// expect the contents of the buffer in string form to be this
789    /// many bytes long.
790    ///
791    /// The character count is cached, so this function is very fast.
792    ///
793    /// # Returns
794    ///
795    /// number of characters in the buffer
796    #[doc(alias = "gtk_text_buffer_get_char_count")]
797    #[doc(alias = "get_char_count")]
798    fn char_count(&self) -> i32 {
799        unsafe { ffi::gtk_text_buffer_get_char_count(self.as_ref().to_glib_none().0) }
800    }
801
802    /// Gets whether the buffer is saving modifications to the buffer
803    /// to allow for undo and redo actions.
804    ///
805    /// See [`begin_irreversible_action()`][Self::begin_irreversible_action()] and
806    /// [`end_irreversible_action()`][Self::end_irreversible_action()] to create
807    /// changes to the buffer that cannot be undone.
808    ///
809    /// # Returns
810    ///
811    /// [`true`] if undoing and redoing changes to the buffer is allowed.
812    #[doc(alias = "gtk_text_buffer_get_enable_undo")]
813    #[doc(alias = "get_enable_undo")]
814    #[doc(alias = "enable-undo")]
815    fn enables_undo(&self) -> bool {
816        unsafe {
817            from_glib(ffi::gtk_text_buffer_get_enable_undo(
818                self.as_ref().to_glib_none().0,
819            ))
820        }
821    }
822
823    ///  one past the last valid
824    /// character in the text buffer.
825    ///
826    /// If dereferenced with [`TextIter::char()`][crate::TextIter::char()], the end
827    /// iterator has a character value of 0.
828    /// The entire buffer lies in the range from the first position in
829    /// the buffer (call [`start_iter()`][Self::start_iter()] to get
830    /// character position 0) to the end iterator.
831    ///
832    /// # Returns
833    ///
834    ///
835    /// ## `iter`
836    /// iterator to initialize
837    #[doc(alias = "gtk_text_buffer_get_end_iter")]
838    #[doc(alias = "get_end_iter")]
839    fn end_iter(&self) -> TextIter {
840        unsafe {
841            let mut iter = TextIter::uninitialized();
842            ffi::gtk_text_buffer_get_end_iter(
843                self.as_ref().to_glib_none().0,
844                iter.to_glib_none_mut().0,
845            );
846            iter
847        }
848    }
849
850    /// Indicates whether the buffer has some text currently selected.
851    ///
852    /// # Returns
853    ///
854    /// [`true`] if the there is text selected
855    #[doc(alias = "gtk_text_buffer_get_has_selection")]
856    #[doc(alias = "get_has_selection")]
857    #[doc(alias = "has-selection")]
858    fn has_selection(&self) -> bool {
859        unsafe {
860            from_glib(ffi::gtk_text_buffer_get_has_selection(
861                self.as_ref().to_glib_none().0,
862            ))
863        }
864    }
865
866    /// , but very slightly more
867    /// efficient, and involves less typing.
868    ///
869    /// # Returns
870    ///
871    /// insertion point mark
872    #[doc(alias = "gtk_text_buffer_get_insert")]
873    fn get_insert(&self) -> TextMark {
874        unsafe {
875            from_glib_none(ffi::gtk_text_buffer_get_insert(
876                self.as_ref().to_glib_none().0,
877            ))
878        }
879    }
880
881    /// Obtains the location of @anchor within @self.
882    /// ## `anchor`
883    /// a child anchor that appears in @self
884    ///
885    /// # Returns
886    ///
887    ///
888    /// ## `iter`
889    /// an iterator to be initialized
890    #[doc(alias = "gtk_text_buffer_get_iter_at_child_anchor")]
891    #[doc(alias = "get_iter_at_child_anchor")]
892    fn iter_at_child_anchor(&self, anchor: &impl IsA<TextChildAnchor>) -> TextIter {
893        unsafe {
894            let mut iter = TextIter::uninitialized();
895            ffi::gtk_text_buffer_get_iter_at_child_anchor(
896                self.as_ref().to_glib_none().0,
897                iter.to_glib_none_mut().0,
898                anchor.as_ref().to_glib_none().0,
899            );
900            iter
901        }
902    }
903
904    /// Initializes @iter to the start of the given line.
905    ///
906    /// If @line_number is greater than or equal to the number of lines
907    /// in the @self, the end iterator is returned.
908    /// ## `line_number`
909    /// line number counting from 0
910    ///
911    /// # Returns
912    ///
913    /// whether the exact position has been found
914    ///
915    /// ## `iter`
916    /// iterator to initialize
917    #[doc(alias = "gtk_text_buffer_get_iter_at_line")]
918    #[doc(alias = "get_iter_at_line")]
919    fn iter_at_line(&self, line_number: i32) -> Option<TextIter> {
920        unsafe {
921            let mut iter = TextIter::uninitialized();
922            let ret = from_glib(ffi::gtk_text_buffer_get_iter_at_line(
923                self.as_ref().to_glib_none().0,
924                iter.to_glib_none_mut().0,
925                line_number,
926            ));
927            if ret { Some(iter) } else { None }
928        }
929    }
930
931    /// Obtains an iterator pointing to @byte_index within the given line.
932    ///
933    /// @byte_index must be the start of a UTF-8 character. Note bytes, not
934    /// characters; UTF-8 may encode one character as multiple bytes.
935    ///
936    /// If @line_number is greater than or equal to the number of lines in the @self,
937    /// the end iterator is returned. And if @byte_index is off the
938    /// end of the line, the iterator at the end of the line is returned.
939    /// ## `line_number`
940    /// line number counting from 0
941    /// ## `byte_index`
942    /// byte index from start of line
943    ///
944    /// # Returns
945    ///
946    /// whether the exact position has been found
947    ///
948    /// ## `iter`
949    /// iterator to initialize
950    #[doc(alias = "gtk_text_buffer_get_iter_at_line_index")]
951    #[doc(alias = "get_iter_at_line_index")]
952    fn iter_at_line_index(&self, line_number: i32, byte_index: i32) -> Option<TextIter> {
953        unsafe {
954            let mut iter = TextIter::uninitialized();
955            let ret = from_glib(ffi::gtk_text_buffer_get_iter_at_line_index(
956                self.as_ref().to_glib_none().0,
957                iter.to_glib_none_mut().0,
958                line_number,
959                byte_index,
960            ));
961            if ret { Some(iter) } else { None }
962        }
963    }
964
965    /// Obtains an iterator pointing to @char_offset within the given line.
966    ///
967    /// Note characters, not bytes; UTF-8 may encode one character as multiple
968    /// bytes.
969    ///
970    /// If @line_number is greater than or equal to the number of lines in the @self,
971    /// the end iterator is returned. And if @char_offset is off the
972    /// end of the line, the iterator at the end of the line is returned.
973    /// ## `line_number`
974    /// line number counting from 0
975    /// ## `char_offset`
976    /// char offset from start of line
977    ///
978    /// # Returns
979    ///
980    /// whether the exact position has been found
981    ///
982    /// ## `iter`
983    /// iterator to initialize
984    #[doc(alias = "gtk_text_buffer_get_iter_at_line_offset")]
985    #[doc(alias = "get_iter_at_line_offset")]
986    fn iter_at_line_offset(&self, line_number: i32, char_offset: i32) -> Option<TextIter> {
987        unsafe {
988            let mut iter = TextIter::uninitialized();
989            let ret = from_glib(ffi::gtk_text_buffer_get_iter_at_line_offset(
990                self.as_ref().to_glib_none().0,
991                iter.to_glib_none_mut().0,
992                line_number,
993                char_offset,
994            ));
995            if ret { Some(iter) } else { None }
996        }
997    }
998
999    /// Initializes @iter with the current position of @mark.
1000    /// ## `mark`
1001    /// a [`TextMark`][crate::TextMark] in @self
1002    ///
1003    /// # Returns
1004    ///
1005    ///
1006    /// ## `iter`
1007    /// iterator to initialize
1008    #[doc(alias = "gtk_text_buffer_get_iter_at_mark")]
1009    #[doc(alias = "get_iter_at_mark")]
1010    fn iter_at_mark(&self, mark: &impl IsA<TextMark>) -> TextIter {
1011        unsafe {
1012            let mut iter = TextIter::uninitialized();
1013            ffi::gtk_text_buffer_get_iter_at_mark(
1014                self.as_ref().to_glib_none().0,
1015                iter.to_glib_none_mut().0,
1016                mark.as_ref().to_glib_none().0,
1017            );
1018            iter
1019        }
1020    }
1021
1022    /// Initializes @iter to a position @char_offset chars from the start
1023    /// of the entire buffer.
1024    ///
1025    /// If @char_offset is -1 or greater than the number
1026    /// of characters in the buffer, @iter is initialized to the end iterator,
1027    /// the iterator one past the last valid character in the buffer.
1028    /// ## `char_offset`
1029    /// char offset from start of buffer, counting from 0, or -1
1030    ///
1031    /// # Returns
1032    ///
1033    ///
1034    /// ## `iter`
1035    /// iterator to initialize
1036    #[doc(alias = "gtk_text_buffer_get_iter_at_offset")]
1037    #[doc(alias = "get_iter_at_offset")]
1038    fn iter_at_offset(&self, char_offset: i32) -> TextIter {
1039        unsafe {
1040            let mut iter = TextIter::uninitialized();
1041            ffi::gtk_text_buffer_get_iter_at_offset(
1042                self.as_ref().to_glib_none().0,
1043                iter.to_glib_none_mut().0,
1044                char_offset,
1045            );
1046            iter
1047        }
1048    }
1049
1050    /// Obtains the number of lines in the buffer.
1051    ///
1052    /// This value is cached, so the function is very fast.
1053    ///
1054    /// # Returns
1055    ///
1056    /// number of lines in the buffer
1057    #[doc(alias = "gtk_text_buffer_get_line_count")]
1058    #[doc(alias = "get_line_count")]
1059    fn line_count(&self) -> i32 {
1060        unsafe { ffi::gtk_text_buffer_get_line_count(self.as_ref().to_glib_none().0) }
1061    }
1062
1063    /// Returns the mark named @name in buffer @self, or [`None`] if no such
1064    /// mark exists in the buffer.
1065    /// ## `name`
1066    /// a mark name
1067    ///
1068    /// # Returns
1069    ///
1070    /// a [`TextMark`][crate::TextMark]
1071    #[doc(alias = "gtk_text_buffer_get_mark")]
1072    #[doc(alias = "get_mark")]
1073    fn mark(&self, name: &str) -> Option<TextMark> {
1074        unsafe {
1075            from_glib_none(ffi::gtk_text_buffer_get_mark(
1076                self.as_ref().to_glib_none().0,
1077                name.to_glib_none().0,
1078            ))
1079        }
1080    }
1081
1082    /// Gets the maximum number of undo levels to perform.
1083    ///
1084    /// If 0, unlimited undo actions may be performed. Note that this may
1085    /// have a memory usage impact as it requires storing an additional
1086    /// copy of the inserted or removed text within the text buffer.
1087    ///
1088    /// # Returns
1089    ///
1090    /// The max number of undo levels allowed (0 indicates unlimited).
1091    #[doc(alias = "gtk_text_buffer_get_max_undo_levels")]
1092    #[doc(alias = "get_max_undo_levels")]
1093    fn max_undo_levels(&self) -> u32 {
1094        unsafe { ffi::gtk_text_buffer_get_max_undo_levels(self.as_ref().to_glib_none().0) }
1095    }
1096
1097    ///  function in a text editor.
1098    ///
1099    /// # Returns
1100    ///
1101    /// [`true`] if the buffer has been modified
1102    #[doc(alias = "gtk_text_buffer_get_modified")]
1103    #[doc(alias = "get_modified")]
1104    fn is_modified(&self) -> bool {
1105        unsafe {
1106            from_glib(ffi::gtk_text_buffer_get_modified(
1107                self.as_ref().to_glib_none().0,
1108            ))
1109        }
1110    }
1111
1112    /// s a selection and what its bounds are.
1113    ///
1114    /// # Returns
1115    ///
1116    /// selection bound mark
1117    #[doc(alias = "gtk_text_buffer_get_selection_bound")]
1118    #[doc(alias = "get_selection_bound")]
1119    fn selection_bound(&self) -> TextMark {
1120        unsafe {
1121            from_glib_none(ffi::gtk_text_buffer_get_selection_bound(
1122                self.as_ref().to_glib_none().0,
1123            ))
1124        }
1125    }
1126
1127    /// Returns [`true`] if some text is selected; places the bounds
1128    /// of the selection in @start and @end.
1129    ///
1130    /// If the selection has length 0, then @start and @end are filled
1131    /// in with the same value. @start and @end will be in ascending order.
1132    /// If @start and @end are [`None`], then they are not filled in, but the
1133    /// return value still indicates whether text is selected.
1134    ///
1135    /// # Returns
1136    ///
1137    /// whether the selection has nonzero length
1138    ///
1139    /// ## `start`
1140    /// iterator to initialize with selection start
1141    ///
1142    /// ## `end`
1143    /// iterator to initialize with selection end
1144    #[doc(alias = "gtk_text_buffer_get_selection_bounds")]
1145    #[doc(alias = "get_selection_bounds")]
1146    fn selection_bounds(&self) -> Option<(TextIter, TextIter)> {
1147        unsafe {
1148            let mut start = TextIter::uninitialized();
1149            let mut end = TextIter::uninitialized();
1150            let ret = from_glib(ffi::gtk_text_buffer_get_selection_bounds(
1151                self.as_ref().to_glib_none().0,
1152                start.to_glib_none_mut().0,
1153                end.to_glib_none_mut().0,
1154            ));
1155            if ret { Some((start, end)) } else { None }
1156        }
1157    }
1158
1159    /// Get a content provider for this buffer.
1160    ///
1161    /// It can be used to make the content of @self available
1162    /// in a [`gdk::Clipboard`][crate::gdk::Clipboard], see [`Clipboard::set_content()`][crate::gdk::Clipboard::set_content()].
1163    ///
1164    /// # Returns
1165    ///
1166    /// a new [`gdk::ContentProvider`][crate::gdk::ContentProvider].
1167    #[doc(alias = "gtk_text_buffer_get_selection_content")]
1168    #[doc(alias = "get_selection_content")]
1169    fn selection_content(&self) -> gdk::ContentProvider {
1170        unsafe {
1171            from_glib_full(ffi::gtk_text_buffer_get_selection_content(
1172                self.as_ref().to_glib_none().0,
1173            ))
1174        }
1175    }
1176
1177    /// Returns the text in the range [@start,@end).
1178    ///
1179    /// Excludes undisplayed text (text marked with tags that set the
1180    /// invisibility attribute) if @include_hidden_chars is [`false`].
1181    /// The returned string includes a 0xFFFC character whenever the
1182    /// buffer contains embedded images, so byte and character indexes
1183    /// into the returned string do correspond to byte and character
1184    /// indexes into the buffer. Contrast with [`text()`][Self::text()].
1185    /// Note that 0xFFFC can occur in normal text as well, so it is not a
1186    /// reliable indicator that a paintable or widget is in the buffer.
1187    /// ## `start`
1188    /// start of a range
1189    /// ## `end`
1190    /// end of a range
1191    /// ## `include_hidden_chars`
1192    /// whether to include invisible text
1193    ///
1194    /// # Returns
1195    ///
1196    /// an allocated UTF-8 string
1197    #[doc(alias = "gtk_text_buffer_get_slice")]
1198    #[doc(alias = "get_slice")]
1199    fn slice(&self, start: &TextIter, end: &TextIter, include_hidden_chars: bool) -> glib::GString {
1200        unsafe {
1201            from_glib_full(ffi::gtk_text_buffer_get_slice(
1202                self.as_ref().to_glib_none().0,
1203                start.to_glib_none().0,
1204                end.to_glib_none().0,
1205                include_hidden_chars.into_glib(),
1206            ))
1207        }
1208    }
1209
1210    /// Initialized @iter with the first position in the text buffer.
1211    ///
1212    /// This is the same as using [`iter_at_offset()`][Self::iter_at_offset()]
1213    /// to get the iter at character offset 0.
1214    ///
1215    /// # Returns
1216    ///
1217    ///
1218    /// ## `iter`
1219    /// iterator to initialize
1220    #[doc(alias = "gtk_text_buffer_get_start_iter")]
1221    #[doc(alias = "get_start_iter")]
1222    fn start_iter(&self) -> TextIter {
1223        unsafe {
1224            let mut iter = TextIter::uninitialized();
1225            ffi::gtk_text_buffer_get_start_iter(
1226                self.as_ref().to_glib_none().0,
1227                iter.to_glib_none_mut().0,
1228            );
1229            iter
1230        }
1231    }
1232
1233    /// Get the [`TextTagTable`][crate::TextTagTable] associated with this buffer.
1234    ///
1235    /// # Returns
1236    ///
1237    /// s tag table
1238    #[doc(alias = "gtk_text_buffer_get_tag_table")]
1239    #[doc(alias = "get_tag_table")]
1240    #[doc(alias = "tag-table")]
1241    fn tag_table(&self) -> TextTagTable {
1242        unsafe {
1243            from_glib_none(ffi::gtk_text_buffer_get_tag_table(
1244                self.as_ref().to_glib_none().0,
1245            ))
1246        }
1247    }
1248
1249    /// Returns the text in the range [@start,@end).
1250    ///
1251    /// Excludes undisplayed text (text marked with tags that set the
1252    /// invisibility attribute) if @include_hidden_chars is [`false`].
1253    /// Does not include characters representing embedded images, so
1254    /// byte and character indexes into the returned string do not
1255    /// correspond to byte and character indexes into the buffer.
1256    /// Contrast with [`slice()`][Self::slice()].
1257    /// ## `start`
1258    /// start of a range
1259    /// ## `end`
1260    /// end of a range
1261    /// ## `include_hidden_chars`
1262    /// whether to include invisible text
1263    ///
1264    /// # Returns
1265    ///
1266    /// an allocated UTF-8 string
1267    #[doc(alias = "gtk_text_buffer_get_text")]
1268    #[doc(alias = "get_text")]
1269    fn text(&self, start: &TextIter, end: &TextIter, include_hidden_chars: bool) -> glib::GString {
1270        unsafe {
1271            from_glib_full(ffi::gtk_text_buffer_get_text(
1272                self.as_ref().to_glib_none().0,
1273                start.to_glib_none().0,
1274                end.to_glib_none().0,
1275                include_hidden_chars.into_glib(),
1276            ))
1277        }
1278    }
1279
1280    ///  signal; insertion actually occurs
1281    /// in the default handler for the signal. @iter is invalidated when
1282    /// insertion occurs (because the buffer contents change), but the
1283    /// default signal handler revalidates it to point to the end of the
1284    /// inserted text.
1285    /// ## `iter`
1286    /// a position in the buffer
1287    /// ## `text`
1288    /// text in UTF-8 format
1289    /// ## `len`
1290    /// length of text in bytes, or -1
1291    #[doc(alias = "gtk_text_buffer_insert")]
1292    fn insert(&self, iter: &mut TextIter, text: &str) {
1293        let len = text.len() as _;
1294        unsafe {
1295            ffi::gtk_text_buffer_insert(
1296                self.as_ref().to_glib_none().0,
1297                iter.to_glib_none_mut().0,
1298                text.to_glib_none().0,
1299                len,
1300            );
1301        }
1302    }
1303
1304    /// Inserts @text in @self.
1305    ///
1306    /// Simply calls [`insert()`][Self::insert()],
1307    /// using the current cursor position as the insertion point.
1308    /// ## `text`
1309    /// text in UTF-8 format
1310    /// ## `len`
1311    /// length of text, in bytes
1312    #[doc(alias = "gtk_text_buffer_insert_at_cursor")]
1313    fn insert_at_cursor(&self, text: &str) {
1314        let len = text.len() as _;
1315        unsafe {
1316            ffi::gtk_text_buffer_insert_at_cursor(
1317                self.as_ref().to_glib_none().0,
1318                text.to_glib_none().0,
1319                len,
1320            );
1321        }
1322    }
1323
1324    ///  variants do
1325    /// not. E.g. see [`slice()`][Self::slice()] and
1326    /// [`text()`][Self::text()].
1327    ///
1328    /// Consider [`create_child_anchor()`][Self::create_child_anchor()] as a more
1329    /// convenient alternative to this function. The buffer will add a
1330    /// reference to the anchor, so you can unref it after insertion.
1331    /// ## `iter`
1332    /// location to insert the anchor
1333    /// ## `anchor`
1334    /// a [`TextChildAnchor`][crate::TextChildAnchor]
1335    #[doc(alias = "gtk_text_buffer_insert_child_anchor")]
1336    fn insert_child_anchor(&self, iter: &mut TextIter, anchor: &impl IsA<TextChildAnchor>) {
1337        unsafe {
1338            ffi::gtk_text_buffer_insert_child_anchor(
1339                self.as_ref().to_glib_none().0,
1340                iter.to_glib_none_mut().0,
1341                anchor.as_ref().to_glib_none().0,
1342            );
1343        }
1344    }
1345
1346    /// Inserts @text in @self.
1347    ///
1348    /// Like [`insert()`][Self::insert()], but the insertion will not occur
1349    /// if @iter is at a non-editable location in the buffer. Usually you
1350    /// want to prevent insertions at ineditable locations if the insertion
1351    /// results from a user action (is interactive).
1352    ///
1353    /// @default_editable indicates the editability of text that doesn't
1354    /// have a tag affecting editability applied to it. Typically the
1355    /// result of [`TextViewExt::is_editable()`][crate::prelude::TextViewExt::is_editable()] is appropriate here.
1356    /// ## `iter`
1357    /// a position in @self
1358    /// ## `text`
1359    /// some UTF-8 text
1360    /// ## `len`
1361    /// length of text in bytes, or -1
1362    /// ## `default_editable`
1363    /// default editability of buffer
1364    ///
1365    /// # Returns
1366    ///
1367    /// whether text was actually inserted
1368    #[doc(alias = "gtk_text_buffer_insert_interactive")]
1369    fn insert_interactive(&self, iter: &mut TextIter, text: &str, default_editable: bool) -> bool {
1370        let len = text.len() as _;
1371        unsafe {
1372            from_glib(ffi::gtk_text_buffer_insert_interactive(
1373                self.as_ref().to_glib_none().0,
1374                iter.to_glib_none_mut().0,
1375                text.to_glib_none().0,
1376                len,
1377                default_editable.into_glib(),
1378            ))
1379        }
1380    }
1381
1382    /// Inserts @text in @self.
1383    ///
1384    /// Calls [`insert_interactive()`][Self::insert_interactive()]
1385    /// at the cursor position.
1386    ///
1387    /// @default_editable indicates the editability of text that doesn't
1388    /// have a tag affecting editability applied to it. Typically the
1389    /// result of [`TextViewExt::is_editable()`][crate::prelude::TextViewExt::is_editable()] is appropriate here.
1390    /// ## `text`
1391    /// text in UTF-8 format
1392    /// ## `len`
1393    /// length of text in bytes, or -1
1394    /// ## `default_editable`
1395    /// default editability of buffer
1396    ///
1397    /// # Returns
1398    ///
1399    /// whether text was actually inserted
1400    #[doc(alias = "gtk_text_buffer_insert_interactive_at_cursor")]
1401    fn insert_interactive_at_cursor(&self, text: &str, default_editable: bool) -> bool {
1402        let len = text.len() as _;
1403        unsafe {
1404            from_glib(ffi::gtk_text_buffer_insert_interactive_at_cursor(
1405                self.as_ref().to_glib_none().0,
1406                text.to_glib_none().0,
1407                len,
1408                default_editable.into_glib(),
1409            ))
1410        }
1411    }
1412
1413    /// Inserts the text in @markup at position @iter.
1414    ///
1415    /// @markup will be inserted in its entirety and must be nul-terminated
1416    /// and valid UTF-8. Emits the [`insert-text`][struct@crate::TextBuffer#insert-text] signal,
1417    /// possibly multiple times; insertion actually occurs in the default handler
1418    /// for the signal. @iter will point to the end of the inserted text on return.
1419    /// ## `iter`
1420    /// location to insert the markup
1421    /// ## `markup`
1422    /// a nul-terminated UTF-8 string containing Pango markup
1423    /// ## `len`
1424    /// length of @markup in bytes, or -1
1425    #[doc(alias = "gtk_text_buffer_insert_markup")]
1426    fn insert_markup(&self, iter: &mut TextIter, markup: &str) {
1427        let len = markup.len() as _;
1428        unsafe {
1429            ffi::gtk_text_buffer_insert_markup(
1430                self.as_ref().to_glib_none().0,
1431                iter.to_glib_none_mut().0,
1432                markup.to_glib_none().0,
1433                len,
1434            );
1435        }
1436    }
1437
1438    ///
1439    /// variants do not. e.g. see [`slice()`][Self::slice()] and
1440    /// [`text()`][Self::text()].
1441    /// ## `iter`
1442    /// location to insert the paintable
1443    /// ## `paintable`
1444    /// a [`gdk::Paintable`][crate::gdk::Paintable]
1445    #[doc(alias = "gtk_text_buffer_insert_paintable")]
1446    fn insert_paintable(&self, iter: &mut TextIter, paintable: &impl IsA<gdk::Paintable>) {
1447        unsafe {
1448            ffi::gtk_text_buffer_insert_paintable(
1449                self.as_ref().to_glib_none().0,
1450                iter.to_glib_none_mut().0,
1451                paintable.as_ref().to_glib_none().0,
1452            );
1453        }
1454    }
1455
1456    /// t matter.
1457    ///
1458    /// Used instead of simply getting/inserting text because it preserves
1459    /// images and tags. If @start and @end are in a different buffer from
1460    /// @self, the two buffers must share the same tag table.
1461    ///
1462    /// Implemented via emissions of the ::insert-text and ::apply-tag signals,
1463    /// so expect those.
1464    /// ## `iter`
1465    /// a position in @self
1466    /// ## `start`
1467    /// a position in a [`TextBuffer`][crate::TextBuffer]
1468    /// ## `end`
1469    /// another position in the same buffer as @start
1470    #[doc(alias = "gtk_text_buffer_insert_range")]
1471    fn insert_range(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter) {
1472        unsafe {
1473            ffi::gtk_text_buffer_insert_range(
1474                self.as_ref().to_glib_none().0,
1475                iter.to_glib_none_mut().0,
1476                start.to_glib_none().0,
1477                end.to_glib_none().0,
1478            );
1479        }
1480    }
1481
1482    /// t editable. The @default_editable
1483    /// parameter indicates whether the text is editable at @iter if
1484    /// no tags enclosing @iter affect editability. Typically the result
1485    /// of [`TextViewExt::is_editable()`][crate::prelude::TextViewExt::is_editable()] is appropriate here.
1486    /// ## `iter`
1487    /// a position in @self
1488    /// ## `start`
1489    /// a position in a [`TextBuffer`][crate::TextBuffer]
1490    /// ## `end`
1491    /// another position in the same buffer as @start
1492    /// ## `default_editable`
1493    /// default editability of the buffer
1494    ///
1495    /// # Returns
1496    ///
1497    /// whether an insertion was possible at @iter
1498    #[doc(alias = "gtk_text_buffer_insert_range_interactive")]
1499    fn insert_range_interactive(
1500        &self,
1501        iter: &mut TextIter,
1502        start: &TextIter,
1503        end: &TextIter,
1504        default_editable: bool,
1505    ) -> bool {
1506        unsafe {
1507            from_glib(ffi::gtk_text_buffer_insert_range_interactive(
1508                self.as_ref().to_glib_none().0,
1509                iter.to_glib_none_mut().0,
1510                start.to_glib_none().0,
1511                end.to_glib_none().0,
1512                default_editable.into_glib(),
1513            ))
1514        }
1515    }
1516
1517    /// Moves @mark to the new location @where_.
1518    ///
1519    /// Emits the [`mark-set`][struct@crate::TextBuffer#mark-set] signal
1520    /// as notification of the move.
1521    /// ## `mark`
1522    /// a [`TextMark`][crate::TextMark]
1523    /// ## `where_`
1524    /// new location for @mark in @self
1525    #[doc(alias = "gtk_text_buffer_move_mark")]
1526    fn move_mark(&self, mark: &impl IsA<TextMark>, where_: &TextIter) {
1527        unsafe {
1528            ffi::gtk_text_buffer_move_mark(
1529                self.as_ref().to_glib_none().0,
1530                mark.as_ref().to_glib_none().0,
1531                where_.to_glib_none().0,
1532            );
1533        }
1534    }
1535
1536    /// Moves the mark named @name (which must exist) to location @where_.
1537    ///
1538    /// See [`move_mark()`][Self::move_mark()] for details.
1539    /// ## `name`
1540    /// name of a mark
1541    /// ## `where_`
1542    /// new location for mark
1543    #[doc(alias = "gtk_text_buffer_move_mark_by_name")]
1544    fn move_mark_by_name(&self, name: &str, where_: &TextIter) {
1545        unsafe {
1546            ffi::gtk_text_buffer_move_mark_by_name(
1547                self.as_ref().to_glib_none().0,
1548                name.to_glib_none().0,
1549                where_.to_glib_none().0,
1550            );
1551        }
1552    }
1553
1554    /// ll ask for the paste data
1555    /// and return, and at some point later after the main loop runs, the paste
1556    /// data will be inserted.
1557    /// ## `clipboard`
1558    /// the [`gdk::Clipboard`][crate::gdk::Clipboard] to paste from
1559    /// ## `override_location`
1560    /// location to insert pasted text
1561    /// ## `default_editable`
1562    /// whether the buffer is editable by default
1563    #[doc(alias = "gtk_text_buffer_paste_clipboard")]
1564    fn paste_clipboard(
1565        &self,
1566        clipboard: &gdk::Clipboard,
1567        override_location: Option<&TextIter>,
1568        default_editable: bool,
1569    ) {
1570        unsafe {
1571            ffi::gtk_text_buffer_paste_clipboard(
1572                self.as_ref().to_glib_none().0,
1573                clipboard.to_glib_none().0,
1574                mut_override(override_location.to_glib_none().0),
1575                default_editable.into_glib(),
1576            );
1577        }
1578    }
1579
1580    ///  marks
1581    /// simultaneously.
1582    ///
1583    /// If you move them to the same place in two steps with
1584    /// [`move_mark()`][Self::move_mark()], you will temporarily select a
1585    /// region in between their old and new locations, which can be pretty
1586    /// inefficient since the temporarily-selected region will force stuff
1587    /// to be recalculated. This function moves them as a unit, which can
1588    /// be optimized.
1589    /// ## `where_`
1590    /// where to put the cursor
1591    #[doc(alias = "gtk_text_buffer_place_cursor")]
1592    fn place_cursor(&self, where_: &TextIter) {
1593        unsafe {
1594            ffi::gtk_text_buffer_place_cursor(
1595                self.as_ref().to_glib_none().0,
1596                where_.to_glib_none().0,
1597            );
1598        }
1599    }
1600
1601    /// Redoes the next redoable action on the buffer, if there is one.
1602    #[doc(alias = "gtk_text_buffer_redo")]
1603    fn redo(&self) {
1604        unsafe {
1605            ffi::gtk_text_buffer_redo(self.as_ref().to_glib_none().0);
1606        }
1607    }
1608
1609    /// re currently writing. That is, using this
1610    /// function is probably a bad idea if you have two or more unrelated
1611    /// code sections that add tags.
1612    /// ## `start`
1613    /// one bound of range to be untagged
1614    /// ## `end`
1615    /// other bound of range to be untagged
1616    #[doc(alias = "gtk_text_buffer_remove_all_tags")]
1617    fn remove_all_tags(&self, start: &TextIter, end: &TextIter) {
1618        unsafe {
1619            ffi::gtk_text_buffer_remove_all_tags(
1620                self.as_ref().to_glib_none().0,
1621                start.to_glib_none().0,
1622                end.to_glib_none().0,
1623            );
1624        }
1625    }
1626
1627    /// Removes the `GtkTextBufferCommitNotify` handler previously registered
1628    /// with [`TextBufferExtManual::add_commit_notify()`][crate::prelude::TextBufferExtManual::add_commit_notify()].
1629    ///
1630    /// This may result in the `user_data_destroy` being called that was passed when registering
1631    /// the commit notify functions.
1632    /// ## `commit_notify_handler`
1633    /// the notify handler identifier returned from
1634    ///   [`TextBufferExtManual::add_commit_notify()`][crate::prelude::TextBufferExtManual::add_commit_notify()].
1635    #[cfg(feature = "v4_16")]
1636    #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
1637    #[doc(alias = "gtk_text_buffer_remove_commit_notify")]
1638    fn remove_commit_notify(&self, commit_notify_handler: u32) {
1639        unsafe {
1640            ffi::gtk_text_buffer_remove_commit_notify(
1641                self.as_ref().to_glib_none().0,
1642                commit_notify_handler,
1643            );
1644        }
1645    }
1646
1647    /// Removes a [`gdk::Clipboard`][crate::gdk::Clipboard] added with
1648    /// [`add_selection_clipboard()`][Self::add_selection_clipboard()]
1649    /// ## `clipboard`
1650    /// a [`gdk::Clipboard`][crate::gdk::Clipboard] added to @self by
1651    ///   [`add_selection_clipboard()`][Self::add_selection_clipboard()]
1652    #[doc(alias = "gtk_text_buffer_remove_selection_clipboard")]
1653    fn remove_selection_clipboard(&self, clipboard: &gdk::Clipboard) {
1654        unsafe {
1655            ffi::gtk_text_buffer_remove_selection_clipboard(
1656                self.as_ref().to_glib_none().0,
1657                clipboard.to_glib_none().0,
1658            );
1659        }
1660    }
1661
1662    /// t have
1663    /// to be in order.
1664    /// ## `tag`
1665    /// a [`TextTag`][crate::TextTag]
1666    /// ## `start`
1667    /// one bound of range to be untagged
1668    /// ## `end`
1669    /// other bound of range to be untagged
1670    #[doc(alias = "gtk_text_buffer_remove_tag")]
1671    fn remove_tag(&self, tag: &impl IsA<TextTag>, start: &TextIter, end: &TextIter) {
1672        unsafe {
1673            ffi::gtk_text_buffer_remove_tag(
1674                self.as_ref().to_glib_none().0,
1675                tag.as_ref().to_glib_none().0,
1676                start.to_glib_none().0,
1677                end.to_glib_none().0,
1678            );
1679        }
1680    }
1681
1682    /// s
1683    /// tag table to get a [`TextTag`][crate::TextTag], then calls
1684    /// [`remove_tag()`][Self::remove_tag()].
1685    /// ## `name`
1686    /// name of a [`TextTag`][crate::TextTag]
1687    /// ## `start`
1688    /// one bound of range to be untagged
1689    /// ## `end`
1690    /// other bound of range to be untagged
1691    #[doc(alias = "gtk_text_buffer_remove_tag_by_name")]
1692    fn remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter) {
1693        unsafe {
1694            ffi::gtk_text_buffer_remove_tag_by_name(
1695                self.as_ref().to_glib_none().0,
1696                name.to_glib_none().0,
1697                start.to_glib_none().0,
1698                end.to_glib_none().0,
1699            );
1700        }
1701    }
1702
1703    ///  marks
1704    /// simultaneously.
1705    ///
1706    /// If you move them in two steps with
1707    /// [`move_mark()`][Self::move_mark()], you will temporarily select a
1708    /// region in between their old and new locations, which can be pretty
1709    /// inefficient since the temporarily-selected region will force stuff
1710    /// to be recalculated. This function moves them as a unit, which can
1711    /// be optimized.
1712    /// ## `ins`
1713    ///  mark
1714    /// ## `bound`
1715    ///  mark
1716    #[doc(alias = "gtk_text_buffer_select_range")]
1717    fn select_range(&self, ins: &TextIter, bound: &TextIter) {
1718        unsafe {
1719            ffi::gtk_text_buffer_select_range(
1720                self.as_ref().to_glib_none().0,
1721                ins.to_glib_none().0,
1722                bound.to_glib_none().0,
1723            );
1724        }
1725    }
1726
1727    /// Sets whether or not to enable undoable actions in the text buffer.
1728    ///
1729    /// Undoable actions in this context are changes to the text content of
1730    /// the buffer. Changes to tags and marks are not tracked.
1731    ///
1732    /// If enabled, the user will be able to undo the last number of actions
1733    /// up to [`max_undo_levels()`][Self::max_undo_levels()].
1734    ///
1735    /// See [`begin_irreversible_action()`][Self::begin_irreversible_action()] and
1736    /// [`end_irreversible_action()`][Self::end_irreversible_action()] to create
1737    /// changes to the buffer that cannot be undone.
1738    /// ## `enable_undo`
1739    /// [`true`] to enable undo
1740    #[doc(alias = "gtk_text_buffer_set_enable_undo")]
1741    #[doc(alias = "enable-undo")]
1742    fn set_enable_undo(&self, enable_undo: bool) {
1743        unsafe {
1744            ffi::gtk_text_buffer_set_enable_undo(
1745                self.as_ref().to_glib_none().0,
1746                enable_undo.into_glib(),
1747            );
1748        }
1749    }
1750
1751    /// Sets the maximum number of undo levels to perform.
1752    ///
1753    /// If 0, unlimited undo actions may be performed. Note that this may
1754    /// have a memory usage impact as it requires storing an additional
1755    /// copy of the inserted or removed text within the text buffer.
1756    /// ## `max_undo_levels`
1757    /// the maximum number of undo actions to perform
1758    #[doc(alias = "gtk_text_buffer_set_max_undo_levels")]
1759    fn set_max_undo_levels(&self, max_undo_levels: u32) {
1760        unsafe {
1761            ffi::gtk_text_buffer_set_max_undo_levels(
1762                self.as_ref().to_glib_none().0,
1763                max_undo_levels,
1764            );
1765        }
1766    }
1767
1768    /// Used to keep track of whether the buffer has been
1769    /// modified since the last time it was saved.
1770    ///
1771    /// Whenever the buffer is saved to disk, call
1772    /// `gtk_text_buffer_set_modified (@self, FALSE)`.
1773    /// When the buffer is modified, it will automatically
1774    /// toggle on the modified bit again. When the modified
1775    /// bit flips, the buffer emits the
1776    /// [`modified-changed`][struct@crate::TextBuffer#modified-changed] signal.
1777    /// ## `setting`
1778    /// modification flag setting
1779    #[doc(alias = "gtk_text_buffer_set_modified")]
1780    fn set_modified(&self, setting: bool) {
1781        unsafe {
1782            ffi::gtk_text_buffer_set_modified(self.as_ref().to_glib_none().0, setting.into_glib());
1783        }
1784    }
1785
1786    /// Deletes current contents of @self, and inserts @text instead. This is
1787    /// automatically marked as an irreversible action in the undo stack. If you
1788    /// wish to mark this action as part of a larger undo operation, call
1789    /// [`delete()`][Self::delete()] and [`insert()`][Self::insert()] directly instead.
1790    ///
1791    /// If @len is -1, @text must be nul-terminated.
1792    /// @text must be valid UTF-8.
1793    /// ## `text`
1794    /// UTF-8 text to insert
1795    /// ## `len`
1796    /// length of @text in bytes
1797    #[doc(alias = "gtk_text_buffer_set_text")]
1798    #[doc(alias = "text")]
1799    fn set_text(&self, text: &str) {
1800        let len = text.len() as _;
1801        unsafe {
1802            ffi::gtk_text_buffer_set_text(
1803                self.as_ref().to_glib_none().0,
1804                text.to_glib_none().0,
1805                len,
1806            );
1807        }
1808    }
1809
1810    /// Undoes the last undoable action on the buffer, if there is one.
1811    #[doc(alias = "gtk_text_buffer_undo")]
1812    fn undo(&self) {
1813        unsafe {
1814            ffi::gtk_text_buffer_undo(self.as_ref().to_glib_none().0);
1815        }
1816    }
1817
1818    /// The position of the insert mark.
1819    ///
1820    /// This is an offset from the beginning of the buffer.
1821    /// It is useful for getting notified when the cursor moves.
1822    #[doc(alias = "cursor-position")]
1823    fn cursor_position(&self) -> i32 {
1824        ObjectExt::property(self.as_ref(), "cursor-position")
1825    }
1826
1827    /// Emitted to apply a tag to a range of text in a [`TextBuffer`][crate::TextBuffer].
1828    ///
1829    /// Applying actually occurs in the default handler.
1830    ///
1831    /// Note that if your handler runs before the default handler
1832    /// it must not invalidate the @start and @end iters (or has to
1833    /// revalidate them).
1834    ///
1835    /// See also:
1836    /// [`apply_tag()`][Self::apply_tag()],
1837    /// [`TextBufferExtManual::insert_with_tags()`][crate::prelude::TextBufferExtManual::insert_with_tags()],
1838    /// [`insert_range()`][Self::insert_range()].
1839    /// ## `tag`
1840    /// the applied tag
1841    /// ## `start`
1842    /// the start of the range the tag is applied to
1843    /// ## `end`
1844    /// the end of the range the tag is applied to
1845    #[doc(alias = "apply-tag")]
1846    fn connect_apply_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
1847        &self,
1848        f: F,
1849    ) -> SignalHandlerId {
1850        unsafe extern "C" fn apply_tag_trampoline<
1851            P: IsA<TextBuffer>,
1852            F: Fn(&P, &TextTag, &TextIter, &TextIter) + 'static,
1853        >(
1854            this: *mut ffi::GtkTextBuffer,
1855            tag: *mut ffi::GtkTextTag,
1856            start: *mut ffi::GtkTextIter,
1857            end: *mut ffi::GtkTextIter,
1858            f: glib::ffi::gpointer,
1859        ) {
1860            unsafe {
1861                let f: &F = &*(f as *const F);
1862                f(
1863                    TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
1864                    &from_glib_borrow(tag),
1865                    &from_glib_borrow(start),
1866                    &from_glib_borrow(end),
1867                )
1868            }
1869        }
1870        unsafe {
1871            let f: Box_<F> = Box_::new(f);
1872            connect_raw(
1873                self.as_ptr() as *mut _,
1874                c"apply-tag".as_ptr(),
1875                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1876                    apply_tag_trampoline::<Self, F> as *const (),
1877                )),
1878                Box_::into_raw(f),
1879            )
1880        }
1881    }
1882
1883    /// Emitted at the beginning of a single user-visible
1884    /// operation on a [`TextBuffer`][crate::TextBuffer].
1885    ///
1886    /// See also:
1887    /// [`begin_user_action()`][Self::begin_user_action()],
1888    /// [`insert_interactive()`][Self::insert_interactive()],
1889    /// [`insert_range_interactive()`][Self::insert_range_interactive()],
1890    /// [`delete_interactive()`][Self::delete_interactive()],
1891    /// [`backspace()`][Self::backspace()],
1892    /// [`delete_selection()`][Self::delete_selection()].
1893    #[doc(alias = "begin-user-action")]
1894    fn connect_begin_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1895        unsafe extern "C" fn begin_user_action_trampoline<
1896            P: IsA<TextBuffer>,
1897            F: Fn(&P) + 'static,
1898        >(
1899            this: *mut ffi::GtkTextBuffer,
1900            f: glib::ffi::gpointer,
1901        ) {
1902            unsafe {
1903                let f: &F = &*(f as *const F);
1904                f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
1905            }
1906        }
1907        unsafe {
1908            let f: Box_<F> = Box_::new(f);
1909            connect_raw(
1910                self.as_ptr() as *mut _,
1911                c"begin-user-action".as_ptr(),
1912                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1913                    begin_user_action_trampoline::<Self, F> as *const (),
1914                )),
1915                Box_::into_raw(f),
1916            )
1917        }
1918    }
1919
1920    /// Emitted when the content of a [`TextBuffer`][crate::TextBuffer] has changed.
1921    #[doc(alias = "changed")]
1922    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1923        unsafe extern "C" fn changed_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
1924            this: *mut ffi::GtkTextBuffer,
1925            f: glib::ffi::gpointer,
1926        ) {
1927            unsafe {
1928                let f: &F = &*(f as *const F);
1929                f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
1930            }
1931        }
1932        unsafe {
1933            let f: Box_<F> = Box_::new(f);
1934            connect_raw(
1935                self.as_ptr() as *mut _,
1936                c"changed".as_ptr(),
1937                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1938                    changed_trampoline::<Self, F> as *const (),
1939                )),
1940                Box_::into_raw(f),
1941            )
1942        }
1943    }
1944
1945    /// Emitted to delete a range from a [`TextBuffer`][crate::TextBuffer].
1946    ///
1947    /// Note that if your handler runs before the default handler
1948    /// it must not invalidate the @start and @end iters (or has
1949    /// to revalidate them). The default signal handler revalidates
1950    /// the @start and @end iters to both point to the location
1951    /// where text was deleted. Handlers which run after the default
1952    /// handler (see g_signal_connect_after()) do not have access to
1953    /// the deleted text.
1954    ///
1955    /// See also: [`delete()`][Self::delete()].
1956    /// ## `start`
1957    /// the start of the range to be deleted
1958    /// ## `end`
1959    /// the end of the range to be deleted
1960    #[doc(alias = "delete-range")]
1961    fn connect_delete_range<F: Fn(&Self, &TextIter, &TextIter) + 'static>(
1962        &self,
1963        f: F,
1964    ) -> SignalHandlerId {
1965        unsafe extern "C" fn delete_range_trampoline<
1966            P: IsA<TextBuffer>,
1967            F: Fn(&P, &TextIter, &TextIter) + 'static,
1968        >(
1969            this: *mut ffi::GtkTextBuffer,
1970            start: *mut ffi::GtkTextIter,
1971            end: *mut ffi::GtkTextIter,
1972            f: glib::ffi::gpointer,
1973        ) {
1974            unsafe {
1975                let f: &F = &*(f as *const F);
1976                f(
1977                    TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
1978                    &from_glib_borrow(start),
1979                    &from_glib_borrow(end),
1980                )
1981            }
1982        }
1983        unsafe {
1984            let f: Box_<F> = Box_::new(f);
1985            connect_raw(
1986                self.as_ptr() as *mut _,
1987                c"delete-range".as_ptr(),
1988                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1989                    delete_range_trampoline::<Self, F> as *const (),
1990                )),
1991                Box_::into_raw(f),
1992            )
1993        }
1994    }
1995
1996    /// Emitted at the end of a single user-visible
1997    /// operation on the [`TextBuffer`][crate::TextBuffer].
1998    ///
1999    /// See also:
2000    /// [`end_user_action()`][Self::end_user_action()],
2001    /// [`insert_interactive()`][Self::insert_interactive()],
2002    /// [`insert_range_interactive()`][Self::insert_range_interactive()],
2003    /// [`delete_interactive()`][Self::delete_interactive()],
2004    /// [`backspace()`][Self::backspace()],
2005    /// [`delete_selection()`][Self::delete_selection()],
2006    /// [`backspace()`][Self::backspace()].
2007    #[doc(alias = "end-user-action")]
2008    fn connect_end_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2009        unsafe extern "C" fn end_user_action_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2010            this: *mut ffi::GtkTextBuffer,
2011            f: glib::ffi::gpointer,
2012        ) {
2013            unsafe {
2014                let f: &F = &*(f as *const F);
2015                f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2016            }
2017        }
2018        unsafe {
2019            let f: Box_<F> = Box_::new(f);
2020            connect_raw(
2021                self.as_ptr() as *mut _,
2022                c"end-user-action".as_ptr(),
2023                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2024                    end_user_action_trampoline::<Self, F> as *const (),
2025                )),
2026                Box_::into_raw(f),
2027            )
2028        }
2029    }
2030
2031    /// Emitted to insert a [`TextChildAnchor`][crate::TextChildAnchor] in a [`TextBuffer`][crate::TextBuffer].
2032    ///
2033    /// Insertion actually occurs in the default handler.
2034    ///
2035    /// Note that if your handler runs before the default handler
2036    /// it must not invalidate the @location iter (or has to
2037    /// revalidate it). The default signal handler revalidates
2038    /// it to be placed after the inserted @anchor.
2039    ///
2040    /// See also: [`insert_child_anchor()`][Self::insert_child_anchor()].
2041    /// ## `location`
2042    /// position to insert @anchor in @textbuffer
2043    /// ## `anchor`
2044    /// the [`TextChildAnchor`][crate::TextChildAnchor] to be inserted
2045    #[doc(alias = "insert-child-anchor")]
2046    fn connect_insert_child_anchor<F: Fn(&Self, &TextIter, &TextChildAnchor) + 'static>(
2047        &self,
2048        f: F,
2049    ) -> SignalHandlerId {
2050        unsafe extern "C" fn insert_child_anchor_trampoline<
2051            P: IsA<TextBuffer>,
2052            F: Fn(&P, &TextIter, &TextChildAnchor) + 'static,
2053        >(
2054            this: *mut ffi::GtkTextBuffer,
2055            location: *mut ffi::GtkTextIter,
2056            anchor: *mut ffi::GtkTextChildAnchor,
2057            f: glib::ffi::gpointer,
2058        ) {
2059            unsafe {
2060                let f: &F = &*(f as *const F);
2061                f(
2062                    TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2063                    &from_glib_borrow(location),
2064                    &from_glib_borrow(anchor),
2065                )
2066            }
2067        }
2068        unsafe {
2069            let f: Box_<F> = Box_::new(f);
2070            connect_raw(
2071                self.as_ptr() as *mut _,
2072                c"insert-child-anchor".as_ptr(),
2073                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2074                    insert_child_anchor_trampoline::<Self, F> as *const (),
2075                )),
2076                Box_::into_raw(f),
2077            )
2078        }
2079    }
2080
2081    /// Emitted to insert a [`gdk::Paintable`][crate::gdk::Paintable] in a [`TextBuffer`][crate::TextBuffer].
2082    ///
2083    /// Insertion actually occurs in the default handler.
2084    ///
2085    /// Note that if your handler runs before the default handler
2086    /// it must not invalidate the @location iter (or has to
2087    /// revalidate it). The default signal handler revalidates
2088    /// it to be placed after the inserted @paintable.
2089    ///
2090    /// See also: [`insert_paintable()`][Self::insert_paintable()].
2091    /// ## `location`
2092    /// position to insert @paintable in @textbuffer
2093    /// ## `paintable`
2094    /// the [`gdk::Paintable`][crate::gdk::Paintable] to be inserted
2095    #[doc(alias = "insert-paintable")]
2096    fn connect_insert_paintable<F: Fn(&Self, &TextIter, &gdk::Paintable) + 'static>(
2097        &self,
2098        f: F,
2099    ) -> SignalHandlerId {
2100        unsafe extern "C" fn insert_paintable_trampoline<
2101            P: IsA<TextBuffer>,
2102            F: Fn(&P, &TextIter, &gdk::Paintable) + 'static,
2103        >(
2104            this: *mut ffi::GtkTextBuffer,
2105            location: *mut ffi::GtkTextIter,
2106            paintable: *mut gdk::ffi::GdkPaintable,
2107            f: glib::ffi::gpointer,
2108        ) {
2109            unsafe {
2110                let f: &F = &*(f as *const F);
2111                f(
2112                    TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2113                    &from_glib_borrow(location),
2114                    &from_glib_borrow(paintable),
2115                )
2116            }
2117        }
2118        unsafe {
2119            let f: Box_<F> = Box_::new(f);
2120            connect_raw(
2121                self.as_ptr() as *mut _,
2122                c"insert-paintable".as_ptr(),
2123                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2124                    insert_paintable_trampoline::<Self, F> as *const (),
2125                )),
2126                Box_::into_raw(f),
2127            )
2128        }
2129    }
2130
2131    /// Emitted as notification after a [`TextMark`][crate::TextMark] is deleted.
2132    ///
2133    /// See also: [`delete_mark()`][Self::delete_mark()].
2134    /// ## `mark`
2135    /// The mark that was deleted
2136    #[doc(alias = "mark-deleted")]
2137    fn connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>(&self, f: F) -> SignalHandlerId {
2138        unsafe extern "C" fn mark_deleted_trampoline<
2139            P: IsA<TextBuffer>,
2140            F: Fn(&P, &TextMark) + 'static,
2141        >(
2142            this: *mut ffi::GtkTextBuffer,
2143            mark: *mut ffi::GtkTextMark,
2144            f: glib::ffi::gpointer,
2145        ) {
2146            unsafe {
2147                let f: &F = &*(f as *const F);
2148                f(
2149                    TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2150                    &from_glib_borrow(mark),
2151                )
2152            }
2153        }
2154        unsafe {
2155            let f: Box_<F> = Box_::new(f);
2156            connect_raw(
2157                self.as_ptr() as *mut _,
2158                c"mark-deleted".as_ptr(),
2159                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2160                    mark_deleted_trampoline::<Self, F> as *const (),
2161                )),
2162                Box_::into_raw(f),
2163            )
2164        }
2165    }
2166
2167    /// Emitted as notification after a [`TextMark`][crate::TextMark] is set.
2168    ///
2169    /// See also:
2170    /// [`create_mark()`][Self::create_mark()],
2171    /// [`move_mark()`][Self::move_mark()].
2172    /// ## `location`
2173    /// The location of @mark in @textbuffer
2174    /// ## `mark`
2175    /// The mark that is set
2176    #[doc(alias = "mark-set")]
2177    fn connect_mark_set<F: Fn(&Self, &TextIter, &TextMark) + 'static>(
2178        &self,
2179        f: F,
2180    ) -> SignalHandlerId {
2181        unsafe extern "C" fn mark_set_trampoline<
2182            P: IsA<TextBuffer>,
2183            F: Fn(&P, &TextIter, &TextMark) + 'static,
2184        >(
2185            this: *mut ffi::GtkTextBuffer,
2186            location: *mut ffi::GtkTextIter,
2187            mark: *mut ffi::GtkTextMark,
2188            f: glib::ffi::gpointer,
2189        ) {
2190            unsafe {
2191                let f: &F = &*(f as *const F);
2192                f(
2193                    TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2194                    &from_glib_borrow(location),
2195                    &from_glib_borrow(mark),
2196                )
2197            }
2198        }
2199        unsafe {
2200            let f: Box_<F> = Box_::new(f);
2201            connect_raw(
2202                self.as_ptr() as *mut _,
2203                c"mark-set".as_ptr(),
2204                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2205                    mark_set_trampoline::<Self, F> as *const (),
2206                )),
2207                Box_::into_raw(f),
2208            )
2209        }
2210    }
2211
2212    /// Emitted when the modified bit of a [`TextBuffer`][crate::TextBuffer] flips.
2213    ///
2214    /// See also: [`set_modified()`][Self::set_modified()].
2215    #[doc(alias = "modified-changed")]
2216    fn connect_modified_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2217        unsafe extern "C" fn modified_changed_trampoline<
2218            P: IsA<TextBuffer>,
2219            F: Fn(&P) + 'static,
2220        >(
2221            this: *mut ffi::GtkTextBuffer,
2222            f: glib::ffi::gpointer,
2223        ) {
2224            unsafe {
2225                let f: &F = &*(f as *const F);
2226                f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2227            }
2228        }
2229        unsafe {
2230            let f: Box_<F> = Box_::new(f);
2231            connect_raw(
2232                self.as_ptr() as *mut _,
2233                c"modified-changed".as_ptr(),
2234                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2235                    modified_changed_trampoline::<Self, F> as *const (),
2236                )),
2237                Box_::into_raw(f),
2238            )
2239        }
2240    }
2241
2242    /// Emitted after paste operation has been completed.
2243    ///
2244    /// This is useful to properly scroll the view to the end
2245    /// of the pasted text. See [`paste_clipboard()`][Self::paste_clipboard()]
2246    /// for more details.
2247    /// ## `clipboard`
2248    /// the [`gdk::Clipboard`][crate::gdk::Clipboard] pasted from
2249    #[doc(alias = "paste-done")]
2250    fn connect_paste_done<F: Fn(&Self, &gdk::Clipboard) + 'static>(&self, f: F) -> SignalHandlerId {
2251        unsafe extern "C" fn paste_done_trampoline<
2252            P: IsA<TextBuffer>,
2253            F: Fn(&P, &gdk::Clipboard) + 'static,
2254        >(
2255            this: *mut ffi::GtkTextBuffer,
2256            clipboard: *mut gdk::ffi::GdkClipboard,
2257            f: glib::ffi::gpointer,
2258        ) {
2259            unsafe {
2260                let f: &F = &*(f as *const F);
2261                f(
2262                    TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2263                    &from_glib_borrow(clipboard),
2264                )
2265            }
2266        }
2267        unsafe {
2268            let f: Box_<F> = Box_::new(f);
2269            connect_raw(
2270                self.as_ptr() as *mut _,
2271                c"paste-done".as_ptr(),
2272                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2273                    paste_done_trampoline::<Self, F> as *const (),
2274                )),
2275                Box_::into_raw(f),
2276            )
2277        }
2278    }
2279
2280    /// Emitted when a request has been made to redo the
2281    /// previously undone operation.
2282    #[doc(alias = "redo")]
2283    fn connect_redo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2284        unsafe extern "C" fn redo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2285            this: *mut ffi::GtkTextBuffer,
2286            f: glib::ffi::gpointer,
2287        ) {
2288            unsafe {
2289                let f: &F = &*(f as *const F);
2290                f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2291            }
2292        }
2293        unsafe {
2294            let f: Box_<F> = Box_::new(f);
2295            connect_raw(
2296                self.as_ptr() as *mut _,
2297                c"redo".as_ptr(),
2298                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2299                    redo_trampoline::<Self, F> as *const (),
2300                )),
2301                Box_::into_raw(f),
2302            )
2303        }
2304    }
2305
2306    /// Emitted to remove all occurrences of @tag from a range
2307    /// of text in a [`TextBuffer`][crate::TextBuffer].
2308    ///
2309    /// Removal actually occurs in the default handler.
2310    ///
2311    /// Note that if your handler runs before the default handler
2312    /// it must not invalidate the @start and @end iters (or has
2313    /// to revalidate them).
2314    ///
2315    /// See also: [`remove_tag()`][Self::remove_tag()].
2316    /// ## `tag`
2317    /// the tag to be removed
2318    /// ## `start`
2319    /// the start of the range the tag is removed from
2320    /// ## `end`
2321    /// the end of the range the tag is removed from
2322    #[doc(alias = "remove-tag")]
2323    fn connect_remove_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
2324        &self,
2325        f: F,
2326    ) -> SignalHandlerId {
2327        unsafe extern "C" fn remove_tag_trampoline<
2328            P: IsA<TextBuffer>,
2329            F: Fn(&P, &TextTag, &TextIter, &TextIter) + 'static,
2330        >(
2331            this: *mut ffi::GtkTextBuffer,
2332            tag: *mut ffi::GtkTextTag,
2333            start: *mut ffi::GtkTextIter,
2334            end: *mut ffi::GtkTextIter,
2335            f: glib::ffi::gpointer,
2336        ) {
2337            unsafe {
2338                let f: &F = &*(f as *const F);
2339                f(
2340                    TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2341                    &from_glib_borrow(tag),
2342                    &from_glib_borrow(start),
2343                    &from_glib_borrow(end),
2344                )
2345            }
2346        }
2347        unsafe {
2348            let f: Box_<F> = Box_::new(f);
2349            connect_raw(
2350                self.as_ptr() as *mut _,
2351                c"remove-tag".as_ptr(),
2352                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2353                    remove_tag_trampoline::<Self, F> as *const (),
2354                )),
2355                Box_::into_raw(f),
2356            )
2357        }
2358    }
2359
2360    /// Emitted when a request has been made to undo the
2361    /// previous operation or set of operations that have
2362    /// been grouped together.
2363    #[doc(alias = "undo")]
2364    fn connect_undo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2365        unsafe extern "C" fn undo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2366            this: *mut ffi::GtkTextBuffer,
2367            f: glib::ffi::gpointer,
2368        ) {
2369            unsafe {
2370                let f: &F = &*(f as *const F);
2371                f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2372            }
2373        }
2374        unsafe {
2375            let f: Box_<F> = Box_::new(f);
2376            connect_raw(
2377                self.as_ptr() as *mut _,
2378                c"undo".as_ptr(),
2379                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2380                    undo_trampoline::<Self, F> as *const (),
2381                )),
2382                Box_::into_raw(f),
2383            )
2384        }
2385    }
2386
2387    #[doc(alias = "can-redo")]
2388    fn connect_can_redo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2389        unsafe extern "C" fn notify_can_redo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2390            this: *mut ffi::GtkTextBuffer,
2391            _param_spec: glib::ffi::gpointer,
2392            f: glib::ffi::gpointer,
2393        ) {
2394            unsafe {
2395                let f: &F = &*(f as *const F);
2396                f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2397            }
2398        }
2399        unsafe {
2400            let f: Box_<F> = Box_::new(f);
2401            connect_raw(
2402                self.as_ptr() as *mut _,
2403                c"notify::can-redo".as_ptr(),
2404                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2405                    notify_can_redo_trampoline::<Self, F> as *const (),
2406                )),
2407                Box_::into_raw(f),
2408            )
2409        }
2410    }
2411
2412    #[doc(alias = "can-undo")]
2413    fn connect_can_undo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2414        unsafe extern "C" fn notify_can_undo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2415            this: *mut ffi::GtkTextBuffer,
2416            _param_spec: glib::ffi::gpointer,
2417            f: glib::ffi::gpointer,
2418        ) {
2419            unsafe {
2420                let f: &F = &*(f as *const F);
2421                f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2422            }
2423        }
2424        unsafe {
2425            let f: Box_<F> = Box_::new(f);
2426            connect_raw(
2427                self.as_ptr() as *mut _,
2428                c"notify::can-undo".as_ptr(),
2429                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2430                    notify_can_undo_trampoline::<Self, F> as *const (),
2431                )),
2432                Box_::into_raw(f),
2433            )
2434        }
2435    }
2436
2437    #[doc(alias = "cursor-position")]
2438    fn connect_cursor_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2439        unsafe extern "C" fn notify_cursor_position_trampoline<
2440            P: IsA<TextBuffer>,
2441            F: Fn(&P) + 'static,
2442        >(
2443            this: *mut ffi::GtkTextBuffer,
2444            _param_spec: glib::ffi::gpointer,
2445            f: glib::ffi::gpointer,
2446        ) {
2447            unsafe {
2448                let f: &F = &*(f as *const F);
2449                f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2450            }
2451        }
2452        unsafe {
2453            let f: Box_<F> = Box_::new(f);
2454            connect_raw(
2455                self.as_ptr() as *mut _,
2456                c"notify::cursor-position".as_ptr(),
2457                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2458                    notify_cursor_position_trampoline::<Self, F> as *const (),
2459                )),
2460                Box_::into_raw(f),
2461            )
2462        }
2463    }
2464
2465    #[doc(alias = "enable-undo")]
2466    fn connect_enable_undo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2467        unsafe extern "C" fn notify_enable_undo_trampoline<
2468            P: IsA<TextBuffer>,
2469            F: Fn(&P) + 'static,
2470        >(
2471            this: *mut ffi::GtkTextBuffer,
2472            _param_spec: glib::ffi::gpointer,
2473            f: glib::ffi::gpointer,
2474        ) {
2475            unsafe {
2476                let f: &F = &*(f as *const F);
2477                f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2478            }
2479        }
2480        unsafe {
2481            let f: Box_<F> = Box_::new(f);
2482            connect_raw(
2483                self.as_ptr() as *mut _,
2484                c"notify::enable-undo".as_ptr(),
2485                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2486                    notify_enable_undo_trampoline::<Self, F> as *const (),
2487                )),
2488                Box_::into_raw(f),
2489            )
2490        }
2491    }
2492
2493    #[doc(alias = "has-selection")]
2494    fn connect_has_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2495        unsafe extern "C" fn notify_has_selection_trampoline<
2496            P: IsA<TextBuffer>,
2497            F: Fn(&P) + 'static,
2498        >(
2499            this: *mut ffi::GtkTextBuffer,
2500            _param_spec: glib::ffi::gpointer,
2501            f: glib::ffi::gpointer,
2502        ) {
2503            unsafe {
2504                let f: &F = &*(f as *const F);
2505                f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2506            }
2507        }
2508        unsafe {
2509            let f: Box_<F> = Box_::new(f);
2510            connect_raw(
2511                self.as_ptr() as *mut _,
2512                c"notify::has-selection".as_ptr(),
2513                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2514                    notify_has_selection_trampoline::<Self, F> as *const (),
2515                )),
2516                Box_::into_raw(f),
2517            )
2518        }
2519    }
2520
2521    #[doc(alias = "text")]
2522    fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2523        unsafe extern "C" fn notify_text_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2524            this: *mut ffi::GtkTextBuffer,
2525            _param_spec: glib::ffi::gpointer,
2526            f: glib::ffi::gpointer,
2527        ) {
2528            unsafe {
2529                let f: &F = &*(f as *const F);
2530                f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2531            }
2532        }
2533        unsafe {
2534            let f: Box_<F> = Box_::new(f);
2535            connect_raw(
2536                self.as_ptr() as *mut _,
2537                c"notify::text".as_ptr(),
2538                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2539                    notify_text_trampoline::<Self, F> as *const (),
2540                )),
2541                Box_::into_raw(f),
2542            )
2543        }
2544    }
2545}
2546
2547impl<O: IsA<TextBuffer>> TextBufferExt for O {}