diff --git a/libsaria/collection/__init__.py b/libsaria/collection/__init__.py index d83774b4..d5842f9f 100644 --- a/libsaria/collection/__init__.py +++ b/libsaria/collection/__init__.py @@ -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() + + diff --git a/ocarina/collection.py b/ocarina/collection.py index dfa4b09f..fab81fb7 100644 --- a/ocarina/collection.py +++ b/ocarina/collection.py @@ -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]) diff --git a/ocarina/info.py b/ocarina/info.py index 89ee9b4f..35c60a8c 100644 --- a/ocarina/info.py +++ b/ocarina/info.py @@ -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 diff --git a/ocarina/tabs.py b/ocarina/tabs.py index b9f4dd10..b28b85cd 100644 --- a/ocarina/tabs.py +++ b/ocarina/tabs.py @@ -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)