diff --git a/data/ui/dialogs/filter_edit.ui b/data/ui/dialogs/filter_edit.ui index aff17b443..d3ca7f00f 100644 --- a/data/ui/dialogs/filter_edit.ui +++ b/data/ui/dialogs/filter_edit.ui @@ -1,116 +1,111 @@ - - - - \ No newline at end of file + + + + diff --git a/src/Dialogs/FilterEdit.vala b/src/Dialogs/FilterEdit.vala index 68dc19166..22a40c877 100644 --- a/src/Dialogs/FilterEdit.vala +++ b/src/Dialogs/FilterEdit.vala @@ -1,14 +1,14 @@ [GtkTemplate (ui = "/dev/geopjr/Tuba/ui/dialogs/filter_edit.ui")] -public class Tuba.Dialogs.FilterEdit : Adw.Dialog { +public class Tuba.Dialogs.FilterEdit : Adw.NavigationPage { [GtkChild] unowned Adw.EntryRow title_row; [GtkChild] unowned Adw.ComboRow expire_in_row; [GtkChild] unowned Adw.PreferencesGroup context_group; [GtkChild] unowned Adw.PreferencesGroup keywords_group; [GtkChild] unowned Gtk.Button save_btn; [GtkChild] unowned Adw.SwitchRow hide_row; - [GtkChild] unowned Adw.ToastOverlay toast_overlay; public signal void saved (API.Filters.Filter filter); + public signal void toast (string toast_content, int dismiss_time); const API.Filters.Filter.ContextType[] ALL_CONTEXT = {HOME, NOTIFICATIONS, PUBLIC, THREAD, ACCOUNT}; const FilterExpiration[] ALL_EXP = {NEVER, MINUTES_30, HOUR_1, HOUR_6, HOUR_12, DAY_1, WEEK_1}; @@ -99,7 +99,7 @@ public class Tuba.Dialogs.FilterEdit : Adw.Dialog { } string? filter_id = null; - public FilterEdit (Gtk.Widget win, API.Filters.Filter? filter = null) { + public FilterEdit (API.Filters.Filter? filter = null) { populate_exp_row (); if (filter != null) { @@ -126,7 +126,6 @@ public class Tuba.Dialogs.FilterEdit : Adw.Dialog { } validate (); - this.present (win); } class ExpWrapper : Object { @@ -246,7 +245,7 @@ public class Tuba.Dialogs.FilterEdit : Adw.Dialog { [GtkCallback] void on_close () { - force_close (); + this.activate_action ("navigation.pop", null); } [GtkCallback] @@ -294,9 +293,7 @@ public class Tuba.Dialogs.FilterEdit : Adw.Dialog { }) .on_error ((code, message) => { this.sensitive = true; - toast_overlay.add_toast (new Adw.Toast (_("Couldn't edit filter: %s").printf (message)) { - timeout = 0 - }); + this.toast (_("Couldn't edit filter: %s").printf (message), 0); warning (@"Couldn't edit filter: $code $message"); }) .exec (); diff --git a/src/Dialogs/Preferences.vala b/src/Dialogs/Preferences.vala index 465fbd0be..8ceb9360b 100644 --- a/src/Dialogs/Preferences.vala +++ b/src/Dialogs/Preferences.vala @@ -63,8 +63,10 @@ public class Tuba.Dialogs.Preferences : Adw.PreferencesDialog { } private void on_edit () { - var dlg = new Dialogs.FilterEdit (win, filter); + var dlg = new Dialogs.FilterEdit (filter); dlg.saved.connect (on_save); + dlg.toast.connect (this.win.on_toast); + this.win.push_subpage (dlg); } private void on_save (API.Filters.Filter filter) { @@ -327,8 +329,16 @@ public class Tuba.Dialogs.Preferences : Adw.PreferencesDialog { [GtkCallback] private void add_keyword_row () { - var dlg = new Dialogs.FilterEdit (this); + var dlg = new Dialogs.FilterEdit (); dlg.saved.connect (on_filter_save); + dlg.toast.connect (on_toast); + this.push_subpage (dlg); + } + + public void on_toast (string toast_content, int dismiss_time) { + this.add_toast (new Adw.Toast (toast_content) { + timeout = dismiss_time + }); } private void on_filter_save (API.Filters.Filter filter) {