Compare commits

...

6 Commits

Author SHA1 Message Date
Bryan Schumaker a84bd85a04 Make 4.10 less likely to crash
I used it over christmas, but I didn't want it to blow up when setting
album art.
2012-03-03 11:19:51 -05:00
Bryan Schumaker 798134b910 Web server improvements
I want to use the remote control this weekend, so I needed to fix it up.
2011-12-22 14:16:33 -05:00
Bryan Schumaker f8ed8c4483 Don't set artwork
Either setting artwork or resizing artwork was causing an annoying
crash.  I disable setting artwork for now so the crashes will stop.
2011-08-14 10:07:53 -04:00
Bryan Schumaker 128415f009 ocarina: Use album art as window icon
This is an experimental feature for now, since I don't know how well
it'll work yet.  The user should always have the option to disable this
feature, even when it works its way out of experimental.
2011-06-27 23:18:39 -04:00
Bryan Schumaker 0017c04bbf libsaria: Bump version to 4.10 2011-06-27 23:18:16 -04:00
Bryan Schumaker fd198294ee makefile: Compile modules from command line
If we compile everything during the "make" step, the compiled modules
can be installed and the python won't have to regenerate them on every
startup.
2011-06-25 18:53:49 -04:00
16 changed files with 142 additions and 42 deletions

View File

@ -1,6 +1,13 @@
all: ocarina.py
./ocarina.py
PY = python2 -c
all: libsaria ocarina ocarina.py
.PHONY: libsaria ocarina
libsaria:
$(PY) "import compileall; compileall.compile_dir('libsaria', force=1)"
ocarina:
$(PY) "import compileall; compileall.compile_dir('ocarina', force=1)"
ocarina.py:
sh scripts/makebin.sh

View File

@ -6,14 +6,14 @@
function set_playing()
{
var button = document.getElementById("button");
button.src = "images/pause.png";
button.src = "pause.png";
button.onclick = pause2;
}
function set_paused()
{
var button = document.getElementById("button");
button.src = "images/play.png";
button.src = "play.png";
button.onclick = play2;
}
@ -33,7 +33,7 @@ function set_play_button()
}
}
}
req.open('GET', "controls.py?a=playing", true);
req.open('GET', "RPC/playing", true);
req.send();
}
@ -72,12 +72,12 @@ function stop2()
<tr><td id="album"></td></tr>
</table>
<table><tr>
<td><img id="button" src="images/play.png" onclick="play2();" /></td>
<td><img src="images/stop.png" onclick="stop2();" /></td>
<td><img src="images/next.png" onclick="next();" /></td>
<td><img id="button" src="play.png" onclick="play2();" /></td>
<td><img src="stop.png" onclick="stop();" /></td>
<td><img src="next.png" onclick="next();" /></td>
</tr><tr>
<td><img src="images/rewind.png" onclick="rewind();" /></td>
<td><img src="images/forward.png" onclick="forward();" /></td>
<td><img src="rewind.png" onclick="rewind();" /></td>
<td><img src="forward.png" onclick="forward();" /></td>
</tr></table>
</body>

View File

@ -6,6 +6,7 @@
<body>
<table>
<tr><td><a href="library.html">Library Browser</a></td></tr>
<tr><td><a href="controls.html">Remote Controls</a></td></tr>
<!--<tr><td><a href="library2.py">Library Browser 2</a></td></tr>
<tr><td><a href="controls.html">Remote Controls</a></td></tr>
<tr><td id="vers"></td><td id="up"></td></tr>-->

View File

@ -11,7 +11,7 @@ function set_attr(attr, id)
}
}
req.open('GET', "controls.py?a=" + attr, true);
req.open('GET', "RPC/" + attr, true);
req.send();
setTimeout("set_attr(\"" + attr + "\", \"" + id + "\")", 3000)
}
@ -26,7 +26,7 @@ function set_attr_once(attr, id)
document.getElementById(id).innerHTML = req.responseText;
}
}
req.open('GET', "controls.py?a=" + attr, true);
req.open('GET', "RPC/" + attr, true);
req.send();
}

