584.2.1
by Graham Whelan
Added plugin for Exaile music player |
1 |
// MusicItems.cs
|
2 |
//
|
|
3 |
// GNOME Do is the legal property of its developers, whose names are too
|
|
4 |
// numerous to list here. Please refer to the COPYRIGHT file distributed with
|
|
5 |
// this 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 |
||
630
by Christopher James Halse Rogers
Fix translations for plugins. |
23 |
using Mono.Addins; |
584.2.1
by Graham Whelan
Added plugin for Exaile music player |
24 |
|
25 |
using Do.Universe; |
|
26 |
||
584.2.2
by Graham Whelan
Fixed namespace issues and database connection handling |
27 |
namespace Exaile |
584.2.1
by Graham Whelan
Added plugin for Exaile music player |
28 |
{
|
29 |
||
30 |
public abstract class MusicItem : Item |
|
31 |
{
|
|
32 |
protected string name, artist, year, cover; |
|
33 |
||
34 |
public MusicItem () |
|
35 |
{
|
|
36 |
}
|
|
37 |
||
38 |
public MusicItem (string name, string artist, string year, string cover): |
|
39 |
this () |
|
40 |
{
|
|
41 |
this.name = name; |
|
42 |
this.artist = artist; |
|
43 |
this.year = year; |
|
44 |
this.cover = cover; |
|
45 |
}
|
|
46 |
||
47 |
public override string Name { get { return name; } } |
|
48 |
public override string Description { get { return artist; } } |
|
49 |
public override string Icon { get { return Cover ?? "gtk-cdrom"; } } |
|
50 |
||
51 |
public virtual string Artist { get { return artist; } } |
|
52 |
public virtual string Year { get { return year; } } |
|
53 |
public virtual string Cover { get { return cover; } } |
|
54 |
||
55 |
}
|
|
56 |
||
57 |
public class AlbumMusicItem : MusicItem |
|
58 |
{
|
|
59 |
public AlbumMusicItem (string name, string artist, string year, string cover): |
|
60 |
base (name, artist, year, cover) |
|
61 |
{
|
|
62 |
}
|
|
63 |
}
|
|
64 |
||
65 |
public class ArtistMusicItem : MusicItem |
|
66 |
{
|
|
67 |
public ArtistMusicItem (string artist, string cover): |
|
68 |
base () |
|
69 |
{
|
|
70 |
this.artist = this.name = artist; |
|
71 |
this.cover = cover; |
|
72 |
}
|
|
73 |
||
74 |
public override string Description |
|
75 |
{
|
|
76 |
get { |
|
630
by Christopher James Halse Rogers
Fix translations for plugins. |
77 |
return string.Format (AddinManager.CurrentLocalizer.GetString ("All music by") + " {0}", artist); |
584.2.1
by Graham Whelan
Added plugin for Exaile music player |
78 |
}
|
79 |
}
|
|
80 |
}
|
|
81 |
||
82 |
public class SongMusicItem : MusicItem, IComparable<SongMusicItem> |
|
83 |
{
|
|
84 |
string file, album; |
|
85 |
int track; |
|
86 |
||
87 |
public SongMusicItem (string name, string artist, string album, string year, string cover, string file, int track): |
|
88 |
base (name, artist, year, cover) |
|
89 |
{
|
|
90 |
this.file = file; |
|
91 |
this.album = album; |
|
92 |
this.track = track; |
|
93 |
}
|
|
94 |
||
95 |
public override string Icon { get { return "gnome-mime-audio"; } } |
|
96 |
public override string Description |
|
97 |
{
|
|
98 |
get { |
|
99 |
return string.Format ("{0} - {1}", artist, album); |
|
100 |
}
|
|
101 |
}
|
|
102 |
||
103 |
public virtual string File { get { return file; } } |
|
104 |
public virtual string Album { get { return album; } } |
|
105 |
public virtual int Track { get { return track; } } |
|
106 |
||
107 |
public int CompareTo (SongMusicItem other) |
|
108 |
{
|
|
109 |
if (album.CompareTo (other.Album) == 0) |
|
110 |
return track - other.Track; |
|
111 |
return album.CompareTo (other.Album); |
|
112 |
}
|
|
113 |
}
|
|
114 |
}
|