Forum: Ruby-Gnome 2 what is the difference between delete and deatroy?

Posted by Pen Ttt (luofeiyu)
on 2010-08-10 13:48
hi ,everyone , i am confused by the following program
require 'gtk2'
button = Gtk::Button.new("Hello World")
button.signal_connect("clicked") {
  puts "Hello World"
}
window = Gtk::Window.new
window.signal_connect("delete_event") {
  puts "delete event occurred"
  false
}
window.signal_connect("destroy") {
  puts "destroy event occurred"
  Gtk.main_quit
}
window.border_width = 10
window.add(button)
button.show
window.show
window.show_all
Gtk.main
why   connect two signal handlers to the window:delete_event,destroy?
mybe one is enough: destroy
1.what is the difference between delete and deatroy?
2.the folowing can run too
require 'gtk2'
button = Gtk::Button.new("Hello World")
button.signal_connect("clicked") {
  puts "Hello World"
}
window = Gtk::Window.new
window.signal_connect("destroy") {
  puts "destroy event occurred"
  Gtk.main_quit
}
window.border_width = 10
window.add(button)
button.show
window.show
window.show_all
Gtk.main

any advice can be appreciated .
Posted by Vincent Carmona (vinc-mai)
on 2010-08-10 14:01
(Received via mailing list)
2010/8/10, Pen Ttt <ruby-forum-incoming@andreas-s.net>:
> }
> why   connect two signal handlers to the window:delete_event,destroy?
>   puts "destroy event occurred"
> --
> ruby-gnome2-devel-en@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en
>

Hi.

When you try to close a window, the delete_event event is sent. If
there is no associed block or if it returns false, then the destroy
event is sent.
delete_event event can be used to interact with the user before the
window is actually detroyed. Usually it is used to present an confirm
dialog ("Are you sure you want to quit ?").

--
Vincent Carmona

------------------------------------------------------------------------------
This SF.net email is sponsored by

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.