-
-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathmain.py
More file actions
52 lines (36 loc) · 1.19 KB
/
main.py
File metadata and controls
52 lines (36 loc) · 1.19 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import gi
gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")
from gi.repository import Gtk, GLib, Gio, Adw
import workbench
overlay: Adw.ToastOverlay = workbench.builder.get_object("overlay")
button_simple: Gtk.Button = workbench.builder.get_object("button_simple")
def simple(_):
toast = Adw.Toast(
title="Toasts are delicious!",
timeout=1,
)
toast.connect("dismissed", lambda _: button_simple.set_sensitive(True))
overlay.add_toast(toast)
button_simple.set_sensitive(False)
button_simple.connect("clicked", simple)
def advanced(_):
message_id = "42"
toast = Adw.Toast(
title="Message sent",
button_label="Undo",
action_name="win.undo",
action_target=GLib.Variant.new_string(message_id),
priority=Adw.ToastPriority.HIGH,
)
overlay.add_toast(toast)
workbench.builder.get_object("button_advanced").connect("clicked", advanced)
action_console = Gio.SimpleAction(
name="undo",
parameter_type=GLib.VariantType("s"),
)
def on_activate(_self, target):
value = target.unpack()
print(f"undo ${value}")
action_console.connect("activate", on_activate)
workbench.window.add_action(action_console)