[Ap-python-commits] python/aptk playlist.py,1.1,1.2
Status: Beta
Brought to you by:
sjah
From: <sj...@us...> - 2002-07-18 09:16:49
|
Update of /cvsroot/ap-python/python/aptk In directory usw-pr-cvs1:/tmp/cvs-serv11378 Modified Files: playlist.py Log Message: Add ability to mark currently playing song at playlist window. Index: playlist.py =================================================================== RCS file: /cvsroot/ap-python/python/aptk/playlist.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** playlist.py 16 Jul 2002 17:10:21 -0000 1.1 --- playlist.py 18 Jul 2002 09:16:46 -0000 1.2 *************** *** 47,50 **** --- 47,51 ---- translated = [values [title] for title in self.titles] + gtk.GtkCList.append (self, translated) *************** *** 53,56 **** --- 54,58 ---- translated = [values [title] for title in self.titles] + gtk.GtkCList.insert (self, row, translated) *************** *** 66,83 **** self.set_column_width (title, widthes [title]) ############################################################################### class PlaylistWindow (gtk.GtkWindow): ! def __init__ (self, pl): """Initializer.""" # Remember self.pl = pl # Init base class gtk.GtkWindow.__init__ (self) # Create list ! self.list = SmartList (["playtime", "track", "title", "album", "artist", "year", "genre"], ! {"playtime" : "Time", "track" : "Track", "title" : "Title", --- 68,108 ---- self.set_column_width (title, widthes [title]) + def set_pixmap (self, r, title_name, pixmap, mask = None): + """Set pixmap.""" + + gtk.GtkCList.set_pixmap (self, r, self.titles.index (title_name), pixmap, mask) + + def set_text (self, r, title_name, text): + """Set text.""" + + gtk.GtkCList.set_text (self, r, self.titles.index (title_name), text) + ############################################################################### class PlaylistWindow (gtk.GtkWindow): ! def __init__ (self, pl, mark_xpmfile): """Initializer.""" # Remember self.pl = pl + self.current = None # Init base class gtk.GtkWindow.__init__ (self) + # Vbox + self.vbox = gtk.GtkVBox () + self.vbox.show () + self.add (self.vbox) + + # Scrolled window for list + self.scrolled = gtk.GtkScrolledWindow () + self.scrolled.show () + self.scrolled.set_policy (1, 0) + self.vbox.add (self.scrolled) + # Create list ! self.list = SmartList (["current", "playtime", "track", "title", "album", "artist", "year", "genre"], ! {"current" : " ", ! "playtime" : "Time", "track" : "Track", "title" : "Title", *************** *** 86,91 **** "year" : "Year", "genre" : "Genre"}) - self.add (self.list) self.list.show () # Register new playlist interface --- 111,121 ---- "year" : "Year", "genre" : "Genre"}) self.list.show () + self.list.column_titles_passive () + self.scrolled.add (self.list) + + # Create pixmap to mark the current song + self.realize () + self.np_pixmap, self.np_mask = gtk.create_pixmap_from_xpm (self, None, mark_xpmfile) # Register new playlist interface *************** *** 96,102 **** gtk.threads_enter () for item in items: ! values = {'title' : item.title, 'filename' : item.filename, 'artist' : item.artist, --- 126,134 ---- gtk.threads_enter () + self.list.freeze () for item in items: ! values = {'current' : '', ! 'title' : item.title, 'filename' : item.filename, 'artist' : item.artist, *************** *** 111,114 **** --- 143,164 ---- pos += 1 + + self.list.thaw () + gtk.threads_leave () + + def cb_set_current (self, pos): + """Called by alsaplayer when the playing song changed.""" + + gtk.threads_enter () + + if self.current != pos - 1: + # Blank previous mark + print self.current + if self.current is not None: + self.list.set_text (self.current, 'current', '') + # Mark row + self.current = pos - 1 + self.list.set_pixmap (self.current, 'current', self.np_pixmap, self.np_mask) + gtk.threads_leave () |