Skip to content

Commit 70a9a84

Browse files
authored
Move playbackmanager lambas where we can see them (#809)
1 parent 8215fff commit 70a9a84

1 file changed

Lines changed: 30 additions & 26 deletions

File tree

src/PlaybackManager.vala

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,9 @@ public class Music.PlaybackManager : Object {
5454
critical ("Unable to start Gstreamer Discoverer: %s", e.message);
5555
}
5656

57-
queue_liststore.items_changed.connect (() => {
58-
var shuffle_action_action = (SimpleAction) GLib.Application.get_default ().lookup_action (Application.ACTION_SHUFFLE);
59-
has_items = queue_liststore.get_n_items () > 0;
60-
shuffle_action_action.set_enabled (queue_liststore.get_n_items () > 1);
61-
update_next_previous_sensitivity ();
62-
});
63-
64-
notify["current-audio"].connect (() => {
65-
playbin.set_state (Gst.State.NULL);
66-
if (current_audio != null) {
67-
playbin.uri = current_audio.uri;
68-
playbin.set_state (Gst.State.PLAYING);
69-
} else {
70-
playbin.uri = "";
71-
playback_position = 0;
57+
queue_liststore.items_changed.connect (on_items_changed);
7258

73-
if (progress_timer != 0) {
74-
Source.remove (progress_timer);
75-
progress_timer = 0;
76-
}
77-
}
78-
79-
update_next_previous_sensitivity ();
80-
81-
var play_pause_action = (SimpleAction) GLib.Application.get_default ().lookup_action (Application.ACTION_PLAY_PAUSE);
82-
play_pause_action.set_enabled (current_audio != null);
83-
});
59+
notify["current-audio"].connect (on_audio_changed);
8460

8561
settings = new Settings ("io.elementary.music");
8662
}
@@ -451,4 +427,32 @@ public class Music.PlaybackManager : Object {
451427

452428
return pix;
453429
}
430+
431+
private void on_items_changed () {
432+
var shuffle_action_action = (SimpleAction) GLib.Application.get_default ().lookup_action (Application.ACTION_SHUFFLE);
433+
has_items = queue_liststore.get_n_items () > 0;
434+
shuffle_action_action.set_enabled (queue_liststore.get_n_items () > 1);
435+
update_next_previous_sensitivity ();
436+
}
437+
438+
private void on_audio_changed () {
439+
playbin.set_state (Gst.State.NULL);
440+
if (current_audio != null) {
441+
playbin.uri = current_audio.uri;
442+
playbin.set_state (Gst.State.PLAYING);
443+
} else {
444+
playbin.uri = "";
445+
playback_position = 0;
446+
447+
if (progress_timer != 0) {
448+
Source.remove (progress_timer);
449+
progress_timer = 0;
450+
}
451+
}
452+
453+
update_next_previous_sensitivity ();
454+
455+
var play_pause_action = (SimpleAction) GLib.Application.get_default ().lookup_action (Application.ACTION_PLAY_PAUSE);
456+
play_pause_action.set_enabled (current_audio != null);
457+
}
454458
}

0 commit comments

Comments
 (0)