define ptr container outside

This commit is contained in:
yggverse 2024-11-11 01:14:09 +02:00
parent 7b2c07ac45
commit a5fc2a7475
58 changed files with 230 additions and 272 deletions

View file

@ -11,10 +11,10 @@ pub struct Control {
impl Control {
// Construct
pub fn new_rc() -> Rc<Self> {
Rc::new(Self {
widget: Widget::new_rc(),
})
pub fn new() -> Self {
Self {
widget: Rc::new(Widget::new()),
}
}
// Getters

View file

@ -1,5 +1,4 @@
use gtk::{PackType, WindowControls};
use std::rc::Rc;
pub struct Widget {
gobject: WindowControls,
@ -7,13 +6,13 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_rc() -> Rc<Self> {
Rc::new(Self {
pub fn new() -> Self {
Self {
gobject: WindowControls::builder()
.side(PackType::End)
.margin_end(4)
.build(),
})
}
}
// Getters

View file

@ -15,10 +15,10 @@ pub struct Menu {
}
#[rustfmt::skip] // @TODO template builder?
impl Menu {
pub fn new_rc(
pub fn new(
browser_action: Rc<BrowserAction>,
window_action: Rc<WindowAction>,
) -> Rc<Self> {
) -> Self {
// Main
let main = gio::Menu::new();
@ -120,7 +120,7 @@ impl Menu {
)));
// Result
Rc::new(Self { widget:Widget::new_rc(&main) })
Self { widget:Rc::new(Widget::new(&main)) }
}
// Getters

View file

@ -1,5 +1,4 @@
use gtk::{gio::Menu, Align, MenuButton};
use std::rc::Rc;
pub struct Widget {
gobject: MenuButton,
@ -7,8 +6,8 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_rc(model: &Menu) -> Rc<Self> {
Rc::new(Self {
pub fn new(model: &Menu) -> Self {
Self {
gobject: MenuButton::builder()
.css_classes(["flat"])
.icon_name("open-menu-symbolic")
@ -16,7 +15,7 @@ impl Widget {
.tooltip_text("Menu")
.valign(Align::Center)
.build(),
})
}
}
// Getters

View file

@ -14,10 +14,10 @@ pub struct Tab {
impl Tab {
// Construct
pub fn new_rc(window_action: Rc<WindowAction>, view: &TabView) -> Rc<Self> {
Rc::new(Self {
widget: Widget::new_rc(view, Append::new_rc(window_action).gobject()),
})
pub fn new(window_action: Rc<WindowAction>, view: &TabView) -> Self {
Self {
widget: Rc::new(Widget::new(view, Append::new(window_action).gobject())),
}
}
// Getters

View file

@ -12,10 +12,10 @@ pub struct Append {
impl Append {
// Construct
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
Rc::new(Self {
widget: Widget::new_rc(window_action),
})
pub fn new(window_action: Rc<WindowAction>) -> Self {
Self {
widget: Rc::new(Widget::new(window_action)),
}
}
// Getters

View file

@ -8,7 +8,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
pub fn new(window_action: Rc<WindowAction>) -> Self {
// Init gobject
let gobject = Button::builder()
.icon_name("tab-new-symbolic")
@ -20,7 +20,7 @@ impl Widget {
// Init events
gobject.connect_clicked(move |_| window_action.append().activate());
Rc::new(Self { gobject })
Self { gobject }
}
// Getters

View file

@ -1,6 +1,5 @@
use adw::{TabBar, TabView};
use gtk::prelude::IsA;
use std::rc::Rc;
pub struct Widget {
gobject: TabBar,
@ -8,15 +7,15 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_rc(view: &TabView, start_action_widget: &impl IsA<gtk::Widget>) -> Rc<Self> {
Rc::new(Self {
pub fn new(view: &TabView, start_action_widget: &impl IsA<gtk::Widget>) -> Self {
Self {
gobject: TabBar::builder()
.autohide(false)
.expand_tabs(false)
.end_action_widget(start_action_widget) // @TODO find solution to append after tabs
.view(view)
.build(),
})
}
}
// Getters

View file

@ -1,6 +1,5 @@
use adw::TabBar;
use gtk::{prelude::BoxExt, Box, MenuButton, Orientation, WindowControls};
use std::rc::Rc;
pub struct Widget {
gobject: Box,
@ -8,7 +7,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_rc(control: &WindowControls, menu: &MenuButton, tab: &TabBar) -> Rc<Self> {
pub fn new(control: &WindowControls, menu: &MenuButton, tab: &TabBar) -> Self {
let gobject = Box::builder()
.orientation(Orientation::Horizontal)
.spacing(8)
@ -18,7 +17,7 @@ impl Widget {
gobject.append(menu);
gobject.append(control);
Rc::new(Self { gobject })
Self { gobject }
}
// Getters