[gnome-music/wip/jfelder/playlistview-random-song: 3/3] playlistview: Select a random song in ShuffleMode
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/playlistview-random-song: 3/3] playlistview: Select a random song in ShuffleMode
- Date: Mon, 15 Apr 2019 16:00:48 +0000 (UTC)
commit 5ce7734178fbdbea4fb76855d267c0c7763a3d2c
Author: Jean Felder <jfelder src gnome org>
Date: Mon Apr 15 17:02:39 2019 +0200
playlistview: Select a random song in ShuffleMode
By default, when a playlist is launched from the play button, the
first song is chosen and the playlist starts. However, if the player
is in ShuffleMode this does not seem right: a random song should be
selected.
Fix it by picking a random row if the player is in ShuffleMode.
Related: #272
gnomemusic/views/playlistview.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/views/playlistview.py b/gnomemusic/views/playlistview.py
index 9f3cfbef..696be02b 100644
--- a/gnomemusic/views/playlistview.py
+++ b/gnomemusic/views/playlistview.py
@@ -23,12 +23,13 @@
# delete this exception statement from your version.
from gettext import gettext as _
+from random import randrange
from gi.repository import Gdk, Gio, GLib, GObject, Gtk, Pango
from gnomemusic import log
from gnomemusic.grilo import grilo
-from gnomemusic.player import ValidationStatus, PlayerPlaylist
+from gnomemusic.player import RepeatMode, ValidationStatus, PlayerPlaylist
from gnomemusic.playlists import Playlists, StaticPlaylists
from gnomemusic.views.baseview import BaseView
from gnomemusic.widgets.notificationspopup import PlaylistNotification
@@ -607,6 +608,9 @@ class PlaylistView(BaseView):
@log
def _on_play_activate(self, menuitem, data=None):
_iter = self.model.get_iter_first()
+ if self.player.props.repeat_mode == RepeatMode.SHUFFLE:
+ index = randrange(len(self.model))
+ _iter = self.model.get_iter_from_string(str(index))
if not _iter:
return
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]