ocarina: Manually set album art when image clicked
This commit is contained in:
parent
091aa3972c
commit
71d73ecdd1
|
@ -52,7 +52,7 @@ label.show()
|
|||
|
||||
sa_id = None
|
||||
def resize_art(*args):
|
||||
set_art(ARTWORK.path)
|
||||
set_art(ARTWORK.get_file())
|
||||
page.disconnect(sa_id)
|
||||
sa_id = page.connect("size-allocate", resize_art)
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ add_button( "UP", button.up_button)
|
|||
|
||||
sa_id = None
|
||||
def resize_art(*args):
|
||||
set_art(ARTWORK.path)
|
||||
set_art(ARTWORK.get_file())
|
||||
tiny.disconnect(sa_id)
|
||||
sa_id = tiny.connect("size-allocate", resize_art)
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# Bryan Schumaker (04 / 23 / 2011)
|
||||
|
||||
import gtk
|
||||
from ocarina import fsselect
|
||||
from libsaria import sources
|
||||
|
||||
def find_new_width(buf, new_h):
|
||||
w = buf.get_width()
|
||||
|
@ -29,17 +31,22 @@ def resize(img, new_h):
|
|||
img.set_from_pixbuf(buf)
|
||||
|
||||
|
||||
class Image(gtk.Image):
|
||||
class FileImage(gtk.Image):
|
||||
def __init__(self):
|
||||
gtk.Image.__init__(self)
|
||||
self.path = None
|
||||
self.path = None
|
||||
self.height = 0
|
||||
self.set_has_tooltip(True)
|
||||
self.connect("query-tooltip", self.tooltip)
|
||||
self.show()
|
||||
|
||||
def get_file(self):
|
||||
return self.path
|
||||
|
||||
def set_image(self, path, height):
|
||||
if path != None:
|
||||
self.path = path
|
||||
self.path = path
|
||||
self.height = height
|
||||
self.set_from_file(path)
|
||||
resize(self, height)
|
||||
|
||||
|
@ -52,29 +59,28 @@ class Image(gtk.Image):
|
|||
return True
|
||||
|
||||
|
||||
class Image(gtk.EventBox):
|
||||
def __init__(self):
|
||||
gtk.EventBox.__init__(self)
|
||||
self.image = FileImage()
|
||||
self.add(self.image)
|
||||
self.connect("button-press-event", self.clicked)
|
||||
self.show()
|
||||
|
||||
#class AlbumArt(gtk.EventBox):
|
||||
#def __init__(self, size=64):
|
||||
#gtk.EventBox.__init__(self)
|
||||
#self.image = AlbumArtImage(size)
|
||||
#self.add(self.image)
|
||||
#self.connect("button-press-event", self.clicked)
|
||||
#self.show_all()
|
||||
|
||||
#def clicked(self, widget, event):
|
||||
#if event.button != 1:
|
||||
#return
|
||||
#if sources.get_attrs("id") == -1:
|
||||
#return
|
||||
#from ocarina import fsselect
|
||||
#path = fsselect.file("Select an image")
|
||||
#if path == None:
|
||||
#return
|
||||
#print "Selected file: %s" % path
|
||||
#try:
|
||||
##self.image.set(path)
|
||||
#sources.library.set_attr(sources.cur_lib_id, "art", path)
|
||||
#except Exception, e:
|
||||
#print e
|
||||
#pass
|
||||
self.get_file = self.image.get_file
|
||||
self.set_image = self.image.set_image
|
||||
|
||||
def clicked(self, widget, event):
|
||||
if event.button != 1:
|
||||
return
|
||||
id = sources.get_attrs("id")
|
||||
if id == -1:
|
||||
return
|
||||
path = fsselect.select_file("Select an image")
|
||||
if path == None:
|
||||
return
|
||||
try:
|
||||
self.set_image(path, self.image.height)
|
||||
sources.set_attr("art", path)
|
||||
except Exception, e:
|
||||
print e
|
||||
|
|
|
@ -65,7 +65,6 @@ def select_path(widget, callback):
|
|||
def run_chooser2(callback):
|
||||
make_chooser2("title", callback)
|
||||
|
||||
|
||||
def run_chooser(chooser):
|
||||
file = None
|
||||
if chooser.run() == gtk.RESPONSE_OK:
|
||||
|
@ -73,19 +72,16 @@ def run_chooser(chooser):
|
|||
chooser.hide()
|
||||
return file
|
||||
|
||||
|
||||
# Use for selecting a file through the GUI
|
||||
def file(title="Select a song"):
|
||||
def select_file(title = "Select a song"):
|
||||
chooser = make_chooser(title, gtk.FILE_CHOOSER_ACTION_OPEN)
|
||||
return run_chooser(chooser)
|
||||
|
||||
|
||||
# Use for selecting a directory through the GUI
|
||||
def dir(title="Select a directory"):
|
||||
def select_dir(title = "Select a directory"):
|
||||
chooser = make_chooser(title, gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
||||
return run_chooser(chooser)
|
||||
|
||||
|
||||
def save(title="Select a location"):
|
||||
def save(title = "Select a location"):
|
||||
chooser = make_chooser(title, gtk.FILE_CHOOSER_ACTION_SAVE)
|
||||
return run_chooser(chooser)
|
||||
|
|
Loading…
Reference in New Issue