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.
This commit is contained in:
parent
0017c04bbf
commit
128415f009
|
@ -9,6 +9,7 @@ from ocarina import body
|
||||||
from ocarina import settings
|
from ocarina import settings
|
||||||
from ocarina.body import footer
|
from ocarina.body import footer
|
||||||
from libsaria import callbacks
|
from libsaria import callbacks
|
||||||
|
import window
|
||||||
import playlist
|
import playlist
|
||||||
import library
|
import library
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ def on_load(file, attrs):
|
||||||
footer.on_load(attrs)
|
footer.on_load(attrs)
|
||||||
queue.refresh()
|
queue.refresh()
|
||||||
body.cur_page_goto()
|
body.cur_page_goto()
|
||||||
|
window.set_icon(attrs["art"])
|
||||||
callbacks.on_load = on_load
|
callbacks.on_load = on_load
|
||||||
|
|
||||||
def on_like(like):
|
def on_like(like):
|
||||||
|
@ -41,6 +43,7 @@ gobject.signal_new("get_art", gobject.GObject, gobject.SIGNAL_RUN_LAST,
|
||||||
def on_get_art_helper(obj, id, path):
|
def on_get_art_helper(obj, id, path):
|
||||||
if id == libsaria.sources.get_cur_id():
|
if id == libsaria.sources.get_cur_id():
|
||||||
footer.set_art(path)
|
footer.set_art(path)
|
||||||
|
window.set_icon(path)
|
||||||
|
|
||||||
on_get_art_obj = gobject.GObject()
|
on_get_art_obj = gobject.GObject()
|
||||||
on_get_art_obj.connect("get_art", on_get_art_helper)
|
on_get_art_obj.connect("get_art", on_get_art_helper)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
import libsaria
|
import libsaria
|
||||||
|
from ocarina import window
|
||||||
|
|
||||||
page = gtk.VBox()
|
page = gtk.VBox()
|
||||||
text = "Experimental"
|
text = "Experimental"
|
||||||
|
@ -16,6 +17,8 @@ def make_check_button(text, func, active):
|
||||||
return button
|
return button
|
||||||
|
|
||||||
SERVER = make_check_button("Enable web server", libsaria.server.toggle_state, libsaria.server.get_state())
|
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(SERVER, False, False)
|
||||||
|
page.pack_start(WINDOW_ART, False, False)
|
||||||
page.show_all()
|
page.show_all()
|
||||||
|
|
|
@ -31,7 +31,20 @@ def set_title(new_title = None):
|
||||||
window.set_title(new_title)
|
window.set_title(new_title)
|
||||||
set_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"):
|
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)
|
window.set_icon_from_file(icon)
|
||||||
set_icon()
|
set_icon()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue