File tree 1 file changed +41
-0
lines changed
1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ import gi
2
+
3
+ gi .require_version ("Xdp" , "1.0" )
4
+ gi .require_version ("XdpGtk4" , "1.0" )
5
+ from gi .repository import Gio , Xdp , XdpGtk4
6
+ import workbench
7
+
8
+ portal = Xdp .Portal ()
9
+ parent = XdpGtk4 .parent_new_gtk (workbench .window )
10
+
11
+ button = workbench .builder .get_object ("button" )
12
+ entry = workbench .builder .get_object ("entry" )
13
+
14
+
15
+ def on_compose_opened (portal , result ):
16
+ success = portal .compose_email_finish (result )
17
+
18
+ if success :
19
+ print ("Success" )
20
+ else :
21
+ print ("Failure, verify that you have an email application." )
22
+
23
+
24
+ def on_clicked (_button ):
25
+ email_address = entry .get_text ()
26
+
27
+ portal .compose_email (
28
+ parent ,
29
+ [email_address ], # addresses
30
+ None , # cc
31
+ None , # bcc
32
+ "Email from Workbench" , # subject
33
+ "Hello World!" , # body
34
+ None , # attachments
35
+ Xdp .EmailFlags .NONE , # flags
36
+ None , # cancellable
37
+ on_compose_opened , # callback
38
+ )
39
+
40
+
41
+ button .connect ("clicked" , on_clicked )
You can’t perform that action at this time.
0 commit comments