DESCRIPTION

A Gtk2::Window is a top-level window displayed on the root window and interacting (or not) with the window manager. It can be an application's main window, a dialog, or a temporary such as a popup splash window.

Delete Event and Destroy

The default action for a delete-event (normally from the window manager close button) is to destroy the window with $window->destroy. In your main window you might want to exit the main loop when that happens.

$toplevel->signal_connect (destroy => sub { Gtk2->main_quit });

If you install a handler for delete-event and return true, meaning "don't propagate", you can do something other than destroy the window. For example

$toplevel->signal_connect (delete_event => sub {
   if (any_unsaved_documents()) {
     popup_ask_save_before_exit_dialog();
     return Gtk2::EVENT_STOP;  # don't go to default destroy
   } else {
     return Gtk2::EVENT_PROPAGATE;
   }
});

In a dialog or secondary app window you might not want to destroy but instead just hide ready for later re-use.

$dialog->signal_connect
  (delete_event => \&Gtk2::Widget::hide_on_delete);

The choice between destroying or hiding is normally just a matter of memory saved against the time to re-create, and how likely the dialog might be needed again. (However if you build windows with Glade it's not particularly easy to re-create them there, so you'll mostly want to just hide in that case.)

A hidden toplevel window is still in Gtk2::Window->list_toplevels and that's a good place to search for an existing window of a desired type to $window->present again.

set_icon_list () allows you to pass in the same icon in several hand-drawn sizes. The list should contain the natural sizes your icon is available in; that is, don't scale the image before passing it to GTK+. Scaling is postponed until the last minute, when the desired final size is known, to allow best quality.

By passing several sizes, you may improve the final image quality of the icon, by reducing or eliminating automatic image scaling.

Recommended sizes to provide: 16x16, 32x32, 48x48 at minimum, and larger images (64x64, 128x128) if you have them.