After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 556976 - Playlists appear in non-obvious order
Playlists appear in non-obvious order
Status: RESOLVED FIXED
Product: banshee
Classification: Other
Component: User Interface
git master
Other Linux
: Normal minor
: 1.x
Assigned To: Banshee Maintainers
Banshee Maintainers
: 527285 558423 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-10-19 18:14 UTC by Wouter Bolsterlee (uws)
Modified: 2009-06-04 19:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Keep playlists sorted by name, and manual/smart status (5.06 KB, patch)
2009-02-02 02:34 UTC, John Millikin
reviewed Details | Review
Keep playlists sorted by name (4.82 KB, patch)
2009-02-02 02:37 UTC, John Millikin
reviewed Details | Review
Keep playlists sorted when inserting or renaming them (19.10 KB, patch)
2009-02-15 05:46 UTC, John Millikin
needs-work Details | Review
Keep playlists sorted when inserting or renaming them (v2) (27.93 KB, patch)
2009-02-20 00:46 UTC, John Millikin
needs-work Details | Review
Keep playlists sorted when inserting or renaming them (v3) (27.98 KB, patch)
2009-02-25 20:37 UTC, John Millikin
committed Details | Review
Fallback to .Name if .Count of two sources is equal (681 bytes, patch)
2009-02-27 21:59 UTC, John Millikin
none Details | Review
Patch to add separate-by-type checkbox (11.77 KB, patch)
2009-02-27 23:06 UTC, Gabriel Burt
committed Details | Review

