hello all,
first let me say that i’m a complete programming and ruby newbie -
haven’t done any programming since writing stuff in basic on my TI99-4a,
circa 1984 - so please forgive any questions or code (!) that seem
ridiculous.
here’s my story/questions…
i’m working on a simple mp3 player written in ruby, using gstreamer
and gtk+… really pretty straightforward - not supposed to do much
except load and save a playlist, and show some playback controls and the
cover art. i’ve got it doing all of that alright, only problem is i
can’t figure out for the life of me how to update the album art when the
song changes, either from a ‘next’ button click, or reaching the end of
the song. i’ve googled the b-jaysus out of refreshing gtk images, and
come up with some different ideas (event boxes, drawing areas…) but i
can’t seem to get anything to work.
i imagine this is something really simple that for some reason i just
can’t figure out. it seems that i have to jump out of the gtk.main loop
in order to update the cover. i know that a Gdk (that’s “d,” not “t,”)
window has an invalidate method, and a queue method, and it seems like
that could be a solution - or maybe through triggering an eventBox…
or through some other blatently obvious solution that i have no idea
about.
here’s a look at what i think should be the relevant code… thanks in
advance for any and all help.
everything is inside a Gtk::Window - here’s the bit about the album
art…
code snippet:
…
“player.img” is dynamic, based on the current song
coverpix = Gdk::Pixbuf.new(player.img, 196, 196)
cover = Gtk::Image.new(coverpix)
cover.show
artBox = Gtk::EventBox.new.add(cover)
artBox.show
box = Gtk::VBox.new(false,0)
box.pack_start(artBox,true,true,2)
box.pack_start(bbox,false,false,2)
box.show
window.add box
window.show
Gtk.main
…
i’ve tried using this bit of code as a ‘refresh’ method, and also
inside the next button’s EventBox block - when i add a “puts player.img”
in there to see what’s happening under the hood, i don’t see anything
until i stop the program (breaking the gtk main loop,) at which point
any and all of the correct image filenames appear for the songs played.
again, sorry if this is a boneheaded question, but i’ve been up high
down and low searching and experimenting with no luck - any ideas would
be appreciated…
-jk