[gnome-boxes/wip/text-editor: 15/16] text-editor: Notify when custom configs can't be applied
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/wip/text-editor: 15/16] text-editor: Notify when custom configs can't be applied
- Date: Fri, 7 Aug 2020 13:58:50 +0000 (UTC)
commit 06f02adfed1651d62780bc1ebcf306f5bc8b6138
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]