libadwaita/auto/
style_manager.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.git)
4// DO NOT EDIT
5
6#[cfg(feature = "v1_6")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
8use crate::AccentColor;
9use crate::{ffi, ColorScheme};
10use glib::{
11    prelude::*,
12    signal::{connect_raw, SignalHandlerId},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    #[doc(alias = "AdwStyleManager")]
19    pub struct StyleManager(Object<ffi::AdwStyleManager, ffi::AdwStyleManagerClass>);
20
21    match fn {
22        type_ => || ffi::adw_style_manager_get_type(),
23    }
24}
25
26impl StyleManager {
27    #[cfg(feature = "v1_6")]
28    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
29    #[doc(alias = "adw_style_manager_get_accent_color")]
30    #[doc(alias = "get_accent_color")]
31    #[doc(alias = "accent-color")]
32    pub fn accent_color(&self) -> AccentColor {
33        unsafe {
34            from_glib(ffi::adw_style_manager_get_accent_color(
35                self.to_glib_none().0,
36            ))
37        }
38    }
39
40    #[cfg(feature = "v1_6")]
41    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
42    #[doc(alias = "adw_style_manager_get_accent_color_rgba")]
43    #[doc(alias = "get_accent_color_rgba")]
44    #[doc(alias = "accent-color-rgba")]
45    pub fn accent_color_rgba(&self) -> gdk::RGBA {
46        unsafe {
47            from_glib_full(ffi::adw_style_manager_get_accent_color_rgba(
48                self.to_glib_none().0,
49            ))
50        }
51    }
52
53    #[doc(alias = "adw_style_manager_get_color_scheme")]
54    #[doc(alias = "get_color_scheme")]
55    #[doc(alias = "color-scheme")]
56    pub fn color_scheme(&self) -> ColorScheme {
57        unsafe {
58            from_glib(ffi::adw_style_manager_get_color_scheme(
59                self.to_glib_none().0,
60            ))
61        }
62    }
63
64    #[doc(alias = "adw_style_manager_get_dark")]
65    #[doc(alias = "get_dark")]
66    #[doc(alias = "dark")]
67    pub fn is_dark(&self) -> bool {
68        unsafe { from_glib(ffi::adw_style_manager_get_dark(self.to_glib_none().0)) }
69    }
70
71    #[doc(alias = "adw_style_manager_get_display")]
72    #[doc(alias = "get_display")]
73    pub fn display(&self) -> Option<gdk::Display> {
74        unsafe { from_glib_none(ffi::adw_style_manager_get_display(self.to_glib_none().0)) }
75    }
76
77    #[cfg(feature = "v1_7")]
78    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
79    #[doc(alias = "adw_style_manager_get_document_font_name")]
80    #[doc(alias = "get_document_font_name")]
81    #[doc(alias = "document-font-name")]
82    pub fn document_font_name(&self) -> glib::GString {
83        unsafe {
84            from_glib_none(ffi::adw_style_manager_get_document_font_name(
85                self.to_glib_none().0,
86            ))
87        }
88    }
89
90    #[doc(alias = "adw_style_manager_get_high_contrast")]
91    #[doc(alias = "get_high_contrast")]
92    #[doc(alias = "high-contrast")]
93    pub fn is_high_contrast(&self) -> bool {
94        unsafe {
95            from_glib(ffi::adw_style_manager_get_high_contrast(
96                self.to_glib_none().0,
97            ))
98        }
99    }
100
101    #[cfg(feature = "v1_7")]
102    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
103    #[doc(alias = "adw_style_manager_get_monospace_font_name")]
104    #[doc(alias = "get_monospace_font_name")]
105    #[doc(alias = "monospace-font-name")]
106    pub fn monospace_font_name(&self) -> glib::GString {
107        unsafe {
108            from_glib_none(ffi::adw_style_manager_get_monospace_font_name(
109                self.to_glib_none().0,
110            ))
111        }
112    }
113
114    #[cfg(feature = "v1_6")]
115    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
116    #[doc(alias = "adw_style_manager_get_system_supports_accent_colors")]
117    #[doc(alias = "get_system_supports_accent_colors")]
118    #[doc(alias = "system-supports-accent-colors")]
119    pub fn is_system_supports_accent_colors(&self) -> bool {
120        unsafe {
121            from_glib(ffi::adw_style_manager_get_system_supports_accent_colors(
122                self.to_glib_none().0,
123            ))
124        }
125    }
126
127    #[doc(alias = "adw_style_manager_get_system_supports_color_schemes")]
128    #[doc(alias = "get_system_supports_color_schemes")]
129    #[doc(alias = "system-supports-color-schemes")]
130    pub fn system_supports_color_schemes(&self) -> bool {
131        unsafe {
132            from_glib(ffi::adw_style_manager_get_system_supports_color_schemes(
133                self.to_glib_none().0,
134            ))
135        }
136    }
137
138    #[doc(alias = "adw_style_manager_set_color_scheme")]
139    #[doc(alias = "color-scheme")]
140    pub fn set_color_scheme(&self, color_scheme: ColorScheme) {
141        unsafe {
142            ffi::adw_style_manager_set_color_scheme(
143                self.to_glib_none().0,
144                color_scheme.into_glib(),
145            );
146        }
147    }
148
149    #[doc(alias = "adw_style_manager_get_default")]
150    #[doc(alias = "get_default")]
151    #[allow(clippy::should_implement_trait)]
152    pub fn default() -> StyleManager {
153        assert_initialized_main_thread!();
154        unsafe { from_glib_none(ffi::adw_style_manager_get_default()) }
155    }
156
157    #[doc(alias = "adw_style_manager_get_for_display")]
158    #[doc(alias = "get_for_display")]
159    pub fn for_display(display: &gdk::Display) -> StyleManager {
160        assert_initialized_main_thread!();
161        unsafe {
162            from_glib_none(ffi::adw_style_manager_get_for_display(
163                display.to_glib_none().0,
164            ))
165        }
166    }
167
168    #[cfg(feature = "v1_6")]
169    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
170    #[doc(alias = "accent-color")]
171    pub fn connect_accent_color_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
172        unsafe extern "C" fn notify_accent_color_trampoline<F: Fn(&StyleManager) + 'static>(
173            this: *mut ffi::AdwStyleManager,
174            _param_spec: glib::ffi::gpointer,
175            f: glib::ffi::gpointer,
176        ) {
177            let f: &F = &*(f as *const F);
178            f(&from_glib_borrow(this))
179        }
180        unsafe {
181            let f: Box_<F> = Box_::new(f);
182            connect_raw(
183                self.as_ptr() as *mut _,
184                c"notify::accent-color".as_ptr() as *const _,
185                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
186                    notify_accent_color_trampoline::<F> as *const (),
187                )),
188                Box_::into_raw(f),
189            )
190        }
191    }
192
193    #[cfg(feature = "v1_6")]
194    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
195    #[doc(alias = "accent-color-rgba")]
196    pub fn connect_accent_color_rgba_notify<F: Fn(&Self) + 'static>(
197        &self,
198        f: F,
199    ) -> SignalHandlerId {
200        unsafe extern "C" fn notify_accent_color_rgba_trampoline<F: Fn(&StyleManager) + 'static>(
201            this: *mut ffi::AdwStyleManager,
202            _param_spec: glib::ffi::gpointer,
203            f: glib::ffi::gpointer,
204        ) {
205            let f: &F = &*(f as *const F);
206            f(&from_glib_borrow(this))
207        }
208        unsafe {
209            let f: Box_<F> = Box_::new(f);
210            connect_raw(
211                self.as_ptr() as *mut _,
212                c"notify::accent-color-rgba".as_ptr() as *const _,
213                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
214                    notify_accent_color_rgba_trampoline::<F> as *const (),
215                )),
216                Box_::into_raw(f),
217            )
218        }
219    }
220
221    #[doc(alias = "color-scheme")]
222    pub fn connect_color_scheme_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
223        unsafe extern "C" fn notify_color_scheme_trampoline<F: Fn(&StyleManager) + 'static>(
224            this: *mut ffi::AdwStyleManager,
225            _param_spec: glib::ffi::gpointer,
226            f: glib::ffi::gpointer,
227        ) {
228            let f: &F = &*(f as *const F);
229            f(&from_glib_borrow(this))
230        }
231        unsafe {
232            let f: Box_<F> = Box_::new(f);
233            connect_raw(
234                self.as_ptr() as *mut _,
235                c"notify::color-scheme".as_ptr() as *const _,
236                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
237                    notify_color_scheme_trampoline::<F> as *const (),
238                )),
239                Box_::into_raw(f),
240            )
241        }
242    }
243
244    #[doc(alias = "dark")]
245    pub fn connect_dark_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
246        unsafe extern "C" fn notify_dark_trampoline<F: Fn(&StyleManager) + 'static>(
247            this: *mut ffi::AdwStyleManager,
248            _param_spec: glib::ffi::gpointer,
249            f: glib::ffi::gpointer,
250        ) {
251            let f: &F = &*(f as *const F);
252            f(&from_glib_borrow(this))
253        }
254        unsafe {
255            let f: Box_<F> = Box_::new(f);
256            connect_raw(
257                self.as_ptr() as *mut _,
258                c"notify::dark".as_ptr() as *const _,
259                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
260                    notify_dark_trampoline::<F> as *const (),
261                )),
262                Box_::into_raw(f),
263            )
264        }
265    }
266
267    #[cfg(feature = "v1_7")]
268    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
269    #[doc(alias = "document-font-name")]
270    pub fn connect_document_font_name_notify<F: Fn(&Self) + 'static>(
271        &self,
272        f: F,
273    ) -> SignalHandlerId {
274        unsafe extern "C" fn notify_document_font_name_trampoline<
275            F: Fn(&StyleManager) + 'static,
276        >(
277            this: *mut ffi::AdwStyleManager,
278            _param_spec: glib::ffi::gpointer,
279            f: glib::ffi::gpointer,
280        ) {
281            let f: &F = &*(f as *const F);
282            f(&from_glib_borrow(this))
283        }
284        unsafe {
285            let f: Box_<F> = Box_::new(f);
286            connect_raw(
287                self.as_ptr() as *mut _,
288                c"notify::document-font-name".as_ptr() as *const _,
289                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
290                    notify_document_font_name_trampoline::<F> as *const (),
291                )),
292                Box_::into_raw(f),
293            )
294        }
295    }
296
297    #[doc(alias = "high-contrast")]
298    pub fn connect_high_contrast_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
299        unsafe extern "C" fn notify_high_contrast_trampoline<F: Fn(&StyleManager) + 'static>(
300            this: *mut ffi::AdwStyleManager,
301            _param_spec: glib::ffi::gpointer,
302            f: glib::ffi::gpointer,
303        ) {
304            let f: &F = &*(f as *const F);
305            f(&from_glib_borrow(this))
306        }
307        unsafe {
308            let f: Box_<F> = Box_::new(f);
309            connect_raw(
310                self.as_ptr() as *mut _,
311                c"notify::high-contrast".as_ptr() as *const _,
312                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
313                    notify_high_contrast_trampoline::<F> as *const (),
314                )),
315                Box_::into_raw(f),
316            )
317        }
318    }
319
320    #[cfg(feature = "v1_7")]
321    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
322    #[doc(alias = "monospace-font-name")]
323    pub fn connect_monospace_font_name_notify<F: Fn(&Self) + 'static>(
324        &self,
325        f: F,
326    ) -> SignalHandlerId {
327        unsafe extern "C" fn notify_monospace_font_name_trampoline<
328            F: Fn(&StyleManager) + 'static,
329        >(
330            this: *mut ffi::AdwStyleManager,
331            _param_spec: glib::ffi::gpointer,
332            f: glib::ffi::gpointer,
333        ) {
334            let f: &F = &*(f as *const F);
335            f(&from_glib_borrow(this))
336        }
337        unsafe {
338            let f: Box_<F> = Box_::new(f);
339            connect_raw(
340                self.as_ptr() as *mut _,
341                c"notify::monospace-font-name".as_ptr() as *const _,
342                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
343                    notify_monospace_font_name_trampoline::<F> as *const (),
344                )),
345                Box_::into_raw(f),
346            )
347        }
348    }
349
350    #[cfg(feature = "v1_6")]
351    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
352    #[doc(alias = "system-supports-accent-colors")]
353    pub fn connect_system_supports_accent_colors_notify<F: Fn(&Self) + 'static>(
354        &self,
355        f: F,
356    ) -> SignalHandlerId {
357        unsafe extern "C" fn notify_system_supports_accent_colors_trampoline<
358            F: Fn(&StyleManager) + 'static,
359        >(
360            this: *mut ffi::AdwStyleManager,
361            _param_spec: glib::ffi::gpointer,
362            f: glib::ffi::gpointer,
363        ) {
364            let f: &F = &*(f as *const F);
365            f(&from_glib_borrow(this))
366        }
367        unsafe {
368            let f: Box_<F> = Box_::new(f);
369            connect_raw(
370                self.as_ptr() as *mut _,
371                c"notify::system-supports-accent-colors".as_ptr() as *const _,
372                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
373                    notify_system_supports_accent_colors_trampoline::<F> as *const (),
374                )),
375                Box_::into_raw(f),
376            )
377        }
378    }
379
380    #[doc(alias = "system-supports-color-schemes")]
381    pub fn connect_system_supports_color_schemes_notify<F: Fn(&Self) + 'static>(
382        &self,
383        f: F,
384    ) -> SignalHandlerId {
385        unsafe extern "C" fn notify_system_supports_color_schemes_trampoline<
386            F: Fn(&StyleManager) + 'static,
387        >(
388            this: *mut ffi::AdwStyleManager,
389            _param_spec: glib::ffi::gpointer,
390            f: glib::ffi::gpointer,
391        ) {
392            let f: &F = &*(f as *const F);
393            f(&from_glib_borrow(this))
394        }
395        unsafe {
396            let f: Box_<F> = Box_::new(f);
397            connect_raw(
398                self.as_ptr() as *mut _,
399                c"notify::system-supports-color-schemes".as_ptr() as *const _,
400                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
401                    notify_system_supports_color_schemes_trampoline::<F> as *const (),
402                )),
403                Box_::into_raw(f),
404            )
405        }
406    }
407}