On Mon, 2007-12-17 at 11:37 +0100, Toralf Lund wrote:
OK, maybe I should tell people what I'm really trying to do - see my
other post. [ ... ]
In any case, I'm on to something that has sort of bugged me for years;
in all my Gtk/Gtkmm window I generally have a button called "Close" or
"Cancel", or a "Close" menu item, depending on the context, that is
supposed to do *exactly* what a window manager close or "window delete"
will do. It seems to me that this isn't exactly uncommon, so why is
there no way of telling Gtk(mm) exactly what I want? I mean, why can't I
just say, "please let this button do a window delete", and forget about
the rest? Or can I do this?
[ ... ]
You already need to connect a signal handler for delete_event so you
can, for instance, show your do-you-really-want-to-close dialog. If you
also have a [Close] button then I'd just connect that to the same signal
handler.
The only reason that this is not quite so simple is that delete_event
uses the nasty return-true/false-to-do-something system. But you can
still abstract that out quite easily to a separate function, so you
have
void on_button_close()
{
if(ask_for_confirmation())
hide();
}
bool on_delete_event()
{
return ask_for_confirmation();
}
or similar.
Emmitting signals directly, for a class that you didn't implement, seems
like messing with the internals of that class.