Skip to content

Commit c1119a0

Browse files
authored
Bind Settings to active instead of state (#1370)
When binding to `state` the `Switch` can be in a wrong position where it is colored to be active, but the slider is at the wrong spot. As per advice in the GTK-chat, one should instead bind to the active-property.
1 parent c4fd92f commit c1119a0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

book/listings/settings/2/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn build_ui(app: &Application) {
3131

3232
// ANCHOR: settings_bind
3333
settings
34-
.bind("is-switch-enabled", &switch, "state")
34+
.bind("is-switch-enabled", &switch, "active")
3535
.flags(SettingsBindFlags::DEFAULT)
3636
.build();
3737
// ANCHOR_END: settings_bind

book/src/settings.md

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

7777
The `Switch` now retains its state even after closing the application.
7878
But we can make this even better.
79-
The `Switch` has a property "state" and `Settings` allows us to bind properties to a specific setting.
79+
The `Switch` has a property "active" and `Settings` allows us to bind properties to a specific setting.
8080
So let's do exactly that.
8181

8282
We can remove the [`boolean`](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio/prelude/trait.SettingsExt.html#tymethod.boolean) call before initializing the `Switch` as well as the [`connect_state_set`](../docs/gtk4/struct.Switch.html#method.connect_state_set) call.

0 commit comments

Comments
 (0)