mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
implement bar box as trait
This commit is contained in:
parent
8b4d184ad7
commit
137a1c72b6
3 changed files with 24 additions and 55 deletions
|
|
@ -6,6 +6,7 @@ use widget::Widget;
|
||||||
|
|
||||||
use super::{Action as WindowAction, BrowserAction, Profile};
|
use super::{Action as WindowAction, BrowserAction, Profile};
|
||||||
use adw::TabView;
|
use adw::TabView;
|
||||||
|
use gtk::Box;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub struct Header {
|
pub struct Header {
|
||||||
|
|
@ -21,16 +22,12 @@ impl Header {
|
||||||
profile: &Rc<Profile>,
|
profile: &Rc<Profile>,
|
||||||
tab_view: &TabView,
|
tab_view: &TabView,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Init components
|
|
||||||
let bar = Rc::new(Bar::build(
|
|
||||||
(browser_action, window_action),
|
|
||||||
profile,
|
|
||||||
tab_view,
|
|
||||||
));
|
|
||||||
|
|
||||||
// Return new struct
|
|
||||||
Self {
|
Self {
|
||||||
widget: Rc::new(Widget::build(&bar.widget.g_box)),
|
widget: Rc::new(Widget::build(&Box::bar(
|
||||||
|
(browser_action, window_action),
|
||||||
|
profile,
|
||||||
|
tab_view,
|
||||||
|
))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,41 @@
|
||||||
mod control;
|
mod control;
|
||||||
mod menu;
|
mod menu;
|
||||||
mod tab;
|
mod tab;
|
||||||
mod widget;
|
|
||||||
|
|
||||||
use control::Control;
|
use control::Control;
|
||||||
use menu::Menu;
|
use menu::Menu;
|
||||||
use tab::Tab;
|
use tab::Tab;
|
||||||
use widget::Widget;
|
|
||||||
|
|
||||||
use super::{BrowserAction, Profile, WindowAction};
|
use super::{BrowserAction, Profile, WindowAction};
|
||||||
use adw::TabView;
|
use adw::TabView;
|
||||||
|
use gtk::{prelude::BoxExt, Box, Orientation};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub struct Bar {
|
pub trait Bar {
|
||||||
pub widget: Rc<Widget>,
|
fn bar(
|
||||||
|
action: (&Rc<BrowserAction>, &Rc<WindowAction>),
|
||||||
|
profile: &Rc<Profile>,
|
||||||
|
view: &TabView,
|
||||||
|
) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bar {
|
impl Bar for Box {
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
/// Build new `Self`
|
/// Build new `Self`
|
||||||
pub fn build(
|
fn bar(
|
||||||
(browser_action, window_action): (&Rc<BrowserAction>, &Rc<WindowAction>),
|
(browser_action, window_action): (&Rc<BrowserAction>, &Rc<WindowAction>),
|
||||||
profile: &Rc<Profile>,
|
profile: &Rc<Profile>,
|
||||||
view: &TabView,
|
view: &TabView,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let control = Control::new();
|
let g_box = Box::builder()
|
||||||
let tab = Tab::new(window_action, view);
|
.orientation(Orientation::Horizontal)
|
||||||
let menu = Rc::new(Menu::build((browser_action, window_action), profile));
|
.spacing(8)
|
||||||
Self {
|
.build();
|
||||||
widget: Rc::new(Widget::build(
|
|
||||||
&control.window_controls,
|
g_box.append(&Tab::new(window_action, view).widget.tab_bar);
|
||||||
&menu.menu_button,
|
g_box.append(&Menu::build((browser_action, window_action), profile).menu_button);
|
||||||
&tab.widget.tab_bar,
|
g_box.append(&Control::new().window_controls);
|
||||||
)),
|
g_box
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
use gtk::{
|
|
||||||
prelude::{BoxExt, IsA},
|
|
||||||
Box, Orientation,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub struct Widget {
|
|
||||||
pub g_box: Box,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget {
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
/// Build new `Self`
|
|
||||||
pub fn build(
|
|
||||||
control: &impl IsA<gtk::Widget>,
|
|
||||||
menu: &impl IsA<gtk::Widget>,
|
|
||||||
tab: &impl IsA<gtk::Widget>,
|
|
||||||
) -> Self {
|
|
||||||
let g_box = Box::builder()
|
|
||||||
.orientation(Orientation::Horizontal)
|
|
||||||
.spacing(8)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
g_box.append(tab);
|
|
||||||
g_box.append(menu);
|
|
||||||
g_box.append(control);
|
|
||||||
|
|
||||||
Self { g_box }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue