3
* GNOME Do is the legal property of its developers. Please refer to the
4
* COPYRIGHT file distributed with this
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.
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.
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/>.
23
using System.Collections.Generic;
32
public class MediaItemSource : ItemSource
35
List<AlbumMusicItem> albums;
36
List<ArtistMusicItem> artists;
37
List<VideoItem> videos;
38
List<PodcastItem> publishers;
40
public MediaItemSource()
42
if (!Util.VersionSupportsIndexing ()) {
43
Log<Banshee>.Error (Util.UnsupportedVersionMessage);
44
throw new Exception (Util.UnsupportedVersionMessage);
47
items = new List<Item> ();
50
public override string Name {
51
get { return Catalog.GetString ("Banshee Media"); }
54
public override string Description {
55
get { return Catalog.GetString ("Indexes Media from Banshee Media Player"); }
58
public override string Icon {
59
get { return "music-player-banshee"; }
62
public override IEnumerable<Type> SupportedItemTypes {
64
yield return typeof (MediaItem);
65
yield return typeof (BrowseMediaItem);
66
yield return typeof (IApplicationItem);
70
public override IEnumerable<Item> Items {
74
public override IEnumerable<Item> ChildrenOfItem (Item parent)
78
children = new List<Item> ();
80
if (parent is IApplicationItem && (parent as IApplicationItem).Exec.Contains ("banshee-1")) {
81
if (albums != null && albums.Count > 0)
82
children.Add (new BrowseAlbumsMusicItem ());
83
if (artists != null && artists.Count > 0)
84
children.Add (new BrowseArtistMusicItem ());
85
if (videos != null && videos.Count > 0)
86
children.Add (new BrowseVideoItem ());
87
if (publishers != null && publishers.Count > 0)
88
children.Add (new BrowsePublisherPodcastItem ());
90
else if (parent is ArtistMusicItem) {
91
foreach (AlbumMusicItem album in Banshee.LoadAlbumsFor (parent as ArtistMusicItem, albums))
94
else if (parent is AlbumMusicItem) {
95
foreach (SongMusicItem song in Banshee.LoadMedia (parent as AlbumMusicItem))
98
else if (parent is PodcastPublisherItem) {
99
foreach (PodcastPodcastItem pc in Banshee.LoadMedia (parent as PodcastPublisherItem))
102
else if (parent is BrowsePublisherPodcastItem) {
103
foreach (PodcastItem podcast in publishers)
104
children.Add (podcast);
106
else if (parent is BrowseVideoItem) {
107
foreach (VideoItem video in videos)
108
children.Add (video);
110
else if (parent is BrowseAlbumsMusicItem) {
111
foreach (AlbumMusicItem album in albums)
112
children.Add (album);
114
else if (parent is BrowseArtistMusicItem) {
115
foreach (ArtistMusicItem artist in artists)
116
children.Add (artist);
122
public override void UpdateItems ()
127
Banshee.LoadVideos (out videos);
128
Banshee.LoadPodcasts (out publishers);
129
Banshee.LoadAlbumsAndArtists (out albums, out artists);
131
foreach (Item video in videos) items.Add (video);
132
foreach (Item album in albums) items.Add (album);
133
foreach (Item artist in artists) items.Add (artist);
134
foreach (Item podcast in publishers) items.Add (podcast);