Re: [Muine] [patch] Sort playlist (including random)
- From: Jorn Baayen <jbaayen gnome org>
- To: Simon Hart <sphart uklinux net>
- Cc: muine-list gnome org
- Subject: Re: [Muine] [patch] Sort playlist (including random)
- Date: Fri, 09 Apr 2004 12:28:10 +0200
Hey,
This is cool. However, I'm not going to commit it as I have different
plans for random- it's a lot of work (and design work, still) so it
might not be here very soon, but it's definitely coming.
But, like I said, this is cool - for people who want random NOW. :)
Cheers,
Jorn
On Fri, 2004-04-09 at 11:20 +0100, Simon Hart wrote:
> Hi,
>
> Thanks for the great player.
>
> This patch allows sorting the playlist in various ways, including
> randomly.
> I'm not suggesting it should be applied - it is probably not the best
> way of providing random playback, but I wanted that feature now ...
>
> As such the patch doesn't provide sensitivity, tooltips, and prevents
> manually re-ordering the playlist (via darg 'n' drop) after a sort has
> being applied.
>
>
> http://www.sphart.uklinux.net/muine-sort.diff
>
> Thanks
> Simon
>
>
> diff -urNX diff.ign muine-0.5.2/src/Album.cs muine-0.5.2-random/src/Album.cs
> --- muine-0.5.2/src/Album.cs 2004-02-26 10:46:10.000000000 +0000
> +++ muine-0.5.2-random/src/Album.cs 2004-04-08 18:47:13.000000000 +0100
> @@ -100,6 +100,17 @@
> }
> }
>
> + private int randomsortkey;
> + public int RandomSortKey {
> + // setattr so can re-randomise playlist
> + set {
> + randomsortkey = value;
> + }
> + get {
> + return randomsortkey;
> + }
> + }
> +
> private static Hashtable pointers = new Hashtable ();
> private static IntPtr cur_ptr = IntPtr.Zero;
>
> diff -urNX diff.ign muine-0.5.2/src/NotificationAreaIcon.cs muine-0.5.2-random/src/NotificationAreaIcon.cs
> --- muine-0.5.2/src/NotificationAreaIcon.cs 2004-04-03 12:00:58.000000000 +0100
> +++ muine-0.5.2-random/src/NotificationAreaIcon.cs 2004-04-08 23:34:01.000000000 +0100
> @@ -197,7 +197,7 @@
> {
> x = menu_x;
> y = menu_y;
> -
> +/*
> int monitor = menu.Screen.GetMonitorAtPoint (x, y);
> Gdk.Rectangle rect = menu.Screen.GetMonitorGeometry (monitor);
>
> @@ -221,7 +221,7 @@
> } else {
> y = rect.Y;
> }
> -
> +*/
> push_in = true;
> }
>
> diff -urNX diff.ign muine-0.5.2/src/PlaylistWindow.cs muine-0.5.2-random/src/PlaylistWindow.cs
> --- muine-0.5.2/src/PlaylistWindow.cs 2004-04-03 12:28:41.000000000 +0100
> +++ muine-0.5.2-random/src/PlaylistWindow.cs 2004-04-08 18:47:13.000000000 +0100
> @@ -43,6 +43,8 @@
> private ImageMenuItem skip_forward_menu_item;
> [Glade.Widget]
> private ImageMenuItem information_menu_item;
> + //[Glade.Widget]
> + //private ImageMenuItem randomize_playlist_by_song_menu_item;
> [Glade.Widget]
> private ImageMenuItem remove_song_menu_item;
> [Glade.Widget]
> @@ -722,6 +724,7 @@
> playlist.Select (playlist.Playing);
> }
>
> +
> public void OpenPlaylist (string fn)
> {
> StreamReader reader;
> @@ -995,7 +998,6 @@
>
> if (playlist.HasNext) {
> playlist.Next ();
> -
> SongChanged (true);
> } else {
> if (repeat_menu_item.Active) {
> @@ -1301,6 +1303,92 @@
> playlist.Select (playlist.Playing);
> }
>
> + public int SortPlaylistByTitleFunc (IntPtr a, IntPtr b)
> + {
> + Song songa = Song.FromHandle (a);
> + Song songb = Song.FromHandle (b);
> + int res = StringUtils.StrCmp (StringUtils.CollateKey (songa.Title), StringUtils.CollateKey (songb.Title));
> + return res;
> + }
> +
> + public int SortPlaylistByAlbumFunc (IntPtr a, IntPtr b)
> + {
> + Song songa = Song.FromHandle (a);
> + Song songb = Song.FromHandle (b);
> + int res = StringUtils.StrCmp (StringUtils.CollateKey (songb.Album), StringUtils.CollateKey (songa.Album));
> + if (res == 0) {
> + if (songa.TrackNumber > 0 && songb.TrackNumber > 0)
> + res = songa.TrackNumber - songb.TrackNumber;
> + else
> + res = StringUtils.StrCmp (StringUtils.CollateKey (songa.Title), StringUtils.CollateKey (songb.Title));
> + }
> + return res;
> + }
> +
> + public int SortPlaylistByRandomFunc (IntPtr a, IntPtr b)
> + {
> + Song songa = Song.FromHandle (a);
> + Song songb = Song.FromHandle (b);
> + int res = songa.RandomSortKey - songb.RandomSortKey;
> + return res;
> + }
> +
> + public int SortPlaylistByRandomAlbumFunc (IntPtr a, IntPtr b)
> + {
> + // XXX this is slow ...
> + Song songa = Song.FromHandle (a);
> + Song songb = Song.FromHandle (b);
> + Album albuma = (Album) Muine.DB.Albums [songa.AlbumKey];
> + Album albumb = (Album) Muine.DB.Albums [songb.AlbumKey];
> + int res = albuma.RandomSortKey - albumb.RandomSortKey;
> + if (res == 0) {
> + if (songa.TrackNumber > 0 && songb.TrackNumber > 0)
> + res = songa.TrackNumber - songb.TrackNumber;
> + else
> + res = StringUtils.StrCmp (StringUtils.CollateKey (songa.Title), StringUtils.CollateKey (songb.Title));
> + }
> + return res;
> + }
> +
> + private void HandleSortByTitleCommand (object o, EventArgs args)
> + {
> + playlist.SortFunc = new HandleView.CompareFunc(SortPlaylistByTitleFunc);
> + NSongsChanged ();
> + }
> +
> + private void HandleSortByAlbumCommand (object o, EventArgs args)
> + {
> + playlist.SortFunc = new HandleView.CompareFunc(SortPlaylistByAlbumFunc);
> + NSongsChanged ();
> + }
> +
> + private void HandleRandomizeBySongCommand (object o, EventArgs args)
> + {
> + Random rand = new Random ();
> +
> + foreach (int i in playlist.Contents) {
> + Song song = Song.FromHandle ((IntPtr)i);
> + song.RandomSortKey = rand.Next ();
> + }
> +
> + playlist.SortFunc = new HandleView.CompareFunc(SortPlaylistByRandomFunc);
> + NSongsChanged ();
> + }
> +
> + private void HandleRandomizeByAlbumCommand (object o, EventArgs args)
> + {
> + Random rand = new Random ();
> +
> + foreach (int i in playlist.Contents) {
> + Song song = Song.FromHandle ((IntPtr)i);
> + Album album = (Album) Muine.DB.Albums [song.AlbumKey];
> + album.RandomSortKey = rand.Next ();
> + }
> +
> + playlist.SortFunc = new HandleView.CompareFunc(SortPlaylistByRandomAlbumFunc);
> + NSongsChanged ();
> + }
> +
> private void HandleClearPlaylistCommand (object o, EventArgs args)
> {
> ClearPlaylist ();
> diff -urNX diff.ign muine-0.5.2/src/Song.cs muine-0.5.2-random/src/Song.cs
> --- muine-0.5.2/src/Song.cs 2004-04-03 14:44:26.000000000 +0100
> +++ muine-0.5.2-random/src/Song.cs 2004-04-08 18:47:13.000000000 +0100
> @@ -152,6 +152,17 @@
> }
> }
>
> + private int randomsortkey;
> + public int RandomSortKey {
> + // setattr so can re-randomise playlist
> + set {
> + randomsortkey = value;
> + }
> + get {
> + return randomsortkey;
> + }
> + }
> +
> public string AlbumKey {
> get {
> if (album.Length == 0)
> _______________________________________________
> muine-list mailing list
> muine-list gnome org
> http://lists.gnome.org/mailman/listinfo/muine-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]