ocarina: Added like and dislike buttons
This commit is contained in:
parent
27c3d2b3f1
commit
a519ad62ab
|
@ -41,11 +41,17 @@ def make_button(stock_item, func, tooltip, show):
|
|||
b.set_tooltip_text(tooltip)
|
||||
return b
|
||||
|
||||
def toggle_connect(button, func):
|
||||
button.t_id = button.connect("toggled", on_toggle, func)
|
||||
|
||||
def toggle_unconnect(button):
|
||||
button.disconnect(button.t_id)
|
||||
|
||||
def toggle_button(func, is_active, show):
|
||||
b = gtk.ToggleButton()
|
||||
b.set_relief(gtk.RELIEF_NONE)
|
||||
b.set_active(is_active)
|
||||
b.connect("toggled", on_toggle, func)
|
||||
toggle_connect(b, func)
|
||||
if show == True:
|
||||
b.show()
|
||||
return b
|
||||
|
@ -102,3 +108,26 @@ def clear_button(show):
|
|||
|
||||
def random_button(is_active, show):
|
||||
return make_toggle("images/random.png", controls.set_rand, "Random", is_active, show)
|
||||
|
||||
def set_like(like):
|
||||
if like == False:
|
||||
like = None
|
||||
controls.set_like(like)
|
||||
|
||||
def like_button(show):
|
||||
return make_toggle("images/thumbs_up.png", set_like, "I like this", False, show)
|
||||
|
||||
def like_button_reconnect(like_button):
|
||||
toggle_connect(like_button, set_like)
|
||||
|
||||
def set_dislike(like):
|
||||
like = not like
|
||||
if like == True:
|
||||
like = None
|
||||
controls.set_like(like)
|
||||
|
||||
def dislike_button(show):
|
||||
return make_toggle("images/thumbs_down.png", set_dislike, "I don't like this", False, show)
|
||||
|
||||
def dislike_button_reconnect(dislike_button):
|
||||
toggle_connect(dislike_button, set_dislike)
|
||||
|
|
|
@ -42,6 +42,9 @@ def on_load():
|
|||
tiny.on_load()
|
||||
detailed.on_load()
|
||||
|
||||
def on_like():
|
||||
detailed.nowplaying.on_like()
|
||||
|
||||
#import gtk
|
||||
#import pango
|
||||
#import ocarina
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# Bryan Schumaker (4 / 21 / 2011)
|
||||
|
||||
import gtk
|
||||
from libsaria import controls
|
||||
from ocarina.body import button
|
||||
|
||||
page = gtk.HBox(False, 5)
|
||||
label = gtk.Label("Now Playing")
|
||||
|
@ -34,9 +36,25 @@ pack_label(attr_box, LENGTH)
|
|||
pack_label(attr_box, COUNT)
|
||||
page.pack_start(attr_box)
|
||||
|
||||
LIKE = button.like_button(True)
|
||||
DISLIKE = button.dislike_button(True)
|
||||
buttons = gtk.HBox(True)
|
||||
buttons.pack_start( LIKE, False, False)
|
||||
buttons.pack_start(DISLIKE, False, False)
|
||||
page.pack_start(buttons, False)
|
||||
|
||||
page.show_all()
|
||||
label.show()
|
||||
|
||||
def on_like():
|
||||
like = controls.get_like()
|
||||
button.toggle_unconnect(LIKE)
|
||||
button.toggle_unconnect(DISLIKE)
|
||||
LIKE.set_active(like == True)
|
||||
DISLIKE.set_active(like == False)
|
||||
button.like_button_reconnect(LIKE)
|
||||
button.dislike_button_reconnect(DISLIKE)
|
||||
|
||||
def on_load(title, artist, album, year, lenstr, count):
|
||||
TITLE.set_text(title)
|
||||
ARTIST.set_text("by %s" % artist)
|
||||
|
@ -44,3 +62,4 @@ def on_load(title, artist, album, year, lenstr, count):
|
|||
YEAR.set_text("Year: %s" % year)
|
||||
LENGTH.set_text("Length: %s" % lenstr)
|
||||
COUNT.set_text("Play count: %s" % count)
|
||||
on_like()
|
||||
|
|
|
@ -24,3 +24,7 @@ def on_load(*args):
|
|||
queue.refresh()
|
||||
body.cur_page_goto()
|
||||
invite("POSTLOAD", on_load)
|
||||
|
||||
def on_like(*args):
|
||||
footer.on_like()
|
||||
invite("POSTSETLIKE", on_like)
|
||||
|
|
Loading…
Reference in New Issue