From ed3b4bcc8410fe5c3e410cba484985eee88951e8 Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 4 Nov 2024 21:45:31 +0200 Subject: [PATCH] apply close action to pinned tabs --- src/app/browser/window/tab/widget.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/app/browser/window/tab/widget.rs b/src/app/browser/window/tab/widget.rs index 5a9c5855..037c9755 100644 --- a/src/app/browser/window/tab/widget.rs +++ b/src/app/browser/window/tab/widget.rs @@ -32,21 +32,25 @@ impl Widget { // Actions - /// Close page at given `position`, `None` to close selected page (if available) - /// * this action does not close pinned pages + /// Close page at given `position`, `None` to close selected page + /// * this action includes `pinned` pages, to prevent that: + /// * deactivate [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) outside if selected page should not be closed + /// * use native [TabView](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html) API with `GObject` reference getter pub fn close(&self, position: Option) { if let Some(page) = self.page(position) { + self.gobject.set_page_pinned(&page, false); self.gobject.close_page(&page); } } /// Close all pages - /// * this action does not close pinned pages + /// * this action includes `pinned` pages, to prevent that: + /// * deactivate [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) outside if selected page should not be closed + /// * use native [TabView](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html) API with `GObject` reference getter pub fn close_all(&self) { - // @TODO skip pinned or make confirmation alert (GTK>=4.10) - if let Some(selected_page) = self.gobject.selected_page() { - self.gobject.close_other_pages(&selected_page); - self.gobject.close_page(&selected_page); + while let Some(page) = self.gobject.selected_page() { + self.gobject.set_page_pinned(&page, false); + self.gobject.close_page(&page); } }