mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-03 01:55:27 +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;
|
mod widget;
|
||||||
|
|
||||||
use action::{Action, Position};
|
use action::{Action, Position};
|
||||||
|
use adw::ToolbarView;
|
||||||
use header::Header;
|
use header::Header;
|
||||||
use sqlite::Transaction;
|
use sqlite::Transaction;
|
||||||
use tab::Tab;
|
use tab::Tab;
|
||||||
|
|
@ -31,13 +32,8 @@ impl Window {
|
||||||
|
|
||||||
// Init components
|
// Init components
|
||||||
let tab = Rc::new(Tab::build(profile, (browser_action, &action)));
|
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(
|
let widget = Rc::new(Widget::build(
|
||||||
&header.widget.toolbar_view,
|
&ToolbarView::header((browser_action, &action), profile, &tab.widget.tab_view),
|
||||||
&tab.widget.tab_view,
|
&tab.widget.tab_view,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,36 @@
|
||||||
mod bar;
|
mod bar;
|
||||||
mod widget;
|
|
||||||
|
|
||||||
use bar::Bar;
|
|
||||||
use widget::Widget;
|
|
||||||
|
|
||||||
use super::{Action as WindowAction, BrowserAction, Profile};
|
use super::{Action as WindowAction, BrowserAction, Profile};
|
||||||
use adw::TabView;
|
use adw::{TabView, ToolbarView};
|
||||||
|
use bar::Bar;
|
||||||
use gtk::Box;
|
use gtk::Box;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub struct Header {
|
pub trait Header {
|
||||||
pub widget: Rc<Widget>,
|
fn header(
|
||||||
|
action: (&Rc<BrowserAction>, &Rc<WindowAction>),
|
||||||
|
profile: &Rc<Profile>,
|
||||||
|
tab_view: &TabView,
|
||||||
|
) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Header {
|
impl Header for ToolbarView {
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
/// Build new `Self`
|
/// Build new `Self`
|
||||||
pub fn build(
|
fn header(
|
||||||
(browser_action, window_action): (&Rc<BrowserAction>, &Rc<WindowAction>),
|
(browser_action, window_action): (&Rc<BrowserAction>, &Rc<WindowAction>),
|
||||||
profile: &Rc<Profile>,
|
profile: &Rc<Profile>,
|
||||||
tab_view: &TabView,
|
tab_view: &TabView,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
let toolbar_view = ToolbarView::builder().build();
|
||||||
widget: Rc::new(Widget::build(&Box::bar(
|
|
||||||
|
toolbar_view.add_top_bar(&Box::bar(
|
||||||
(browser_action, window_action),
|
(browser_action, window_action),
|
||||||
profile,
|
profile,
|
||||||
tab_view,
|
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