[gnome-boxes/preferences-snapshots-display-errors-in-toasts: 2/3] preferences, snapshots: Display error messages in Toast




commit 29f4493b1dc19a3539a92840711eb3448528e1e7
Author: Felipe Borges <felipeborges gnome org>
Date:   Thu Jan 20 17:32:59 2022 +0100

    preferences, snapshots: Display error messages in Toast
    
    To be consistent with the Toasts that allow for undoing deletions.

 src/preferences/snapshots-page.vala | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/src/preferences/snapshots-page.vala b/src/preferences/snapshots-page.vala
index cabc0acb..67804b3f 100644
--- a/src/preferences/snapshots-page.vala
+++ b/src/preferences/snapshots-page.vala
@@ -7,7 +7,21 @@
 
     [GtkChild]
     private unowned Gtk.Overlay toast_overlay;
-    private Boxes.PreferencesToast toast;
+    private Boxes.PreferencesToast _toast;
+    private Boxes.PreferencesToast toast {
+        set {
+            if (_toast != null) {
+                _toast.dismiss ();
+            }
+
+            _toast = value;
+            toast_overlay.add_overlay (_toast);
+        }
+
+        get {
+            return _toast;
+        }
+    }
 
     [GtkChild]
     private unowned Hdy.PreferencesGroup preferences_group;
@@ -112,7 +126,6 @@ private void on_row_deleted (Boxes.PreferencesToast new_toast) {
         }
 
         toast = new_toast;
-        toast_overlay.add_overlay (toast);
     }
 
     private int config_sort_func (Gtk.ListBoxRow row1, Gtk.ListBoxRow row2) {
@@ -147,8 +160,11 @@ private async void create_snapshot () {
             listbox.add (create_snapshot_row (new_snapshot));
         } catch (GLib.Error e) {
             var msg = _("Failed to create snapshot of %s").printf (machine.name);
-            machine.window.notificationbar.display_error (msg);
             warning (e.message);
+
+            toast = new Boxes.PreferencesToast () {
+                message = msg
+            };
         }
         this.activity = null;
 


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