-
-
Notifications
You must be signed in to change notification settings - Fork 87
/
main.js
37 lines (30 loc) · 929 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import Xdp from "gi://Xdp";
import XdpGtk from "gi://XdpGtk4";
import Gio from "gi://Gio";
Gio._promisify(Xdp.Portal.prototype, "compose_email", "compose_email_finish");
const portal = new Xdp.Portal();
const parent = XdpGtk.parent_new_gtk(workbench.window);
const button = workbench.builder.get_object("button");
const entry = workbench.builder.get_object("entry");
async function onClicked() {
const email_address = entry.get_text();
const success = await portal.compose_email(
parent,
[email_address], // addresses
null, // cc
null, // bcc
"Email from Workbench", // subject
"Hello World!", // body
null, // attachments
Xdp.EmailFlags.NONE, // flags
null, // cancellable
);
if (success) {
console.log("Success");
} else {
console.log("Failure, verify that you have an email application.");
}
}
button.connect("clicked", () => {
onClicked().catch(logError);
});