From fd624f34e74601e12e974fdfc8882aaf024c9441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 21 Mar 2024 16:26:51 -0700 Subject: [PATCH] bind to widget --- src/Widgets/AppSettingsView.vala | 12 ++++++------ src/Widgets/SettingsOption.vala | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Widgets/AppSettingsView.vala b/src/Widgets/AppSettingsView.vala index e4925e75..2594bf1f 100644 --- a/src/Widgets/AppSettingsView.vala +++ b/src/Widgets/AppSettingsView.vala @@ -81,9 +81,9 @@ public class Widgets.AppSettingsView : Switchboard.SettingsPage { } private void remove_bindings () { - Settings.unbind (bubbles_option.widget, "state"); - Settings.unbind (sound_option.widget, "state"); - Settings.unbind (remember_option.widget, "state"); + Settings.unbind (bubbles_option, "active"); + Settings.unbind (sound_option, "active"); + Settings.unbind (remember_option, "active"); } private void update_selected_app () { @@ -91,9 +91,9 @@ public class Widgets.AppSettingsView : Switchboard.SettingsPage { var app_id = notify_manager.selected_app_id; var selected_app = notify_manager.apps.get (app_id); - selected_app.settings.bind ("bubbles", bubbles_option.widget, "state", GLib.SettingsBindFlags.DEFAULT); - selected_app.settings.bind ("sounds", sound_option.widget, "state", GLib.SettingsBindFlags.DEFAULT); - selected_app.settings.bind ("remember", remember_option.widget, "state", GLib.SettingsBindFlags.DEFAULT); + selected_app.settings.bind ("bubbles", bubbles_option, "active", DEFAULT); + selected_app.settings.bind ("sounds", sound_option, "active", DEFAULT); + selected_app.settings.bind ("remember", remember_option, "active", DEFAULT); title = selected_app.app_info.get_display_name (); icon = selected_app.app_info.get_icon (); diff --git a/src/Widgets/SettingsOption.vala b/src/Widgets/SettingsOption.vala index 9e23a677..4dec5acd 100644 --- a/src/Widgets/SettingsOption.vala +++ b/src/Widgets/SettingsOption.vala @@ -18,10 +18,11 @@ */ public class Widgets.SettingsOption : Gtk.Grid { + public bool active { get; set; } + public string image_path { get; construct; } public string title { get; construct; } public string description { get; construct; } - public Gtk.Switch widget { get; private set; } private Gtk.Grid card; private Gtk.Settings gtk_settings; @@ -42,7 +43,7 @@ public class Widgets.SettingsOption : Gtk.Grid { card.add_css_class (Granite.STYLE_CLASS_CARD); card.add_css_class (Granite.STYLE_CLASS_ROUNDED); - widget = new Gtk.Switch () { + var widget = new Gtk.Switch () { valign = START }; @@ -64,6 +65,8 @@ public class Widgets.SettingsOption : Gtk.Grid { }); update_image_resource (); + + bind_property ("active", widget, "active", SYNC_CREATE | BIDIRECTIONAL); } private void update_image_resource () {