View File

@ -10,6 +10,7 @@ docs.update(rpc.docs)
types = {
"html":"text/html",
"js":"text/javascript",
"png":"image/png",
}
def lookup(file):

View File

@ -30,6 +30,27 @@ def library(write):
color = "white"
write("</table></body></html>")
def controls_page(write):
write_file(write, "html/controls.html")
def play_button(write):
write_file(write, "html/images/play.png")
def pause_button(write):
write_file(write, "html/images/pause.png")
def stop_button(write):
write_file(write, "html/images/stop.png")
def next_button(write):
write_file(write, "html/images/next.png")
def rewind_button(write):
write_file(write, "html/images/rewind.png")
def forward_button(write):
write_file(write, "html/images/forward.png")
def controls(write):
write_file(write, "html/controls.js")
@ -39,6 +60,13 @@ def utils(write):
docs = {
"index.html":(index, "html"),
"library.html":(library, "html"),
"controls.html":(controls_page, "html"),
"controls.js":(controls, "js"),
"utils.js":(utils, "js"),
"play.png":(play_button, "png"),
"pause.png":(pause_button, "png"),
"stop.png":(stop_button, "png"),
"next.png":(next_button, "png"),
"forward.png":(rewind_button, "png"),
"rewind.png":(forward_button, "png"),
}

View File

@ -9,12 +9,44 @@ def play(write):
def pause(write):
controls.pause()
def next(write):
controls.next()
def stop(write):
controls.stop()
def forward(write):
controls.seek_forward()
def rewind(write):
controls.seek_backward()
def play_id(write, id):
sources.play_id(long(id[0]))
def title(write):
write(sources.get_attrs("title")[0])
def artist(write):
write(sources.get_attrs("artist")[0])
def album(write):
write(sources.get_attrs("album")[0])
def playing(write):
write(controls.playing())
rpc = {
"play.html":(play, "html"),
"pause.html":(pause, "html"),
"play":(play, "html"),
"pause":(pause, "html"),
"stop":(stop, "html"),
"next":(next, "html"),
"forward":(forward, "html"),
"rewind":(rewind, "html"),
"title":(title, "html"),
"artist":(artist, "html"),
"album":(album, "html"),
"playing":(playing, "html"),
"play_id":(play_id, "html"),
}

View File

@ -1,9 +1,9 @@
# Bryan Schumaker (5 / 6 / 2011)
__major__ = 4
__minor__ = 9
__minor__ = 10
__bug__ = 0
__dev__ = False
__dev__ = True
__vstr__ = "%s.%s" % (__major__, __minor__)
if __bug__ > 0:

View File

