aboutsummaryrefslogtreecommitdiff
path: root/main/src/windows/preferences_window/general_preferences_page.vala
diff options
context:
space:
mode:
authoreerielili <lionel@les-miquelots.net>2024-08-25 13:32:38 +0000
committerGitHub <noreply@github.com>2024-08-25 13:32:38 +0000
commit45755727db79a2935376d24e7bde7eadb0f2f7ca (patch)
tree73715da99c9d980079df6f2d561822364655e04d /main/src/windows/preferences_window/general_preferences_page.vala
parent62cdea3a5e701c04f3a7fd9d6b5f48e28fef1f72 (diff)
parent51252f74c94c17d56aa75534652bdc5d43a504cb (diff)
downloaddino-add-yourself.tar.gz
dino-add-yourself.zip
Merge branch 'master' into add-yourselfadd-yourself
Diffstat (limited to 'main/src/windows/preferences_window/general_preferences_page.vala')
-rw-r--r--main/src/windows/preferences_window/general_preferences_page.vala39
1 files changed, 39 insertions, 0 deletions
diff --git a/main/src/windows/preferences_window/general_preferences_page.vala b/main/src/windows/preferences_window/general_preferences_page.vala
new file mode 100644
index 00000000..7aa6c2bd
--- /dev/null
+++ b/main/src/windows/preferences_window/general_preferences_page.vala
@@ -0,0 +1,39 @@
+using Gtk;
+
+public class Dino.Ui.ViewModel.GeneralPreferencesPage : Object {
+ public bool send_typing { get; set; }
+ public bool send_marker { get; set; }
+ public bool notifications { get; set; }
+ public bool convert_emojis { get; set; }
+}
+
+[GtkTemplate (ui = "/im/dino/Dino/preferences_window_general.ui")]
+public class Dino.Ui.GeneralPreferencesPage : Adw.PreferencesPage {
+ [GtkChild] private unowned Switch typing_switch;
+ [GtkChild] private unowned Switch marker_switch;
+ [GtkChild] private unowned Switch notification_switch;
+ [GtkChild] private unowned Switch emoji_switch;
+
+ public ViewModel.GeneralPreferencesPage model { get; set; default = new ViewModel.GeneralPreferencesPage(); }
+ 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("send-typing", typing_switch, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL),
+ model.bind_property("send-marker", marker_switch, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL),
+ model.bind_property("notifications", notification_switch, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL),
+ model.bind_property("convert-emojis", emoji_switch, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL)
+ };
+ } else {
+ model_bindings = new Binding[0];
+ }
+ }
+}