Skip to content

Commit

Permalink
MainWindow: Create a instance of Adw.Toast every time when showing it (
Browse files Browse the repository at this point in the history
…#166)

Adw.ToastOverlay.add_toast() takes ownership of given toast
  • Loading branch information
ryonakano authored Mar 3, 2024
1 parent 88a25e8 commit 7c416d3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ public class MainWindow : Adw.ApplicationWindow {
child = split_view
};

var updated_toast = new Adw.Toast (_("Entry updated.")) {
timeout = 5
};

var deleted_toast = new Adw.Toast (_("Entry deleted.")) {
timeout = 5
};

content = overlay;

files_view.new_activated.connect (() => {
Expand All @@ -77,6 +69,9 @@ public class MainWindow : Adw.ApplicationWindow {
model.load.begin ();

if (is_success) {
var deleted_toast = new Adw.Toast (_("Entry deleted.")) {
timeout = 5
};
overlay.add_toast (deleted_toast);
}
});
Expand All @@ -88,6 +83,10 @@ public class MainWindow : Adw.ApplicationWindow {
edit_view.saved.connect (() => {
desktop_file.copy_to (backup_desktop_file);
model.load.begin ();

var updated_toast = new Adw.Toast (_("Entry updated.")) {
timeout = 5
};
overlay.add_toast (updated_toast);
});

Expand Down

0 comments on commit 7c416d3

Please sign in to comment.