Re: Question about delete_event_impl
- From: Murray Cumming <murrayc murrayc com>
- To: "J. Baltasar Garcia Perez-Schofield" <jbgarcia uvigo es>
- Cc: gtkmm-list gnome org
- Subject: Re: Question about delete_event_impl
- Date: Tue, 24 Jan 2006 20:01:08 +0100
On Tue, 2006-01-24 at 17:16 +0100, J. Baltasar Garcia Perez-Schofield
wrote:
> Hi, there !
>
> I'm using Gtkmm 2.4 for a new project, with the interface classes
> generated by Glade.
I think you mean glademm. It has its own mailing list. libglademm (not
glademm) is recommended.
> My problem is that I want to intercept the closing
> event of a window, and I've read that you can simply override the
> following method in your window:
>
> gint delete_event_impl(GdkEventAny *);
Maybe you are reading gtkmm 1.2 documentation. In the gtkmm 2.0 and
gtkmm 2.4 (2.8 is the latest version of gtkmm 2.4) APIs, you can
override
bool on_delete_event(GdkEventAny* event);
There is no need to connect to a signal if you are just overriding this
default signal handler. However, you might need to call the base class
on_delete_event() from your override.
> So I have my class VentanaPpal inheriting from VentanaPpal_Glade which
> inherits from Gtk::Window as well, and then I introduce the line above
> in the .h file and implement the method in the .cpp file:
>
> gint VentanaPpal::delete_event_impl(GdkEventAny *)
> {
> if ( askYesNo( "Are you sure?" ) )
> {
> if ( getCurrentDocument() != NULL ) {
> saveCurrentDocument();
> }
>
> Gtk::Main::quit();
> return false;
> }
>
> return true;
> }
>
> Not very complex/specialized code. Also, the "exit" menu option signal
> handle calls delete_event_impl() function.
>
> Once the application is running, selecting the "exit" menu option makes
> the application to exit correctly, asking the user whether he or she is
> sure or not. However, if I close the window, it just finishes its
> execution.
>
> The documentation says that when a window is about to be closed, the
> signal handle for delete is called, as well as the delete_event_impl()
> method.
>
> Where's my error ?
>
> I also tried to connect a signal manually, in the constructor of
> VentanaPpal_Glade:
>
> signal_delete_event().connect(SigC::slot(*this,
> &VentanaPpal_glade::on_close), false);
>
> However, it then complains about functors.h not ignoring a void value
> (I suppose it has to do with the template receiving the method pointer).
>
> Regards,
>
> Baltasar
>
>
>
> --
>
> PBC -- J. Baltasar Garc�Perez-Schofield
> jbgarcia en uvigo de es http://webs.uvigo.es/jbgarcia/
> Dep. Inform�ca, Universidad de Vigo, Espa�Spain)
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
--
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]