@ -18,6 +18,9 @@ def stock_image(stock_item):
img = gtk.image_new_from_stock(stock_item, SIZE)
return img
def big_image(stock_item):
return gtk.image_new_from_stock(stock_item, gtk.ICON_SIZE_DND)
def file_image(file):
img = gtk.image_new_from_file(file)
return img
@ -43,6 +46,12 @@ def make_button(stock_item, func, tooltip, show):
default_button_attrs(b, stock_image(stock_item), tooltip, show)
return b
def make_big_button(stock_item, func, tooltip, show):
b = gtk.Button()
b.connect("clicked", on_click, func)
default_button_attrs(b, big_image(stock_item), tooltip, show)
return b
def toggle_connect(button, func):
button.t_id = button.connect("toggled", on_toggle, func)
button.t_func = func
@ -61,22 +70,22 @@ def make_toggle(img_file, func, tooltip, is_active, show):
def rewind_button(show):
return make_button(gtk.STOCK_MEDIA_REWIND, controls.seek_backward, "Rewind", show)
return make_big_button(gtk.STOCK_MEDIA_REWIND, controls.seek_backward, "Rewind", show)
def forward_button(show):
return make_button(gtk.STOCK_MEDIA_FORWARD, controls.seek_forward, "Fast Forward", show)
return make_big_button(gtk.STOCK_MEDIA_FORWARD, controls.seek_forward, "Fast Forward", show)
def play_button(show):
return make_button(gtk.STOCK_MEDIA_PLAY, controls.play, "Play", show)
return make_big_button(gtk.STOCK_MEDIA_PLAY, controls.play, "Play", show)
def pause_button(show):
return make_button(gtk.STOCK_MEDIA_PAUSE, controls.pause, "Pause", show)
return make_big_button(gtk.STOCK_MEDIA_PAUSE, controls.pause, "Pause", show)
def stop_button(show):
return make_button(gtk.STOCK_MEDIA_STOP, controls.stop, "Stop", show)
return make_big_button(gtk.STOCK_MEDIA_STOP, controls.stop, "Stop", show)
def next_button(show):
return make_button(gtk.STOCK_MEDIA_NEXT, controls.next, "Next", show)
return make_big_button(gtk.STOCK_MEDIA_NEXT, controls.next, "Next", show)
def update_button(show):
return make_button(gtk.STOCK_REFRESH, sources.library.update_lib, "Update Library", show)

View File

@ -32,7 +32,7 @@ def slider_tooltip(slider, event):
slider.set_tooltip_text(audio.get_time_at(prcnt))
slider = gtk.HScale( gtk.Adjustment(0.0, 0.0, 100.0, 0.1, 1.0, 1.0) )
slider.set_size_request(150, 20)
slider.set_size_request(800, 20)
slider.set_draw_value(False)
slider.set_range(0, 101)
slider.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
@ -51,7 +51,6 @@ add_button( "PLAY", button.play_button)
add_button( "PAUSE", button.pause_button, False)
add_button( "STOP", button.stop_button)
add_button( "NEXT", button.next_button)
add_button( "DOWN", button.down_button)
action.show()
detailed.set_action_widget(action, gtk.PACK_END)
@ -62,7 +61,7 @@ def set_art(path):
def update_pos(time):
slider_update(slider)
cur_pos.set_text(time)
cur_pos.set_markup("<span size='x-large'>%s</span>" % time)
def on_play():
PLAY.hide()

View File

@ -1,12 +1,14 @@
# Bryan Schumaker (4 / 21 / 2011)
import gtk
import gobject
from libsaria import controls
from ocarina.body import button
from ocarina.body import image
page = gtk.HBox(False, 5)
label = gtk.Label("Now Playing")
label.set_markup("<span size='x-large'>Now Playing</span>")
ARTWORK = image.Image()
page.pack_start(ARTWORK, False, False)
@ -42,10 +44,6 @@ 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, False)
page.show_all()
label.show()
@ -57,7 +55,7 @@ def resize_art(*args):
sa_id = page.connect("size-allocate", resize_art)
def set_art(path):
ARTWORK.set_image(path, 64)
ARTWORK.set_image(path, 128)
def on_like(like):
def _on_like1(like):
@ -67,12 +65,16 @@ def on_like(like):
button.toggle_call_unconnected(DISLIKE, _on_like1, like)
button.toggle_call_unconnected(LIKE, _on_like0, like)
def set_tag(label, text):
markup = gobject.markup_escape_text(text)
label.set_markup("<span size='xx-large'>%s</span>" % markup)
def on_load(attrs):
TITLE.set_text(attrs["title"])
ARTIST.set_text("by %s" % attrs["artist"])
ALBUM.set_text("from %s" % attrs["album"])
YEAR.set_text("Year: %s" % attrs["year"])
LENGTH.set_text("Length: %s" % attrs["lenstr"])
COUNT.set_text("Play count: %s" % attrs["count"])
set_tag(TITLE, attrs["title"])
set_tag(ARTIST, attrs["artist"])
set_tag(ALBUM, attrs["album"])
set_tag(YEAR, "Year: %s" % attrs["year"])
set_tag(LENGTH, "Length: %s" % attrs["lenstr"])
set_tag(COUNT, "Count: %s" % attrs["count"])
set_art(attrs["art"])
on_like(attrs["like"])

