Re: Gtk::Widget::signal_delete_event ()



2012-10-14 01:56, Ian Martin skrev:
On 14/10/12 05:02, Phil Wolff wrote:
Documentation says "The default handler for this signal destroys the window. Connecting Gtk::Widget::hide_on_delete() to this signal will cause the window to be hidden instead, so that it can later be shown again without reconstructing it."

This is exactly the behavior I want, but g++ says "error: ‘hide_on_delete’ is not a member of ‘Gtk::Widget’".

What am I missing?

Hi,
looking at the docs, it's only referred to in gtkmm 3.6; however, it's not listed as a method of Gtk::Window, and isn't in the Gtk documentation at the gtk doc site.  I didn't look through the source, but I'd guess it's still being implemented. 

You look at the wrong class. It's Gtk::Widget, not Gtk::Window.
Why not just override signal::hide() instead? - with the proviso that altering expected and reasonable behaviour tends to fail user acceptance testing.

Ian.
Much of the gtkmm documentation is automatically copied from gtk+, and to some extent adjusted to C++. E.g. "gtk_widget_hide_on_delete()" in the gtk+ documentation is translated to "Gtk::Widget::hide_on_delete()" in the gtkmm documentation. This is done by the command gmmproc in glibmm.

As you can expect, this kind of automatic translation is not always perfect. In this case it does not take into account that gtk_widget_hide_on_delete() is not wrapped in a gtkmm method. There is a gtk_widget_hide_on_delete() in gtk+, but there is no Gtk::Widget::hide_on_delete() in gtkmm. I don't know if there is a good reason not to include it in gtkmm, or if it's just that no one has taken the time to do it.

You can connect the gtk+ function to the signal, and see if it works as you want. The function arguments to the signal handler don't fit gtk_widget_hide_on_delete(). One way to solve this problem is that you write a small signal handler that calls gtk_widget_hide_on_delete(). Alternatively you can solve the problem with sigc::bind and sigc::hide.

Kjell



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]