Skip to main content

sourceview5/auto/
buffer.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{BracketMatchType, ChangeCaseType, Language, Mark, SortFlags, StyleScheme, ffi};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{SignalHandlerId, connect_raw},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "GtkSourceBuffer")]
17    pub struct Buffer(Object<ffi::GtkSourceBuffer, ffi::GtkSourceBufferClass>) @extends gtk::TextBuffer;
18
19    match fn {
20        type_ => || ffi::gtk_source_buffer_get_type(),
21    }
22}
23
24impl Buffer {
25    pub const NONE: Option<&'static Buffer> = None;
26
27    #[doc(alias = "gtk_source_buffer_new")]
28    pub fn new(table: Option<&gtk::TextTagTable>) -> Buffer {
29        assert_initialized_main_thread!();
30        unsafe { from_glib_full(ffi::gtk_source_buffer_new(table.to_glib_none().0)) }
31    }
32
33    #[doc(alias = "gtk_source_buffer_new_with_language")]
34    #[doc(alias = "new_with_language")]
35    pub fn with_language(language: &Language) -> Buffer {
36        skip_assert_initialized!();
37        unsafe {
38            from_glib_full(ffi::gtk_source_buffer_new_with_language(
39                language.to_glib_none().0,
40            ))
41        }
42    }
43
44    // rustdoc-stripper-ignore-next
45    /// Creates a new builder-pattern struct instance to construct [`Buffer`] objects.
46    ///
47    /// This method returns an instance of [`BufferBuilder`](crate::builders::BufferBuilder) which can be used to create [`Buffer`] objects.
48    pub fn builder() -> BufferBuilder {
49        BufferBuilder::new()
50    }
51}
52
53impl Default for Buffer {
54    fn default() -> Self {
55        glib::object::Object::new::<Self>()
56    }
57}
58
59// rustdoc-stripper-ignore-next
60/// A [builder-pattern] type to construct [`Buffer`] objects.
61///
62/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
63#[must_use = "The builder must be built to be used"]
64pub struct BufferBuilder {
65    builder: glib::object::ObjectBuilder<'static, Buffer>,
66}
67
68impl BufferBuilder {
69    fn new() -> Self {
70        Self {
71            builder: glib::object::Object::builder(),
72        }
73    }
74
75    pub fn highlight_matching_brackets(self, highlight_matching_brackets: bool) -> Self {
76        Self {
77            builder: self
78                .builder
79                .property("highlight-matching-brackets", highlight_matching_brackets),
80        }
81    }
82
83    pub fn highlight_syntax(self, highlight_syntax: bool) -> Self {
84        Self {
85            builder: self.builder.property("highlight-syntax", highlight_syntax),
86        }
87    }
88
89    pub fn implicit_trailing_newline(self, implicit_trailing_newline: bool) -> Self {
90        Self {
91            builder: self
92                .builder
93                .property("implicit-trailing-newline", implicit_trailing_newline),
94        }
95    }
96
97    pub fn language(self, language: &Language) -> Self {
98        Self {
99            builder: self.builder.property("language", language.clone()),
100        }
101    }
102
103    pub fn style_scheme(self, style_scheme: &StyleScheme) -> Self {
104        Self {
105            builder: self.builder.property("style-scheme", style_scheme.clone()),
106        }
107    }
108
109    pub fn enable_undo(self, enable_undo: bool) -> Self {
110        Self {
111            builder: self.builder.property("enable-undo", enable_undo),
112        }
113    }
114
115    pub fn tag_table(self, tag_table: &gtk::TextTagTable) -> Self {
116        Self {
117            builder: self.builder.property("tag-table", tag_table.clone()),
118        }
119    }
120
121    pub fn text(self, text: impl Into<glib::GString>) -> Self {
122        Self {
123            builder: self.builder.property("text", text.into()),
124        }
125    }
126
127    // rustdoc-stripper-ignore-next
128    /// Build the [`Buffer`].
129    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
130    pub fn build(self) -> Buffer {
131        assert_initialized_main_thread!();
132        self.builder.build()
133    }
134}
135
136pub trait BufferExt: IsA<Buffer> + 'static {
137    //#[doc(alias = "gtk_source_buffer_backward_iter_to_source_mark")]
138    //fn backward_iter_to_source_mark(&self, iter: /*Unimplemented*/gtk::TextIter, category: Option<&str>) -> bool {
139    //    unsafe { TODO: call ffi:gtk_source_buffer_backward_iter_to_source_mark() }
140    //}
141
142    #[doc(alias = "gtk_source_buffer_change_case")]
143    fn change_case(
144        &self,
145        case_type: ChangeCaseType,
146        start: &mut gtk::TextIter,
147        end: &mut gtk::TextIter,
148    ) {
149        unsafe {
150            ffi::gtk_source_buffer_change_case(
151                self.as_ref().to_glib_none().0,
152                case_type.into_glib(),
153                start.to_glib_none_mut().0,
154                end.to_glib_none_mut().0,
155            );
156        }
157    }
158
159    #[doc(alias = "gtk_source_buffer_create_source_mark")]
160    fn create_source_mark(
161        &self,
162        name: Option<&str>,
163        category: &str,
164        where_: &gtk::TextIter,
165    ) -> Mark {
166        unsafe {
167            from_glib_none(ffi::gtk_source_buffer_create_source_mark(
168                self.as_ref().to_glib_none().0,
169                name.to_glib_none().0,
170                category.to_glib_none().0,
171                where_.to_glib_none().0,
172            ))
173        }
174    }
175
176    //#[doc(alias = "gtk_source_buffer_create_source_tag")]
177    //fn create_source_tag(&self, tag_name: Option<&str>, first_property_name: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> gtk::TextTag {
178    //    unsafe { TODO: call ffi:gtk_source_buffer_create_source_tag() }
179    //}
180
181    #[doc(alias = "gtk_source_buffer_ensure_highlight")]
182    fn ensure_highlight(&self, start: &gtk::TextIter, end: &gtk::TextIter) {
183        unsafe {
184            ffi::gtk_source_buffer_ensure_highlight(
185                self.as_ref().to_glib_none().0,
186                start.to_glib_none().0,
187                end.to_glib_none().0,
188            );
189        }
190    }
191
192    //#[doc(alias = "gtk_source_buffer_forward_iter_to_source_mark")]
193    //fn forward_iter_to_source_mark(&self, iter: /*Unimplemented*/gtk::TextIter, category: Option<&str>) -> bool {
194    //    unsafe { TODO: call ffi:gtk_source_buffer_forward_iter_to_source_mark() }
195    //}
196
197    #[doc(alias = "gtk_source_buffer_get_context_classes_at_iter")]
198    #[doc(alias = "get_context_classes_at_iter")]
199    fn context_classes_at_iter(&self, iter: &gtk::TextIter) -> Vec<glib::GString> {
200        unsafe {
201            FromGlibPtrContainer::from_glib_full(
202                ffi::gtk_source_buffer_get_context_classes_at_iter(
203                    self.as_ref().to_glib_none().0,
204                    iter.to_glib_none().0,
205                ),
206            )
207        }
208    }
209
210    #[doc(alias = "gtk_source_buffer_get_highlight_matching_brackets")]
211    #[doc(alias = "get_highlight_matching_brackets")]
212    #[doc(alias = "highlight-matching-brackets")]
213    fn is_highlight_matching_brackets(&self) -> bool {
214        unsafe {
215            from_glib(ffi::gtk_source_buffer_get_highlight_matching_brackets(
216                self.as_ref().to_glib_none().0,
217            ))
218        }
219    }
220
221    #[doc(alias = "gtk_source_buffer_get_highlight_syntax")]
222    #[doc(alias = "get_highlight_syntax")]
223    #[doc(alias = "highlight-syntax")]
224    fn is_highlight_syntax(&self) -> bool {
225        unsafe {
226            from_glib(ffi::gtk_source_buffer_get_highlight_syntax(
227                self.as_ref().to_glib_none().0,
228            ))
229        }
230    }
231
232    #[doc(alias = "gtk_source_buffer_get_implicit_trailing_newline")]
233    #[doc(alias = "get_implicit_trailing_newline")]
234    #[doc(alias = "implicit-trailing-newline")]
235    fn is_implicit_trailing_newline(&self) -> bool {
236        unsafe {
237            from_glib(ffi::gtk_source_buffer_get_implicit_trailing_newline(
238                self.as_ref().to_glib_none().0,
239            ))
240        }
241    }
242
243    #[doc(alias = "gtk_source_buffer_get_language")]
244    #[doc(alias = "get_language")]
245    fn language(&self) -> Option<Language> {
246        unsafe {
247            from_glib_none(ffi::gtk_source_buffer_get_language(
248                self.as_ref().to_glib_none().0,
249            ))
250        }
251    }
252
253    #[doc(alias = "gtk_source_buffer_get_loading")]
254    #[doc(alias = "get_loading")]
255    #[doc(alias = "loading")]
256    fn is_loading(&self) -> bool {
257        unsafe {
258            from_glib(ffi::gtk_source_buffer_get_loading(
259                self.as_ref().to_glib_none().0,
260            ))
261        }
262    }
263
264    #[cfg(feature = "v5_18")]
265    #[cfg_attr(docsrs, doc(cfg(feature = "v5_18")))]
266    #[doc(alias = "gtk_source_buffer_get_markup")]
267    #[doc(alias = "get_markup")]
268    fn markup(&self, start: &mut gtk::TextIter, end: &mut gtk::TextIter) -> glib::GString {
269        unsafe {
270            from_glib_full(ffi::gtk_source_buffer_get_markup(
271                self.as_ref().to_glib_none().0,
272                start.to_glib_none_mut().0,
273                end.to_glib_none_mut().0,
274            ))
275        }
276    }
277
278    #[doc(alias = "gtk_source_buffer_get_source_marks_at_iter")]
279    #[doc(alias = "get_source_marks_at_iter")]
280    fn source_marks_at_iter(&self, iter: &mut gtk::TextIter, category: Option<&str>) -> Vec<Mark> {
281        unsafe {
282            FromGlibPtrContainer::from_glib_container(
283                ffi::gtk_source_buffer_get_source_marks_at_iter(
284                    self.as_ref().to_glib_none().0,
285                    iter.to_glib_none_mut().0,
286                    category.to_glib_none().0,
287                ),
288            )
289        }
290    }
291
292    #[doc(alias = "gtk_source_buffer_get_source_marks_at_line")]
293    #[doc(alias = "get_source_marks_at_line")]
294    fn source_marks_at_line(&self, line: i32, category: Option<&str>) -> Vec<Mark> {
295        unsafe {
296            FromGlibPtrContainer::from_glib_container(
297                ffi::gtk_source_buffer_get_source_marks_at_line(
298                    self.as_ref().to_glib_none().0,
299                    line,
300                    category.to_glib_none().0,
301                ),
302            )
303        }
304    }
305
306    #[doc(alias = "gtk_source_buffer_get_style_scheme")]
307    #[doc(alias = "get_style_scheme")]
308    #[doc(alias = "style-scheme")]
309    fn style_scheme(&self) -> Option<StyleScheme> {
310        unsafe {
311            from_glib_none(ffi::gtk_source_buffer_get_style_scheme(
312                self.as_ref().to_glib_none().0,
313            ))
314        }
315    }
316
317    //#[doc(alias = "gtk_source_buffer_iter_backward_to_context_class_toggle")]
318    //fn iter_backward_to_context_class_toggle(&self, iter: /*Unimplemented*/gtk::TextIter, context_class: &str) -> bool {
319    //    unsafe { TODO: call ffi:gtk_source_buffer_iter_backward_to_context_class_toggle() }
320    //}
321
322    //#[doc(alias = "gtk_source_buffer_iter_forward_to_context_class_toggle")]
323    //fn iter_forward_to_context_class_toggle(&self, iter: /*Unimplemented*/gtk::TextIter, context_class: &str) -> bool {
324    //    unsafe { TODO: call ffi:gtk_source_buffer_iter_forward_to_context_class_toggle() }
325    //}
326
327    #[doc(alias = "gtk_source_buffer_iter_has_context_class")]
328    fn iter_has_context_class(&self, iter: &gtk::TextIter, context_class: &str) -> bool {
329        unsafe {
330            from_glib(ffi::gtk_source_buffer_iter_has_context_class(
331                self.as_ref().to_glib_none().0,
332                iter.to_glib_none().0,
333                context_class.to_glib_none().0,
334            ))
335        }
336    }
337
338    #[doc(alias = "gtk_source_buffer_join_lines")]
339    fn join_lines(&self, start: &mut gtk::TextIter, end: &mut gtk::TextIter) {
340        unsafe {
341            ffi::gtk_source_buffer_join_lines(
342                self.as_ref().to_glib_none().0,
343                start.to_glib_none_mut().0,
344                end.to_glib_none_mut().0,
345            );
346        }
347    }
348
349    #[doc(alias = "gtk_source_buffer_remove_source_marks")]
350    fn remove_source_marks(
351        &self,
352        start: &gtk::TextIter,
353        end: &gtk::TextIter,
354        category: Option<&str>,
355    ) {
356        unsafe {
357            ffi::gtk_source_buffer_remove_source_marks(
358                self.as_ref().to_glib_none().0,
359                start.to_glib_none().0,
360                end.to_glib_none().0,
361                category.to_glib_none().0,
362            );
363        }
364    }
365
366    #[doc(alias = "gtk_source_buffer_set_highlight_matching_brackets")]
367    #[doc(alias = "highlight-matching-brackets")]
368    fn set_highlight_matching_brackets(&self, highlight: bool) {
369        unsafe {
370            ffi::gtk_source_buffer_set_highlight_matching_brackets(
371                self.as_ref().to_glib_none().0,
372                highlight.into_glib(),
373            );
374        }
375    }
376
377    #[doc(alias = "gtk_source_buffer_set_highlight_syntax")]
378    #[doc(alias = "highlight-syntax")]
379    fn set_highlight_syntax(&self, highlight: bool) {
380        unsafe {
381            ffi::gtk_source_buffer_set_highlight_syntax(
382                self.as_ref().to_glib_none().0,
383                highlight.into_glib(),
384            );
385        }
386    }
387
388    #[doc(alias = "gtk_source_buffer_set_implicit_trailing_newline")]
389    #[doc(alias = "implicit-trailing-newline")]
390    fn set_implicit_trailing_newline(&self, implicit_trailing_newline: bool) {
391        unsafe {
392            ffi::gtk_source_buffer_set_implicit_trailing_newline(
393                self.as_ref().to_glib_none().0,
394                implicit_trailing_newline.into_glib(),
395            );
396        }
397    }
398
399    #[doc(alias = "gtk_source_buffer_set_language")]
400    #[doc(alias = "language")]
401    fn set_language(&self, language: Option<&Language>) {
402        unsafe {
403            ffi::gtk_source_buffer_set_language(
404                self.as_ref().to_glib_none().0,
405                language.to_glib_none().0,
406            );
407        }
408    }
409
410    #[doc(alias = "gtk_source_buffer_set_style_scheme")]
411    #[doc(alias = "style-scheme")]
412    fn set_style_scheme(&self, scheme: Option<&StyleScheme>) {
413        unsafe {
414            ffi::gtk_source_buffer_set_style_scheme(
415                self.as_ref().to_glib_none().0,
416                scheme.to_glib_none().0,
417            );
418        }
419    }
420
421    #[doc(alias = "gtk_source_buffer_sort_lines")]
422    fn sort_lines(
423        &self,
424        start: &mut gtk::TextIter,
425        end: &mut gtk::TextIter,
426        flags: SortFlags,
427        column: i32,
428    ) {
429        unsafe {
430            ffi::gtk_source_buffer_sort_lines(
431                self.as_ref().to_glib_none().0,
432                start.to_glib_none_mut().0,
433                end.to_glib_none_mut().0,
434                flags.into_glib(),
435                column,
436            );
437        }
438    }
439
440    #[doc(alias = "bracket-matched")]
441    fn connect_bracket_matched<F: Fn(&Self, Option<&gtk::TextIter>, BracketMatchType) + 'static>(
442        &self,
443        f: F,
444    ) -> SignalHandlerId {
445        unsafe extern "C" fn bracket_matched_trampoline<
446            P: IsA<Buffer>,
447            F: Fn(&P, Option<&gtk::TextIter>, BracketMatchType) + 'static,
448        >(
449            this: *mut ffi::GtkSourceBuffer,
450            iter: *mut gtk::ffi::GtkTextIter,
451            state: ffi::GtkSourceBracketMatchType,
452            f: glib::ffi::gpointer,
453        ) {
454            unsafe {
455                let f: &F = &*(f as *const F);
456                f(
457                    Buffer::from_glib_borrow(this).unsafe_cast_ref(),
458                    Option::<gtk::TextIter>::from_glib_borrow(iter)
459                        .as_ref()
460                        .as_ref(),
461                    from_glib(state),
462                )
463            }
464        }
465        unsafe {
466            let f: Box_<F> = Box_::new(f);
467            connect_raw(
468                self.as_ptr() as *mut _,
469                c"bracket-matched".as_ptr() as *const _,
470                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
471                    bracket_matched_trampoline::<Self, F> as *const (),
472                )),
473                Box_::into_raw(f),
474            )
475        }
476    }
477
478    #[doc(alias = "cursor-moved")]
479    fn connect_cursor_moved<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
480        unsafe extern "C" fn cursor_moved_trampoline<P: IsA<Buffer>, F: Fn(&P) + 'static>(
481            this: *mut ffi::GtkSourceBuffer,
482            f: glib::ffi::gpointer,
483        ) {
484            unsafe {
485                let f: &F = &*(f as *const F);
486                f(Buffer::from_glib_borrow(this).unsafe_cast_ref())
487            }
488        }
489        unsafe {
490            let f: Box_<F> = Box_::new(f);
491            connect_raw(
492                self.as_ptr() as *mut _,
493                c"cursor-moved".as_ptr() as *const _,
494                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
495                    cursor_moved_trampoline::<Self, F> as *const (),
496                )),
497                Box_::into_raw(f),
498            )
499        }
500    }
501
502    #[doc(alias = "highlight-updated")]
503    fn connect_highlight_updated<F: Fn(&Self, &gtk::TextIter, &gtk::TextIter) + 'static>(
504        &self,
505        f: F,
506    ) -> SignalHandlerId {
507        unsafe extern "C" fn highlight_updated_trampoline<
508            P: IsA<Buffer>,
509            F: Fn(&P, &gtk::TextIter, &gtk::TextIter) + 'static,
510        >(
511            this: *mut ffi::GtkSourceBuffer,
512            start: *mut gtk::ffi::GtkTextIter,
513            end: *mut gtk::ffi::GtkTextIter,
514            f: glib::ffi::gpointer,
515        ) {
516            unsafe {
517                let f: &F = &*(f as *const F);
518                f(
519                    Buffer::from_glib_borrow(this).unsafe_cast_ref(),
520                    &from_glib_borrow(start),
521                    &from_glib_borrow(end),
522                )
523            }
524        }
525        unsafe {
526            let f: Box_<F> = Box_::new(f);
527            connect_raw(
528                self.as_ptr() as *mut _,
529                c"highlight-updated".as_ptr() as *const _,
530                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
531                    highlight_updated_trampoline::<Self, F> as *const (),
532                )),
533                Box_::into_raw(f),
534            )
535        }
536    }
537
538    #[doc(alias = "source-mark-updated")]
539    fn connect_source_mark_updated<F: Fn(&Self, &gtk::TextMark) + 'static>(
540        &self,
541        f: F,
542    ) -> SignalHandlerId {
543        unsafe extern "C" fn source_mark_updated_trampoline<
544            P: IsA<Buffer>,
545            F: Fn(&P, &gtk::TextMark) + 'static,
546        >(
547            this: *mut ffi::GtkSourceBuffer,
548            mark: *mut gtk::ffi::GtkTextMark,
549            f: glib::ffi::gpointer,
550        ) {
551            unsafe {
552                let f: &F = &*(f as *const F);
553                f(
554                    Buffer::from_glib_borrow(this).unsafe_cast_ref(),
555                    &from_glib_borrow(mark),
556                )
557            }
558        }
559        unsafe {
560            let f: Box_<F> = Box_::new(f);
561            connect_raw(
562                self.as_ptr() as *mut _,
563                c"source-mark-updated".as_ptr() as *const _,
564                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
565                    source_mark_updated_trampoline::<Self, F> as *const (),
566                )),
567                Box_::into_raw(f),
568            )
569        }
570    }
571
572    #[doc(alias = "highlight-matching-brackets")]
573    fn connect_highlight_matching_brackets_notify<F: Fn(&Self) + 'static>(
574        &self,
575        f: F,
576    ) -> SignalHandlerId {
577        unsafe extern "C" fn notify_highlight_matching_brackets_trampoline<
578            P: IsA<Buffer>,
579            F: Fn(&P) + 'static,
580        >(
581            this: *mut ffi::GtkSourceBuffer,
582            _param_spec: glib::ffi::gpointer,
583            f: glib::ffi::gpointer,
584        ) {
585            unsafe {
586                let f: &F = &*(f as *const F);
587                f(Buffer::from_glib_borrow(this).unsafe_cast_ref())
588            }
589        }
590        unsafe {
591            let f: Box_<F> = Box_::new(f);
592            connect_raw(
593                self.as_ptr() as *mut _,
594                c"notify::highlight-matching-brackets".as_ptr() as *const _,
595                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
596                    notify_highlight_matching_brackets_trampoline::<Self, F> as *const (),
597                )),
598                Box_::into_raw(f),
599            )
600        }
601    }
602
603    #[doc(alias = "highlight-syntax")]
604    fn connect_highlight_syntax_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
605        unsafe extern "C" fn notify_highlight_syntax_trampoline<
606            P: IsA<Buffer>,
607            F: Fn(&P) + 'static,
608        >(
609            this: *mut ffi::GtkSourceBuffer,
610            _param_spec: glib::ffi::gpointer,
611            f: glib::ffi::gpointer,
612        ) {
613            unsafe {
614                let f: &F = &*(f as *const F);
615                f(Buffer::from_glib_borrow(this).unsafe_cast_ref())
616            }
617        }
618        unsafe {
619            let f: Box_<F> = Box_::new(f);
620            connect_raw(
621                self.as_ptr() as *mut _,
622                c"notify::highlight-syntax".as_ptr() as *const _,
623                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
624                    notify_highlight_syntax_trampoline::<Self, F> as *const (),
625                )),
626                Box_::into_raw(f),
627            )
628        }
629    }
630
631    #[doc(alias = "implicit-trailing-newline")]
632    fn connect_implicit_trailing_newline_notify<F: Fn(&Self) + 'static>(
633        &self,
634        f: F,
635    ) -> SignalHandlerId {
636        unsafe extern "C" fn notify_implicit_trailing_newline_trampoline<
637            P: IsA<Buffer>,
638            F: Fn(&P) + 'static,
639        >(
640            this: *mut ffi::GtkSourceBuffer,
641            _param_spec: glib::ffi::gpointer,
642            f: glib::ffi::gpointer,
643        ) {
644            unsafe {
645                let f: &F = &*(f as *const F);
646                f(Buffer::from_glib_borrow(this).unsafe_cast_ref())
647            }
648        }
649        unsafe {
650            let f: Box_<F> = Box_::new(f);
651            connect_raw(
652                self.as_ptr() as *mut _,
653                c"notify::implicit-trailing-newline".as_ptr() as *const _,
654                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
655                    notify_implicit_trailing_newline_trampoline::<Self, F> as *const (),
656                )),
657                Box_::into_raw(f),
658            )
659        }
660    }
661
662    #[doc(alias = "language")]
663    fn connect_language_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
664        unsafe extern "C" fn notify_language_trampoline<P: IsA<Buffer>, F: Fn(&P) + 'static>(
665            this: *mut ffi::GtkSourceBuffer,
666            _param_spec: glib::ffi::gpointer,
667            f: glib::ffi::gpointer,
668        ) {
669            unsafe {
670                let f: &F = &*(f as *const F);
671                f(Buffer::from_glib_borrow(this).unsafe_cast_ref())
672            }
673        }
674        unsafe {
675            let f: Box_<F> = Box_::new(f);
676            connect_raw(
677                self.as_ptr() as *mut _,
678                c"notify::language".as_ptr() as *const _,
679                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
680                    notify_language_trampoline::<Self, F> as *const (),
681                )),
682                Box_::into_raw(f),
683            )
684        }
685    }
686
687    #[cfg(feature = "v5_10")]
688    #[cfg_attr(docsrs, doc(cfg(feature = "v5_10")))]
689    #[doc(alias = "loading")]
690    fn connect_loading_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
691        unsafe extern "C" fn notify_loading_trampoline<P: IsA<Buffer>, F: Fn(&P) + 'static>(
692            this: *mut ffi::GtkSourceBuffer,
693            _param_spec: glib::ffi::gpointer,
694            f: glib::ffi::gpointer,
695        ) {
696            unsafe {
697                let f: &F = &*(f as *const F);
698                f(Buffer::from_glib_borrow(this).unsafe_cast_ref())
699            }
700        }
701        unsafe {
702            let f: Box_<F> = Box_::new(f);
703            connect_raw(
704                self.as_ptr() as *mut _,
705                c"notify::loading".as_ptr() as *const _,
706                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
707                    notify_loading_trampoline::<Self, F> as *const (),
708                )),
709                Box_::into_raw(f),
710            )
711        }
712    }
713
714    #[doc(alias = "style-scheme")]
715    fn connect_style_scheme_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
716        unsafe extern "C" fn notify_style_scheme_trampoline<P: IsA<Buffer>, F: Fn(&P) + 'static>(
717            this: *mut ffi::GtkSourceBuffer,
718            _param_spec: glib::ffi::gpointer,
719            f: glib::ffi::gpointer,
720        ) {
721            unsafe {
722                let f: &F = &*(f as *const F);
723                f(Buffer::from_glib_borrow(this).unsafe_cast_ref())
724            }
725        }
726        unsafe {
727            let f: Box_<F> = Box_::new(f);
728            connect_raw(
729                self.as_ptr() as *mut _,
730                c"notify::style-scheme".as_ptr() as *const _,
731                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
732                    notify_style_scheme_trampoline::<Self, F> as *const (),
733                )),
734                Box_::into_raw(f),
735            )
736        }
737    }
738}
739
740impl<O: IsA<Buffer>> BufferExt for O {}