View File

@ -18,16 +18,16 @@ def add_button(name, button):
header_body.pack_start(button, False, False)
header_body.pack_start(entry.entry)
add_button( "OPEN", button.open_button(True))
add_button( "SAVE", button.save_button(True))
#add_button( "OPEN", button.open_button(True))
#add_button( "SAVE", button.save_button(True))
add_button( "PREFS", button.prefs_button(True))
sep = gtk.VSeparator()
sep.show()
header_body.pack_start(sep, False, False)
add_button("UPDATE", button.update_button(True))
add_button( "CLEAR", button.clear_button(True))
#add_button("UPDATE", button.update_button(True))
#add_button( "CLEAR", button.clear_button(True))
add_button( "GOTO", button.goto_button(True))
add_button("RANDOM", button.random_button(prefs.get("libsaria.random"), True))
add_button("VOLUME", button.volume_button(prefs.get("libsaria.audio.volume"), True))

View File

@ -9,6 +9,7 @@ from ocarina import body
from ocarina import settings
from ocarina.body import footer
from libsaria import callbacks
import window
import playlist
import library
@ -24,6 +25,7 @@ def on_load(file, attrs):
footer.on_load(attrs)
queue.refresh()
body.cur_page_goto()
window.set_icon(attrs["art"])
callbacks.on_load = on_load
def on_like(like):
@ -40,7 +42,9 @@ gobject.signal_new("get_art", gobject.GObject, gobject.SIGNAL_RUN_LAST,
def on_get_art_helper(obj, id, path):
if id == libsaria.sources.get_cur_id():
footer.set_art(path)
#footer.set_art(path)
#window.set_icon(path)
pass
on_get_art_obj = gobject.GObject()
on_get_art_obj.connect("get_art", on_get_art_helper)

View File

@ -2,6 +2,7 @@
import gtk
import libsaria
from ocarina import window
page = gtk.VBox()
text = "Experimental"
@ -16,6 +17,8 @@ def make_check_button(text, func, active):
return button
SERVER = make_check_button("Enable web server", libsaria.server.toggle_state, libsaria.server.get_state())
WINDOW_ART = make_check_button("Use album art as window icon", window.toggle_art_icon, window.get_art_icon_state())
page.pack_start(SERVER, False, False)
page.pack_start(WINDOW_ART, False, False)
page.show_all()

View File

@ -4,10 +4,11 @@ import gtk
attrs = ("id", "track", "title", "lenstr", "artist", "album", "year")
columns = ["Id", "#", "Title", "Length", "Artist", "Album", "Year"]
col_width = [ 2, 20, 300, 60, 125, 125, 50]
col_width = [ 2, 30, 500, 75, 325, 310, 30]
cell = gtk.CellRendererText()
cell.set_fixed_height_from_font(1)
cell.set_property("size-points", 12)
class Column(gtk.TreeViewColumn):
def __init__(self, index, label):

View File

@ -31,7 +31,20 @@ def set_title(new_title = None):
window.set_title(new_title)
set_title()
def get_art_icon_state():
return libsaria.prefs.get("ocarina.window.articon")
def toggle_art_icon(newval):
libsaria.prefs.set("ocarina.window.articon", newval)
icon = "images/ocarina.png"
if newval == True:
icon = libsaria.sources.all_attrs()["art"]
set_icon(icon)
libsaria.prefs.init("ocarina.window.articon", False)
def set_icon(icon = "images/ocarina.png"):
if (icon != "images/ocarina.png") and (get_art_icon_state() == False):
icon = "images/ocarina.png"
window.set_icon_from_file(icon)
set_icon()