# HG changeset patch # User Josef "Jeff" Sipek # Date 1155430800 14400 # Node ID dd00b69169c6da68e9d53a2f7f0bc38c504db90f # Parent 80a717f97cef24994b09859fda95794c8231a157 Created initial ui thread code, fixed up playlist code diff -r 80a717f97cef -r dd00b69169c6 vixm/playlist.py --- 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] + diff -r 80a717f97cef -r dd00b69169c6 vixm/ui.py --- /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) +