142 lines
3.0 KiB
Python
142 lines
3.0 KiB
Python
# Bryan Schumaker (8/22/2010)
|
|
|
|
import ocarina
|
|
gtk = ocarina.gtk
|
|
libsaria = ocarina.libsaria
|
|
button = None
|
|
entry = None
|
|
pbar = None
|
|
|
|
lib_get_cur_id = libsaria.collection.lib_get_cur_id
|
|
lib_get_attr = libsaria.collection.lib_get_attr
|
|
|
|
filter = None
|
|
info = None
|
|
|
|
class Bar(gtk.VBox):
|
|
def __init__(self, sep_on_top):
|
|
gtk.VBox.__init__(self)
|
|
self.show()
|
|
self.sep = gtk.HSeparator()
|
|
self.sep.show()
|
|
self.contents = gtk.HBox()
|
|
self.contents.show()
|
|
if sep_on_top == True:
|
|
self.pack_start(self.sep)
|
|
self.pack_start(self.contents)
|
|
else:
|
|
self.pack_start(self.contents)
|
|
self.pack_start(self.sep)
|
|
|
|
def pack(self, widget, expand=False, fill=False):
|
|
self.contents.pack_start(widget, expand, fill)
|
|
|
|
|
|
class FilterBar(Bar):
|
|
def __init__(self):
|
|
Bar.__init__(self, False)
|
|
global button
|
|
global entry
|
|
|
|
self.pack(entry.FilterEntry(), True, True)
|
|
self.pack(button.OpenButton())
|
|
|
|
|
|
class InfoBar(Bar):
|
|
def __init__(self, up_button):
|
|
Bar.__init__(self, True)
|
|
global button
|
|
global libsaria
|
|
|
|
self.title = gtk.Label("Ocarina 4.1")
|
|
self.title.show()
|
|
self.pack(self.title, True, True)
|
|
self.pack(button.PlayButton())
|
|
self.pack(button.PauseButton())
|
|
self.pack(button.StopButton())
|
|
self.pack(button.UpButton(up_button))
|
|
|
|
libsaria.event.invite("POSTLOAD", self.change_title)
|
|
|
|
def change_title(self, filepath):
|
|
id = libsaria.collection.lib_get_cur_id()
|
|
title = lib_get_attr(id, "title")
|
|
artist = libsaria.collection.lib_get_attr(id, "artist")
|
|
self.title.set_text("%s by %s" % (title,artist))
|
|
|
|
|
|
class InfoTab(gtk.Notebook):
|
|
def __init__(self, down_button):
|
|
gtk.Notebook.__init__(self)
|
|
|
|
hbox = gtk.HBox()
|
|
hbox.show()
|
|
|
|
hbox.pack_start(pbar.PBar(), True, True)
|
|
hbox.pack_start(button.PlayButton())
|
|
hbox.pack_start(button.PauseButton())
|
|
hbox.pack_start(button.StopButton())
|
|
hbox.pack_start(button.DownButton(down_button))
|
|
self.set_action_widget(hbox, gtk.PACK_END)
|
|
|
|
self.down_button = down_button
|
|
self.cur_page = 0
|
|
self.connect("switch_page", self.switched_pages)
|
|
|
|
def add_page(self, content, label):
|
|
self.prepend_page(content, label)
|
|
self.set_current_page(0)
|
|
|
|
def switched_pages(self, notebook, page, page_num):
|
|
new_page = self.get_nth_page(page_num)
|
|
self.cur_page = page_num
|
|
|
|
|
|
class TwoWayPane(InfoBar):
|
|
def __init__(self):
|
|
InfoBar.__init__(self, self.up_button)
|
|
self.bar = self.contents
|
|
self.tab = InfoTab(self.down_button)
|
|
self.pack_start(self.tab)
|
|
|
|
def up_button(self):
|
|
self.bar.hide()
|
|
self.tab.show()
|
|
|
|
def down_button(self):
|
|
self.bar.show()
|
|
self.tab.hide()
|
|
|
|
|
|
def init():
|
|
global info
|
|
global filter
|
|
global button
|
|
global entry
|
|
global pbar
|
|
|
|
import button
|
|
import entry
|
|
import pbar
|
|
|
|
info = TwoWayPane()
|
|
filter = FilterBar()
|
|
add_info_page("Test", gtk.Label("test label!"))
|
|
|
|
def get_info():
|
|
global info
|
|
return info
|
|
|
|
def get_filter():
|
|
global filter
|
|
return filter
|
|
|
|
def add_info_page(label, content):
|
|
global info
|
|
if label.__class__ == str:
|
|
label = gtk.Label(label)
|
|
label.show()
|
|
content.show()
|
|
info.tab.add_page(content, label)
|
|
|