diff options
Diffstat (limited to 'main/src/windows/preferences_window/tweaks_preferences_page.vala')
| -rw-r--r-- | main/src/windows/preferences_window/tweaks_preferences_page.vala | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/main/src/windows/preferences_window/tweaks_preferences_page.vala b/main/src/windows/preferences_window/tweaks_preferences_page.vala new file mode 100644 index 00000000..906ca1ae --- /dev/null +++ b/main/src/windows/preferences_window/tweaks_preferences_page.vala @@ -0,0 +1,33 @@ +using Gtk; + +public class Dino.Ui.ViewModel.TweaksPreferencesPage : Object { + public int avatar_roundness { get; set; } + public string custom_css { get; set; default = ""; } +} + +[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; + [GtkChild] private unowned Gtk.TextBuffer custom_css_buffer; + + public ViewModel.TweaksPreferencesPage model { get; set; default = new ViewModel.TweaksPreferencesPage(); } + private Binding[] model_bindings = new Binding[0]; + + construct { + this.notify["model"].connect(on_model_changed); + } + + private void on_model_changed() { + foreach (Binding binding in model_bindings) { + binding.unbind(); + } + if (model != null) { + model_bindings = new Binding[] { + model.bind_property("avatar-roundness", avatar_roundness_row, "value", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), + model.bind_property("custom-css", custom_css_buffer, "text", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL) + }; + } else { + model_bindings = new Binding[0]; + } + } +} |
