comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Where do I get my Cairo context from (in GTK3)?
Date: Wed, 27 Apr 2016 10:08:11 +0200
Date: 2016-04-27T10:08:11+02:00	[thread overview]
Message-ID: <nfps27$1lko$1@gioia.aioe.org> (raw)
In-Reply-To: 31e4394b-eb85-4d31-bd25-f2bd332c7c9b@googlegroups.com

On 27/04/2016 09:47, briot.emmanuel@gmail.com wrote:
>> I would use On_* procedures if I didn't need user data. Until now no
>> success.
>
> Are you sure you really need that user data ? In my experience, it is often
> better to extend the widget type in your application, store whatever information
> is needed in that child type, and then use the On_* procedure passing a Slot
> object (so that the callback receives your widget type, rather than the widget
> on which the action occurred). This works in 95% of the cases.

Quite the opposite, this works in only few cases. The problem is that 
the handler of a signal is practically never the issuer of. So handling 
own events is very rare, only when the widget is a reusable extension of 
some other widget and the signal is used internally.

End instances of widgets are never like that. The most frequent case is 
a container widget handling signals from its children. The first 
parameter of the handler is never ever used, because the identification 
of the issuer is the handler procedure itself. The user parameter is the 
container widget, which is the case for the OP, I suppose.

> The GNAT Development Studio (GPS), which is about 500_000 lines of code
> has almost no use of user data, and those that remain are mostly because
> that part of the code hasn't been updated yet.

I have several GTK projects with exactly opposite statistics. Callbacks 
without user data are never used. Though many widgets are extensions as 
you suggested.

The design of handler connecting should have a reverse version 
"connect-from" in addition to current "connect-to", in a language like 
Ada without full double dispatch.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  reply	other threads:[~2016-04-27  8:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-24 20:44 Where do I get my Cairo context from (in GTK3)? hreba
2016-04-25  7:40 ` Dmitry A. Kazakov
2016-04-25 10:03   ` hreba
2016-04-25 11:58     ` Dmitry A. Kazakov
2016-04-26  7:22       ` briot.emmanuel
2016-04-26  7:34         ` hreba
2016-04-27  7:47           ` briot.emmanuel
2016-04-27  8:08             ` Dmitry A. Kazakov [this message]
2016-04-28  7:48               ` briot.emmanuel
2016-04-27 13:15             ` hreba
2016-04-27 13:37               ` Dmitry A. Kazakov
2016-04-28  7:49                 ` briot.emmanuel
2016-08-05 15:56 ` borisgaertner56
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox