Skip to content

Commit 7493f4d

Browse files
Hofer-Julianbilelmoussaoui
authored andcommitted
book: Use generated wrapper method
1 parent b48ef5f commit 7493f4d

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

book/listings/g_object_properties/3/custom_button/imp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl WidgetImpl for CustomButton {}
5858
// Trait shared by all buttons
5959
impl ButtonImpl for CustomButton {
6060
fn clicked(&self) {
61-
let incremented_number = self.number.get() + 1;
61+
let incremented_number = self.obj().number() + 1;
6262
self.obj().set_number(incremented_number);
6363
}
6464
}

book/listings/g_object_signals/2/custom_button/imp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static MAX_NUMBER: i32 = 8;
6969
// Trait shared by all buttons
7070
impl ButtonImpl for CustomButton {
7171
fn clicked(&self) {
72-
let incremented_number = self.number.get() + 1;
72+
let incremented_number = self.obj().number() + 1;
7373
let obj = self.obj();
7474
// If `number` reached `MAX_NUMBER`,
7575
// emit "max-number-reached" signal and set `number` back to 0

book/src/g_object_properties.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master
6767
```
6868

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

7373
```rust ,no_run,noplayground

0 commit comments

Comments
 (0)