Update of /cvsroot/ap-python/python/aptk
In directory usw-pr-cvs1:/tmp/cvs-serv21190/aptk
Modified Files:
playlist.py
Log Message:
Handle remove button.
Index: playlist.py
===================================================================
RCS file: /cvsroot/ap-python/python/aptk/playlist.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** playlist.py 26 Jul 2002 14:32:54 -0000 1.9
--- playlist.py 27 Jul 2002 16:23:32 -0000 1.10
***************
*** 27,30 ****
--- 27,32 ----
gdk = gtk.gdk
+ # TODO: Make this code more simple and faster!!!
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
class List (gtk.ScrolledWindow):
***************
*** 202,208 ****
# Blank old marked row
if self.__marked_path:
! iter = self.__store.get_iter (self.__marked_path)
! value = self.__mark_pixbuf and self.__blank_pixbuf or ''
! self.__store.set (iter, self.__COLUMN_CURRENT, value)
if row != -1:
--- 204,213 ----
# Blank old marked row
if self.__marked_path:
! try:
! iter = self.__store.get_iter (self.__marked_path)
! value = self.__mark_pixbuf and self.__blank_pixbuf or ''
! self.__store.set (iter, self.__COLUMN_CURRENT, value)
! except:
! pass
if row != -1:
***************
*** 220,223 ****
--- 225,234 ----
self.__store.clear ()
+ def remove (self, n):
+ """Remove row."""
+
+ iter = self.__store.get_iter ((n,))
+ self.__store.remove (iter)
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
class PlaylistWindow (gtk.Window):
***************
*** 296,299 ****
--- 307,311 ----
# Connect signals
self.clear_button.connect ("clicked", self.__gtkcb_clear_clicked)
+ self.remove_button.connect ("clicked", self.__gtkcb_remove_clicked)
self.connect ("destroy", self.__gtkcb_destroy)
self.__list.get_treeview ().connect ("row-activated", self.__gtkcb_list_row_activated)
***************
*** 354,358 ****
"""Alsaplayer's callback."""
! print "Remove: ", start, end
def __gtkcb_list_row_activated (self, tree, path, column):
--- 366,371 ----
"""Alsaplayer's callback."""
! for n in range (end-start+1):
! self.__list.remove (start-1)
def __gtkcb_list_row_activated (self, tree, path, column):
***************
*** 381,384 ****
--- 394,414 ----
self.__pl.clear ()
gtk.threads_enter ()
+
+ def __gtkcb_remove_clicked (self, w):
+ """Handler for remove button clicked signal."""
+
+ selection = self.__list.get_treeview ().get_selection ()
+
+ # Create list of items
+ list = []
+ selection.selected_foreach (lambda model, path, iter: list.append (path [0]))
+
+ list.sort ()
+ list.reverse ()
+
+ gdk.threads_leave ()
+ for n in list:
+ self.__pl.remove (n+1, n+1)
+ gdk.threads_enter ()
def __gtkcb_destroy (self, widget):
|