diff --git a/src/app/browser/window/header/bar/tab.rs b/src/app/browser/window/header/bar/tab.rs index e48da2e4..ae6ca0b2 100644 --- a/src/app/browser/window/header/bar/tab.rs +++ b/src/app/browser/window/header/bar/tab.rs @@ -3,6 +3,7 @@ mod append; use super::WindowAction; use adw::{TabBar, TabView}; use append::Append; +use gtk::Button; use std::rc::Rc; pub trait Tab { @@ -14,7 +15,7 @@ impl Tab for TabBar { TabBar::builder() .autohide(false) .expand_tabs(false) - .end_action_widget(&Append::build(window_action).widget.button) // @TODO find solution to append after tabs + .end_action_widget(&Button::append(window_action)) // @TODO find solution to append after tabs .view(view) .build() } diff --git a/src/app/browser/window/header/bar/tab/append.rs b/src/app/browser/window/header/bar/tab/append.rs index 376d9d4b..1562c924 100644 --- a/src/app/browser/window/header/bar/tab/append.rs +++ b/src/app/browser/window/header/bar/tab/append.rs @@ -1,21 +1,25 @@ -mod widget; - -use widget::Widget; - use super::WindowAction; +use gtk::{prelude::ButtonExt, Align, Button}; use std::rc::Rc; -pub struct Append { - pub widget: Rc, +pub trait Append { + fn append(window_action: &Rc) -> Self; } -impl Append { - // Constructors +impl Append for Button { + fn append(window_action: &Rc) -> Self { + let button = Button::builder() + .icon_name("tab-new-symbolic") + .css_classes(["flat"]) + .valign(Align::Center) + .tooltip_text("New tab") + .build(); - /// Build new `Self` - pub fn build(window_action: &Rc) -> Self { - Self { - widget: Rc::new(Widget::build(window_action)), - } + button.connect_clicked({ + let window_action = window_action.clone(); + move |_| window_action.append.activate_default_once() + }); + + button } } diff --git a/src/app/browser/window/header/bar/tab/append/widget.rs b/src/app/browser/window/header/bar/tab/append/widget.rs deleted file mode 100644 index 065342c3..00000000 --- a/src/app/browser/window/header/bar/tab/append/widget.rs +++ /dev/null @@ -1,30 +0,0 @@ -use super::WindowAction; -use gtk::{prelude::ButtonExt, Align, Button}; -use std::rc::Rc; - -pub struct Widget { - pub button: Button, -} - -impl Widget { - // Constructors - - /// Build new `Self` - pub fn build(window_action: &Rc) -> Self { - // Init gobject - let button = Button::builder() - .icon_name("tab-new-symbolic") - .css_classes(["flat"]) - .valign(Align::Center) - .tooltip_text("New tab") - .build(); - - // Init events - button.connect_clicked({ - let window_action = window_action.clone(); - move |_| window_action.append.activate_default_once() - }); - - Self { button } - } -}