~iwarford/do-plugins/fart-plugin-fwiw

« back to all changes in this revision

Viewing changes to xmms2/src/MusicItems.cs

  • Committer: Jason Jones
  • Date: 2008-12-24 04:45:02 UTC
  • mfrom: (335.1.9 do-plugins)
  • Revision ID: jasonedwardjones@gmail.com-20081224044502-ra56ym06cp1iqs7t
MergedĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  MusicItems.cs
 
2
//
 
3
//  GNOME Do is the legal property of its developers, whose names are too numerous
 
4
//  to list here.  Please refer to the COPYRIGHT file distributed with this
 
5
//  source distribution.
 
6
//
 
7
//  This program is free software: you can redistribute it and/or modify
 
8
//  it under the terms of the GNU General Public License as published by
 
9
//  the Free Software Foundation, either version 3 of the License, or
 
10
//  (at your option) any later version.
 
11
//
 
12
//  This program is distributed in the hope that it will be useful,
 
13
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
//  GNU General Public License for more details.
 
16
//
 
17
//  You should have received a copy of the GNU General Public License
 
18
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 
 
20
using System;
 
21
using System.Collections.Generic;
 
22
 
 
23
 
 
24
using Do.Universe;
 
25
 
 
26
namespace Do.Addins.xmms2
 
27
{
 
28
 
 
29
        public abstract class MusicItem : Item
 
30
        {
 
31
                protected string name, artist, cover;
 
32
                
 
33
                public MusicItem ()
 
34
                {
 
35
                }
 
36
 
 
37
                public MusicItem (string name, string artist,string cover):
 
38
                        this ()
 
39
                {
 
40
                        this.name = name;
 
41
                        this.artist = artist;
 
42
                        this.cover = cover;
 
43
                }
 
44
 
 
45
                public override string Name { get { return name; } }
 
46
                public override string Description { get { return artist; } }
 
47
                public override string Icon { get { return Cover ?? "gtk-cdrom"; } }
 
48
 
 
49
                public virtual string Artist { get { return artist; } }
 
50
                public virtual string Cover { get { return cover; } }
 
51
 
 
52
        }
 
53
 
 
54
        public class AlbumMusicItem : MusicItem
 
55
        {
 
56
                public AlbumMusicItem (string name, string artist, string cover):
 
57
                        base (name, artist, cover)
 
58
                {
 
59
                }
 
60
        }
 
61
 
 
62
        public class ArtistMusicItem : MusicItem
 
63
        {
 
64
                public ArtistMusicItem (string artist, string cover):
 
65
                        base ()
 
66
                {
 
67
                        this.artist = this.name = artist;
 
68
                        this.cover = cover;
 
69
                }
 
70
 
 
71
                public override string Description
 
72
                {
 
73
                        get {
 
74
                                return string.Format ("All music by {0}", artist);
 
75
                        }
 
76
                }
 
77
        }
 
78
 
 
79
        public class SongMusicItem : MusicItem, IComparable
 
80
        {
 
81
                string album; 
 
82
                int id;
 
83
 
 
84
                public SongMusicItem (int id,  string artist, string album, string name):
 
85
                        base (name, artist, null)
 
86
                {
 
87
                        this.id = id;
 
88
                        this.album = album;
 
89
                }
 
90
 
 
91
                public override string Icon { get { return "gnome-mime-audio"; } }
 
92
                public override string Description
 
93
                {
 
94
                        get {
 
95
                                return string.Format ("{0} - {1}", artist, album);
 
96
                        }
 
97
                }
 
98
 
 
99
                public virtual string Album { get { return album; } }
 
100
                public virtual int Id { get { return id; } }
 
101
                
 
102
                public int CompareTo (object o)
 
103
                {
 
104
                        SongMusicItem other = o as SongMusicItem;
 
105
                        if (album.CompareTo (other.Album) == 0)
 
106
                                return id - other.Id;
 
107
                        return album.CompareTo (other.Album);
 
108
                }
 
109
        }
 
110
}