Skip to main content

gtk/auto/
font_chooser.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
5#[cfg(feature = "v3_24")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
7use crate::FontChooserLevel;
8use crate::ffi;
9use glib::{
10    object::ObjectType as _,
11    prelude::*,
12    signal::{SignalHandlerId, connect_raw},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    /// [`FontChooser`][crate::FontChooser] is an interface that can be implemented by widgets
19    /// displaying the list of fonts. In GTK+, the main objects
20    /// that implement this interface are [`FontChooserWidget`][crate::FontChooserWidget],
21    /// [`FontChooserDialog`][crate::FontChooserDialog] and [`FontButton`][crate::FontButton]. The GtkFontChooser interface
22    /// has been introducted in GTK+ 3.2.
23    ///
24    /// ## Properties
25    ///
26    ///
27    /// #### `font`
28    ///  The font description as a string, e.g. "Sans Italic 12".
29    ///
30    /// Readable | Writable
31    ///
32    ///
33    /// #### `font-desc`
34    ///  The font description as a [`pango::FontDescription`][crate::pango::FontDescription].
35    ///
36    /// Readable | Writable
37    ///
38    ///
39    /// #### `font-features`
40    ///  The selected font features, in a format that is compatible with
41    /// CSS and with Pango attributes.
42    ///
43    /// Readable
44    ///
45    ///
46    /// #### `language`
47    ///  The language for which the [`font-features`][struct@crate::FontChooser#font-features] were
48    /// selected, in a format that is compatible with CSS and with Pango
49    /// attributes.
50    ///
51    /// Readable | Writable
52    ///
53    ///
54    /// #### `level`
55    ///  The level of granularity to offer for selecting fonts.
56    ///
57    /// Readable | Writable
58    ///
59    ///
60    /// #### `preview-text`
61    ///  The string with which to preview the font.
62    ///
63    /// Readable | Writable
64    ///
65    ///
66    /// #### `show-preview-entry`
67    ///  Whether to show an entry to change the preview text.
68    ///
69    /// Readable | Writable
70    ///
71    /// ## Signals
72    ///
73    ///
74    /// #### `font-activated`
75    ///  Emitted when a font is activated.
76    /// This usually happens when the user double clicks an item,
77    /// or an item is selected and the user presses one of the keys
78    /// Space, Shift+Space, Return or Enter.
79    ///
80    ///
81    ///
82    /// # Implements
83    ///
84    /// [`FontChooserExt`][trait@crate::prelude::FontChooserExt]
85    #[doc(alias = "GtkFontChooser")]
86    pub struct FontChooser(Interface<ffi::GtkFontChooser, ffi::GtkFontChooserIface>);
87
88    match fn {
89        type_ => || ffi::gtk_font_chooser_get_type(),
90    }
91}
92
93impl FontChooser {
94    pub const NONE: Option<&'static FontChooser> = None;
95}
96
97/// Trait containing all [`struct@FontChooser`] methods.
98///
99/// # Implementors
100///
101/// [`FontButton`][struct@crate::FontButton], [`FontChooserDialog`][struct@crate::FontChooserDialog], [`FontChooserWidget`][struct@crate::FontChooserWidget], [`FontChooser`][struct@crate::FontChooser]
102pub trait FontChooserExt: IsA<FontChooser> + 'static {
103    /// Gets the currently-selected font name.
104    ///
105    /// Note that this can be a different string than what you set with
106    /// [`set_font()`][Self::set_font()], as the font chooser widget may
107    /// normalize font names and thus return a string with a different
108    /// structure. For example, “Helvetica Italic Bold 12” could be
109    /// normalized to “Helvetica Bold Italic 12”.
110    ///
111    /// Use `pango_font_description_equal()` if you want to compare two
112    /// font descriptions.
113    ///
114    /// # Returns
115    ///
116    /// A string with the name
117    ///  of the current font, or [`None`] if no font is selected. You must
118    ///  free this string with `g_free()`.
119    #[doc(alias = "gtk_font_chooser_get_font")]
120    #[doc(alias = "get_font")]
121    fn font(&self) -> Option<glib::GString> {
122        unsafe {
123            from_glib_full(ffi::gtk_font_chooser_get_font(
124                self.as_ref().to_glib_none().0,
125            ))
126        }
127    }
128
129    /// Gets the currently-selected font.
130    ///
131    /// Note that this can be a different string than what you set with
132    /// [`set_font()`][Self::set_font()], as the font chooser widget may
133    /// normalize font names and thus return a string with a different
134    /// structure. For example, “Helvetica Italic Bold 12” could be
135    /// normalized to “Helvetica Bold Italic 12”.
136    ///
137    /// Use `pango_font_description_equal()` if you want to compare two
138    /// font descriptions.
139    ///
140    /// # Returns
141    ///
142    /// A [`pango::FontDescription`][crate::pango::FontDescription] for the
143    ///  current font, or [`None`] if no font is selected.
144    #[doc(alias = "gtk_font_chooser_get_font_desc")]
145    #[doc(alias = "get_font_desc")]
146    #[doc(alias = "font-desc")]
147    fn font_desc(&self) -> Option<pango::FontDescription> {
148        unsafe {
149            from_glib_full(ffi::gtk_font_chooser_get_font_desc(
150                self.as_ref().to_glib_none().0,
151            ))
152        }
153    }
154
155    /// Gets the [`pango::FontFace`][crate::pango::FontFace] representing the selected font group
156    /// details (i.e. family, slant, weight, width, etc).
157    ///
158    /// If the selected font is not installed, returns [`None`].
159    ///
160    /// # Returns
161    ///
162    /// A [`pango::FontFace`][crate::pango::FontFace] representing the
163    ///  selected font group details, or [`None`]. The returned object is owned by
164    ///  `self` and must not be modified or freed.
165    #[doc(alias = "gtk_font_chooser_get_font_face")]
166    #[doc(alias = "get_font_face")]
167    fn font_face(&self) -> Option<pango::FontFace> {
168        unsafe {
169            from_glib_none(ffi::gtk_font_chooser_get_font_face(
170                self.as_ref().to_glib_none().0,
171            ))
172        }
173    }
174
175    /// Gets the [`pango::FontFamily`][crate::pango::FontFamily] representing the selected font family.
176    /// Font families are a collection of font faces.
177    ///
178    /// If the selected font is not installed, returns [`None`].
179    ///
180    /// # Returns
181    ///
182    /// A [`pango::FontFamily`][crate::pango::FontFamily] representing the
183    ///  selected font family, or [`None`]. The returned object is owned by `self`
184    ///  and must not be modified or freed.
185    #[doc(alias = "gtk_font_chooser_get_font_family")]
186    #[doc(alias = "get_font_family")]
187    fn font_family(&self) -> Option<pango::FontFamily> {
188        unsafe {
189            from_glib_none(ffi::gtk_font_chooser_get_font_family(
190                self.as_ref().to_glib_none().0,
191            ))
192        }
193    }
194
195    /// Gets the currently-selected font features.
196    ///
197    /// # Returns
198    ///
199    /// the currently selected font features
200    #[cfg(feature = "v3_24")]
201    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
202    #[doc(alias = "gtk_font_chooser_get_font_features")]
203    #[doc(alias = "get_font_features")]
204    #[doc(alias = "font-features")]
205    fn font_features(&self) -> Option<glib::GString> {
206        unsafe {
207            from_glib_full(ffi::gtk_font_chooser_get_font_features(
208                self.as_ref().to_glib_none().0,
209            ))
210        }
211    }
212
213    /// Gets the custom font map of this font chooser widget,
214    /// or [`None`] if it does not have one.
215    ///
216    /// # Returns
217    ///
218    /// a [`pango::FontMap`][crate::pango::FontMap], or [`None`]
219    #[doc(alias = "gtk_font_chooser_get_font_map")]
220    #[doc(alias = "get_font_map")]
221    fn font_map(&self) -> Option<pango::FontMap> {
222        unsafe {
223            from_glib_full(ffi::gtk_font_chooser_get_font_map(
224                self.as_ref().to_glib_none().0,
225            ))
226        }
227    }
228
229    /// The selected font size.
230    ///
231    /// # Returns
232    ///
233    /// A n integer representing the selected font size,
234    ///  or -1 if no font size is selected.
235    #[doc(alias = "gtk_font_chooser_get_font_size")]
236    #[doc(alias = "get_font_size")]
237    fn font_size(&self) -> i32 {
238        unsafe { ffi::gtk_font_chooser_get_font_size(self.as_ref().to_glib_none().0) }
239    }
240
241    /// Gets the language that is used for font features.
242    ///
243    /// # Returns
244    ///
245    /// the currently selected language
246    #[cfg(feature = "v3_24")]
247    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
248    #[doc(alias = "gtk_font_chooser_get_language")]
249    #[doc(alias = "get_language")]
250    fn language(&self) -> Option<glib::GString> {
251        unsafe {
252            from_glib_full(ffi::gtk_font_chooser_get_language(
253                self.as_ref().to_glib_none().0,
254            ))
255        }
256    }
257
258    /// Returns the current level of granularity for selecting fonts.
259    ///
260    /// # Returns
261    ///
262    /// the current granularity level
263    #[cfg(feature = "v3_24")]
264    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
265    #[doc(alias = "gtk_font_chooser_get_level")]
266    #[doc(alias = "get_level")]
267    fn level(&self) -> FontChooserLevel {
268        unsafe {
269            from_glib(ffi::gtk_font_chooser_get_level(
270                self.as_ref().to_glib_none().0,
271            ))
272        }
273    }
274
275    /// Gets the text displayed in the preview area.
276    ///
277    /// # Returns
278    ///
279    /// the text displayed in the
280    ///  preview area
281    #[doc(alias = "gtk_font_chooser_get_preview_text")]
282    #[doc(alias = "get_preview_text")]
283    #[doc(alias = "preview-text")]
284    fn preview_text(&self) -> Option<glib::GString> {
285        unsafe {
286            from_glib_full(ffi::gtk_font_chooser_get_preview_text(
287                self.as_ref().to_glib_none().0,
288            ))
289        }
290    }
291
292    /// Returns whether the preview entry is shown or not.
293    ///
294    /// # Returns
295    ///
296    /// [`true`] if the preview entry is shown
297    ///  or [`false`] if it is hidden.
298    #[doc(alias = "gtk_font_chooser_get_show_preview_entry")]
299    #[doc(alias = "get_show_preview_entry")]
300    #[doc(alias = "show-preview-entry")]
301    fn shows_preview_entry(&self) -> bool {
302        unsafe {
303            from_glib(ffi::gtk_font_chooser_get_show_preview_entry(
304                self.as_ref().to_glib_none().0,
305            ))
306        }
307    }
308
309    /// Adds a filter function that decides which fonts to display
310    /// in the font chooser.
311    /// ## `filter`
312    /// a `GtkFontFilterFunc`, or [`None`]
313    #[doc(alias = "gtk_font_chooser_set_filter_func")]
314    fn set_filter_func(
315        &self,
316        filter: Option<Box_<dyn Fn(&pango::FontFamily, &pango::FontFace) -> bool + 'static>>,
317    ) {
318        let filter_data: Box_<
319            Option<Box_<dyn Fn(&pango::FontFamily, &pango::FontFace) -> bool + 'static>>,
320        > = Box_::new(filter);
321        unsafe extern "C" fn filter_func(
322            family: *const pango::ffi::PangoFontFamily,
323            face: *const pango::ffi::PangoFontFace,
324            data: glib::ffi::gpointer,
325        ) -> glib::ffi::gboolean {
326            unsafe {
327                let family = from_glib_borrow(family);
328                let face = from_glib_borrow(face);
329                let callback = &*(data as *mut Option<
330                    Box_<dyn Fn(&pango::FontFamily, &pango::FontFace) -> bool + 'static>,
331                >);
332                if let Some(ref callback) = *callback {
333                    callback(&family, &face)
334                } else {
335                    panic!("cannot get closure...")
336                }
337                .into_glib()
338            }
339        }
340        let filter = if filter_data.is_some() {
341            Some(filter_func as _)
342        } else {
343            None
344        };
345        unsafe extern "C" fn destroy_func(data: glib::ffi::gpointer) {
346            unsafe {
347                let _callback = Box_::from_raw(
348                    data as *mut Option<
349                        Box_<dyn Fn(&pango::FontFamily, &pango::FontFace) -> bool + 'static>,
350                    >,
351                );
352            }
353        }
354        let destroy_call3 = Some(destroy_func as _);
355        let super_callback0: Box_<
356            Option<Box_<dyn Fn(&pango::FontFamily, &pango::FontFace) -> bool + 'static>>,
357        > = filter_data;
358        unsafe {
359            ffi::gtk_font_chooser_set_filter_func(
360                self.as_ref().to_glib_none().0,
361                filter,
362                Box_::into_raw(super_callback0) as *mut _,
363                destroy_call3,
364            );
365        }
366    }
367
368    /// Sets the currently-selected font.
369    /// ## `fontname`
370    /// a font name like “Helvetica 12” or “Times Bold 18”
371    #[doc(alias = "gtk_font_chooser_set_font")]
372    #[doc(alias = "font")]
373    fn set_font(&self, fontname: &str) {
374        unsafe {
375            ffi::gtk_font_chooser_set_font(
376                self.as_ref().to_glib_none().0,
377                fontname.to_glib_none().0,
378            );
379        }
380    }
381
382    /// Sets the currently-selected font from `font_desc`.
383    /// ## `font_desc`
384    /// a [`pango::FontDescription`][crate::pango::FontDescription]
385    #[doc(alias = "gtk_font_chooser_set_font_desc")]
386    #[doc(alias = "font-desc")]
387    fn set_font_desc(&self, font_desc: &pango::FontDescription) {
388        unsafe {
389            ffi::gtk_font_chooser_set_font_desc(
390                self.as_ref().to_glib_none().0,
391                font_desc.to_glib_none().0,
392            );
393        }
394    }
395
396    ///
397    /// FcConfig *config;
398    /// PangoFontMap *fontmap;
399    ///
400    /// config = FcInitLoadConfigAndFonts ();
401    /// FcConfigAppFontAddFile (config, my_app_font_file);
402    ///
403    /// fontmap = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT);
404    /// pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (fontmap), config);
405    ///
406    /// gtk_font_chooser_set_font_map (font_chooser, fontmap);
407    /// ]|
408    ///
409    /// Note that other GTK+ widgets will only be able to use the application-specific
410    /// font if it is present in the font map they use:
411    ///
412    ///
413    /// ```text
414    /// context = gtk_widget_get_pango_context (label);
415    /// pango_context_set_font_map (context, fontmap);
416    /// ```
417    /// ## `fontmap`
418    /// a [`pango::FontMap`][crate::pango::FontMap]
419    #[doc(alias = "gtk_font_chooser_set_font_map")]
420    fn set_font_map(&self, fontmap: Option<&impl IsA<pango::FontMap>>) {
421        unsafe {
422            ffi::gtk_font_chooser_set_font_map(
423                self.as_ref().to_glib_none().0,
424                fontmap.map(|p| p.as_ref()).to_glib_none().0,
425            );
426        }
427    }
428
429    /// Sets the language to use for font features.
430    /// ## `language`
431    /// a language
432    #[cfg(feature = "v3_24")]
433    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
434    #[doc(alias = "gtk_font_chooser_set_language")]
435    #[doc(alias = "language")]
436    fn set_language(&self, language: &str) {
437        unsafe {
438            ffi::gtk_font_chooser_set_language(
439                self.as_ref().to_glib_none().0,
440                language.to_glib_none().0,
441            );
442        }
443    }
444
445    /// Sets the desired level of granularity for selecting fonts.
446    /// ## `level`
447    /// the desired level of granularity
448    #[cfg(feature = "v3_24")]
449    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
450    #[doc(alias = "gtk_font_chooser_set_level")]
451    #[doc(alias = "level")]
452    fn set_level(&self, level: FontChooserLevel) {
453        unsafe {
454            ffi::gtk_font_chooser_set_level(self.as_ref().to_glib_none().0, level.into_glib());
455        }
456    }
457
458    /// Sets the text displayed in the preview area.
459    /// The `text` is used to show how the selected font looks.
460    /// ## `text`
461    /// the text to display in the preview area
462    #[doc(alias = "gtk_font_chooser_set_preview_text")]
463    #[doc(alias = "preview-text")]
464    fn set_preview_text(&self, text: &str) {
465        unsafe {
466            ffi::gtk_font_chooser_set_preview_text(
467                self.as_ref().to_glib_none().0,
468                text.to_glib_none().0,
469            );
470        }
471    }
472
473    /// Shows or hides the editable preview entry.
474    /// ## `show_preview_entry`
475    /// whether to show the editable preview entry or not
476    #[doc(alias = "gtk_font_chooser_set_show_preview_entry")]
477    #[doc(alias = "show-preview-entry")]
478    fn set_show_preview_entry(&self, show_preview_entry: bool) {
479        unsafe {
480            ffi::gtk_font_chooser_set_show_preview_entry(
481                self.as_ref().to_glib_none().0,
482                show_preview_entry.into_glib(),
483            );
484        }
485    }
486
487    /// Emitted when a font is activated.
488    /// This usually happens when the user double clicks an item,
489    /// or an item is selected and the user presses one of the keys
490    /// Space, Shift+Space, Return or Enter.
491    /// ## `fontname`
492    /// the font name
493    #[doc(alias = "font-activated")]
494    fn connect_font_activated<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
495        unsafe extern "C" fn font_activated_trampoline<
496            P: IsA<FontChooser>,
497            F: Fn(&P, &str) + 'static,
498        >(
499            this: *mut ffi::GtkFontChooser,
500            fontname: *mut std::ffi::c_char,
501            f: glib::ffi::gpointer,
502        ) {
503            unsafe {
504                let f: &F = &*(f as *const F);
505                f(
506                    FontChooser::from_glib_borrow(this).unsafe_cast_ref(),
507                    &glib::GString::from_glib_borrow(fontname),
508                )
509            }
510        }
511        unsafe {
512            let f: Box_<F> = Box_::new(f);
513            connect_raw(
514                self.as_ptr() as *mut _,
515                c"font-activated".as_ptr(),
516                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
517                    font_activated_trampoline::<Self, F> as *const (),
518                )),
519                Box_::into_raw(f),
520            )
521        }
522    }
523
524    #[doc(alias = "font")]
525    fn connect_font_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
526        unsafe extern "C" fn notify_font_trampoline<P: IsA<FontChooser>, F: Fn(&P) + 'static>(
527            this: *mut ffi::GtkFontChooser,
528            _param_spec: glib::ffi::gpointer,
529            f: glib::ffi::gpointer,
530        ) {
531            unsafe {
532                let f: &F = &*(f as *const F);
533                f(FontChooser::from_glib_borrow(this).unsafe_cast_ref())
534            }
535        }
536        unsafe {
537            let f: Box_<F> = Box_::new(f);
538            connect_raw(
539                self.as_ptr() as *mut _,
540                c"notify::font".as_ptr(),
541                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
542                    notify_font_trampoline::<Self, F> as *const (),
543                )),
544                Box_::into_raw(f),
545            )
546        }
547    }
548
549    #[doc(alias = "font-desc")]
550    fn connect_font_desc_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
551        unsafe extern "C" fn notify_font_desc_trampoline<
552            P: IsA<FontChooser>,
553            F: Fn(&P) + 'static,
554        >(
555            this: *mut ffi::GtkFontChooser,
556            _param_spec: glib::ffi::gpointer,
557            f: glib::ffi::gpointer,
558        ) {
559            unsafe {
560                let f: &F = &*(f as *const F);
561                f(FontChooser::from_glib_borrow(this).unsafe_cast_ref())
562            }
563        }
564        unsafe {
565            let f: Box_<F> = Box_::new(f);
566            connect_raw(
567                self.as_ptr() as *mut _,
568                c"notify::font-desc".as_ptr(),
569                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
570                    notify_font_desc_trampoline::<Self, F> as *const (),
571                )),
572                Box_::into_raw(f),
573            )
574        }
575    }
576
577    #[cfg(feature = "v3_24")]
578    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
579    #[doc(alias = "font-features")]
580    fn connect_font_features_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
581        unsafe extern "C" fn notify_font_features_trampoline<
582            P: IsA<FontChooser>,
583            F: Fn(&P) + 'static,
584        >(
585            this: *mut ffi::GtkFontChooser,
586            _param_spec: glib::ffi::gpointer,
587            f: glib::ffi::gpointer,
588        ) {
589            unsafe {
590                let f: &F = &*(f as *const F);
591                f(FontChooser::from_glib_borrow(this).unsafe_cast_ref())
592            }
593        }
594        unsafe {
595            let f: Box_<F> = Box_::new(f);
596            connect_raw(
597                self.as_ptr() as *mut _,
598                c"notify::font-features".as_ptr(),
599                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
600                    notify_font_features_trampoline::<Self, F> as *const (),
601                )),
602                Box_::into_raw(f),
603            )
604        }
605    }
606
607    #[cfg(feature = "v3_24")]
608    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
609    #[doc(alias = "language")]
610    fn connect_language_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
611        unsafe extern "C" fn notify_language_trampoline<
612            P: IsA<FontChooser>,
613            F: Fn(&P) + 'static,
614        >(
615            this: *mut ffi::GtkFontChooser,
616            _param_spec: glib::ffi::gpointer,
617            f: glib::ffi::gpointer,
618        ) {
619            unsafe {
620                let f: &F = &*(f as *const F);
621                f(FontChooser::from_glib_borrow(this).unsafe_cast_ref())
622            }
623        }
624        unsafe {
625            let f: Box_<F> = Box_::new(f);
626            connect_raw(
627                self.as_ptr() as *mut _,
628                c"notify::language".as_ptr(),
629                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
630                    notify_language_trampoline::<Self, F> as *const (),
631                )),
632                Box_::into_raw(f),
633            )
634        }
635    }
636
637    #[cfg(feature = "v3_24")]
638    #[cfg_attr(docsrs, doc(cfg(feature = "v3_24")))]
639    #[doc(alias = "level")]
640    fn connect_level_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
641        unsafe extern "C" fn notify_level_trampoline<P: IsA<FontChooser>, F: Fn(&P) + 'static>(
642            this: *mut ffi::GtkFontChooser,
643            _param_spec: glib::ffi::gpointer,
644            f: glib::ffi::gpointer,
645        ) {
646            unsafe {
647                let f: &F = &*(f as *const F);
648                f(FontChooser::from_glib_borrow(this).unsafe_cast_ref())
649            }
650        }
651        unsafe {
652            let f: Box_<F> = Box_::new(f);
653            connect_raw(
654                self.as_ptr() as *mut _,
655                c"notify::level".as_ptr(),
656                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
657                    notify_level_trampoline::<Self, F> as *const (),
658                )),
659                Box_::into_raw(f),
660            )
661        }
662    }
663
664    #[doc(alias = "preview-text")]
665    fn connect_preview_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
666        unsafe extern "C" fn notify_preview_text_trampoline<
667            P: IsA<FontChooser>,
668            F: Fn(&P) + 'static,
669        >(
670            this: *mut ffi::GtkFontChooser,
671            _param_spec: glib::ffi::gpointer,
672            f: glib::ffi::gpointer,
673        ) {
674            unsafe {
675                let f: &F = &*(f as *const F);
676                f(FontChooser::from_glib_borrow(this).unsafe_cast_ref())
677            }
678        }
679        unsafe {
680            let f: Box_<F> = Box_::new(f);
681            connect_raw(
682                self.as_ptr() as *mut _,
683                c"notify::preview-text".as_ptr(),
684                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
685                    notify_preview_text_trampoline::<Self, F> as *const (),
686                )),
687                Box_::into_raw(f),
688            )
689        }
690    }
691
692    #[doc(alias = "show-preview-entry")]
693    fn connect_show_preview_entry_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
694        unsafe extern "C" fn notify_show_preview_entry_trampoline<
695            P: IsA<FontChooser>,
696            F: Fn(&P) + 'static,
697        >(
698            this: *mut ffi::GtkFontChooser,
699            _param_spec: glib::ffi::gpointer,
700            f: glib::ffi::gpointer,
701        ) {
702            unsafe {
703                let f: &F = &*(f as *const F);
704                f(FontChooser::from_glib_borrow(this).unsafe_cast_ref())
705            }
706        }
707        unsafe {
708            let f: Box_<F> = Box_::new(f);
709            connect_raw(
710                self.as_ptr() as *mut _,
711                c"notify::show-preview-entry".as_ptr(),
712                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
713                    notify_show_preview_entry_trampoline::<Self, F> as *const (),
714                )),
715                Box_::into_raw(f),
716            )
717        }
718    }
719}
720
721impl<O: IsA<FontChooser>> FontChooserExt for O {}