Description Wouter Bolsterlee (uws) 2008-10-19 18:14:31 UTC
The playlists under the "Music Library" source appear in random order (I guess it's sorted by creating date, or database id, which likely yields the same results). Sorting playlists by name would be much more useful. Grouping manual and automatic playlists is *not* desirable (it seems to work that way now), since as a user I do not care about that when selecting the playlist I want to listen to.
Comment 1 Wouter Bolsterlee (uws) 2008-10-25 21:32:48 UTC
Hmm. 1.3.3 has a way to sort the playlists from the context menu of the Music Library.
Comment 2 Wouter Bolsterlee (uws) 2008-10-27 09:03:30 UTC
Reopening. The order is not preserved between restarts. Moreover, the UI is a bit clumsy (well hidden in a context menu, while no functionality should be accessible from a context menu only).
Comment 3 Andrew Conkling 2008-10-29 17:34:15 UTC
(In reply to comment #2)
> Moreover, the UI is a
> bit clumsy (well hidden in a context menu, while no functionality should be
> accessible from a context menu only).

I'd think Alphabetical sort order would be a good default. Also, I filed bug 558423 to capture the lack of "memory" for the sort order.
Comment 4 Mateusz Barucha 2009-01-30 18:02:37 UTC
Associated issue: When creating new playlist, it appears at the top of the list. After restart, the position is changed. It should appear at that position right after creation (user won't have troubles finding it, since there is an animation making it easy to spot).
Comment 5 John Millikin 2009-02-02 02:34:22 UTC
Created attachment 127741 [details] [review]
Keep playlists sorted by name, and manual/smart status
Comment 6 John Millikin 2009-02-02 02:37:57 UTC
Created attachment 127742 [details] [review]
Keep playlists sorted by name

Alternative to the first patch. Changes behavior to ignore distinctions between manual and smart playlists. I made it a separate patch so it'll be easier for a core dev to decide which one they like.
Comment 7 Gabriel Burt 2009-02-03 22:23:04 UTC
Hey John, one thing to note, instead of this:

pl.Renamed += new SourceRenamedHandler (OnChildRenamed);

you can just write

pl.Renamed += OnChildRenamed;

I think maybe C# 1.0 didn't allow the latter.
Comment 8 Gabriel Burt 2009-02-03 22:42:49 UTC
John, Source's Rename method already raises the Source.Updated event - so let's use that as our trigger for resorting.  That way we can have sort-by-count and otehrs and trigger them all off that.

Also, there is already a NameComparer class in Source - you can change it to be case insensitive if you want (probably a good idea).

Instead of modifying PrimarySource, let's make the change in Source.cs itself - change AddChildSource to listen for Updated on each child (and to trigger an immediately resort) and stop listening in RemoveChildSource.

It would be good to have a way for sources to identify the ways that their children can be sorted.  Name and Size are pretty common, but Last.fm has Play Count and Station Type too - would be good if Sources could specify the ways they can be sorted, and the Gtk# context menus/items etc would all be created automatically/consistently.

So you could have something like
struct SourceSortType
{
    public IComparer<Source> Comparer;
    public string Name;  // a not-translated string we can store in gconf to remember the user's pref
    public string Label; // the translated name we show in the context menu
    public bool? ForceDirection; // null if asc/desc are options, or true/false if always forced to asc(true) or desc
}

SourceSortType name = new SourceSortType (new NameComparer (), "name", Catalog.GetString ("name"), null);
SourceSortType station_type = new SourceSortType (new StationTypeComparer (), "station-type", Catalog.GetString ("Station Type"), true);

I like how the Last.fm source has an icon, the extra " by", and its sort menuitems are radio items.

See src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs for how Last.fm currently does it.

Given all the above, you could then put Name and Count as default options for LibrarySources (Music/Video/Podcast).  Maybe could work in a checkbox pref for whether to group by type - maybe could be generic and that's what Last.fm would use too.
Comment 9 John Millikin 2009-02-15 05:46:32 UTC
Created attachment 128752 [details] [review]
Keep playlists sorted when inserting or renaming them

Resort playlists (in fact, all sources) automatically based on `Updated` events from their children.

A few notes on this patch, where I modified classes not directly related to sorting:

> Core/Banshee.ThickClient/Banshee.Sources.Gui/CellEditEntry.cs
The `EditingDone` signal was being sent twice in some cases. Normally this isn't a problem, but with playlists reordered on rename it was causing two playlists to be renamed at once. Now each editor will only fire the signal once.

> Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs
The `SourceView` immediately updated the `SourceModel`'s order field when a source was modified. With updates to the sort order now coming in immediately after source creation, this caused assertions to be raised in `gtk_tree_view_bin_expose()`. I modified the source view to set a flag indicating resorting is needed, and then resorting the entire model after the next expose event.

> Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml
Cosmetic change to put the "sort children" menu in library sources in roughly the same place as in Last.FM, which I think looks nicer.

> It would be good to have a way for sources to identify the ways that their
> children can be sorted.  Name and Size are pretty common, but Last.fm has Play
> Count and Station Type too - would be good if Sources could specify the ways
> they can be sorted, and the Gtk# context menus/items etc would all be created
> automatically/consistently.
This patch has a beginning on this, but generating dynamic menus in a GtkAction-based UI turned out to be tremendously difficult. The only working examples I could find relied on being able to override `Gtk.Action:CreateMenuItem()`, which is not possible in Gtk#. I found two upstream bug reports regarding this, <https://bugzilla.novell.com/show_bug.cgi?id=381744> and <https://bugzilla.novell.com/show_bug.cgi?id=318131>. Once those are solved, dynamic sorting menus will be possible to implement.

> a not-translated string we can store in gconf to remember the user's pref
There's a separate bug about this, bug 558423. It will probably be easier to use integer indexes of the active sort order, like the Last.FM plugin currently does.
Comment 10 Michael Martin-Smucker 2009-02-18 23:54:33 UTC
(In reply to comment #0)
> Sorting playlists by name would be much more useful. Grouping manual
> and automatic playlists is *not* desirable (it seems to work that way now),
> since as a user I do not care about that when selecting the playlist I want to
> listen to.
> 

Just to throw in my two cents from a "normal user" point of view:  I personally like grouping manual and smart playlists separately (visually I like that the icons go together, plus it's just what I'm used to).  Within those two divisions, I would prefer grouping the playlists alphabetically.
Comment 11 Gabriel Burt 2009-02-19 01:29:49 UTC
John,

We generate a dynamic menu for 'Add to Playlist', see TrackActions.cs.  Let's use a id/string based key to store which sort in gconf, too - indexes are too fragile/inhibit future flexibility.

Does anybody use "Name Descending"?  I think we should just remove it; makes finding what 99% of people really want (sort by name) much easier too.

Source should probably default to an empty list of sort optiosn; the Name and Size should probably only be set as default for PrimarySources.  Let's make the default SourceSortType objects static - no reason to have multiple ones around; and maybe make them public static readonly so we can pick and choose which to reuse in Last.fm etc.

Instead of having ActiveChildSortIndex let's just have a ActiveChildSort property that returns the actual SourceSortType object (so we can get the label etc from it).

Thanks, this is looking quite good.
Comment 12 Andrew Conkling 2009-02-19 13:15:01 UTC
*** Bug 558423 has been marked as a duplicate of this bug. ***
Comment 13 John Millikin 2009-02-20 00:46:09 UTC
Created attachment 129109 [details] [review]
Keep playlists sorted when inserting or renaming them (v2)

Implements gabaug's above suggestions. I left NameDescending in as a sort choice for primary sources, because I didn't want to include potentially contentious choices in the patch.
Comment 14 Gabriel Burt 2009-02-20 01:21:48 UTC
What is the point of the None sort option?  I could see possibly having a 'Manual' sort option where the user could reorder them, but if there aren't any other options I'd rather the Sort menu be empty and the list of sort options null.

Expand "if (!(item != null && item.Active)) { return; }" etc out onto three lines, please.

Regarind the resorting happening in the OnExposeEvent override - why?  Are you sure the problem you were seeing before wasn't calling into Gtk+ code from a non-mainloop thread?  You should be able to modify the model anytime you want - from the main thread.  Use Banshee.Base.ThreadAssist.ProxyToMain if you need to.

Put a newline between things like this:

+        };
+        public override SourceSortType[] S

Did you mean to include the CellEditEntry.cs fix?  I don't really care, but thought I'd mention it in case you didn't.

You might/should test it, but I think instead of doing the BuildSortEventHandler thing, you can declare the delegate inline and it will capture the variable appropriately.  It won't capture a variable declared in a foreach () as I learned a few weeks ago (makes sense context-wise) though, just fyi.

Thanks John, this is really close to perfect.
Comment 15 John Millikin 2009-02-20 01:41:51 UTC
> What is the point of the None sort option?  I could see possibly having a
> 'Manual' sort option where the user could reorder them, but if there aren't any
> other options I'd rather the Sort menu be empty and the list of sort options
> null.
The "None" option provides a default sort type for sources that don't support sorting. I don't intend it to be displayed in menus, it's just for implementing a reasonable `DefaultChildSort`.

> Regarind the resorting happening in the OnExposeEvent override - why?  Are you
> sure the problem you were seeing before wasn't calling into Gtk+ code from a
> non-mainloop thread?  You should be able to modify the model anytime you want -
> from the main thread.  Use Banshee.Base.ThreadAssist.ProxyToMain if you need
> to.
The `SourceView` class *does* use `ProxyToMain()` when setting the order. I don't know enough about the innards of GObject/GTK+/Gtk# to confidently diagnose the error, but if you want to try, it's quite reproducible: leave `Banshee.Sources.Gui/SourceView.cs` unmodified, and create a new playlist that will be sorted *below* an existing playlist.

> Did you mean to include the CellEditEntry.cs fix?  I don't really care, but
> thought I'd mention it in case you didn't.
Yes, see the notes in the post for the first version of the patch. Without the fix, renaming a playlist will rename, resort, and rename *again* -- potentially renaming some other playlist.

> You might/should test it, but I think instead of doing the
> BuildSortEventHandler thing, you can declare the delegate inline and it will
> capture the variable appropriately.  It won't capture a variable declared in a
> foreach () as I learned a few weeks ago (makes sense context-wise) though,
> just fyi.
This doesn't work; it will detect every menu item as selecting the last available sort option. Otherwise, it would be quite difficult to use delegates at all because updating the variables they reference would not propagate to the delegate.
Comment 16 Wouter Bolsterlee (uws) 2009-02-20 18:54:36 UTC
I'd say less is more here. There is no point in having "No sorting", and there's no point in having Z-A sorting either.
Comment 17 John Millikin 2009-02-20 19:34:18 UTC
> I'd say less is more here. There is no point in having "No sorting", and
> there's no point in having Z-A sorting either.
As I said above, the "no sorting" option is not exposed to users. It is merely a default sorting value, an internal implementation detail.

Z -> A sorting is supported in the main track list, so I assume *somebody* finds it useful.
Comment 18 Wouter Bolsterlee (uws) 2009-02-21 00:16:43 UTC
(In reply to comment #17)
> As I said above, the "no sorting" option is not exposed to users. It is merely
> a default sorting value, an internal implementation detail.

Thanks for pointing that out, I missed that earlier on.

> Z -> A sorting is supported in the main track list, so I assume *somebody*
> finds it useful.

Yes, but there it's a column that can be sorted on either "this way" or "the other way around". Even I find it useful to e.g. easily find properties which have a "" or NULL value, or the other way around, i.e. find some rare metadata values that *have* been provided in only few of my files :)
Comment 19 John Millikin 2009-02-25 20:37:50 UTC
Created attachment 129515 [details] [review]
Keep playlists sorted when inserting or renaming them (v3)

Apologies for the delay.

Fixes indentation style, removes Z-A sorting from the available options for primary sources.
Comment 20 Gabriel Burt 2009-02-27 20:29:48 UTC
Thanks John, I fixed a few things up and committed:

1) Moved SourceSortType to its own file
2) Checked in Radio toggled event that the radio item is Active to avoid sorting unnecessarily by the one that isn't active anymore
3) Changed Last.fm to use the same SortChildrenAction, and just override the action's label
4) removed the SortNone stuff, default sort is now just null, and added checks for SortTypes.Len > 0 where needed


