use trait for ToolbarView

This commit is contained in:
yggverse 2025-01-26 16:46:48 +02:00
parent 49c1f5923b
commit 1077368116
3 changed files with 21 additions and 41 deletions

View file

@ -1,33 +1,36 @@
mod bar;
mod widget;
use bar::Bar;
use widget::Widget;
use super::{Action as WindowAction, BrowserAction, Profile};
use adw::TabView;
use adw::{TabView, ToolbarView};
use bar::Bar;
use gtk::Box;
use std::rc::Rc;
pub struct Header {
pub widget: Rc<Widget>,
pub trait Header {
fn header(
action: (&Rc<BrowserAction>, &Rc<WindowAction>),
profile: &Rc<Profile>,
tab_view: &TabView,
) -> Self;
}
impl Header {
impl Header for ToolbarView {
// Constructors
/// Build new `Self`
pub fn build(
fn header(
(browser_action, window_action): (&Rc<BrowserAction>, &Rc<WindowAction>),
profile: &Rc<Profile>,
tab_view: &TabView,
) -> Self {
Self {
widget: Rc::new(Widget::build(&Box::bar(
(browser_action, window_action),
profile,
tab_view,
))),
}
let toolbar_view = ToolbarView::builder().build();
toolbar_view.add_top_bar(&Box::bar(
(browser_action, window_action),
profile,
tab_view,
));
toolbar_view
}
}

View file

@ -1,19 +0,0 @@
use adw::ToolbarView;
use gtk::prelude::IsA;
pub struct Widget {
pub toolbar_view: ToolbarView,
}
impl Widget {
// Constructors
/// Build new `Self`
pub fn build(top_bar: &impl IsA<gtk::Widget>) -> Self {
let toolbar_view = ToolbarView::builder().build();
toolbar_view.add_top_bar(top_bar);
Self { toolbar_view }
}
}