Skip to content

Commit

Permalink
Fix libadwaita example
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronErhardt committed Nov 4, 2024
1 parent 221bf34 commit d31e92c
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions examples/libadwaita/simple_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct AppModel {

// ANCHOR: msg
#[derive(Debug)]
enum AppInput {
enum AppMsg {
Increment,
Decrement,
}
Expand All @@ -26,7 +26,7 @@ struct AppWidgets {

// ANCHOR: simple_component
impl SimpleComponent for AppModel {
type Input = AppInput;
type Input = AppMsg;
type Output = ();

type Init = u8;
Expand Down Expand Up @@ -72,13 +72,21 @@ impl SimpleComponent for AppModel {
vbox.append(&header);
vbox.append(&content);

inc_button.connect_clicked(clone!(@strong sender => move |_| {
sender.input(AppInput::Increment);
}));
inc_button.connect_clicked(clone!(
#[strong]
sender,
move |_| {
sender.input(AppMsg::Increment);
}
));

dec_button.connect_clicked(clone!(@strong sender => move |_| {
sender.input(AppInput::Decrement);
}));
dec_button.connect_clicked(clone!(
#[strong]
sender,
move |_| {
sender.input(AppMsg::Decrement);
}
));

let widgets = AppWidgets { label };

Expand All @@ -87,10 +95,10 @@ impl SimpleComponent for AppModel {

fn update(&mut self, message: Self::Input, _sender: ComponentSender<Self>) {
match message {
AppInput::Increment => {
AppMsg::Increment => {
self.counter = self.counter.wrapping_add(1);
}
AppInput::Decrement => {
AppMsg::Decrement => {
self.counter = self.counter.wrapping_sub(1);
}
}
Expand Down

0 comments on commit d31e92c

Please sign in to comment.