I am creating an image slideshow in ruby, using gtk pixbuf to load images. I am very new to ruby & GTK, this may be an stupid question.
Currently image changes are linked to the GUI button_press_event, I would like them to change /refresh automatically based on a set time, like a slideshow or animation. I saw the gtk animation using a gif method, but I would like to use individual jpeg files inline sequence, so that I can set the time to show a slide. Once the loop has gone through all the images, the GUI should display buttons for replay or quit. ( I haven't used @time yet, it is just there for possibilities ) Thanks for any suggestions;
require 'gtk2'
class Pics
attr_accessor :pile, :picindex, :imgLoaded, :image, :box, :window, :time
def initialize
@window = Gtk::Window.new()
@window.signal_connect("destroy"){Gtk.main_quit}
pic1 = "1.jpg"
pic2 = "2.jpg"
pic3 = "3.jpg"
pic4 = "4.jpg"
@pile = [pic1, pic2, pic3, pic4]
@picindex = 0
self.getImage
@box = Gtk::EventBox.new.add(@image)
@time = true
end
def nuImage
@box.remove(@image)
@picindex = @picindex + 1
@picindex = 0 if @picindex == @pile.length
self.getImage
@box.add(@image)
@box.show
end
def getImage
@imgLoaded = @pile[@picindex]
img = Gdk::Pixbuf.new(@imgLoaded, 556, 900)
@image = Gtk::Image.new(img)
@image.show
end
end # class Pics
pics = Pics.new
pics.box.signal_connect("button_press_event"){pics.nuImage}
pics.window.set_default_size(556, 900)
pics.window.add(pics.box)
pics.window.show_all
Gtk.main