mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
rename constructors
This commit is contained in:
parent
941b1cc283
commit
edb385f903
36 changed files with 266 additions and 180 deletions
|
|
@ -17,7 +17,10 @@ pub struct Menu {
|
|||
|
||||
#[rustfmt::skip] // @TODO template builder?
|
||||
impl Menu {
|
||||
pub fn new(
|
||||
// Constructors
|
||||
|
||||
/// Build new `Self`
|
||||
pub fn build(
|
||||
(browser_action, window_action): (&Rc<BrowserAction>, &Rc<WindowAction>),
|
||||
profile: &Rc<Profile>,
|
||||
) -> Self {
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ impl Tab {
|
|||
// Construct
|
||||
pub fn new(window_action: &Rc<WindowAction>, view: &TabView) -> Self {
|
||||
Self {
|
||||
widget: Rc::new(Widget::new(
|
||||
widget: Rc::new(Widget::build(
|
||||
view,
|
||||
&Append::new(window_action).widget.gobject,
|
||||
&Append::build(window_action).widget.button,
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ mod widget;
|
|||
|
||||
use widget::Widget;
|
||||
|
||||
use crate::app::browser::window::action::Action as WindowAction;
|
||||
use super::WindowAction;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Append {
|
||||
|
|
@ -10,10 +10,12 @@ pub struct Append {
|
|||
}
|
||||
|
||||
impl Append {
|
||||
// Construct
|
||||
pub fn new(window_action: &Rc<WindowAction>) -> Self {
|
||||
// Constructors
|
||||
|
||||
/// Build new `Self`
|
||||
pub fn build(window_action: &Rc<WindowAction>) -> Self {
|
||||
Self {
|
||||
widget: Rc::new(Widget::new(window_action.clone())),
|
||||
widget: Rc::new(Widget::build(window_action)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
use crate::app::browser::window::action::Action as WindowAction;
|
||||
use super::WindowAction;
|
||||
use gtk::{prelude::ButtonExt, Align, Button};
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Widget {
|
||||
pub gobject: Button,
|
||||
pub button: Button,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new(window_action: Rc<WindowAction>) -> Self {
|
||||
// Constructors
|
||||
|
||||
/// Build new `Self`
|
||||
pub fn build(window_action: &Rc<WindowAction>) -> Self {
|
||||
// Init gobject
|
||||
let gobject = Button::builder()
|
||||
let button = Button::builder()
|
||||
.icon_name("tab-new-symbolic")
|
||||
.css_classes(["flat"])
|
||||
.valign(Align::Center)
|
||||
|
|
@ -18,8 +20,11 @@ impl Widget {
|
|||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked(move |_| window_action.append.activate_default_once());
|
||||
button.connect_clicked({
|
||||
let window_action = window_action.clone();
|
||||
move |_| window_action.append.activate_default_once()
|
||||
});
|
||||
|
||||
Self { gobject }
|
||||
Self { button }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@ pub struct Widget {
|
|||
}
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new(view: &TabView, start_action_widget: &impl IsA<gtk::Widget>) -> Self {
|
||||
// Constructors
|
||||
|
||||
/// Build new `Self`
|
||||
pub fn build(view: &TabView, start_action_widget: &impl IsA<gtk::Widget>) -> Self {
|
||||
Self {
|
||||
tab_bar: TabBar::builder()
|
||||
.autohide(false)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,21 @@
|
|||
use adw::TabBar;
|
||||
use gtk::{prelude::BoxExt, Box, MenuButton, Orientation, WindowControls};
|
||||
use gtk::{
|
||||
prelude::{BoxExt, IsA},
|
||||
Box, Orientation,
|
||||
};
|
||||
|
||||
pub struct Widget {
|
||||
pub g_box: Box,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new(control: &WindowControls, menu: &MenuButton, tab: &TabBar) -> Self {
|
||||
// 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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue