Skip to content

Commit 5b08ea4

Browse files
committed
Revert some next/previous stuff
1 parent 845d0ec commit 5b08ea4

File tree

2 files changed

+37
-61
lines changed

2 files changed

+37
-61
lines changed

src/Services/PlaybackManager.vala

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
*/
55

66
public class Music.PlaybackManager : Object {
7-
public signal bool ask_has_previous ();
8-
public signal bool ask_has_next (bool repeat_all);
97
public signal void invalids_found (int count);
108

119
public AudioObject? current_audio { get; set; default = null; }
@@ -187,61 +185,69 @@ public class Music.PlaybackManager : Object {
187185
public void next (bool eos = false) {
188186
direction = Direction.NEXT;
189187
next_by_eos = eos;
190-
uint position;
191-
bool from_queue = queue_liststore.find (current_audio, out position);
188+
uint position = -1;
189+
queue_liststore.find (current_audio, out position);
192190

193-
if (from_queue && position != queue_liststore.get_n_items () - 1) {
194-
current_audio = (AudioObject) queue_liststore.get_item (position + 1);
195-
return;
196-
}
191+
if (position != -1) {
192+
if (!next_by_eos) {
193+
if (position == queue_liststore.get_n_items () - 1) {
194+
current_audio = (AudioObject) queue_liststore.get_item (0);
195+
if (position == 0) {
196+
seek_to_progress (0);
197+
}
198+
} else {
199+
current_audio = (AudioObject) queue_liststore.get_item (position + 1);
200+
}
197201

198-
if (next_by_eos) {
202+
return;
203+
}
199204
switch (settings.get_string ("repeat-mode")) {
200205
case "disabled":
206+
if (position == queue_liststore.get_n_items () - 1) {
207+
current_audio = null;
208+
return;
209+
}
210+
211+
current_audio = (AudioObject) queue_liststore.get_item (position + 1);
212+
201213
break;
202214

203215
case "all":
204-
if (!from_queue) {
205-
ask_has_next (true);
206-
return;
207-
} else {
216+
if (position == queue_liststore.get_n_items () - 1) {
208217
current_audio = (AudioObject) queue_liststore.get_item (0);
209218
if (position == 0) {
210219
seek_to_progress (0);
211220
}
212-
return;
221+
} else {
222+
current_audio = (AudioObject) queue_liststore.get_item (position + 1);
213223
}
214224

225+
break;
226+
215227
case "one":
216228
seek_to_progress (0);
217-
return;
229+
break;
218230
}
219231
}
220-
221-
ask_has_next (false);
222232
}
223233

224234
public void previous () {
225235
direction = Direction.PREVIOUS;
226236
uint position = -1;
237+
queue_liststore.find (current_audio, out position);
227238

228-
if (queue_liststore.find (current_audio, out position)) {
229-
if (position == 0) {
230-
uint n_items = queue_liststore.get_n_items ();
231-
if (n_items == 1) {
232-
seek_to_progress (0);
233-
} else {
234-
current_audio = (AudioObject) queue_liststore.get_item (n_items - 1);
235-
}
236-
237-
return;
238-
}
239-
239+
if (position != -1 && position != 0) {
240240
current_audio = (AudioObject) queue_liststore.get_item (position - 1);
241-
return;
242241
}
243242

244-
ask_has_previous ();
243+
if (position == 0) {
244+
uint n_items = queue_liststore.get_n_items ();
245+
if (n_items == 1) {
246+
seek_to_progress (0);
247+
} else {
248+
current_audio = (AudioObject) queue_liststore.get_item (n_items - 1);
249+
}
250+
}
245251
}
246252

247253
public void shuffle () {

src/Views/LibraryView.vala

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,36 +55,6 @@ public class Music.LibraryView : Gtk.Box {
5555
});
5656

5757
selection_model.set_selected (Gtk.INVALID_LIST_POSITION);
58-
59-
playback_manager.ask_has_next.connect ((repeat_all) => {
60-
if (selection_model.get_n_items () == 0) {
61-
return false;
62-
}
63-
64-
if (selection_model.selected < selection_model.get_n_items () - 1) {
65-
selection_model.set_selected (selection_model.selected + 1);
66-
return true;
67-
} else if (repeat_all) {
68-
selection_model.set_selected (0);
69-
return true;
70-
}
71-
72-
return false;
73-
});
74-
75-
playback_manager.ask_has_previous.connect (() => {
76-
if (selection_model.get_n_items () == 0) {
77-
return false;
78-
}
79-
80-
if (selection_model.selected > 0) {
81-
selection_model.set_selected (selection_model.selected - 1);
82-
} else {
83-
selection_model.set_selected (selection_model.get_n_items () - 1);
84-
}
85-
86-
return true;
87-
});
8858
}
8959

9060
private void update_stack () {

0 commit comments

Comments
 (0)