Livslängd för program

Most applications will have only one Window, or only one main window. These applications can use Gtk::Application::make_window_and_run(int argc, char** argv, T_Args&&... args). It creates and shows a window. When the window is hidden, make_window_and_run() deletes the window and returns to the caller. This might happen when the user closes the window, or when your code decides to hide the window with set_visible(false). You can prevent the user from closing the window (for instance, if there are unsaved changes) by overriding Gtk::Window::on_close_request().

De flesta av våra exempel använder denna teknik.