198 lines
4.4 KiB
Python
198 lines
4.4 KiB
Python
# Bryan Schumaker (8/22/2010)
|
|
|
|
import ocarina
|
|
gtk = ocarina.gtk
|
|
pango = ocarina.pango
|
|
libsaria = ocarina.libsaria
|
|
button = None
|
|
entry = None
|
|
pbar = None
|
|
label = None
|
|
image = None
|
|
|
|
lib_get_cur_id = libsaria.sources.lib_get_cur_id
|
|
get_attrs = libsaria.sources.get_attrs
|
|
file_to_id = libsaria.sources.file_to_id
|
|
|
|
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())
|
|
self.pack(button.ExportButton())
|
|
self.pack(button.ClearButton())
|
|
self.pack(button.ExportButton())
|
|
self.pack(button.RandomButton())
|
|
self.pack(button.VolumeButton())
|
|
|
|
|
|
class InfoBar(Bar):
|
|
def __init__(self, up_button):
|
|
Bar.__init__(self, True)
|
|
global button
|
|
global libsaria
|
|
|
|
self.title = gtk.Label(ocarina.__vers__)
|
|
self.title.show()
|
|
self.title.set_ellipsize(pango.ELLIPSIZE_END)
|
|
|
|
self.pack(self.title, True, True)
|
|
self.pack(label.TimeLabel())
|
|
self.pack(label.LengthLabel2())
|
|
self.pack(button.RewindButton())
|
|
self.pack(button.ForwardButton())
|
|
self.pack(button.PlayButton())
|
|
self.pack(button.PauseButton())
|
|
self.pack(button.StopButton())
|
|
self.pack(button.NextButton())
|
|
self.pack(button.UpButton(up_button))
|
|
|
|
libsaria.event.invite("POSTLOAD", self.change_title)
|
|
|
|
def change_title(self, filepath):
|
|
id = file_to_id(filepath)
|
|
title, artist = get_attrs(id, "title", "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(label.TimeLabel())
|
|
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.NextButton())
|
|
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 NowPlaying(gtk.HBox):
|
|
def __init__(self):
|
|
gtk.HBox.__init__(self, False, 5)
|
|
inner = gtk.HBox(True, 5)
|
|
|
|
tsw = gtk.ScrolledWindow()
|
|
tsw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER)
|
|
view = gtk.Viewport()
|
|
view.set_shadow_type(gtk.SHADOW_NONE)
|
|
tags = gtk.VBox(True)
|
|
tags.pack_start(label.TitleLabel())
|
|
tags.pack_start(label.ArtistLabel())
|
|
tags.pack_start(label.AlbumLabel())
|
|
view.add(tags)
|
|
tsw.add(view)
|
|
inner.pack_start(tsw)
|
|
|
|
attrs = gtk.VBox()
|
|
attrs.pack_start(label.YearLabel())
|
|
attrs.pack_start(label.LengthLabel())
|
|
attrs.pack_start(label.CountLabel())
|
|
inner.pack_start(attrs)
|
|
|
|
self.pack_start(image.AlbumArt(), False, False)
|
|
self.pack_start(inner)
|
|
self.show_all()
|
|
|
|
|
|
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)
|
|
if libsaria.prefs["INFOPANEUP"] == True:
|
|
self.up_button()
|
|
else:
|
|
self.down_button()
|
|
|
|
def up_button(self):
|
|
self.bar.hide()
|
|
self.tab.show()
|
|
libsaria.prefs["INFOPANEUP"] = True
|
|
|
|
def down_button(self):
|
|
self.bar.show()
|
|
self.tab.hide()
|
|
libsaria.prefs["INFOPANEUP"] = False
|
|
|
|
|
|
def init():
|
|
global info
|
|
global filter
|
|
global button
|
|
global entry
|
|
global pbar
|
|
global label
|
|
global image
|
|
|
|
import button
|
|
import entry
|
|
import pbar
|
|
import label
|
|
import image
|
|
|
|
libsaria.init_pref("INFOPANEUP", False)
|
|
info = TwoWayPane()
|
|
filter = FilterBar()
|
|
add_info_page("Now Playing", NowPlaying())
|
|
|
|
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)
|
|
|