Ocarina: Began redoing footer
The new code should be more maintainable and less confusing / intimidating.
This commit is contained in:
parent
5d4d86275e
commit
b5665b016f
|
@ -1,138 +1,150 @@
|
|||
# Bryan Schumaker (11/25/2010)
|
||||
|
||||
import gtk
|
||||
import pango
|
||||
import ocarina
|
||||
import libsaria
|
||||
import tiny
|
||||
|
||||
from ocarina.components import label
|
||||
from ocarina.components import button
|
||||
from ocarina.components import pbar
|
||||
from ocarina.components import image
|
||||
footer = gtk.VBox()
|
||||
hsep = gtk.HSeparator()
|
||||
hsep.show()
|
||||
|
||||
footer = gtk.VBox()
|
||||
bar = gtk.HBox()
|
||||
title = gtk.Label()
|
||||
tabs = gtk.Notebook()
|
||||
act_bar = gtk.HBox()
|
||||
|
||||
pages = dict()
|
||||
|
||||
def change_title(filepath):
|
||||
id = libsaria.path.file_id(filepath)
|
||||
(ttl, artst) = libsaria.sources.library.get_attrs(id, "title", "artist")
|
||||
title.set_text("%s by %s" % (ttl, artst))
|
||||
|
||||
def bar_add(widget, expand = False, fill = False):
|
||||
bar.pack_start(widget, expand, fill)
|
||||
|
||||
def act_bar_add(widget, expand = False, fill = False):
|
||||
act_bar.pack_start(widget, expand, fill)
|
||||
|
||||
def add_page(title, widget):
|
||||
label = gtk.Label(title)
|
||||
pages[title] = widget
|
||||
tabs.append_page(widget, label)
|
||||
|
||||
def remove_page(title):
|
||||
page = pages.get(title, None)
|
||||
if page == None:
|
||||
return
|
||||
n = tabs.page_num(page)
|
||||
tabs.remove_page(n)
|
||||
del pages[title]
|
||||
|
||||
def up_button():
|
||||
tabs.show()
|
||||
bar.hide()
|
||||
libsaria.prefs.set_pref("ocarina.footer.up", True)
|
||||
|
||||
def down_button():
|
||||
tabs.hide()
|
||||
bar.show()
|
||||
libsaria.prefs.set_pref("ocarina.footer.up", False)
|
||||
|
||||
def make_bar():
|
||||
title.set_text(ocarina.__vers__)
|
||||
title.set_ellipsize(pango.ELLIPSIZE_END)
|
||||
title.show()
|
||||
|
||||
bar_add(image.AlbumArt(24))
|
||||
bar_add(title, True, True)
|
||||
bar_add(label.TimeLabel())
|
||||
bar_add(label.LengthLabel2())
|
||||
bar_add(button.RewindButton())
|
||||
bar_add(button.ForwardButton())
|
||||
bar_add(button.PlayButton())
|
||||
bar_add(button.PauseButton())
|
||||
bar_add(button.StopButton())
|
||||
bar_add(button.NextButton())
|
||||
bar_add(button.UpButton(up_button))
|
||||
|
||||
bar.show()
|
||||
footer.pack_start(bar)
|
||||
|
||||
def make_action_bar():
|
||||
act_bar_add(label.TimeLabel())
|
||||
act_bar_add(pbar.PBar(), True, True)
|
||||
act_bar_add(button.PlayButton())
|
||||
act_bar_add(button.PauseButton())
|
||||
act_bar_add(button.StopButton())
|
||||
act_bar_add(button.NextButton())
|
||||
act_bar_add(button.DownButton(down_button))
|
||||
act_bar.show()
|
||||
|
||||
def make_now_playing_page():
|
||||
page = gtk.HBox(False, 5)
|
||||
page.pack_start(image.AlbumArt(), False, False)
|
||||
|
||||
tags = gtk.ScrolledWindow()
|
||||
tags.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
view = gtk.Viewport()
|
||||
view.set_shadow_type(gtk.SHADOW_NONE)
|
||||
tag_box = gtk.VBox(True)
|
||||
tag_box.pack_start(label.TitleLabel())
|
||||
tag_box.pack_start(label.ArtistLabel())
|
||||
tag_box.pack_start(label.AlbumLabel())
|
||||
view.add(tag_box)
|
||||
tags.add(view)
|
||||
page.pack_start(tags)
|
||||
|
||||
attrs = gtk.HBox(False, 5)
|
||||
tags2 = gtk.VBox()
|
||||
tags2.pack_start(label.YearLabel())
|
||||
tags2.pack_start(label.LengthLabel())
|
||||
tags2.pack_start(label.CountLabel())
|
||||
attrs.pack_start(tags2)
|
||||
|
||||
buttons = gtk.HBox()
|
||||
buttons.pack_start(button.LikeButton(), False, False)
|
||||
buttons.pack_start(button.DislikeButton(), False, False)
|
||||
attrs.pack_start(buttons, False)
|
||||
page.pack_start(attrs)
|
||||
|
||||
page.show_all()
|
||||
add_page("Now Playing", page)
|
||||
footer.pack_start(hsep, True, True)
|
||||
footer.pack_start(tiny.tiny, True, True)
|
||||
footer.show()
|
||||
|
||||
|
||||
def make_tabs():
|
||||
make_action_bar()
|
||||
tabs.set_action_widget(act_bar, gtk.PACK_END)
|
||||
make_now_playing_page()
|
||||
tabs.show_all()
|
||||
footer.pack_start(tabs)
|
||||
#import gtk
|
||||
#import pango
|
||||
#import ocarina
|
||||
#import libsaria
|
||||
|
||||
def init():
|
||||
sep = gtk.HSeparator()
|
||||
footer.pack_start(sep)
|
||||
footer.show_all()
|
||||
make_bar()
|
||||
make_tabs()
|
||||
#from ocarina.components import label
|
||||
#from ocarina.components import button
|
||||
#from ocarina.components import pbar
|
||||
#from ocarina.components import image
|
||||
|
||||
up = libsaria.init_pref("ocarina.footer.up", False)
|
||||
if up == True:
|
||||
up_button()
|
||||
else:
|
||||
down_button()
|
||||
libsaria.event.invite("POSTLOAD", change_title)
|
||||
init()
|
||||
#footer = gtk.VBox()
|
||||
#bar = gtk.HBox()
|
||||
#title = gtk.Label()
|
||||
#tabs = gtk.Notebook()
|
||||
#act_bar = gtk.HBox()
|
||||
|
||||
#pages = dict()
|
||||
|
||||
#def change_title(filepath):
|
||||
#id = libsaria.path.file_id(filepath)
|
||||
#(ttl, artst) = libsaria.sources.library.get_attrs(id, "title", "artist")
|
||||
#title.set_text("%s by %s" % (ttl, artst))
|
||||
|
||||
#def bar_add(widget, expand = False, fill = False):
|
||||
#bar.pack_start(widget, expand, fill)
|
||||
|
||||
#def act_bar_add(widget, expand = False, fill = False):
|
||||
#act_bar.pack_start(widget, expand, fill)
|
||||
|
||||
#def add_page(title, widget):
|
||||
#label = gtk.Label(title)
|
||||
#pages[title] = widget
|
||||
#tabs.append_page(widget, label)
|
||||
|
||||
#def remove_page(title):
|
||||
#page = pages.get(title, None)
|
||||
#if page == None:
|
||||
#return
|
||||
#n = tabs.page_num(page)
|
||||
#tabs.remove_page(n)
|
||||
#del pages[title]
|
||||
|
||||
#def up_button():
|
||||
#tabs.show()
|
||||
#bar.hide()
|
||||
#libsaria.prefs.set_pref("ocarina.footer.up", True)
|
||||
|
||||
#def down_button():
|
||||
#tabs.hide()
|
||||
#bar.show()
|
||||
#libsaria.prefs.set_pref("ocarina.footer.up", False)
|
||||
|
||||
#def make_bar():
|
||||
#title.set_text(ocarina.__vers__)
|
||||
#title.set_ellipsize(pango.ELLIPSIZE_END)
|
||||
#title.show()
|
||||
|
||||
#bar_add(image.AlbumArt(24))
|
||||
#bar_add(title, True, True)
|
||||
#bar_add(label.TimeLabel())
|
||||
#bar_add(label.LengthLabel2())
|
||||
#bar_add(button.RewindButton())
|
||||
#bar_add(button.ForwardButton())
|
||||
#bar_add(button.PlayButton())
|
||||
#bar_add(button.PauseButton())
|
||||
#bar_add(button.StopButton())
|
||||
#bar_add(button.NextButton())
|
||||
#bar_add(button.UpButton(up_button))
|
||||
|
||||
#bar.show()
|
||||
#footer.pack_start(bar)
|
||||
|
||||
#def make_action_bar():
|
||||
#act_bar_add(label.TimeLabel())
|
||||
#act_bar_add(pbar.PBar(), True, True)
|
||||
#act_bar_add(button.PlayButton())
|
||||
#act_bar_add(button.PauseButton())
|
||||
#act_bar_add(button.StopButton())
|
||||
#act_bar_add(button.NextButton())
|
||||
#act_bar_add(button.DownButton(down_button))
|
||||
#act_bar.show()
|
||||
|
||||
#def make_now_playing_page():
|
||||
#page = gtk.HBox(False, 5)
|
||||
#page.pack_start(image.AlbumArt(), False, False)
|
||||
|
||||
#tags = gtk.ScrolledWindow()
|
||||
#tags.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
#view = gtk.Viewport()
|
||||
#view.set_shadow_type(gtk.SHADOW_NONE)
|
||||
#tag_box = gtk.VBox(True)
|
||||
#tag_box.pack_start(label.TitleLabel())
|
||||
#tag_box.pack_start(label.ArtistLabel())
|
||||
#tag_box.pack_start(label.AlbumLabel())
|
||||
#view.add(tag_box)
|
||||
#tags.add(view)
|
||||
#page.pack_start(tags)
|
||||
|
||||
#attrs = gtk.HBox(False, 5)
|
||||
#tags2 = gtk.VBox()
|
||||
#tags2.pack_start(label.YearLabel())
|
||||
#tags2.pack_start(label.LengthLabel())
|
||||
#tags2.pack_start(label.CountLabel())
|
||||
#attrs.pack_start(tags2)
|
||||
|
||||
#buttons = gtk.HBox()
|
||||
#buttons.pack_start(button.LikeButton(), False, False)
|
||||
#buttons.pack_start(button.DislikeButton(), False, False)
|
||||
#attrs.pack_start(buttons, False)
|
||||
#page.pack_start(attrs)
|
||||
|
||||
#page.show_all()
|
||||
#add_page("Now Playing", page)
|
||||
|
||||
|
||||
#def make_tabs():
|
||||
#make_action_bar()
|
||||
#tabs.set_action_widget(act_bar, gtk.PACK_END)
|
||||
#make_now_playing_page()
|
||||
#tabs.show_all()
|
||||
#footer.pack_start(tabs)
|
||||
|
||||
#def init():
|
||||
#sep = gtk.HSeparator()
|
||||
#footer.pack_start(sep)
|
||||
#footer.show_all()
|
||||
#make_bar()
|
||||
#make_tabs()
|
||||
|
||||
#up = libsaria.init_pref("ocarina.footer.up", False)
|
||||
#if up == True:
|
||||
#up_button()
|
||||
#else:
|
||||
#down_button()
|
||||
#libsaria.event.invite("POSTLOAD", change_title)
|
||||
#init()
|
||||
|
|
13
ocarina/body/footer/tiny.py
Normal file
13
ocarina/body/footer/tiny.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Bryan Schumaker (2 / 17 / 2011)
|
||||
|
||||
import gtk
|
||||
import pango
|
||||
import ocarina
|
||||
|
||||
tiny = gtk.HBox()
|
||||
now_playing = gtk.Label(ocarina.__vers__)
|
||||
now_playing.set_ellipsize(pango.ELLIPSIZE_END)
|
||||
now_playing.show()
|
||||
|
||||
tiny.pack_start(now_playing, True, True)
|
||||
tiny.show()
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import gtk
|
||||
import header
|
||||
#import footer
|
||||
import footer
|
||||
SHRINK = gtk.SHRINK
|
||||
GROW = gtk.FILL | gtk.EXPAND
|
||||
|
||||
|
@ -17,10 +17,13 @@ class OcarinaPage(gtk.Table):
|
|||
|
||||
def visible(self):
|
||||
self.attach_top(header.header)
|
||||
self.attach_bottom(footer.footer)
|
||||
|
||||
def invisible(self):
|
||||
if header.header.get_parent() == self:
|
||||
self.remove(header.header)
|
||||
if footer.footer.get_parent() == self:
|
||||
self.remove(footer.footer)
|
||||
|
||||
def attach_top(self, content):
|
||||
self.attach(content, 0, 1, 0, 1, GROW, SHRINK)
|
||||
|
|
Loading…
Reference in New Issue
Block a user