diff --git a/src/Library/demos/Power Profile Monitor/main.blp b/src/Library/demos/Power Profile Monitor/main.blp new file mode 100644 index 000000000..4e4555892 --- /dev/null +++ b/src/Library/demos/Power Profile Monitor/main.blp @@ -0,0 +1,32 @@ +using Gtk 4.0; +using Adw 1; + +Adw.ToastOverlay overlay { + Adw.StatusPage { + title: _("Power Profile Monitor"); + description: _("Monitor Power Mode"); + + Box { + spacing: 24; + orientation: vertical; + + Box { + halign: center; + spacing: 6; + Image { + icon-name: "lightbulb-symbolic"; + styles ["dim-label"] + } + Label { + label: _("Try toggling Power Mode to \"Power Saver\" from Settings → Power\n or from Quick Toggles"); + styles ["dim-label"] + } + } + + LinkButton { + label: "API Reference"; + uri: "https://docs.gtk.org/gio/iface.PowerProfileMonitor.html"; + } + } + } +} diff --git a/src/Library/demos/Power Profile Monitor/main.js b/src/Library/demos/Power Profile Monitor/main.js new file mode 100644 index 000000000..604b29d6b --- /dev/null +++ b/src/Library/demos/Power Profile Monitor/main.js @@ -0,0 +1,25 @@ +import Adw from "gi://Adw"; +import Gio from "gi://Gio"; + +const power_profile_monitor = Gio.PowerProfileMonitor.dup_default(); +const overlay = workbench.builder.get_object("overlay"); + +power_profile_monitor.connect("notify::power-saver-enabled", () => { + let toast; + + if (power_profile_monitor.power_saver_enabled) { + toast = new Adw.Toast({ + title: "Backup paused to save power", + button_label: "Resume", + priority: Adw.ToastPriority.HIGH, + }); + } else { + toast = new Adw.Toast({ + title: "Backup resumed", + priority: Adw.ToastPriority.HIGH, + }); + } + + overlay.add_toast(toast); +}); + diff --git a/src/Library/demos/Power Profile Monitor/main.json b/src/Library/demos/Power Profile Monitor/main.json new file mode 100644 index 000000000..3a9be6e2f --- /dev/null +++ b/src/Library/demos/Power Profile Monitor/main.json @@ -0,0 +1,6 @@ +{ + "category": "platform", + "description": "Monitor Power Mode", + "panels": ["code", "preview"], + "autorun": true +}