Mercurial > vixm
changeset 3:dd00b69169c6
Created initial ui thread code, fixed up playlist code
author | Josef "Jeff" Sipek <jeffpc@josefsipek.net> |
---|---|
date | Sat, 12 Aug 2006 21:00:00 -0400 |
parents | 80a717f97cef |
children | b34cc91f003d |
files | vixm/playlist.py vixm/ui.py |
diffstat | 2 files changed, 61 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/vixm/playlist.py Sat Aug 12 20:21:06 2006 -0400 +++ b/vixm/playlist.py Sat Aug 12 21:00:00 2006 -0400 @@ -1,15 +1,28 @@ # a playlist definition +import xmms + +LIST_PRIO = 0 +LIST_DEFAULT = 1 + class playlist: - def __init__(self): + def __init__(self, allowrandom=False): self.__list = [] + self.__allowrand = allowrandom # allow randomization of this list - def enqueue(self, song) + def enqueue(self, song): + """ Append a song to the list """ self.__list.append(song) - def dequeue(self, song) + def dequeue(self, song): + """ Remove a song from the list """ self.__list.remove(song) def pop(self): - self.__list.pop(0) + """ Pop the next song """ + return self.__list.pop(0) + def __getitem__(self, i): + """ Get item at position i """ + return self.__list[i] +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vixm/ui.py Sat Aug 12 21:00:00 2006 -0400 @@ -0,0 +1,44 @@ +# all the user interface related bits + +import time +from threading import Thread +import xmms + +import playlist, song + +def run(): + """ this is where we start execution """ + + # first, let's create the two playlists + print "Creating playlists..." + lists = {} + lists[playlist.LIST_PRIO] = playlist.playlist() + lists[playlist.LIST_DEFAULT] = playlist.playlist(allowrandom=True) + + # read in the info for all the songs in XMMS's playlist + print "Loading songs from XMMS's playlist..." + songs = [] + listlength = xmms.control.get_playlist_length() + for i in range(0,listlength): + s = song.song(i) + lists[playlist.LIST_DEFAULT].enqueue(s) + + print "Instanciating ui thread..." + ui = uiThread() + ui.start() + + while True: + print "Checking for xmms events" + time.sleep(1) + +class uiThread(Thread): + """ This is the main ui thread class, it does all the magic + necessary to have a vi-like interface """ + def __init__(self): + Thread.__init__(self) + + def run(self): + while True: + print "Checking for ui events" + time.sleep(1) +