Skip to content

Commit

Permalink
book: Use generated wrapper method
Browse files Browse the repository at this point in the history
  • Loading branch information
Hofer-Julian authored and bilelmoussaoui committed Apr 9, 2023
1 parent b48ef5f commit 7493f4d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion book/listings/g_object_properties/3/custom_button/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl WidgetImpl for CustomButton {}
// Trait shared by all buttons
impl ButtonImpl for CustomButton {
fn clicked(&self) {
let incremented_number = self.number.get() + 1;
let incremented_number = self.obj().number() + 1;
self.obj().set_number(incremented_number);
}
}
Expand Down
2 changes: 1 addition & 1 deletion book/listings/g_object_signals/2/custom_button/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static MAX_NUMBER: i32 = 8;
// Trait shared by all buttons
impl ButtonImpl for CustomButton {
fn clicked(&self) {
let incremented_number = self.number.get() + 1;
let incremented_number = self.obj().number() + 1;
let obj = self.obj();
// If `number` reached `MAX_NUMBER`,
// emit "max-number-reached" signal and set `number` back to 0
Expand Down
2 changes: 1 addition & 1 deletion book/src/g_object_properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master
```

We also have to adapt the `clicked` method.
Before we modified `number` directly, now we can use the generated wrapper method `set_number`.
Before we modified `number` directly, now we can use the generated wrapper methods `number` and `set_number`.
This way the "notify" signal will be emitted, which is necessary for the bindings to work as expected.

```rust ,no_run,noplayground
Expand Down

0 comments on commit 7493f4d

Please sign in to comment.