[gnome-boxes/wip/run-in-bg] libvirt-machine-properties: Verify that our Flatpak is authorized to run in bg
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/wip/run-in-bg] libvirt-machine-properties: Verify that our Flatpak is authorized to run in bg
- Date: Tue, 8 Dec 2020 10:42:02 +0000 (UTC)
commit 046bd92ef6258ea006826c5b2a6246ee93b67c71
Author: Felipe Borges <felipeborges gnome org>
Date: Tue Dec 8 11:37:51 2020 +0100
libvirt-machine-properties: Verify that our Flatpak is authorized to run in bg
Otherwise we shouldn't let users set VMs to "Run in background".
See #379
src/libvirt-machine-properties.vala | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
---
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 2bd89153..270acaca 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -760,9 +760,32 @@ private void on_vcpus_changed (Boxes.Property property, int vcpus) {
_("ā%sā will be paused automatically to save
resources.").printf (name);
});
+ toggle.notify["active"].connect (on_run_in_bg);
+
return box;
}
+ private async void on_run_in_bg () {
+ if (!machine.run_in_bg)
+ return;
+
+ yield Portals.get_default ().request_to_run_in_background (
+ (response, results) => {
+ if (response != 0) {
+ try {
+ machine.run_in_bg = false;
+
+ var msg = _("Boxes is not authorized to run in the background");
+ machine.window.notificationbar.display_error (msg);
+ } catch (GLib.Error error) {
+ warning ("Failed to reset VM's run-in-bg setting: %s", error.message);
+ }
+ } else {
+ debug ("User authorized Boxes to run in background");
+ }
+ });
+ }
+
private Boxes.SnapshotsProperty add_snapshots_property (ref List<Boxes.Property> list) {
var property = new SnapshotsProperty (machine);
list.append (property);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]