[gnome-boxes/wip/text-editor: 7/8] text-editor: Notify when custom configs can't be applied




commit e944337ff24f35c562aaa5807132acadd0a2fcdb
Author: Felipe Borges <felipeborges gnome org>
Date:   Fri Aug 7 15:49:53 2020 +0200

    text-editor: Notify when custom configs can't be applied

 src/text-editor.vala | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
---
diff --git a/src/text-editor.vala b/src/text-editor.vala
index d2a7ae87..6b53129b 100644
--- a/src/text-editor.vala
+++ b/src/text-editor.vala
@@ -39,7 +39,14 @@ public async void save () {
 
         var saved = yield save_original_config (config);
 
+
         var xml = view.buffer.text;
+        if (config.to_xml () == xml) {
+            debug ("Nothing changed in the VM configuration");
+            return;
+        }
+
+
         GVirConfig.Domain? custom_config = null;
         try {
             custom_config = new GVirConfig.Domain.from_xml (xml);
@@ -49,7 +56,22 @@ public async void save () {
 
         add_metadata (custom_config);
 
-        machine.domain.set_config (custom_config);
+        try {
+            machine.domain.set_config (custom_config);
+        } catch (GLib.Error error) {
+            warning ("Failed to save custom VM configuration: %s", error.message);
+            var msg = _("Boxes failed to save VM configuration changes: %s");
+            App.app.main_window.notificationbar.display_error (msg);
+
+            return;
+        }
+
+        if (machine.is_running) {
+            var message = _("Changes require restart of ā€œ%sā€.").printf (machine.name);
+            App.app.main_window.notificationbar.display_for_action (message, _("_Restart"), () => {
+                machine.restart ();
+            });
+        }
     }
 
     private void add_metadata (GVirConfig.Domain config) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]