mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
define ptr container outside
This commit is contained in:
parent
7b2c07ac45
commit
a5fc2a7475
58 changed files with 230 additions and 272 deletions
|
|
@ -17,20 +17,20 @@ pub struct Control {
|
|||
|
||||
impl Control {
|
||||
// Construct
|
||||
pub fn new_rc(action_send: SimpleAction) -> Rc<Self> {
|
||||
pub fn new(action_send: SimpleAction) -> Self {
|
||||
// Init components
|
||||
let counter = Counter::new_rc();
|
||||
let send = Send::new_rc(action_send);
|
||||
let counter = Rc::new(Counter::new());
|
||||
let send = Rc::new(Send::new(action_send));
|
||||
|
||||
// Init widget
|
||||
let widget = Widget::new_rc(counter.gobject(), send.gobject());
|
||||
let widget = Rc::new(Widget::new(counter.gobject(), send.gobject()));
|
||||
|
||||
// Return activated struct
|
||||
Rc::new(Self {
|
||||
Self {
|
||||
counter,
|
||||
send,
|
||||
widget,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
|
|
|||
|
|
@ -11,12 +11,10 @@ pub struct Counter {
|
|||
|
||||
impl Counter {
|
||||
// Construct
|
||||
pub fn new_rc() -> Rc<Self> {
|
||||
// Init widget
|
||||
let widget = Widget::new_rc();
|
||||
|
||||
// Result
|
||||
Rc::new(Self { widget })
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
widget: Rc::new(Widget::new()),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use gtk::{prelude::WidgetExt, Label};
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Widget {
|
||||
gobject: Label,
|
||||
|
|
@ -7,10 +6,10 @@ pub struct Widget {
|
|||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new_rc() -> Rc<Self> {
|
||||
let gobject = Label::builder().build();
|
||||
|
||||
Rc::new(Self { gobject })
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: Label::builder().build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
mod widget;
|
||||
|
||||
use widget::Widget;
|
||||
|
||||
use gtk::{gio::SimpleAction, Button};
|
||||
|
|
@ -11,12 +10,12 @@ pub struct Send {
|
|||
|
||||
impl Send {
|
||||
// Construct
|
||||
pub fn new_rc(action_send: SimpleAction) -> Rc<Self> {
|
||||
pub fn new(action_send: SimpleAction) -> Self {
|
||||
// Init widget
|
||||
let widget = Widget::new_rc(action_send);
|
||||
let widget = Rc::new(Widget::new(action_send));
|
||||
|
||||
// Result
|
||||
Rc::new(Self { widget })
|
||||
Self { widget }
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ use gtk::{
|
|||
prelude::{ActionExt, ButtonExt, WidgetExt},
|
||||
Button,
|
||||
};
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Widget {
|
||||
gobject: Button,
|
||||
|
|
@ -11,7 +10,7 @@ pub struct Widget {
|
|||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new_rc(action_send: SimpleAction) -> Rc<Self> {
|
||||
pub fn new(action_send: SimpleAction) -> Self {
|
||||
// Init gobject
|
||||
let gobject = Button::builder()
|
||||
//.css_classes(["accent"])
|
||||
|
|
@ -25,8 +24,8 @@ impl Widget {
|
|||
}
|
||||
});
|
||||
|
||||
// Return activated struct
|
||||
Rc::new(Self { gobject })
|
||||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use gtk::{prelude::BoxExt, Align, Box, Button, Label, Orientation};
|
||||
use std::rc::Rc;
|
||||
|
||||
const SPACING: i32 = 8;
|
||||
|
||||
|
|
@ -9,7 +8,7 @@ pub struct Widget {
|
|||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new_rc(limit: &Label, send: &Button) -> Rc<Self> {
|
||||
pub fn new(limit: &Label, send: &Button) -> Self {
|
||||
// Init gobject
|
||||
let gobject = Box::builder()
|
||||
.halign(Align::End)
|
||||
|
|
@ -20,8 +19,8 @@ impl Widget {
|
|||
gobject.append(limit);
|
||||
gobject.append(send);
|
||||
|
||||
// Return new struct
|
||||
Rc::new(Self { gobject })
|
||||
// Return new `Self`
|
||||
Self { gobject }
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
|
|
|||
|
|
@ -11,12 +11,10 @@ pub struct Form {
|
|||
|
||||
impl Form {
|
||||
// Construct
|
||||
pub fn new_rc(action_update: SimpleAction) -> Rc<Self> {
|
||||
// Init widget
|
||||
let widget = Widget::new_rc(action_update);
|
||||
|
||||
// Result
|
||||
Rc::new(Self { widget })
|
||||
pub fn new(action_update: SimpleAction) -> Self {
|
||||
Self {
|
||||
widget: Rc::new(Widget::new(action_update)),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use gtk::{
|
|||
prelude::{ActionExt, TextBufferExt, TextViewExt, WidgetExt},
|
||||
TextView, WrapMode,
|
||||
};
|
||||
use std::rc::Rc;
|
||||
|
||||
const MARGIN: i32 = 8;
|
||||
|
||||
|
|
@ -14,7 +13,7 @@ pub struct Widget {
|
|||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new_rc(action_update: SimpleAction) -> Rc<Self> {
|
||||
pub fn new(action_update: SimpleAction) -> Self {
|
||||
// Init gobject
|
||||
let gobject = TextView::builder()
|
||||
.bottom_margin(MARGIN)
|
||||
|
|
@ -29,8 +28,8 @@ impl Widget {
|
|||
action_update.activate(None);
|
||||
});
|
||||
|
||||
// Return activated struct
|
||||
Rc::new(Self { gobject })
|
||||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
|
|
|||
|
|
@ -11,12 +11,10 @@ pub struct Title {
|
|||
|
||||
impl Title {
|
||||
// Construct
|
||||
pub fn new_rc(title: Option<&str>) -> Rc<Self> {
|
||||
// Init widget
|
||||
let widget = Widget::new_rc(title);
|
||||
|
||||
// Result
|
||||
Rc::new(Self { widget })
|
||||
pub fn new(title: Option<&str>) -> Self {
|
||||
Self {
|
||||
widget: Rc::new(Widget::new(title)),
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use gtk::{prelude::WidgetExt, Align, Label};
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Widget {
|
||||
gobject: Label,
|
||||
|
|
@ -7,7 +6,7 @@ pub struct Widget {
|
|||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new_rc(title: Option<&str>) -> Rc<Self> {
|
||||
pub fn new(title: Option<&str>) -> Self {
|
||||
let gobject = Label::builder()
|
||||
.css_classes(["heading"])
|
||||
.halign(Align::Start)
|
||||
|
|
@ -23,7 +22,7 @@ impl Widget {
|
|||
}
|
||||
}
|
||||
|
||||
Rc::new(Self { gobject })
|
||||
Self { gobject }
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use gtk::{prelude::BoxExt, Box, Label, Orientation, TextView};
|
||||
use std::rc::Rc;
|
||||
|
||||
const MARGIN: i32 = 6;
|
||||
const SPACING: i32 = 8;
|
||||
|
|
@ -10,7 +9,7 @@ pub struct Widget {
|
|||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new_rc(title: &Label, response: &TextView, control: &Box) -> Rc<Self> {
|
||||
pub fn new(title: &Label, response: &TextView, control: &Box) -> Self {
|
||||
let gobject = Box::builder()
|
||||
.margin_bottom(MARGIN)
|
||||
.margin_end(MARGIN)
|
||||
|
|
@ -24,7 +23,7 @@ impl Widget {
|
|||
gobject.append(response);
|
||||
gobject.append(control);
|
||||
|
||||
Rc::new(Self { gobject })
|
||||
Self { gobject }
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue