Mercurial > vixm
annotate vixm/ui.py @ 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 | |
children | 187453f856a7 |
rev | line source |
---|---|
3
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
1 # all the user interface related bits |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
2 |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
3 import time |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
4 from threading import Thread |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
5 import xmms |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
6 |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
7 import playlist, song |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
8 |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
9 def run(): |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
10 """ this is where we start execution """ |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
11 |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
12 # first, let's create the two playlists |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
13 print "Creating playlists..." |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
14 lists = {} |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
15 lists[playlist.LIST_PRIO] = playlist.playlist() |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
16 lists[playlist.LIST_DEFAULT] = playlist.playlist(allowrandom=True) |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
17 |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
18 # read in the info for all the songs in XMMS's playlist |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
19 print "Loading songs from XMMS's playlist..." |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
20 songs = [] |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
21 listlength = xmms.control.get_playlist_length() |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
22 for i in range(0,listlength): |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
23 s = song.song(i) |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
24 lists[playlist.LIST_DEFAULT].enqueue(s) |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
25 |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
26 print "Instanciating ui thread..." |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
27 ui = uiThread() |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
28 ui.start() |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
29 |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
30 while True: |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
31 print "Checking for xmms events" |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
32 time.sleep(1) |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
33 |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
34 class uiThread(Thread): |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
35 """ This is the main ui thread class, it does all the magic |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
36 necessary to have a vi-like interface """ |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
37 def __init__(self): |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
38 Thread.__init__(self) |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
39 |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
40 def run(self): |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
41 while True: |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
42 print "Checking for ui events" |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
43 time.sleep(1) |
dd00b69169c6
Created initial ui thread code, fixed up playlist code
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
diff
changeset
|
44 |