aboutsummaryrefslogtreecommitdiff
path: root/main/src/windows/preferences_window/tweaks_preferences_page.vala
blob: 6da43348e28ed5137d84a29e7f828a35d6f1c803 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using Gtk;

public class Dino.Ui.ViewModel.TweaksPreferencesPage : Object {
    public int avatar_roundness { get; set; }
}

[GtkTemplate (ui = "/im/dino/Dino/preferences_window/tweaks_preferences_page.ui")]
public class Dino.Ui.TweaksPreferencesPage : Adw.PreferencesPage {
    [GtkChild] private unowned Adw.SpinRow avatar_roundness_row;

    public ViewModel.TweaksPreferencesPage model { get; set; default = new ViewModel.TweaksPreferencesPage(); }
    private Binding? avatar_roundness_binding;

    construct {
        this.notify["model"].connect(on_model_changed);
    }

    private void on_model_changed() {
        if (avatar_roundness_binding != null) {
            avatar_roundness_binding.unbind();
            avatar_roundness_binding = null;
        }
        if (model != null) {
            avatar_roundness_binding = model.bind_property("avatar-roundness", avatar_roundness_row, "value", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
        }
    }
}