[gnome-boxes/preferences-snapshots-display-errors-in-toasts: 1/3] preferences, toast: Make PreferencesToast display simple errors




commit 54bb1c4ed80d01a28b767dd803b53b1e503b8b19
Author: Felipe Borges <felipeborges gnome org>
Date:   Thu Jan 20 17:09:27 2022 +0100

    preferences, toast: Make PreferencesToast display simple errors
    
    These are messages that don't have an action button assigned to it.
    
    Let's hide the button and only show when there's an action function
    assigned.

 data/ui/preferences/preferences-toast.ui | 2 +-
 src/preferences/preferences-toast.vala   | 1 +
 src/preferences/snapshot-list-row.vala   | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/data/ui/preferences/preferences-toast.ui b/data/ui/preferences/preferences-toast.ui
index 911f7253..eadcf563 100644
--- a/data/ui/preferences/preferences-toast.ui
+++ b/data/ui/preferences/preferences-toast.ui
@@ -22,7 +22,7 @@
 
     <child>
       <object class="GtkButton" id="button">
-        <property name="visible">True</property>
+        <property name="visible">False</property>
         <property name="valign">center</property>
         <property name="label" translatable="yes">Undo</property>
         <signal name="clicked" handler="on_undo_button_clicked"/>
diff --git a/src/preferences/preferences-toast.vala b/src/preferences/preferences-toast.vala
index 43e99440..14a6deec 100644
--- a/src/preferences/preferences-toast.vala
+++ b/src/preferences/preferences-toast.vala
@@ -21,6 +21,7 @@
 
     public string action {
         set {
+            button.visible = true;
             button.label = value; 
         }
         get {
diff --git a/src/preferences/snapshot-list-row.vala b/src/preferences/snapshot-list-row.vala
index 7c0a28f8..46efa675 100644
--- a/src/preferences/snapshot-list-row.vala
+++ b/src/preferences/snapshot-list-row.vala
@@ -147,6 +147,7 @@ private void on_delete_button_clicked () {
 
         var toast = new Boxes.PreferencesToast () {
             message = message,
+            action = _("Undo"),
             undo_func = (owned) undo,
             dismiss_func = (owned) really_remove,
         };


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