Should this this script error ? (Gtk::button and set_image)

Hi, I was trying to change the icons of a button when the
mouse moves over the button, and when it moves out again.
I was trying to use set_image but I recieved a little error.
Unsure whether this could be a bug, here is an
example script (you probably need to use some
own Images)

SCRIPT START

require ‘gtk2’

make button that holds first image

button = Gtk::Button.new()
this_image = Gtk::Image.new(‘/foobar.png’)

assign 2 extra images

second_image = Gtk::Image.new(‘/foobar1.jpg’)
third_image = Gtk::Image.new(‘/foobar2.jpg’)

button.set_image this_image
button.set_image second_image
button.set_image third_image
button.set_image this_image
button.set_image second_image

add the things up

w=Gtk::Window.new
w.add(button)
w.show_all
Gtk.main

SCRIPT END

The error I recieve is:

image_test.rb
(eval):5:in set_property': destroyed GLib::Object (TypeError) from (eval):5:in set_image’
from image_test.rb:14

In another script where I try to use
set_image to get a new image, a similar error happens:
in set_property': destroyed GLib::Object from (eval):5:in set_image’

(On a sidenote, I was trying to change the icon of
a button when the mouse hovers over the button, and when
hovers out again, just like in Javascript. I am still not
sure how to properly do this in ruby-gnome)


Get your free email from http://www.linuxmail.org

Powered by Outblaze


Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

Hi,

In [email protected]
“[ruby-gnome2-devel-en] Should this this script error ? (Gtk::button
and set_image)” on Wed, 08 Nov 2006 02:02:37 +0100,
“Roebe XXX” [email protected] wrote:

Hi, I was trying to change the icons of a button when the
mouse moves over the button, and when it moves out again.
I was trying to use set_image but I recieved a little error.
Unsure whether this could be a bug, here is an
example script (you probably need to use some
own Images)

I found a workaround. (Yes, really just a workaround)
It’s that accessing button’s child before re-set_image.

button.set_image this_image
button.child
button.set_image second_image
button.child
button.set_image third_image
button.child
button.set_image this_image
button.child
button.set_image second_image

(On a sidenote, I was trying to change the icon of
a button when the mouse hovers over the button, and when
hovers out again, just like in Javascript. I am still not
sure how to properly do this in ruby-gnome)

What about using Gtk::Stock instead of Gtk::Image? You can
find Gtk::Stock sample Demo::AppWindow#register_stock_icons
in gtk/sample/gtk-demo/appvindow.rb.

Thanks,

kou


Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642