From a1cf47fb1fc0b49948ae9e52a82a1b5623f586e6 Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 23 Sep 2024 22:01:48 +0300 Subject: [PATCH] toggle pin status outside --- src/browser/main/tab/label/mod.rs | 17 ++++++----------- src/browser/main/tab/mod.rs | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/browser/main/tab/label/mod.rs b/src/browser/main/tab/label/mod.rs index 47854a27..e3f88705 100644 --- a/src/browser/main/tab/label/mod.rs +++ b/src/browser/main/tab/label/mod.rs @@ -35,22 +35,17 @@ impl Label { Self { pin, title, widget } } - // Actions - pub fn pin(&self) -> bool { - // Toggle status - let is_pinned = !self.pin.widget().is_visible(); - - // Update pin widget + // Setters + pub fn pin(&self, is_pinned: bool) { self.pin.widget().set_visible(is_pinned); - - // Update label widget self.title.widget().set_visible(!is_pinned); - - // Result - is_pinned } // Getters + pub fn is_pinned(&self) -> bool { + self.pin.widget().is_visible() + } + pub fn widget(&self) -> &Box { &self.widget } diff --git a/src/browser/main/tab/mod.rs b/src/browser/main/tab/mod.rs index c818242d..a4f85cc7 100644 --- a/src/browser/main/tab/mod.rs +++ b/src/browser/main/tab/mod.rs @@ -34,7 +34,7 @@ impl Tab { move |_, n: i32, _, _| { // double click if n == 2 { - label.pin(); + label.pin(!label.is_pinned()); // toggle } } });