1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
# Copyright (C) 2009-2010 Erin Drummond
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# The developers of the Exaile media player hereby grant permission
# for non-GPL compatible GStreamer and Exaile plugins to be used and
# distributed together with GStreamer and Exaile. This permission is
# above and beyond the permissions granted by the GPL license by which
# Exaile is covered. If you modify this code, you may extend this
# exception to your version of the code, but you are not obligated to
# do so. If you do not wish to do so, delete this exception statement
# from your version.
class TreeItem(object):
def __init__(self, id, name, has_been_expanded=False):
self._id = id
self._name = name
self._type = type
self._has_been_expanded = has_been_expanded
def __repr__(self):
return self._name
#Getter and Setter crap
def get_id(self):
return self._id
def get_name(self):
return self._name
def get_has_been_expanded(self):
return self._has_been_expanded
def set_has_been_expanded(self, value):
self._has_been_expanded = value
#this is the location in the TreeStore so that child objects can be added to this object (row_pointer should be a TreeIter object)
def get_row_pointer(self):
return self._row_pointer
def set_row_pointer(self, value):
self._row_pointer = value
id = property(get_id)
name = property(get_name)
expanded = property(get_has_been_expanded, set_has_been_expanded)
row_pointer = property(get_row_pointer, set_row_pointer)
class Artist(TreeItem):
def __init__(self, id, name, has_been_expanded=False):
TreeItem.__init__(self, id, name, has_been_expanded)
self._albums = []
#add an album to this artist
def add_album(self, album):
if isinstance(album, Album):
album.artist_name = self.name
self._albums.append(album)
def get_albums(self):
return self._albums
albums = property(get_albums)
class Album(TreeItem):
def __init__(self, id, name, has_been_expanded=False):
TreeItem.__init__(self, id, name, has_been_expanded)
self._tracks = []
self._artist_name = "Default"
def add_track(self, track):
if isinstance(track, Track):
track.artist_name = self.artist_name
track.album_name = self.name
self._tracks.append(track)
def get_tracks(self):
return self._tracks
def get_artist_name(self):
return self._artist_name
def set_artist_name(self, value):
self._artist_name = value
tracks = property(get_tracks)
artist_name = property(get_artist_name, set_artist_name)
class Track(TreeItem):
def __init__(self, id, name, url):
TreeItem.__init__(self, id, name)
self._url = url
self._artist_name = "http://jamendo.com"
self._album = "http://jamendo.com"
def get_url(self):
return self._url
def get_album_name(self):
return self._album
def set_album_name(self, value):
self._album = value
def get_artist_name(self):
return self._artist_name
def set_artist_name(self, value):
self._artist_name = value
url = property(get_url)
#used for adding the track to the playlist initially
artist_name = property(get_artist_name, set_artist_name)
album_name = property(get_album_name, set_album_name)
|