Browse Source

toggle pin status outside

master
yggverse 2 months ago
parent
commit
a1cf47fb1f
  1. 17
      src/browser/main/tab/label/mod.rs
  2. 2
      src/browser/main/tab/mod.rs

17
src/browser/main/tab/label/mod.rs

@ -35,22 +35,17 @@ impl Label { @@ -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
}

2
src/browser/main/tab/mod.rs

@ -34,7 +34,7 @@ impl Tab { @@ -34,7 +34,7 @@ impl Tab {
move |_, n: i32, _, _| {
// double click
if n == 2 {
label.pin();
label.pin(!label.is_pinned()); // toggle
}
}
});

Loading…
Cancel
Save