Playlist borders
Both top and bottom playlist borders are present, but both only have a placeholder label for now. Double clicking on a row in the list will play a song now.
This commit is contained in:
parent
c5a7508573
commit
4d41cbfc30
|
@ -23,14 +23,18 @@ def new_source(path, bg=True):
|
|||
return 0
|
||||
return call("NEWSOURCE", library.scan, path)
|
||||
|
||||
|
||||
def walk_library():
|
||||
global library
|
||||
for track in library:
|
||||
yield track
|
||||
|
||||
|
||||
def lib_get_attr(id, attr):
|
||||
global library
|
||||
return library.get_attr(id, attr)
|
||||
|
||||
def lib_play_id(id):
|
||||
filepath = lib_get_attr(id, "filepath")
|
||||
libsaria.music.load(filepath)
|
||||
libsaria.music.play()
|
||||
|
||||
|
||||
|
|
|
@ -12,12 +12,16 @@ gtk = ocarina.gtk
|
|||
|
||||
|
||||
class Collection(gtk.ScrolledWindow):
|
||||
def __init__(self, mouse_motion):
|
||||
def __init__(self, mouse_motion, select):
|
||||
gtk.ScrolledWindow.__init__(self)
|
||||
self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.list = list.List()
|
||||
|
||||
self.list.connect("motion-notify-event", self.on_mouse_motion)
|
||||
self.list.connect("row-activated", self.row_activated)
|
||||
self.mouse_motion = mouse_motion
|
||||
self.selected_row = select
|
||||
|
||||
self.add(self.list)
|
||||
self.show()
|
||||
|
||||
|
@ -48,10 +52,16 @@ class Collection(gtk.ScrolledWindow):
|
|||
string = self.mouse_motion(list_row)
|
||||
list.set_value(list_iter, len(list_row)-1, "Played: %s"%string)
|
||||
|
||||
def row_activated(self, widget, path, column):
|
||||
list = self.list.list
|
||||
iter = list.get_iter(path)
|
||||
row = list[iter]
|
||||
self.selected_row(row)
|
||||
|
||||
|
||||
class Library(Collection):
|
||||
def __init__(self):
|
||||
Collection.__init__(self, self.mouse_motion)
|
||||
Collection.__init__(self, self.mouse_motion, self.select_row)
|
||||
libsaria.event.invite("POSTSTART", self.populate, bg=True)
|
||||
|
||||
def populate(self):
|
||||
|
@ -63,3 +73,6 @@ class Library(Collection):
|
|||
|
||||
def mouse_motion(self, row):
|
||||
return collection.lib_get_attr(row[0], "playcount")
|
||||
|
||||
def select_row(self, row):
|
||||
collection.lib_play_id(row[0])
|
||||
|
|
|
@ -3,21 +3,50 @@
|
|||
import ocarina
|
||||
gtk = ocarina.gtk
|
||||
|
||||
info = gtk.VBox()
|
||||
info.show()
|
||||
class Filter(gtk.VBox):
|
||||
def __init__(self):
|
||||
gtk.VBox.__init__(self)
|
||||
self.show()
|
||||
self.sep = gtk.HSeparator()
|
||||
self.sep.show()
|
||||
self.filter_box = gtk.HBox()
|
||||
self.pack_start(self.filter_box)
|
||||
self.filter_box.show()
|
||||
self.pack_start(self.sep)
|
||||
|
||||
hsep = gtk.HSeparator()
|
||||
hsep.show()
|
||||
def pack(self, widget, expand=True, fill=True):
|
||||
self.filter_box.pack_start(widget, expand, fill)
|
||||
|
||||
info.pack_start(hsep)
|
||||
|
||||
class Info(gtk.VBox):
|
||||
def __init__(self):
|
||||
gtk.VBox.__init__(self)
|
||||
self.show()
|
||||
self.sep = gtk.HSeparator()
|
||||
self.sep.show()
|
||||
self.pack_start(self.sep)
|
||||
|
||||
|
||||
filter = Filter()
|
||||
info = Info()
|
||||
|
||||
|
||||
def init():
|
||||
global info
|
||||
label = gtk.Label("Test label")
|
||||
global filter
|
||||
label = gtk.Label("Bottom label")
|
||||
label.show()
|
||||
info.pack_start(label)
|
||||
|
||||
label2 = gtk.Label("Top label")
|
||||
label2.show()
|
||||
filter.pack(label2)
|
||||
|
||||
def get_info():
|
||||
global info
|
||||
return info
|
||||
|
||||
|
||||
def get_filter():
|
||||
global filter
|
||||
return filter
|
||||
|
|
|
@ -12,24 +12,36 @@ contents = dict()
|
|||
cur_page = 0
|
||||
|
||||
bottom = None
|
||||
top = None
|
||||
|
||||
|
||||
class TabPage(gtk.VBox):
|
||||
def __init__(self, content):
|
||||
gtk.VBox.__init__(self)
|
||||
self.content = content
|
||||
self.pack_start(content, True, True, 0)
|
||||
#self.pack_end(content, True, True, 0)
|
||||
self.show()
|
||||
|
||||
def visible(self):
|
||||
global bottom
|
||||
global top
|
||||
print top, bottom
|
||||
if top is not None:
|
||||
self.pack_start(top, False, False)
|
||||
if self.content is not None:
|
||||
self.pack_start(self.content, True, True)
|
||||
if bottom is not None:
|
||||
self.pack_end(bottom, False, False)
|
||||
self.pack_start(bottom, False, False)
|
||||
if hasattr(self.content, "visible"):
|
||||
self.content.visible()
|
||||
|
||||
def invisible(self):
|
||||
global bottom
|
||||
global top
|
||||
if top is not None and top.get_parent() is not None:
|
||||
self.remove(top)
|
||||
if self.content is not None and self.content.get_parent() is not None:
|
||||
self.remove(self.content)
|
||||
if bottom is not None and bottom.get_parent() is not None:
|
||||
self.remove(bottom)
|
||||
if hasattr(self.content, "invisible"):
|
||||
|
@ -39,8 +51,10 @@ class TabPage(gtk.VBox):
|
|||
def init():
|
||||
import info
|
||||
global bottom
|
||||
global top
|
||||
info.init()
|
||||
bottom = info.get_info()
|
||||
top = info.get_filter()
|
||||
global tabs
|
||||
tabs = gtk.Notebook()
|
||||
tabs.set_tab_pos(gtk.POS_LEFT)
|
||||
|
|
Loading…
Reference in New Issue