libhelium/auto/
application.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
6use crate::{ffi, RGBColor};
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 = "HeApplication")]
17    pub struct Application(Object<ffi::HeApplication, ffi::HeApplicationClass>) @extends gtk::Application, gio::Application, @implements gio::ActionGroup, gio::ActionMap;
18
19    match fn {
20        type_ => || ffi::he_application_get_type(),
21    }
22}
23
24impl Application {
25    pub const NONE: Option<&'static Application> = None;
26
27    // rustdoc-stripper-ignore-next
28    /// Creates a new builder-pattern struct instance to construct [`Application`] objects.
29    ///
30    /// This method returns an instance of [`ApplicationBuilder`](crate::builders::ApplicationBuilder) which can be used to create [`Application`] objects.
31    pub fn builder() -> ApplicationBuilder {
32        ApplicationBuilder::new()
33    }
34}
35
36// rustdoc-stripper-ignore-next
37/// A [builder-pattern] type to construct [`Application`] objects.
38///
39/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
40#[must_use = "The builder must be built to be used"]
41pub struct ApplicationBuilder {
42    builder: glib::object::ObjectBuilder<'static, Application>,
43}
44
45impl ApplicationBuilder {
46    fn new() -> Self {
47        Self {
48            builder: glib::object::Object::builder(),
49        }
50    }
51
52    pub fn default_accent_color(self, default_accent_color: &RGBColor) -> Self {
53        Self {
54            builder: self
55                .builder
56                .property("default-accent-color", default_accent_color),
57        }
58    }
59
60    pub fn override_accent_color(self, override_accent_color: bool) -> Self {
61        Self {
62            builder: self
63                .builder
64                .property("override-accent-color", override_accent_color),
65        }
66    }
67
68    pub fn override_dark_style(self, override_dark_style: bool) -> Self {
69        Self {
70            builder: self
71                .builder
72                .property("override-dark-style", override_dark_style),
73        }
74    }
75
76    pub fn override_contrast(self, override_contrast: bool) -> Self {
77        Self {
78            builder: self
79                .builder
80                .property("override-contrast", override_contrast),
81        }
82    }
83
84    pub fn default_contrast(self, default_contrast: f64) -> Self {
85        Self {
86            builder: self.builder.property("default-contrast", default_contrast),
87        }
88    }
89
90    pub fn is_content(self, is_content: bool) -> Self {
91        Self {
92            builder: self.builder.property("is-content", is_content),
93        }
94    }
95
96    pub fn is_mono(self, is_mono: bool) -> Self {
97        Self {
98            builder: self.builder.property("is-mono", is_mono),
99        }
100    }
101
102    pub fn menubar(self, menubar: &impl IsA<gio::MenuModel>) -> Self {
103        Self {
104            builder: self.builder.property("menubar", menubar.clone().upcast()),
105        }
106    }
107
108    pub fn register_session(self, register_session: bool) -> Self {
109        Self {
110            builder: self.builder.property("register-session", register_session),
111        }
112    }
113
114    pub fn application_id(self, application_id: impl Into<glib::GString>) -> Self {
115        Self {
116            builder: self
117                .builder
118                .property("application-id", application_id.into()),
119        }
120    }
121
122    pub fn flags(self, flags: gio::ApplicationFlags) -> Self {
123        Self {
124            builder: self.builder.property("flags", flags),
125        }
126    }
127
128    pub fn inactivity_timeout(self, inactivity_timeout: u32) -> Self {
129        Self {
130            builder: self
131                .builder
132                .property("inactivity-timeout", inactivity_timeout),
133        }
134    }
135
136    pub fn resource_base_path(self, resource_base_path: impl Into<glib::GString>) -> Self {
137        Self {
138            builder: self
139                .builder
140                .property("resource-base-path", resource_base_path.into()),
141        }
142    }
143
144    #[cfg(feature = "gio_v2_80")]
145    #[cfg_attr(docsrs, doc(cfg(feature = "gio_v2_80")))]
146    pub fn version(self, version: impl Into<glib::GString>) -> Self {
147        Self {
148            builder: self.builder.property("version", version.into()),
149        }
150    }
151
152    // rustdoc-stripper-ignore-next
153    /// Build the [`Application`].
154    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
155    pub fn build(self) -> Application {
156        let ret = self.builder.build();
157        {
158            Application::register_startup_hook(&ret);
159        }
160        ret
161    }
162}
163
164pub trait HeApplicationExt: IsA<Application> + 'static {
165    #[doc(alias = "he_application_get_effective_accent_color")]
166    #[doc(alias = "get_effective_accent_color")]
167    fn effective_accent_color(&self) -> Option<RGBColor> {
168        unsafe {
169            from_glib_full(ffi::he_application_get_effective_accent_color(
170                self.as_ref().to_glib_none().0,
171            ))
172        }
173    }
174
175    #[doc(alias = "he_application_get_default_accent_color")]
176    #[doc(alias = "get_default_accent_color")]
177    fn default_accent_color(&self) -> Option<RGBColor> {
178        unsafe {
179            from_glib_none(ffi::he_application_get_default_accent_color(
180                self.as_ref().to_glib_none().0,
181            ))
182        }
183    }
184
185    #[doc(alias = "he_application_get_override_accent_color")]
186    #[doc(alias = "get_override_accent_color")]
187    fn is_override_accent_color(&self) -> bool {
188        unsafe {
189            from_glib(ffi::he_application_get_override_accent_color(
190                self.as_ref().to_glib_none().0,
191            ))
192        }
193    }
194
195    #[doc(alias = "he_application_set_override_accent_color")]
196    fn set_override_accent_color(&self, value: bool) {
197        unsafe {
198            ffi::he_application_set_override_accent_color(
199                self.as_ref().to_glib_none().0,
200                value.into_glib(),
201            );
202        }
203    }
204
205    #[doc(alias = "he_application_get_override_dark_style")]
206    #[doc(alias = "get_override_dark_style")]
207    fn is_override_dark_style(&self) -> bool {
208        unsafe {
209            from_glib(ffi::he_application_get_override_dark_style(
210                self.as_ref().to_glib_none().0,
211            ))
212        }
213    }
214
215    #[doc(alias = "he_application_set_override_dark_style")]
216    fn set_override_dark_style(&self, value: bool) {
217        unsafe {
218            ffi::he_application_set_override_dark_style(
219                self.as_ref().to_glib_none().0,
220                value.into_glib(),
221            );
222        }
223    }
224
225    #[doc(alias = "he_application_get_override_contrast")]
226    #[doc(alias = "get_override_contrast")]
227    fn is_override_contrast(&self) -> bool {
228        unsafe {
229            from_glib(ffi::he_application_get_override_contrast(
230                self.as_ref().to_glib_none().0,
231            ))
232        }
233    }
234
235    #[doc(alias = "he_application_set_override_contrast")]
236    fn set_override_contrast(&self, value: bool) {
237        unsafe {
238            ffi::he_application_set_override_contrast(
239                self.as_ref().to_glib_none().0,
240                value.into_glib(),
241            );
242        }
243    }
244
245    #[doc(alias = "he_application_get_default_contrast")]
246    #[doc(alias = "get_default_contrast")]
247    fn default_contrast(&self) -> f64 {
248        unsafe { ffi::he_application_get_default_contrast(self.as_ref().to_glib_none().0) }
249    }
250
251    #[doc(alias = "he_application_set_default_contrast")]
252    fn set_default_contrast(&self, value: f64) {
253        unsafe {
254            ffi::he_application_set_default_contrast(self.as_ref().to_glib_none().0, value);
255        }
256    }
257
258    #[doc(alias = "he_application_get_is_content")]
259    #[doc(alias = "get_is_content")]
260    fn is_content(&self) -> bool {
261        unsafe {
262            from_glib(ffi::he_application_get_is_content(
263                self.as_ref().to_glib_none().0,
264            ))
265        }
266    }
267
268    #[doc(alias = "he_application_set_is_content")]
269    fn set_is_content(&self, value: bool) {
270        unsafe {
271            ffi::he_application_set_is_content(self.as_ref().to_glib_none().0, value.into_glib());
272        }
273    }
274
275    #[doc(alias = "he_application_get_is_mono")]
276    #[doc(alias = "get_is_mono")]
277    fn is_mono(&self) -> bool {
278        unsafe {
279            from_glib(ffi::he_application_get_is_mono(
280                self.as_ref().to_glib_none().0,
281            ))
282        }
283    }
284
285    #[doc(alias = "he_application_set_is_mono")]
286    fn set_is_mono(&self, value: bool) {
287        unsafe {
288            ffi::he_application_set_is_mono(self.as_ref().to_glib_none().0, value.into_glib());
289        }
290    }
291
292    #[doc(alias = "accent-color-changed")]
293    fn connect_accent_color_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
294        unsafe extern "C" fn accent_color_changed_trampoline<
295            P: IsA<Application>,
296            F: Fn(&P) + 'static,
297        >(
298            this: *mut ffi::HeApplication,
299            f: glib::ffi::gpointer,
300        ) {
301            let f: &F = &*(f as *const F);
302            f(Application::from_glib_borrow(this).unsafe_cast_ref())
303        }
304        unsafe {
305            let f: Box_<F> = Box_::new(f);
306            connect_raw(
307                self.as_ptr() as *mut _,
308                c"accent-color-changed".as_ptr() as *const _,
309                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
310                    accent_color_changed_trampoline::<Self, F> as *const (),
311                )),
312                Box_::into_raw(f),
313            )
314        }
315    }
316
317    #[doc(alias = "default-accent-color")]
318    fn connect_default_accent_color_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
319        unsafe extern "C" fn notify_default_accent_color_trampoline<
320            P: IsA<Application>,
321            F: Fn(&P) + 'static,
322        >(
323            this: *mut ffi::HeApplication,
324            _param_spec: glib::ffi::gpointer,
325            f: glib::ffi::gpointer,
326        ) {
327            let f: &F = &*(f as *const F);
328            f(Application::from_glib_borrow(this).unsafe_cast_ref())
329        }
330        unsafe {
331            let f: Box_<F> = Box_::new(f);
332            connect_raw(
333                self.as_ptr() as *mut _,
334                c"notify::default-accent-color".as_ptr() as *const _,
335                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
336                    notify_default_accent_color_trampoline::<Self, F> as *const (),
337                )),
338                Box_::into_raw(f),
339            )
340        }
341    }
342
343    #[doc(alias = "override-accent-color")]
344    fn connect_override_accent_color_notify<F: Fn(&Self) + 'static>(
345        &self,
346        f: F,
347    ) -> SignalHandlerId {
348        unsafe extern "C" fn notify_override_accent_color_trampoline<
349            P: IsA<Application>,
350            F: Fn(&P) + 'static,
351        >(
352            this: *mut ffi::HeApplication,
353            _param_spec: glib::ffi::gpointer,
354            f: glib::ffi::gpointer,
355        ) {
356            let f: &F = &*(f as *const F);
357            f(Application::from_glib_borrow(this).unsafe_cast_ref())
358        }
359        unsafe {
360            let f: Box_<F> = Box_::new(f);
361            connect_raw(
362                self.as_ptr() as *mut _,
363                c"notify::override-accent-color".as_ptr() as *const _,
364                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
365                    notify_override_accent_color_trampoline::<Self, F> as *const (),
366                )),
367                Box_::into_raw(f),
368            )
369        }
370    }
371
372    #[doc(alias = "override-dark-style")]
373    fn connect_override_dark_style_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
374        unsafe extern "C" fn notify_override_dark_style_trampoline<
375            P: IsA<Application>,
376            F: Fn(&P) + 'static,
377        >(
378            this: *mut ffi::HeApplication,
379            _param_spec: glib::ffi::gpointer,
380            f: glib::ffi::gpointer,
381        ) {
382            let f: &F = &*(f as *const F);
383            f(Application::from_glib_borrow(this).unsafe_cast_ref())
384        }
385        unsafe {
386            let f: Box_<F> = Box_::new(f);
387            connect_raw(
388                self.as_ptr() as *mut _,
389                c"notify::override-dark-style".as_ptr() as *const _,
390                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
391                    notify_override_dark_style_trampoline::<Self, F> as *const (),
392                )),
393                Box_::into_raw(f),
394            )
395        }
396    }
397
398    #[doc(alias = "override-contrast")]
399    fn connect_override_contrast_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
400        unsafe extern "C" fn notify_override_contrast_trampoline<
401            P: IsA<Application>,
402            F: Fn(&P) + 'static,
403        >(
404            this: *mut ffi::HeApplication,
405            _param_spec: glib::ffi::gpointer,
406            f: glib::ffi::gpointer,
407        ) {
408            let f: &F = &*(f as *const F);
409            f(Application::from_glib_borrow(this).unsafe_cast_ref())
410        }
411        unsafe {
412            let f: Box_<F> = Box_::new(f);
413            connect_raw(
414                self.as_ptr() as *mut _,
415                c"notify::override-contrast".as_ptr() as *const _,
416                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
417                    notify_override_contrast_trampoline::<Self, F> as *const (),
418                )),
419                Box_::into_raw(f),
420            )
421        }
422    }
423
424    #[doc(alias = "default-contrast")]
425    fn connect_default_contrast_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
426        unsafe extern "C" fn notify_default_contrast_trampoline<
427            P: IsA<Application>,
428            F: Fn(&P) + 'static,
429        >(
430            this: *mut ffi::HeApplication,
431            _param_spec: glib::ffi::gpointer,
432            f: glib::ffi::gpointer,
433        ) {
434            let f: &F = &*(f as *const F);
435            f(Application::from_glib_borrow(this).unsafe_cast_ref())
436        }
437        unsafe {
438            let f: Box_<F> = Box_::new(f);
439            connect_raw(
440                self.as_ptr() as *mut _,
441                c"notify::default-contrast".as_ptr() as *const _,
442                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
443                    notify_default_contrast_trampoline::<Self, F> as *const (),
444                )),
445                Box_::into_raw(f),
446            )
447        }
448    }
449
450    #[doc(alias = "is-content")]
451    fn connect_is_content_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
452        unsafe extern "C" fn notify_is_content_trampoline<
453            P: IsA<Application>,
454            F: Fn(&P) + 'static,
455        >(
456            this: *mut ffi::HeApplication,
457            _param_spec: glib::ffi::gpointer,
458            f: glib::ffi::gpointer,
459        ) {
460            let f: &F = &*(f as *const F);
461            f(Application::from_glib_borrow(this).unsafe_cast_ref())
462        }
463        unsafe {
464            let f: Box_<F> = Box_::new(f);
465            connect_raw(
466                self.as_ptr() as *mut _,
467                c"notify::is-content".as_ptr() as *const _,
468                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
469                    notify_is_content_trampoline::<Self, F> as *const (),
470                )),
471                Box_::into_raw(f),
472            )
473        }
474    }
475
476    #[doc(alias = "is-mono")]
477    fn connect_is_mono_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
478        unsafe extern "C" fn notify_is_mono_trampoline<P: IsA<Application>, F: Fn(&P) + 'static>(
479            this: *mut ffi::HeApplication,
480            _param_spec: glib::ffi::gpointer,
481            f: glib::ffi::gpointer,
482        ) {
483            let f: &F = &*(f as *const F);
484            f(Application::from_glib_borrow(this).unsafe_cast_ref())
485        }
486        unsafe {
487            let f: Box_<F> = Box_::new(f);
488            connect_raw(
489                self.as_ptr() as *mut _,
490                c"notify::is-mono".as_ptr() as *const _,
491                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
492                    notify_is_mono_trampoline::<Self, F> as *const (),
493                )),
494                Box_::into_raw(f),
495            )
496        }
497    }
498}
499
500impl<O: IsA<Application>> HeApplicationExt for O {}