summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorey Berla <corey@berla.me>2023-04-13 15:50:41 -0700
committerOndrej Holy <oholy@redhat.com>2023-04-21 06:54:06 +0000
commitf763e1f97cf4d47ca70ab6f964460e72206bbced (patch)
tree2d78eba4670489c4b98a1592b254350e0ad45eed
parenta76d23f79ef558dbed8109d5469abeb5d6a78666 (diff)
downloadnautilus-f763e1f97cf4d47ca70ab6f964460e72206bbced.tar.gz
window: Dismiss previous undo toast when undo action has changed
We present a new toast every time the undo action changed which is confusing because you might have several undo toasts appearing over each other. To complicate matters, the previous undo toasts lie (undo'ing would actually undo a different action). There was a proposal in #2350 to batch undo toasts, but that's problematic because our undo manager is designed to undo exactly 1 action, we do not have an undo stack. The more straightforward solution seems to be simply dismissing the old undo toasts, when we popup a new undo toast. Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2350
-rw-r--r--src/nautilus-window.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 9424f154d..0033dcf5d 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -112,6 +112,7 @@ struct _NautilusWindow
/* Notifications */
AdwToastOverlay *toast_overlay;
+ AdwToast *last_undo_toast;
/* Toolbar */
GtkWidget *toolbar;
@@ -1275,12 +1276,19 @@ nautilus_window_on_undo_changed (NautilusFileUndoManager *manager,
}
}
+ if (window->last_undo_toast != NULL)
+ {
+ adw_toast_dismiss (window->last_undo_toast);
+ g_clear_weak_pointer (&window->last_undo_toast);
+ }
+
if (popup_toast)
{
toast = adw_toast_new (label);
adw_toast_set_button_label (toast, _("Undo"));
adw_toast_set_action_name (toast, "win.undo");
adw_toast_set_priority (toast, ADW_TOAST_PRIORITY_HIGH);
+ g_set_weak_pointer (&window->last_undo_toast, toast);
adw_toast_overlay_add_toast (window->toast_overlay, toast);
}
}