~karol-bedkowski/do-plugins/putty-fix-324282_load_parameter

« back to all changes in this revision

Viewing changes to Banshee/src/MediaItems.cs

  • Committer: Alex Launi
  • Date: 2009-01-23 02:23:36 UTC
  • mfrom: (276.4.12 bansheeplugin)
  • Revision ID: alex.launi@gmail.com-20090123022336-z0hf1ycf7pvg5i0d
Add full Banshee plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* MediaItems.cs
 
2
 *
 
3
 * GNOME Do is the legal property of its developers. Please refer to the
 
4
 * 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
 
 
21
using System;
 
22
using Do.Universe;
 
23
 
 
24
using Mono.Unix;
 
25
 
 
26
namespace Banshee
 
27
{
 
28
        public interface IMediaFile : IFileItem
 
29
        {
 
30
                string Year { get; }
 
31
                string Title { get; }
 
32
                string Artist { get; }
 
33
        }
 
34
        
 
35
        public class MediaItem : Item
 
36
        {
 
37
                protected string name, artist, year, cover;
 
38
                
 
39
                public MediaItem ()
 
40
                {
 
41
                }
 
42
                
 
43
                public MediaItem (string name, string artist, string year, string cover)
 
44
                {
 
45
                        this.name = name;
 
46
                        this.artist = artist;
 
47
                        this.year = year;
 
48
 
 
49
                        if (System.IO.File.Exists (cover))
 
50
                                this.cover = cover;
 
51
                }
 
52
                
 
53
                public override string Name {
 
54
                        get { return name; }
 
55
                }
 
56
                
 
57
                public override string Description {
 
58
                        get { return year == null ? Artist : string.Format ("{0} ({1})", artist, Year); }
 
59
                }
 
60
                
 
61
                public override string Icon {
 
62
                        get { return cover ?? "applications-multimedia"; }
 
63
                }
 
64
                
 
65
                public virtual string Artist {
 
66
                        get { return artist; }
 
67
                }
 
68
                
 
69
                public virtual string Year {
 
70
                        get { return year; }
 
71
                }
 
72
                
 
73
                public virtual string Cover {
 
74
                        get { return cover; }
 
75
                }
 
76
        }
 
77
        
 
78
        public class VideoItem : MediaItem, IMediaFile
 
79
        {
 
80
                string file;
 
81
                public VideoItem (string name, string artist, string year, string cover, string file) :
 
82
                        base (name, artist, year, cover)
 
83
                {
 
84
                        this.file = file;
 
85
                }
 
86
                
 
87
                public override string Icon {
 
88
                        get { return cover ?? "video-x-generic"; }
 
89
                }
 
90
                
 
91
                public string Title {
 
92
                        get { return Name; }
 
93
                }
 
94
                public string Path {
 
95
                        get { return file; }
 
96
                }
 
97
 
 
98
                public string Uri {
 
99
                        get { return string.Format ("file://{0}", Path); }
 
100
                }
 
101
        }
 
102
        
 
103
        public class PodcastItem : MediaItem
 
104
        {
 
105
                public PodcastItem ()
 
106
                {
 
107
                }
 
108
                
 
109
                public PodcastItem (string artist, string year, string cover) : base ()
 
110
                {
 
111
                        this.artist = artist;
 
112
                        this.year = year;
 
113
                        this.cover = cover;
 
114
                }
 
115
                
 
116
                public override string Icon {
 
117
                        get { return cover ?? "audio-x-generic"; }
 
118
                }
 
119
        }
 
120
        
 
121
        public class PodcastPublisherItem : PodcastItem
 
122
        {
 
123
                public PodcastPublisherItem (string artist, string year, string cover) :
 
124
                        base (artist, year, cover)
 
125
                {
 
126
                        this.name = artist;
 
127
                }
 
128
        }
 
129
         
 
130
        public class PodcastPodcastItem : PodcastItem, IMediaFile
 
131
        {               
 
132
                string file;
 
133
                public PodcastPodcastItem (string name, string artist, string year, string cover, string file) :
 
134
                        base (artist, year, cover)
 
135
                {
 
136
                        this.name = name;
 
137
                        this.file = file;
 
138
                }
 
139
                
 
140
                public override string Icon {
 
141
                        get { return "audio-x-generic"; }
 
142
                }
 
143
 
 
144
                public string Title {
 
145
                        get { return Name; }
 
146
                }
 
147
                
 
148
                public string Path {
 
149
                        get { return file; }
 
150
                }
 
151
 
 
152
                public string Uri {
 
153
                        get { return string.Format ("file://{0}", Path); }
 
154
                }
 
155
        }
 
156
                        
 
157
        public class MusicItem : MediaItem
 
158
        {
 
159
                public MusicItem ()
 
160
                {
 
161
                }
 
162
                
 
163
                public MusicItem (string name, string artist, string year, string cover)
 
164
                        : base (name, artist, year, cover)
 
165
                {
 
166
                }
 
167
                
 
168
                public override string Icon {
 
169
                        get { return cover ?? "gtk-cdrom"; }
 
170
                }
 
171
        }
 
172
        
 
173
        public class AlbumMusicItem : MusicItem
 
174
        {
 
175
                public AlbumMusicItem (string name, string artist, string year, string cover) : 
 
176
                        base (name, artist, year, cover)
 
177
                {
 
178
                }
 
179
        }
 
180
        
 
181
        public class ArtistMusicItem : MusicItem
 
182
        {
 
183
                public ArtistMusicItem (string name, string cover) : base ()
 
184
                {
 
185
                        this.name = this.artist = name;
 
186
                        this.cover = cover;
 
187
                }
 
188
                
 
189
                public override string Description {
 
190
                        get { return string.Format ("{0} {1} {2}", 
 
191
                                Catalog.GetString ("All Music by"), artist, Year); }
 
192
                }
 
193
                
 
194
                public override string Icon {
 
195
                        get { return cover ?? "audio-input-microphone"; }
 
196
                }
 
197
        }
 
198
        
 
199
        public class SongMusicItem : MusicItem, IMediaFile
 
200
        {
 
201
                string file, album, track;
 
202
                
 
203
                public SongMusicItem (string name, string artist, string album, string year,
 
204
                        string cover, string track, string file) : base (name, artist, year, cover)
 
205
                {
 
206
                        this.file = file;
 
207
                        this.album = album;
 
208
                        this.track = track;
 
209
                }
 
210
                
 
211
                public override string Description {
 
212
                        get { return string.Format ("{0} - {1}", artist, album); }
 
213
                }
 
214
                
 
215
                public override string Icon {
 
216
                        get { return "audio-x-generic"; }
 
217
                }
 
218
 
 
219
                public string Title {
 
220
                        get { return Name; }
 
221
                }
 
222
                
 
223
                public string Path {
 
224
                        get { return file; }
 
225
                }
 
226
 
 
227
                public string Uri {
 
228
                        get { return string.Format ("file://{0}", Path); }
 
229
                }
 
230
                
 
231
                public string Album {
 
232
                        get { return album; }
 
233
                }
 
234
                
 
235
                public string Track {
 
236
                        get { return track != null ? track.PadLeft (3, '0') : string.Empty; }
 
237
                }
 
238
        }
 
239
}
 
 
b'\\ No newline at end of file'