Buttons
Added a button class, and attached play/pause buttons to the bottom of the window.
This commit is contained in:
parent
4d41cbfc30
commit
2f562bcc81
|
@ -36,6 +36,7 @@ def startup():
|
||||||
global plugin
|
global plugin
|
||||||
import music
|
import music
|
||||||
import plugin
|
import plugin
|
||||||
|
|
||||||
event.start("PRESTART")
|
event.start("PRESTART")
|
||||||
music.init()
|
music.init()
|
||||||
plugin.load_all()
|
plugin.load_all()
|
||||||
|
|
|
@ -16,6 +16,8 @@ QUEUE = 2
|
||||||
import collection
|
import collection
|
||||||
library = collection.Collection()
|
library = collection.Collection()
|
||||||
|
|
||||||
|
cur_lib_id = -1
|
||||||
|
|
||||||
def new_source(path, bg=True):
|
def new_source(path, bg=True):
|
||||||
global library
|
global library
|
||||||
path = expand(path)
|
path = expand(path)
|
||||||
|
@ -30,11 +32,19 @@ def walk_library():
|
||||||
|
|
||||||
def lib_get_attr(id, attr):
|
def lib_get_attr(id, attr):
|
||||||
global library
|
global library
|
||||||
return library.get_attr(id, attr)
|
if id >= 0:
|
||||||
|
return library.get_attr(id, attr)
|
||||||
|
return None
|
||||||
|
|
||||||
def lib_play_id(id):
|
def lib_play_id(id):
|
||||||
|
global cur_lib_id
|
||||||
|
cur_lib_id = id
|
||||||
filepath = lib_get_attr(id, "filepath")
|
filepath = lib_get_attr(id, "filepath")
|
||||||
libsaria.music.load(filepath)
|
libsaria.music.load(filepath)
|
||||||
libsaria.music.play()
|
libsaria.music.play()
|
||||||
|
|
||||||
|
def lib_get_cur_id():
|
||||||
|
global cur_lib_id
|
||||||
|
return cur_lib_id
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
# Bryan Schumaker (8/26/2010)
|
||||||
|
|
||||||
|
import ocarina
|
||||||
|
LS = ocarina.libsaria
|
||||||
|
gtk = ocarina.gtk
|
||||||
|
|
||||||
|
class Button(gtk.Button):
|
||||||
|
def __init__(self, stock, func=None, show=True):
|
||||||
|
gtk.Button.__init__(self)
|
||||||
|
self.func = func
|
||||||
|
img = gtk.image_new_from_stock(stock, gtk.ICON_SIZE_MENU)
|
||||||
|
img.show()
|
||||||
|
self.add(img)
|
||||||
|
self.set_relief(gtk.RELIEF_NONE)
|
||||||
|
self.click_id = self.connect("clicked", self.clicked)
|
||||||
|
if show == True:
|
||||||
|
self.show()
|
||||||
|
|
||||||
|
def clicked(self, button):
|
||||||
|
self.func()
|
||||||
|
|
||||||
|
def show(self, *args):
|
||||||
|
gtk.Button.show(self)
|
||||||
|
|
||||||
|
def hide(self, *args):
|
||||||
|
gtk.Button.hide(self)
|
||||||
|
|
||||||
|
|
||||||
|
class PlayButton(Button):
|
||||||
|
def __init__(self):
|
||||||
|
Button.__init__(self, gtk.STOCK_MEDIA_PLAY)
|
||||||
|
LS.event.invite("POSTPLAY", self.hide)
|
||||||
|
LS.event.invite("POSTPAUSE", self.show)
|
||||||
|
LS.event.invite("POSTSTOP", self.show)
|
||||||
|
def clicked(self, button):
|
||||||
|
LS.music.play()
|
||||||
|
|
||||||
|
|
||||||
|
class PauseButton(Button):
|
||||||
|
def __init__(self):
|
||||||
|
Button.__init__(self, gtk.STOCK_MEDIA_PAUSE, show=False)
|
||||||
|
LS.event.invite("POSTPLAY", self.show)
|
||||||
|
LS.event.invite("POSTPAUSE", self.hide)
|
||||||
|
LS.event.invite("POSTSTOP", self.hide)
|
||||||
|
def clicked(self, button):
|
||||||
|
LS.music.pause()
|
|
@ -1,46 +1,69 @@
|
||||||
# Bryan Schumaker (8/22/2010)
|
# Bryan Schumaker (8/22/2010)
|
||||||
|
|
||||||
import ocarina
|
import ocarina
|
||||||
gtk = ocarina.gtk
|
gtk = ocarina.gtk
|
||||||
|
libsaria = ocarina.libsaria
|
||||||
|
button = None
|
||||||
|
|
||||||
class Filter(gtk.VBox):
|
lib_get_cur_id = libsaria.collection.lib_get_cur_id
|
||||||
def __init__(self):
|
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)
|
gtk.VBox.__init__(self)
|
||||||
self.show()
|
self.show()
|
||||||
self.sep = gtk.HSeparator()
|
self.sep = gtk.HSeparator()
|
||||||
self.sep.show()
|
self.sep.show()
|
||||||
self.filter_box = gtk.HBox()
|
self.contents = gtk.HBox()
|
||||||
self.pack_start(self.filter_box)
|
self.contents.show()
|
||||||
self.filter_box.show()
|
if sep_on_top == True:
|
||||||
self.pack_start(self.sep)
|
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=True, fill=True):
|
def pack(self, widget, expand=False, fill=False):
|
||||||
self.filter_box.pack_start(widget, expand, fill)
|
self.contents.pack_start(widget, expand, fill)
|
||||||
|
|
||||||
|
|
||||||
class Info(gtk.VBox):
|
class InfoBar(Bar):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
gtk.VBox.__init__(self)
|
Bar.__init__(self, True)
|
||||||
self.show()
|
global button
|
||||||
self.sep = gtk.HSeparator()
|
global libsaria
|
||||||
self.sep.show()
|
|
||||||
self.pack_start(self.sep)
|
|
||||||
|
|
||||||
|
self.title = gtk.Label("Ocarina 4.1")
|
||||||
|
self.title.show()
|
||||||
|
self.pack(self.title, True, True)
|
||||||
|
self.pack(button.PlayButton())
|
||||||
|
self.pack(button.PauseButton())
|
||||||
|
|
||||||
filter = Filter()
|
libsaria.event.invite("POSTLOAD", self.change_title)
|
||||||
info = Info()
|
|
||||||
|
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))
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
global info
|
global info
|
||||||
global filter
|
global filter
|
||||||
label = gtk.Label("Bottom label")
|
global button
|
||||||
label.show()
|
|
||||||
info.pack_start(label)
|
import button
|
||||||
|
info = InfoBar()
|
||||||
|
filter = Bar(False)
|
||||||
|
|
||||||
label2 = gtk.Label("Top label")
|
label2 = gtk.Label("Top label")
|
||||||
label2.show()
|
label2.show()
|
||||||
filter.pack(label2)
|
filter.pack(label2, True, True)
|
||||||
|
|
||||||
|
|
||||||
def get_info():
|
def get_info():
|
||||||
global info
|
global info
|
||||||
|
|
|
@ -19,13 +19,11 @@ class TabPage(gtk.VBox):
|
||||||
def __init__(self, content):
|
def __init__(self, content):
|
||||||
gtk.VBox.__init__(self)
|
gtk.VBox.__init__(self)
|
||||||
self.content = content
|
self.content = content
|
||||||
#self.pack_end(content, True, True, 0)
|
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def visible(self):
|
def visible(self):
|
||||||
global bottom
|
global bottom
|
||||||
global top
|
global top
|
||||||
print top, bottom
|
|
||||||
if top is not None:
|
if top is not None:
|
||||||
self.pack_start(top, False, False)
|
self.pack_start(top, False, False)
|
||||||
if self.content is not None:
|
if self.content is not None:
|
||||||
|
|
Loading…
Reference in New Issue