Things still to do:
1) fall back to sorting by name if size (etc) equal
2) checkbox to separate by type (maybe on by default?)
Comment 21 John Millikin 2009-02-27 21:59:11 UTC
Created attachment 129689 [details] [review]
Fallback to .Name if .Count of two sources is equal
Comment 22 Wouter Bolsterlee (uws) 2009-02-27 22:25:04 UTC
Many thanks for working on this!

One question remains for me:

(In reply to comment #2)
> Moreover, the UI is a
> bit clumsy (well hidden in a context menu, while no functionality should be
> accessible from a context menu only).

Has this also been addressed?

Comment 23 Gabriel Burt 2009-02-27 23:06:50 UTC
Created attachment 129693 [details] [review]
Patch to add separate-by-type checkbox

This patch adds a separate-by-type checkbox to the sort menus, and falls back to Name if other comparisons are equal (eg size).
Comment 24 Gabriel Burt 2009-02-27 23:26:53 UTC
(In reply to comment #22)
> > bit clumsy (well hidden in a context menu, while no functionality should be
> > accessible from a context menu only).
> 
> Has this also been addressed?

No, not yet.  Should it go in the Media menu by the new playlist options?  I guess that makes the most sense with how we currently do things.  Thinking ahead/bigger picture, would it make sense to have a toplevel menu for Source and for Tracks or something?  I don't like how we sort of cram everything into Edit etc.
Comment 25 Wouter Bolsterlee (uws) 2009-02-27 23:32:00 UTC
(In reply to comment #24)
> (In reply to comment #22)
> > > bit clumsy (well hidden in a context menu, while no functionality should be
> > > accessible from a context menu only).
> > Has this also been addressed?

> No, not yet.  Should it go in the Media menu by the new playlist options?  I
> guess that makes the most sense with how we currently do things.

Hard to decide. It's a bit of a mess right now indeed.

> Thinking
> ahead/bigger picture, would it make sense to have a toplevel menu for Source
> and for Tracks or something?  I don't like how we sort of cram everything into
> Edit etc.

Sounds like a good idea. Having a main menu item for each "thing" in the user interface, e.g. "Source" and "Song" makes sense imho.

Comment 26 Gabriel Burt 2009-02-27 23:51:08 UTC
Would you file a new bug, Wouter?  This one is really fixed.
Comment 27 Wouter Bolsterlee (uws) 2009-02-28 11:25:54 UTC
Eh, this one is not yet fixed:

(In reply to comment #24)
> (In reply to comment #22)
> > > bit clumsy (well hidden in a context menu, while no functionality should be
> > > accessible from a context menu only).
> > Has this also been addressed?
> No, not yet.

Functionality that is only available from a context menu is not following Gnome standards (this is also in the HIG).

Wrt. the menu rethinking, that is indeed a separate bug.
Comment 28 Wouter Bolsterlee (uws) 2009-02-28 11:28:28 UTC
(In reply to comment #27)
> Wrt. the menu rethinking, that is indeed a separate bug.

I filed bug 573526 to track the menu rethinking.

Comment 29 Gabriel Burt 2009-06-04 19:16:54 UTC
*** Bug 527285 has been marked as a duplicate of this bug. ***
Comment 30 Gabriel Burt 2009-06-04 19:26:41 UTC
Wouter, please file a separate bug for the context/menu bug.  The playlist
order itself is resolved.