Re: What is the difference between 'signal_{event}' and 'on_{event}'?



2010/8/8 Tao Wang <dancefire gmail com>:
> Hi,
>
> I'm a little confused on connecting a member function by
> 'signal_{event}().connect()' and override 'on_{event}()' function.
>
> Say Gtk::Widget as an example, if I want to do something when 'show' event
> happened, I will create a member function, on_my_show(), and connect it to
> signal_show(). However, I also found a virtual member function in the API,
> on_show(). It looks likely can be overrideed and do the samething as
> previous on_my_show(). I'm not sure, but I guess that I do not need to
> connect to the signal_show() by myself, it should be already connected by
> Gtk::Window() constructor.
>
> So, could anyone make me clear, when should we create our own member
> function and connect it to the signal? and when should we just override the
> 'on_{event}' virtual function inherited from parent's class? Thanks in
> advance.
>

on_{event} are default signal handlers and signal_{event} are methods
emitting a signal. But not every signal has such handler, because when new
signal appears in C library, then only signal_{event} can be added to C++
bindings. Adding new default signal handler to already released bindings
could break its ABI.

So if there is no on_{event} signal handler, then only way to handle this is to
write your own (e.g. on_my_{event}) and connect to the signal_{event}.
Otherwise overriding a default signal handler should be enough.

Hope this helps,
Krzesimir


> --
> Regards
>
> Tao Wang
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
>


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