electron_sys/interface/
notification_options.rs

1use crate::class::NativeImage;
2use js_sys::JsString;
3use wasm_bindgen::prelude::*;
4
5#[wasm_bindgen]
6#[derive(Clone, Debug, PartialEq)]
7pub struct NotificationOptions {
8    actions: Option<Box<[JsValue]>>,
9    body: JsString,
10    close_button_text: Option<JsString>,
11    has_reply: Option<bool>,
12    icon: Option<NativeImage>,
13    reply_placeholder: Option<JsString>,
14    silent: Option<bool>,
15    sound: Option<JsString>,
16    subtitle: Option<JsString>,
17    timeout_type: Option<JsString>,
18    title: JsString,
19    urgency: Option<JsString>,
20}
21
22#[wasm_bindgen]
23impl NotificationOptions {
24    #[allow(clippy::too_many_arguments)]
25    #[wasm_bindgen(constructor)]
26    pub fn new(
27        actions: Option<Box<[JsValue]>>,
28        body: JsString,
29        close_button_text: Option<JsString>,
30        has_reply: Option<bool>,
31        icon: Option<NativeImage>,
32        reply_placeholder: Option<JsString>,
33        silent: Option<bool>,
34        sound: Option<JsString>,
35        subtitle: Option<JsString>,
36        timeout_type: Option<JsString>,
37        title: JsString,
38        urgency: Option<JsString>,
39    ) -> NotificationOptions {
40        NotificationOptions {
41            actions,
42            body,
43            close_button_text,
44            has_reply,
45            icon,
46            reply_placeholder,
47            silent,
48            sound,
49            subtitle,
50            timeout_type,
51            title,
52            urgency,
53        }
54    }
55
56    #[wasm_bindgen(getter)]
57    pub fn actions(&self) -> Option<Box<[JsValue]>> {
58        self.actions.clone()
59    }
60
61    #[wasm_bindgen(setter)]
62    pub fn set_actions(&mut self, value: Option<Box<[JsValue]>>) {
63        self.actions = value;
64    }
65
66    #[wasm_bindgen(getter)]
67    pub fn body(&self) -> JsString {
68        self.body.clone()
69    }
70
71    #[wasm_bindgen(setter)]
72    pub fn set_body(&mut self, value: JsString) {
73        self.body = value;
74    }
75
76    #[wasm_bindgen(getter)]
77    pub fn close_button_text(&self) -> Option<JsString> {
78        self.close_button_text.clone()
79    }
80
81    #[wasm_bindgen(setter)]
82    pub fn set_close_button_text(&mut self, value: Option<JsString>) {
83        self.close_button_text = value;
84    }
85
86    #[wasm_bindgen(getter)]
87    pub fn has_reply(&self) -> Option<bool> {
88        self.has_reply
89    }
90
91    #[wasm_bindgen(setter)]
92    pub fn set_has_reply(&mut self, value: Option<bool>) {
93        self.has_reply = value;
94    }
95
96    #[wasm_bindgen(getter)]
97    pub fn icon(&self) -> Option<NativeImage> {
98        self.icon.clone()
99    }
100
101    #[wasm_bindgen(setter)]
102    pub fn set_icon(&mut self, value: Option<NativeImage>) {
103        self.icon = value;
104    }
105
106    #[wasm_bindgen(getter)]
107    pub fn reply_placeholder(&self) -> Option<JsString> {
108        self.reply_placeholder.clone()
109    }
110
111    #[wasm_bindgen(setter)]
112    pub fn set_reply_placeholder(&mut self, value: Option<JsString>) {
113        self.reply_placeholder = value;
114    }
115
116    #[wasm_bindgen(getter)]
117    pub fn silent(&self) -> Option<bool> {
118        self.silent
119    }
120
121    #[wasm_bindgen(setter)]
122    pub fn set_silent(&mut self, value: Option<bool>) {
123        self.silent = value;
124    }
125
126    #[wasm_bindgen(getter)]
127    pub fn sound(&self) -> Option<JsString> {
128        self.sound.clone()
129    }
130
131    #[wasm_bindgen(setter)]
132    pub fn set_sound(&mut self, value: Option<JsString>) {
133        self.sound = value;
134    }
135
136    #[wasm_bindgen(getter)]
137    pub fn subtitle(&self) -> Option<JsString> {
138        self.subtitle.clone()
139    }
140
141    #[wasm_bindgen(setter)]
142    pub fn set_subtitle(&mut self, value: Option<JsString>) {
143        self.subtitle = value;
144    }
145
146    #[wasm_bindgen(getter)]
147    pub fn timeout_type(&self) -> Option<JsString> {
148        self.timeout_type.clone()
149    }
150
151    #[wasm_bindgen(setter)]
152    pub fn set_timeout_type(&mut self, value: Option<JsString>) {
153        self.timeout_type = value;
154    }
155
156    #[wasm_bindgen(getter)]
157    pub fn title(&self) -> JsString {
158        self.title.clone()
159    }
160
161    #[wasm_bindgen(setter)]
162    pub fn set_title(&mut self, value: JsString) {
163        self.title = value;
164    }
165
166    #[wasm_bindgen(getter)]
167    pub fn urgency(&self) -> Option<JsString> {
168        self.urgency.clone()
169    }
170
171    #[wasm_bindgen(setter)]
172    pub fn set_urgency(&mut self, value: Option<JsString>) {
173        self.urgency = value;
174    }
175}