mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
begin Titan protocol implementation
This commit is contained in:
parent
236d941b37
commit
879fe7a6f6
37 changed files with 609 additions and 102 deletions
|
|
@ -16,14 +16,16 @@ pub struct Control {
|
|||
}
|
||||
|
||||
impl Control {
|
||||
// Construct
|
||||
pub fn new(action_send: SimpleAction) -> Self {
|
||||
// Constructors
|
||||
|
||||
/// Build new `Self`
|
||||
pub fn build(action_send: SimpleAction) -> Self {
|
||||
// Init components
|
||||
let counter = Rc::new(Counter::new());
|
||||
let send = Rc::new(Send::new(action_send));
|
||||
let send = Rc::new(Send::build(action_send));
|
||||
|
||||
// Init widget
|
||||
let widget = Rc::new(Widget::new(&counter.widget.label, &send.widget.button));
|
||||
let widget = Rc::new(Widget::build(&counter.widget.label, &send.widget.button));
|
||||
|
||||
// Return activated struct
|
||||
Self {
|
||||
|
|
@ -34,10 +36,10 @@ impl Control {
|
|||
}
|
||||
|
||||
// Actions
|
||||
pub fn update(&self, chars_left: Option<i32>) {
|
||||
pub fn update(&self, bytes_left: Option<usize>) {
|
||||
// Update children components
|
||||
self.counter.update(chars_left);
|
||||
self.send.update(match chars_left {
|
||||
self.counter.update(bytes_left);
|
||||
self.send.update(match bytes_left {
|
||||
Some(left) => left > 0,
|
||||
None => false,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ impl Counter {
|
|||
}
|
||||
|
||||
// Actions
|
||||
pub fn update(&self, chars_left: Option<i32>) {
|
||||
self.widget.update(chars_left);
|
||||
pub fn update(&self, bytes_left: Option<usize>) {
|
||||
self.widget.update(bytes_left);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ impl Widget {
|
|||
}
|
||||
|
||||
// Actions
|
||||
pub fn update(&self, chars_left: Option<i32>) {
|
||||
match chars_left {
|
||||
pub fn update(&self, bytes_left: Option<usize>) {
|
||||
match bytes_left {
|
||||
Some(value) => {
|
||||
// Update color on chars left reached
|
||||
self.label
|
||||
|
|
|
|||
|
|
@ -9,10 +9,12 @@ pub struct Send {
|
|||
}
|
||||
|
||||
impl Send {
|
||||
// Construct
|
||||
pub fn new(action_send: SimpleAction) -> Self {
|
||||
// Constructors
|
||||
|
||||
/// Build new `Self`
|
||||
pub fn build(action_send: SimpleAction) -> Self {
|
||||
// Init widget
|
||||
let widget = Rc::new(Widget::new(action_send));
|
||||
let widget = Rc::new(Widget::build(action_send));
|
||||
|
||||
// Result
|
||||
Self { widget }
|
||||
|
|
|
|||
|
|
@ -9,12 +9,15 @@ pub struct Widget {
|
|||
}
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new(action_send: SimpleAction) -> Self {
|
||||
// Constructors
|
||||
|
||||
/// Build new `Self`
|
||||
pub fn build(action_send: SimpleAction) -> Self {
|
||||
// Init main widget
|
||||
let button = Button::builder()
|
||||
.css_classes(["accent"]) // | `suggested-action`
|
||||
.label("Send")
|
||||
.sensitive(false)
|
||||
.build();
|
||||
|
||||
// Init events
|
||||
|
|
|
|||
|
|
@ -7,8 +7,10 @@ pub struct Widget {
|
|||
}
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new(limit: &Label, send: &Button) -> Self {
|
||||
// Constructors
|
||||
|
||||
/// Build new `Self`
|
||||
pub fn build(limit: &Label, send: &Button) -> Self {
|
||||
// Init main widget
|
||||
let g_box = Box::builder()
|
||||
.halign(Align::End)
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@ pub struct Form {
|
|||
}
|
||||
|
||||
impl Form {
|
||||
// Construct
|
||||
pub fn new(action_update: SimpleAction) -> Self {
|
||||
// Constructors
|
||||
|
||||
/// Build new `Self`
|
||||
pub fn build(action_update: SimpleAction) -> Self {
|
||||
Self {
|
||||
widget: Rc::new(Widget::new(action_update)),
|
||||
widget: Rc::new(Widget::build(action_update)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,8 +14,10 @@ pub struct Widget {
|
|||
}
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new(action_update: SimpleAction) -> Self {
|
||||
// Constructors
|
||||
|
||||
/// Build new `Self`
|
||||
pub fn build(action_update: SimpleAction) -> Self {
|
||||
// Init [SourceView](https://gitlab.gnome.org/GNOME/gtksourceview) type buffer
|
||||
let buffer = Buffer::builder().build();
|
||||
|
||||
|
|
@ -44,6 +46,10 @@ impl Widget {
|
|||
action_update.activate(None);
|
||||
});
|
||||
|
||||
text_view.connect_realize(move |this| {
|
||||
this.grab_focus();
|
||||
});
|
||||
|
||||
// Return activated `Self`
|
||||
Self { text_view }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,10 +9,12 @@ pub struct Title {
|
|||
}
|
||||
|
||||
impl Title {
|
||||
// Construct
|
||||
pub fn new(title: Option<&str>) -> Self {
|
||||
// Constructors
|
||||
|
||||
/// Build new `Self`
|
||||
pub fn build(title: Option<&str>) -> Self {
|
||||
Self {
|
||||
widget: Rc::new(Widget::new(title)),
|
||||
widget: Rc::new(Widget::build(title)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@ pub struct Widget {
|
|||
}
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new(title: Option<&str>) -> Self {
|
||||
// Constructors
|
||||
|
||||
/// Build new `Self`
|
||||
pub fn build(title: Option<&str>) -> Self {
|
||||
let label = Label::builder()
|
||||
.css_classes(["heading"])
|
||||
.halign(Align::Start)
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ pub struct Widget {
|
|||
}
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new(title: &Label, response: &TextView, control: &Box) -> Self {
|
||||
// Constructors
|
||||
|
||||
/// Build new `Self`
|
||||
pub fn build(title: &Label, response: &TextView, control: &Box) -> Self {
|
||||
let g_box = Box::builder()
|
||||
.margin_bottom(MARGIN)
|
||||
.margin_end(MARGIN)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue