gio/auto/
notification.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
5use crate::{ffi, Icon, NotificationPriority};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    #[doc(alias = "GNotification")]
10    pub struct Notification(Object<ffi::GNotification>);
11
12    match fn {
13        type_ => || ffi::g_notification_get_type(),
14    }
15}
16
17impl Notification {
18    #[doc(alias = "g_notification_new")]
19    pub fn new(title: &str) -> Notification {
20        unsafe { from_glib_full(ffi::g_notification_new(title.to_glib_none().0)) }
21    }
22
23    #[doc(alias = "g_notification_add_button")]
24    pub fn add_button(&self, label: &str, detailed_action: &str) {
25        unsafe {
26            ffi::g_notification_add_button(
27                self.to_glib_none().0,
28                label.to_glib_none().0,
29                detailed_action.to_glib_none().0,
30            );
31        }
32    }
33
34    //#[doc(alias = "g_notification_add_button_with_target")]
35    //pub fn add_button_with_target(&self, label: &str, action: &str, target_format: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
36    //    unsafe { TODO: call ffi:g_notification_add_button_with_target() }
37    //}
38
39    #[doc(alias = "g_notification_add_button_with_target_value")]
40    pub fn add_button_with_target_value(
41        &self,
42        label: &str,
43        action: &str,
44        target: Option<&glib::Variant>,
45    ) {
46        unsafe {
47            ffi::g_notification_add_button_with_target_value(
48                self.to_glib_none().0,
49                label.to_glib_none().0,
50                action.to_glib_none().0,
51                target.to_glib_none().0,
52            );
53        }
54    }
55
56    #[doc(alias = "g_notification_set_body")]
57    pub fn set_body(&self, body: Option<&str>) {
58        unsafe {
59            ffi::g_notification_set_body(self.to_glib_none().0, body.to_glib_none().0);
60        }
61    }
62
63    #[cfg(feature = "v2_70")]
64    #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
65    #[doc(alias = "g_notification_set_category")]
66    pub fn set_category(&self, category: Option<&str>) {
67        unsafe {
68            ffi::g_notification_set_category(self.to_glib_none().0, category.to_glib_none().0);
69        }
70    }
71
72    #[doc(alias = "g_notification_set_default_action")]
73    pub fn set_default_action(&self, detailed_action: &str) {
74        unsafe {
75            ffi::g_notification_set_default_action(
76                self.to_glib_none().0,
77                detailed_action.to_glib_none().0,
78            );
79        }
80    }
81
82    //#[doc(alias = "g_notification_set_default_action_and_target")]
83    //pub fn set_default_action_and_target(&self, action: &str, target_format: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
84    //    unsafe { TODO: call ffi:g_notification_set_default_action_and_target() }
85    //}
86
87    #[doc(alias = "g_notification_set_default_action_and_target_value")]
88    pub fn set_default_action_and_target_value(
89        &self,
90        action: &str,
91        target: Option<&glib::Variant>,
92    ) {
93        unsafe {
94            ffi::g_notification_set_default_action_and_target_value(
95                self.to_glib_none().0,
96                action.to_glib_none().0,
97                target.to_glib_none().0,
98            );
99        }
100    }
101
102    #[doc(alias = "g_notification_set_icon")]
103    pub fn set_icon(&self, icon: &impl IsA<Icon>) {
104        unsafe {
105            ffi::g_notification_set_icon(self.to_glib_none().0, icon.as_ref().to_glib_none().0);
106        }
107    }
108
109    #[doc(alias = "g_notification_set_priority")]
110    pub fn set_priority(&self, priority: NotificationPriority) {
111        unsafe {
112            ffi::g_notification_set_priority(self.to_glib_none().0, priority.into_glib());
113        }
114    }
115
116    #[doc(alias = "g_notification_set_title")]
117    pub fn set_title(&self, title: &str) {
118        unsafe {
119            ffi::g_notification_set_title(self.to_glib_none().0, title.to_glib_none().0);
120        }
121    }
122}