Skip to content

Commit

Permalink
Add stream Lock to avoid emitting events when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Aug 15, 2017
1 parent 6d130a9 commit 26e3513
Show file tree
Hide file tree
Showing 25 changed files with 104 additions and 58 deletions.
2 changes: 1 addition & 1 deletion examples/buttons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl Widget for Win {
// Specify the type of the root widget.
type Root = Window;

fn model(_: ()) -> Model {
fn model(_: &Relm<Self>, _: ()) -> Model {
Model {
counter: 0,
}
Expand Down
4 changes: 2 additions & 2 deletions examples/child-prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Widget for Button {
type Msg = ButtonMsg;
type Root = gtk::Button;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
}

fn root(&self) -> Self::Root {
Expand Down Expand Up @@ -107,7 +107,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = gtk::Window;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
}

fn root(&self) -> Self::Root {
Expand Down
2 changes: 1 addition & 1 deletion examples/clock-nightly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}

Expand Down
2 changes: 1 addition & 1 deletion examples/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}

Expand Down
4 changes: 2 additions & 2 deletions examples/communication-attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ impl Widget for Win {
}

impl Win {
fn inc(&self) -> Option<CounterMsg> {
fn inc(&mut self) -> Option<CounterMsg> {
Some(Increment)
}

fn text_change(&self, input: String) -> Msg {
fn text_change(&mut self, input: String) -> Msg {
TextChange(input)
}
}
Expand Down
10 changes: 5 additions & 5 deletions examples/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl Widget for Text {
type Msg = TextMsg;
type Root = gtk::Box;

fn model(_: ()) -> TextModel {
fn model(_: &Relm<Self>, _: ()) -> TextModel {
TextModel {
content: String::new(),
}
Expand Down Expand Up @@ -130,7 +130,7 @@ impl Widget for Counter {
type Msg = CounterMsg;
type Root = gtk::Box;

fn model(_: ()) -> CounterModel {
fn model(_: &Relm<Self>, _: ()) -> CounterModel {
CounterModel {
counter: 0,
}
Expand Down Expand Up @@ -203,7 +203,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;

fn model(_: ()) -> Model {
fn model(_: &Relm<Self>, _: ()) -> Model {
Model {
counter: 0,
}
Expand Down Expand Up @@ -253,7 +253,7 @@ impl Widget for Win {
let Win { ref counter1, ref counter2, ref text, ref window, .. } = *win.borrow();
connect!(text@Change(text), relm, TextChange(text));
connect!(text@Change(_), counter1, with win_clone win_clone.inc());
connect!(counter1@Increment, counter2, Increment);
connect!(counter1@Increment, counter2, Decrement);
connect!(button, connect_clicked(_), counter1, Decrement);

window.add(&hbox);
Expand All @@ -268,7 +268,7 @@ impl Widget for Win {
}

impl Win {
fn inc(&self) -> CounterMsg {
fn inc(&mut self) -> CounterMsg {
Increment
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Widget for Button {
type Msg = ();
type Root = gtk::Button;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
}

fn root(&self) -> Self::Root {
Expand Down Expand Up @@ -92,7 +92,7 @@ impl Widget for VBox {
type Msg = ();
type Root = EventBox;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}

Expand Down Expand Up @@ -131,7 +131,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
}

fn root(&self) -> Self::Root {
Expand Down
4 changes: 2 additions & 2 deletions examples/generic-widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl<T: Clone + IncDec + Display + 'static> Widget for Counter<T> {
type Msg = CounterMsg<T>;
type Root = gtk::Box;

fn model(value: T) -> Self::Model {
fn model(_: &Relm<Self>, value: T) -> Self::Model {
Model {
counter: value,
}
Expand Down Expand Up @@ -153,7 +153,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}

Expand Down
2 changes: 1 addition & 1 deletion examples/key-events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;

fn model(_: ()) -> Model {
fn model(_: &Relm<Self>, _: ()) -> Model {
Model {
press_count: 0,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/model-param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl Widget for Win {
// Specify the type of the root widget.
type Root = Window;

fn model(counter: i32) -> Model {
fn model(_: &Relm<Self>, counter: i32) -> Model {
Model {
counter: counter,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/multi-container-attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use self::Msg::*;

#[widget]
impl Widget for MyFrame {
fn model(_: ()) -> () {
fn model() -> () {
}

fn update(&mut self, _msg: ()) {
Expand Down
10 changes: 5 additions & 5 deletions examples/multi-container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Widget for CenterButton {
type Msg = ();
type Root = gtk::Button;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
}

fn parent_id() -> Option<&'static str> {
Expand Down Expand Up @@ -87,7 +87,7 @@ impl Widget for Button {
type Msg = ();
type Root = gtk::Button;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
}

fn parent_id() -> Option<&'static str> {
Expand Down Expand Up @@ -119,7 +119,7 @@ impl Widget for MyFrame {
type Msg = ();
type Root = Frame;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
}

fn root(&self) -> Self::Root {
Expand Down Expand Up @@ -181,7 +181,7 @@ impl Widget for SplitBox {
type Msg = ();
type Root = gtk::Box;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}

Expand Down Expand Up @@ -226,7 +226,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
}

fn root(&self) -> Self::Root {
Expand Down
2 changes: 1 addition & 1 deletion examples/multi-generic-widget-attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub enum Msg {

#[widget]
impl Widget for Win {
fn model(_: ()) -> () {
fn model() -> () {
()
}

Expand Down
4 changes: 2 additions & 2 deletions examples/multi-generic-widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<S: Clone + Display + IncDec, T: Clone + Display + IncDec> Widget for Counte
type Msg = CounterMsg;
type Root = gtk::Box;

fn model((value1, value2): (S, T)) -> Self::Model {
fn model(_: &Relm<Self>, (value1, value2): (S, T)) -> Self::Model {
Model {
counter1: value1,
_counter2: value2,
Expand Down Expand Up @@ -164,7 +164,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}

Expand Down
6 changes: 3 additions & 3 deletions examples/multiple-widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Widget for Text {
type Msg = TextMsg;
type Root = gtk::Box;

fn model(_: ()) -> TextModel {
fn model(_: &Relm<Self>, _: ()) -> TextModel {
TextModel {
content: String::new(),
}
Expand Down Expand Up @@ -131,7 +131,7 @@ impl Widget for Counter {
type Msg = CounterMsg;
type Root = gtk::Box;

fn model(_: ()) -> Model {
fn model(_: &Relm<Self>, _: ()) -> Model {
Model {
counter: 0,
}
Expand Down Expand Up @@ -197,7 +197,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}

Expand Down
2 changes: 1 addition & 1 deletion examples/nested-loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}

Expand Down
8 changes: 4 additions & 4 deletions examples/relm-root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl Widget for Button {
type Msg = ();
type Root = gtk::Button;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
}

fn root(&self) -> gtk::Button {
Expand Down Expand Up @@ -91,7 +91,7 @@ impl Widget for VBox {
type Msg = ();
type Root = EventBox;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}

Expand Down Expand Up @@ -125,7 +125,7 @@ impl Widget for MyVBox {
type Msg = ();
type Root = <VBox as Widget>::Root;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
}

fn root(&self) -> EventBox {
Expand Down Expand Up @@ -172,7 +172,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
}

fn root(&self) -> Window {
Expand Down
2 changes: 1 addition & 1 deletion examples/sync-callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}

Expand Down
2 changes: 1 addition & 1 deletion examples/text-fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;

fn model(_: ()) -> Model {
fn model(_: &Relm<Self>, _: ()) -> Model {
Model {
content: String::new(),
}
Expand Down
4 changes: 2 additions & 2 deletions examples/widget-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl Widget for Counter {
type ModelParam = ();
type Msg = CounterMsg;

fn model(_: ()) -> Model {
fn model(_: &Relm<Self>, _: ()) -> Model {
Model {
counter: 0,
}
Expand Down Expand Up @@ -136,7 +136,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;

fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}

Expand Down
Loading

0 comments on commit 26e3513

Please sign in to comment.