Permalink
Browse files

Add stream Lock to avoid emitting events when needed

  • Loading branch information...
antoyo committed May 6, 2017
1 parent 6d130a9 commit 26e351385d85f10feb39a14c879143c4b502f40c
View
@@ -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,
}
View
@@ -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 {
@@ -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 {
@@ -57,7 +57,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;
fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}
View
@@ -55,7 +55,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;
fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}
@@ -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)
}
}
View
@@ -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(),
}
@@ -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,
}
@@ -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,
}
@@ -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);
@@ -268,7 +268,7 @@ impl Widget for Win {
}
impl Win {
fn inc(&self) -> CounterMsg {
fn inc(&mut self) -> CounterMsg {
Increment
}
}
View
@@ -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 {
@@ -92,7 +92,7 @@ impl Widget for VBox {
type Msg = ();
type Root = EventBox;
fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}
@@ -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 {
@@ -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,
}
@@ -153,7 +153,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;
fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}
View
@@ -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,
}
View
@@ -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,
}
@@ -43,7 +43,7 @@ use self::Msg::*;
#[widget]
impl Widget for MyFrame {
fn model(_: ()) -> () {
fn model() -> () {
}
fn update(&mut self, _msg: ()) {
@@ -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> {
@@ -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> {
@@ -119,7 +119,7 @@ impl Widget for MyFrame {
type Msg = ();
type Root = Frame;
fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
}
fn root(&self) -> Self::Root {
@@ -181,7 +181,7 @@ impl Widget for SplitBox {
type Msg = ();
type Root = gtk::Box;
fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}
@@ -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 {
@@ -124,7 +124,7 @@ pub enum Msg {
#[widget]
impl Widget for Win {
fn model(_: ()) -> () {
fn model() -> () {
()
}
@@ -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,
@@ -164,7 +164,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;
fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}
@@ -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(),
}
@@ -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,
}
@@ -197,7 +197,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;
fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}
View
@@ -74,7 +74,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;
fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}
View
@@ -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 {
@@ -91,7 +91,7 @@ impl Widget for VBox {
type Msg = ();
type Root = EventBox;
fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}
@@ -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 {
@@ -172,7 +172,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;
fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
}
fn root(&self) -> Window {
@@ -49,7 +49,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;
fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}
View
@@ -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(),
}
View
@@ -66,7 +66,7 @@ impl Widget for Counter {
type ModelParam = ();
type Msg = CounterMsg;
fn model(_: ()) -> Model {
fn model(_: &Relm<Self>, _: ()) -> Model {
Model {
counter: 0,
}
@@ -136,7 +136,7 @@ impl Widget for Win {
type Msg = Msg;
type Root = Window;
fn model(_: ()) -> () {
fn model(_: &Relm<Self>, _: ()) -> () {
()
}
Oops, something went wrong.

0 comments on commit 26e3513

Please sign in to comment.