From c5a750857398dae4f4b653466d404468a8dd79b5 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Sun, 22 Aug 2010 12:40:39 -0400 Subject: [PATCH] Began bottom pane I only need to create one bottom pane instance now. When the tabs are changed, the object will be removed from the old tab and added to the new one. This will preserve the state of the pane between tabs. --- libsaria/collection/tree.py | 16 ++++++++++++++-- ocarina/info.py | 23 +++++++++++++++++++++++ ocarina/tabs.py | 14 +++++++++++++- 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 ocarina/info.py diff --git a/libsaria/collection/tree.py b/libsaria/collection/tree.py index 5d5f10c4..7f8d72ae 100644 --- a/libsaria/collection/tree.py +++ b/libsaria/collection/tree.py @@ -1,6 +1,6 @@ # Bryan Schumaker (8 / 12 / 2010) -get = dict.get +get = dict.get class TagNode(dict): def __init__(self, id): @@ -15,7 +15,19 @@ class TagNode(dict): self["filepath"] = filepath self["playcount"] = 0 - self["length"] = audio.length + + length = audio.length + sf = 0 + sec = length % 60 + if sec >= 10: + sf = "" + min = (length - sec) / 60 + mf = 0 + if min >= 10: + mf = "" + + self["seconds"] = audio.length + self["length"] = "%s%s:%s%s" % (mf, min, sf, sec) def walk(self): yield self diff --git a/ocarina/info.py b/ocarina/info.py new file mode 100644 index 00000000..89ee9b4f --- /dev/null +++ b/ocarina/info.py @@ -0,0 +1,23 @@ +# Bryan Schumaker (8/22/2010) + +import ocarina +gtk = ocarina.gtk + +info = gtk.VBox() +info.show() + +hsep = gtk.HSeparator() +hsep.show() + +info.pack_start(hsep) + + +def init(): + global info + label = gtk.Label("Test label") + label.show() + info.pack_start(label) + +def get_info(): + global info + return info diff --git a/ocarina/tabs.py b/ocarina/tabs.py index 94106a2e..b9f4dd10 100644 --- a/ocarina/tabs.py +++ b/ocarina/tabs.py @@ -11,6 +11,8 @@ tabs = None contents = dict() cur_page = 0 +bottom = None + class TabPage(gtk.VBox): def __init__(self, content): @@ -20,15 +22,25 @@ class TabPage(gtk.VBox): self.show() def visible(self): + global bottom + if bottom is not None: + self.pack_end(bottom, False, False) if hasattr(self.content, "visible"): self.content.visible() def invisible(self): + global bottom + if bottom is not None and bottom.get_parent() is not None: + self.remove(bottom) if hasattr(self.content, "invisible"): self.content.invisible() def init(): + import info + global bottom + info.init() + bottom = info.get_info() global tabs tabs = gtk.Notebook() tabs.set_tab_pos(gtk.POS_LEFT) @@ -60,7 +72,7 @@ def remove_page(text): def switch_page(notebook, page, page_num): global cur_page old = notebook.get_nth_page(cur_page) - old.invisible() new = notebook.get_nth_page(page_num) + old.invisible() new.visible() cur_page = page_num