mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
use trait for ToolbarView
This commit is contained in:
parent
49c1f5923b
commit
1077368116
3 changed files with 21 additions and 41 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue