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
|
|
@ -5,6 +5,7 @@ pub mod tab;
|
|||
mod widget;
|
||||
|
||||
use action::{Action, Position};
|
||||
use adw::ToolbarView;
|
||||
use header::Header;
|
||||
use sqlite::Transaction;
|
||||
use tab::Tab;
|
||||
|
|
@ -31,13 +32,8 @@ impl Window {
|
|||
|
||||
// Init components
|
||||
let tab = Rc::new(Tab::build(profile, (browser_action, &action)));
|
||||
let header = Rc::new(Header::build(
|
||||
(browser_action, &action),
|
||||
profile,
|
||||
&tab.widget.tab_view,
|
||||
));
|
||||
let widget = Rc::new(Widget::build(
|
||||
&header.widget.toolbar_view,
|
||||
&ToolbarView::header((browser_action, &action), profile, &tab.widget.tab_view),
|
||||
&tab.widget.tab_view,
|
||||
));
|
||||
|
||||
|
|
|
|||
|
|
@ -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