[go: up one dir, main page]

gtk4/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#![allow(deprecated)]
5
6use crate::{ffi, FontChooserLevel};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "GtkFontChooser")]
17    pub struct FontChooser(Interface<ffi::GtkFontChooser, ffi::GtkFontChooserIface>);
18
19    match fn {
20        type_ => || ffi::gtk_font_chooser_get_type(),
21    }
22}
23
24impl FontChooser {
25    pub const NONE: Option<&'static FontChooser> = None;
26}
27
28pub trait FontChooserExt: IsA<FontChooser> + 'static {
29    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
30    #[allow(deprecated)]
31    #[doc(alias = "gtk_font_chooser_get_font")]
32    #[doc(alias = "get_font")]
33    fn font(&self) -> Option<glib::GString> {
34        unsafe {
35            from_glib_full(ffi::gtk_font_chooser_get_font(
36                self.as_ref().to_glib_none().0,
37            ))
38        }
39    }
40
41    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
42    #[allow(deprecated)]
43    #[doc(alias = "gtk_font_chooser_get_font_desc")]
44    #[doc(alias = "get_font_desc")]
45    #[doc(alias = "font-desc")]
46    fn font_desc(&self) -> Option<pango::FontDescription> {
47        unsafe {
48            from_glib_full(ffi::gtk_font_chooser_get_font_desc(
49                self.as_ref().to_glib_none().0,
50            ))
51        }
52    }
53
54    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
55    #[allow(deprecated)]
56    #[doc(alias = "gtk_font_chooser_get_font_face")]
57    #[doc(alias = "get_font_face")]
58    fn font_face(&self) -> Option<pango::FontFace> {
59        unsafe {
60            from_glib_none(ffi::gtk_font_chooser_get_font_face(
61                self.as_ref().to_glib_none().0,
62            ))
63        }
64    }
65
66    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
67    #[allow(deprecated)]
68    #[doc(alias = "gtk_font_chooser_get_font_family")]
69    #[doc(alias = "get_font_family")]
70    fn font_family(&self) -> Option<pango::FontFamily> {
71        unsafe {
72            from_glib_none(ffi::gtk_font_chooser_get_font_family(
73                self.as_ref().to_glib_none().0,
74            ))
75        }
76    }
77
78    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
79    #[allow(deprecated)]
80    #[doc(alias = "gtk_font_chooser_get_font_features")]
81    #[doc(alias = "get_font_features")]
82    #[doc(alias = "font-features")]
83    fn font_features(&self) -> glib::GString {
84        unsafe {
85            from_glib_full(ffi::gtk_font_chooser_get_font_features(
86                self.as_ref().to_glib_none().0,
87            ))
88        }
89    }
90
91    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
92    #[allow(deprecated)]
93    #[doc(alias = "gtk_font_chooser_get_font_map")]
94    #[doc(alias = "get_font_map")]
95    fn font_map(&self) -> Option<pango::FontMap> {
96        unsafe {
97            from_glib_full(ffi::gtk_font_chooser_get_font_map(
98                self.as_ref().to_glib_none().0,
99            ))
100        }
101    }
102
103    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
104    #[allow(deprecated)]
105    #[doc(alias = "gtk_font_chooser_get_font_size")]
106    #[doc(alias = "get_font_size")]
107    fn font_size(&self) -> i32 {
108        unsafe { ffi::gtk_font_chooser_get_font_size(self.as_ref().to_glib_none().0) }
109    }
110
111    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
112    #[allow(deprecated)]
113    #[doc(alias = "gtk_font_chooser_get_language")]
114    #[doc(alias = "get_language")]
115    fn language(&self) -> glib::GString {
116        unsafe {
117            from_glib_full(ffi::gtk_font_chooser_get_language(
118                self.as_ref().to_glib_none().0,
119            ))
120        }
121    }
122
123    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
124    #[allow(deprecated)]
125    #[doc(alias = "gtk_font_chooser_get_level")]
126    #[doc(alias = "get_level")]
127    fn level(&self) -> FontChooserLevel {
128        unsafe {
129            from_glib(ffi::gtk_font_chooser_get_level(
130                self.as_ref().to_glib_none().0,
131            ))
132        }
133    }
134
135    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
136    #[allow(deprecated)]
137    #[doc(alias = "gtk_font_chooser_get_preview_text")]
138    #[doc(alias = "get_preview_text")]
139    #[doc(alias = "preview-text")]
140    fn preview_text(&self) -> glib::GString {
141        unsafe {
142            from_glib_full(ffi::gtk_font_chooser_get_preview_text(
143                self.as_ref().to_glib_none().0,
144            ))
145        }
146    }
147
148    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
149    #[allow(deprecated)]
150    #[doc(alias = "gtk_font_chooser_get_show_preview_entry")]
151    #[doc(alias = "get_show_preview_entry")]
152    #[doc(alias = "show-preview-entry")]
153    fn shows_preview_entry(&self) -> bool {
154        unsafe {
155            from_glib(ffi::gtk_font_chooser_get_show_preview_entry(
156                self.as_ref().to_glib_none().0,
157            ))
158        }
159    }
160
161    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
162    #[allow(deprecated)]
163    #[doc(alias = "gtk_font_chooser_set_filter_func")]
164    fn set_filter_func<P: Fn(&pango::FontFamily, &pango::FontFace) -> bool + 'static>(
165        &self,
166        filter: P,
167    ) {
168        let filter_data: Box_<P> = Box_::new(filter);
169        unsafe extern "C" fn filter_func<
170            P: Fn(&pango::FontFamily, &pango::FontFace) -> bool + 'static,
171        >(
172            family: *const pango::ffi::PangoFontFamily,
173            face: *const pango::ffi::PangoFontFace,
174            data: glib::ffi::gpointer,
175        ) -> glib::ffi::gboolean {
176            let family = from_glib_borrow(family);
177            let face = from_glib_borrow(face);
178            let callback = &*(data as *mut P);
179            (*callback)(&family, &face).into_glib()
180        }
181        let filter = Some(filter_func::<P> as _);
182        unsafe extern "C" fn destroy_func<
183            P: Fn(&pango::FontFamily, &pango::FontFace) -> bool + 'static,
184        >(
185            data: glib::ffi::gpointer,
186        ) {
187            let _callback = Box_::from_raw(data as *mut P);
188        }
189        let destroy_call3 = Some(destroy_func::<P> as _);
190        let super_callback0: Box_<P> = filter_data;
191        unsafe {
192            ffi::gtk_font_chooser_set_filter_func(
193                self.as_ref().to_glib_none().0,
194                filter,
195                Box_::into_raw(super_callback0) as *mut _,
196                destroy_call3,
197            );
198        }
199    }
200
201    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
202    #[allow(deprecated)]
203    #[doc(alias = "gtk_font_chooser_set_font")]
204    #[doc(alias = "font")]
205    fn set_font(&self, fontname: &str) {
206        unsafe {
207            ffi::gtk_font_chooser_set_font(
208                self.as_ref().to_glib_none().0,
209                fontname.to_glib_none().0,
210            );
211        }
212    }
213
214    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
215    #[allow(deprecated)]
216    #[doc(alias = "gtk_font_chooser_set_font_desc")]
217    #[doc(alias = "font-desc")]
218    fn set_font_desc(&self, font_desc: &pango::FontDescription) {
219        unsafe {
220            ffi::gtk_font_chooser_set_font_desc(
221                self.as_ref().to_glib_none().0,
222                font_desc.to_glib_none().0,
223            );
224        }
225    }
226
227    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
228    #[allow(deprecated)]
229    #[doc(alias = "gtk_font_chooser_set_font_map")]
230    fn set_font_map(&self, fontmap: Option<&impl IsA<pango::FontMap>>) {
231        unsafe {
232            ffi::gtk_font_chooser_set_font_map(
233                self.as_ref().to_glib_none().0,
234                fontmap.map(|p| p.as_ref()).to_glib_none().0,
235            );
236        }
237    }
238
239    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
240    #[allow(deprecated)]
241    #[doc(alias = "gtk_font_chooser_set_language")]
242    #[doc(alias = "language")]
243    fn set_language(&self, language: &str) {
244        unsafe {
245            ffi::gtk_font_chooser_set_language(
246                self.as_ref().to_glib_none().0,
247                language.to_glib_none().0,
248            );
249        }
250    }
251
252    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
253    #[allow(deprecated)]
254    #[doc(alias = "gtk_font_chooser_set_level")]
255    #[doc(alias = "level")]
256    fn set_level(&self, level: FontChooserLevel) {
257        unsafe {
258            ffi::gtk_font_chooser_set_level(self.as_ref().to_glib_none().0, level.into_glib());
259        }
260    }
261
262    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
263    #[allow(deprecated)]
264    #[doc(alias = "gtk_font_chooser_set_preview_text")]
265    #[doc(alias = "preview-text")]
266    fn set_preview_text(&self, text: &str) {
267        unsafe {
268            ffi::gtk_font_chooser_set_preview_text(
269                self.as_ref().to_glib_none().0,
270                text.to_glib_none().0,
271            );
272        }
273    }
274
275    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
276    #[allow(deprecated)]
277    #[doc(alias = "gtk_font_chooser_set_show_preview_entry")]
278    #[doc(alias = "show-preview-entry")]
279    fn set_show_preview_entry(&self, show_preview_entry: bool) {
280        unsafe {
281            ffi::gtk_font_chooser_set_show_preview_entry(
282                self.as_ref().to_glib_none().0,
283                show_preview_entry.into_glib(),
284            );
285        }
286    }
287
288    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
289    #[doc(alias = "font-activated")]
290    fn connect_font_activated<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
291        unsafe extern "C" fn font_activated_trampoline<
292            P: IsA<FontChooser>,
293            F: Fn(&P, &str) + 'static,
294        >(
295            this: *mut ffi::GtkFontChooser,
296            fontname: *mut std::ffi::c_char,
297            f: glib::ffi::gpointer,
298        ) {
299            let f: &F = &*(f as *const F);
300            f(
301                FontChooser::from_glib_borrow(this).unsafe_cast_ref(),
302                &glib::GString::from_glib_borrow(fontname),
303            )
304        }
305        unsafe {
306            let f: Box_<F> = Box_::new(f);
307            connect_raw(
308                self.as_ptr() as *mut _,
309                c"font-activated".as_ptr() as *const _,
310                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
311                    font_activated_trampoline::<Self, F> as *const (),
312                )),
313                Box_::into_raw(f),
314            )
315        }
316    }
317
318    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
319    #[doc(alias = "font")]
320    fn connect_font_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
321        unsafe extern "C" fn notify_font_trampoline<P: IsA<FontChooser>, F: Fn(&P) + 'static>(
322            this: *mut ffi::GtkFontChooser,
323            _param_spec: glib::ffi::gpointer,
324            f: glib::ffi::gpointer,
325        ) {
326            let f: &F = &*(f as *const F);
327            f(FontChooser::from_glib_borrow(this).unsafe_cast_ref())
328        }
329        unsafe {
330            let f: Box_<F> = Box_::new(f);
331            connect_raw(
332                self.as_ptr() as *mut _,
333                c"notify::font".as_ptr() as *const _,
334                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
335                    notify_font_trampoline::<Self, F> as *const (),
336                )),
337                Box_::into_raw(f),
338            )
339        }
340    }
341
342    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
343    #[doc(alias = "font-desc")]
344    fn connect_font_desc_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
345        unsafe extern "C" fn notify_font_desc_trampoline<
346            P: IsA<FontChooser>,
347            F: Fn(&P) + 'static,
348        >(
349            this: *mut ffi::GtkFontChooser,
350            _param_spec: glib::ffi::gpointer,
351            f: glib::ffi::gpointer,
352        ) {
353            let f: &F = &*(f as *const F);
354            f(FontChooser::from_glib_borrow(this).unsafe_cast_ref())
355        }
356        unsafe {
357            let f: Box_<F> = Box_::new(f);
358            connect_raw(
359                self.as_ptr() as *mut _,
360                c"notify::font-desc".as_ptr() as *const _,
361                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
362                    notify_font_desc_trampoline::<Self, F> as *const (),
363                )),
364                Box_::into_raw(f),
365            )
366        }
367    }
368
369    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
370    #[doc(alias = "font-features")]
371    fn connect_font_features_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
372        unsafe extern "C" fn notify_font_features_trampoline<
373            P: IsA<FontChooser>,
374            F: Fn(&P) + 'static,
375        >(
376            this: *mut ffi::GtkFontChooser,
377            _param_spec: glib::ffi::gpointer,
378            f: glib::ffi::gpointer,
379        ) {
380            let f: &F = &*(f as *const F);
381            f(FontChooser::from_glib_borrow(this).unsafe_cast_ref())
382        }
383        unsafe {
384            let f: Box_<F> = Box_::new(f);
385            connect_raw(
386                self.as_ptr() as *mut _,
387                c"notify::font-features".as_ptr() as *const _,
388                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
389                    notify_font_features_trampoline::<Self, F> as *const (),
390                )),
391                Box_::into_raw(f),
392            )
393        }
394    }
395
396    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
397    #[doc(alias = "language")]
398    fn connect_language_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
399        unsafe extern "C" fn notify_language_trampoline<
400            P: IsA<FontChooser>,
401            F: Fn(&P) + 'static,
402        >(
403            this: *mut ffi::GtkFontChooser,
404            _param_spec: glib::ffi::gpointer,
405            f: glib::ffi::gpointer,
406        ) {
407            let f: &F = &*(f as *const F);
408            f(FontChooser::from_glib_borrow(this).unsafe_cast_ref())
409        }
410        unsafe {
411            let f: Box_<F> = Box_::new(f);
412            connect_raw(
413                self.as_ptr() as *mut _,
414                c"notify::language".as_ptr() as *const _,
415                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
416                    notify_language_trampoline::<Self, F> as *const (),
417                )),
418                Box_::into_raw(f),
419            )
420        }
421    }
422
423    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
424    #[doc(alias = "level")]
425    fn connect_level_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
426        unsafe extern "C" fn notify_level_trampoline<P: IsA<FontChooser>, F: Fn(&P) + 'static>(
427            this: *mut ffi::GtkFontChooser,
428            _param_spec: glib::ffi::gpointer,
429            f: glib::ffi::gpointer,
430        ) {
431            let f: &F = &*(f as *const F);
432            f(FontChooser::from_glib_borrow(this).unsafe_cast_ref())
433        }
434        unsafe {
435            let f: Box_<F> = Box_::new(f);
436            connect_raw(
437                self.as_ptr() as *mut _,
438                c"notify::level".as_ptr() as *const _,
439                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
440                    notify_level_trampoline::<Self, F> as *const (),
441                )),
442                Box_::into_raw(f),
443            )
444        }
445    }
446
447    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
448    #[doc(alias = "preview-text")]
449    fn connect_preview_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
450        unsafe extern "C" fn notify_preview_text_trampoline<
451            P: IsA<FontChooser>,
452            F: Fn(&P) + 'static,
453        >(
454            this: *mut ffi::GtkFontChooser,
455            _param_spec: glib::ffi::gpointer,
456            f: glib::ffi::gpointer,
457        ) {
458            let f: &F = &*(f as *const F);
459            f(FontChooser::from_glib_borrow(this).unsafe_cast_ref())
460        }
461        unsafe {
462            let f: Box_<F> = Box_::new(f);
463            connect_raw(
464                self.as_ptr() as *mut _,
465                c"notify::preview-text".as_ptr() as *const _,
466                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
467                    notify_preview_text_trampoline::<Self, F> as *const (),
468                )),
469                Box_::into_raw(f),
470            )
471        }
472    }
473
474    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
475    #[doc(alias = "show-preview-entry")]
476    fn connect_show_preview_entry_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
477        unsafe extern "C" fn notify_show_preview_entry_trampoline<
478            P: IsA<FontChooser>,
479            F: Fn(&P) + 'static,
480        >(
481            this: *mut ffi::GtkFontChooser,
482            _param_spec: glib::ffi::gpointer,
483            f: glib::ffi::gpointer,
484        ) {
485            let f: &F = &*(f as *const F);
486            f(FontChooser::from_glib_borrow(this).unsafe_cast_ref())
487        }
488        unsafe {
489            let f: Box_<F> = Box_::new(f);
490            connect_raw(
491                self.as_ptr() as *mut _,
492                c"notify::show-preview-entry".as_ptr() as *const _,
493                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
494                    notify_show_preview_entry_trampoline::<Self, F> as *const (),
495                )),
496                Box_::into_raw(f),
497            )
498        }
499    }
500}
501
502impl<O: IsA<FontChooser>> FontChooserExt for O {}