Re: explicit signal connection vs. overriding function
- From: José Alburquerque <jaalburquerque cox net>
- To: Piscium <groknok yahoo ie>
- Cc: gtkmm-list gnome org
- Subject: Re: explicit signal connection vs. overriding function
- Date: Mon, 10 May 2010 17:37:07 -0400
On Mon, 2010-05-10 at 20:50 +0000, Piscium wrote:
> And what are the advantages of each way of connecting signals?
>
> It seems to me that overriding a signal method requires less typing, and results perhaps in more readable code.
>
> On the other hand, the method on_expose_event used in DrawingArea is protected, so one can override it only if one derives from DrawingArea, which may not be always expedient.
>
> Are there any other advantages and disadvantages?
>
> And are there any subtle semantic differences between the two ways? I would assume that overriding the signal method somehow causes the signal to be connected behind the scenes, though I have no clue how that would be done.
>
One difference from connecting versus deriving is that with connecting,
it is possible to use connect_notify() instead of connect() which allows
controlling whether the handler will be called before or after the
default signal handler:
http://library.gnome.org/devel/glibmm/unstable/classGlib_1_1SignalProxy1.html#a1dd40d7c3475124bb78053805fbde3f8
>
>
>
>
> ----- Original Message ----
> From: José Alburquerque <jaalburquerque cox net>
> To: Piscium <groknok yahoo ie>
> Cc: gtkmm-list gnome org
> Sent: Mon, 10 May, 2010 21:30:55
> Subject: Re: explicit signal connection vs. overriding function
>
> On Mon, 2010-05-10 at 19:57 +0000, Piscium wrote:
> > This begs the question: are the two methods of handling signals equivalent? Is it always possible to choose either of them?
> >
>
> Yes, there are two methods. Classes that are derived from Glib::Object
> that have signals such as signal_signalname() (which can be connected
> to) also have virtual methods such as on_signalname(). If that class is
> overridden, overriding the on_signalname() is another way of handling
> the signal.
>
--
José
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]