~elementary-apps/noise/0.4.x

« back to all changes in this revision

Viewing changes to core/Playlists/Playlist.vala

  • Committer: Corentin Noël
  • Author(s): Baptiste Gelez
  • Date: 2017-11-03 10:39:06 UTC
  • Revision ID: git-v1:e56cb30d9beaa45b13c71ab9fb978d7100144cfa
Change the queue mechanism to make it less confusing (#65)

* Change the queue mechanism to make it less confusing

Fix #2

Now, when you double-click on a song, it is played and other songs of
the current list are added to the queue.

Also improved the style of some parts of the code, and changed many
Gee.HashMap<int, Media> to ArrayList<int, Media> (they were acting as
arrays, I don't know why they were maps).

* Remove `this` when possible

* Use GObject construction as much as possible

* Use Playlist.get, Playlist.set and Playlist.iterator when possible

* Soft-copy lists in ListView.vala

* construct accessor on properties needing it

* Make Noise.Plugins.CDView.dev public to support construct

* Fix many GObject warninsgs and segfaults

* Make it possible to jump to a specific track from the queue

* Fix duplicated queue bug

* Order the queue correctly

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 *
26
26
 * Authored by: Corentin Noël <corentin@elementary.io>
27
27
 */
28
 
 
 
28
 
29
29
public abstract class Noise.Playlist : Object {
30
30
    public signal void request_play ();
31
 
    public virtual Gee.ArrayQueue<Media> medias { get; internal set; }
32
 
 
33
 
    public int64 rowid { get; set; }
 
31
 
 
32
    public virtual Gee.ArrayList<Media> medias { get; internal set; default = new Gee.ArrayList<Media> (); }
 
33
 
 
34
    public int64 rowid { get; construct set; }
34
35
    public GLib.Icon icon;
35
36
    internal string _name = "";
36
37
    public virtual string name {
37
38
        get {
38
39
            return _name;
39
 
        } 
40
 
        set {
 
40
        }
 
41
        construct set {
41
42
            string old_name = _name;
42
43
            _name = value;
43
44
            updated (old_name);
56
57
    public abstract void clear ();
57
58
 
58
59
    public bool is_empty () {
59
 
        return (medias.size <= 0);
 
60
        return medias.size <= 0;
 
61
    }
 
62
 
 
63
    /**
 
64
    * Retrives a Media at an index in this playlist
 
65
    */
 
66
    public new Media get (int index) {
 
67
        return medias[index];
 
68
    }
 
69
 
 
70
    public new void set (int index, Media m) {
 
71
        medias[index] = m;
 
72
    }
 
73
 
 
74
    public Gee.Iterator<Media> iterator () {
 
75
        return medias.iterator ();
60
76
    }
61
77
}