Skip to content

Commit

Permalink
Cleanup + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Aug 26, 2023
1 parent c51c0ce commit c84e426
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/AppRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public class Sound.AppRow : Gtk.ListBoxRow {
private Gtk.Scale volume_scale;
private Gtk.Switch mute_switch;

private bool updating = false;

construct {
image = new Gtk.Image () {
pixel_size = 32
Expand Down Expand Up @@ -69,22 +67,20 @@ public class Sound.AppRow : Gtk.ListBoxRow {
icon_button.clicked.connect (() => toggle_mute_application ());

mute_switch.state_set.connect ((state) => {
toggle_mute_application (state);
toggle_mute_application (!state);
return true;
});
}

private void toggle_mute_application (bool? custom = null) {
if (app == null || updating) {
if (app == null) {
return;
}

PulseAudioManager.get_default ().mute_application (app, null != null ? custom : !app.muted);
PulseAudioManager.get_default ().mute_application (app, custom != null ? custom : !app.muted);
}

private void update () {
updating = true;

volume_scale.set_value (app.volume);
mute_switch.state = !app.muted;
volume_scale.sensitive = !app.muted;
Expand All @@ -98,8 +94,6 @@ public class Sound.AppRow : Gtk.ListBoxRow {
} else {
((Gtk.Image) icon_button.image).icon_name = "audio-volume-medium";
}

updating = false;
}

public void bind_app (App app) {
Expand Down

0 comments on commit c84e426

Please sign in to comment.