[gnome-boxes/wip/run-in-bg: 10/13] 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: 10/13] libvirt-machine-properties: Verify that our Flatpak is authorized to run in bg
- Date: Tue, 15 Dec 2020 10:28:56 +0000 (UTC)
commit d18426d487db1a5bb2546e4b215425bf939d4619
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 | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
---
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 2bd89153..cbfe53db 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -758,11 +758,36 @@ private void on_vcpus_changed (Boxes.Property property, int vcpus) {
toggle.notify["active"].connect ((tooltip) => {
box.tooltip_text = toggle.active? _("ā%sā will not be paused automatically.").printf (name) :
_("ā%sā will be paused automatically to save
resources.").printf (name);
+ if (toggle.get_active ())
+ 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) {
+ debug ("User authorized Boxes to run in background");
+
+ return;
+ }
+
+ 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);
+ }
+ });
+ }
+
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]