Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppSettingsView: Fix initial switch toggle position #104

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Widgets/AppSettingsView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ 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 () {
var notify_manager = Backend.NotifyManager.get_default ();
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 ();
Expand Down
7 changes: 5 additions & 2 deletions src/Widgets/SettingsOption.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
};

Expand All @@ -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 () {
Expand Down
Loading