comp.lang.ada
 help / color / mirror / Atom feed
From: Emmanuel Briot <briot.emmanuel@gmail.com>
Subject: Re: GtkAda callback and event
Date: Sat, 11 Sep 2021 00:36:20 -0700 (PDT)	[thread overview]
Message-ID: <59b164ed-f32a-4786-bed7-78504714dfden@googlegroups.com> (raw)
In-Reply-To: <shgg7j$1lu0$1@gioia.aioe.org>

> My design is to instantiate Gtk.Handlers.User_Return_Callback (and 
> parameterless handler) with GObject_Record and the user data set to the 
> tree view. Then I use this handler everywhere without caring what object 
> emits the event. The emitter is irrelevant in 90% of cases. 

I haven't done any GtkAda in almost five years now, so I had a bit forgotten.
The scenario you describe would be something like:
   - click on the [expand] button to expand the currently selected node in a tree view.

To implement this, I would have a function that "expends current node" and receive
a tree view widget.

I would then connect the button `click` callback to that function, using the `Slot`
parameter of the high-level callbacks, rather than the user_data.

In most cases, you do not need access to the button itself. Using user_data is really
when you need both the widget and additional information. Here the callback only needs
access to one widget (The tree view), so using Slot is definitely easier. And will properly
manage the life time of the widget, too, which might not be trivial to do with a user
callback (need to call Ref and Unref).

      reply	other threads:[~2021-09-11  7:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-04 21:39 GtkAda callback and event DrPi
2021-09-04 22:29 ` Dmitry A. Kazakov
2021-09-05 13:50   ` DrPi
2021-09-05 14:48     ` Dmitry A. Kazakov
2021-09-05 14:58       ` DrPi
2021-09-05 15:04         ` DrPi
2021-09-05 15:12           ` Dmitry A. Kazakov
2021-09-05 15:20             ` DrPi
2021-09-05 15:53               ` Dmitry A. Kazakov
2021-09-05 20:49                 ` DrPi
2021-09-09  6:56                   ` Emmanuel Briot
2021-09-09  7:57                     ` DrPi
2021-09-09 18:41                       ` Jere
2021-09-09 19:58                         ` Dmitry A. Kazakov
2021-09-09 21:01                           ` Jere
2021-09-10  6:38                             ` Dmitry A. Kazakov
2021-09-10  6:56                               ` Emmanuel Briot
2021-09-10 20:42                                 ` DrPi
2021-09-10 20:58                                   ` Dmitry A. Kazakov
2021-09-11  7:38                                     ` Emmanuel Briot
2021-09-11 15:24                                     ` DrPi
2021-09-11 15:56                                       ` Dmitry A. Kazakov
2021-09-12  7:08                                       ` AdaMagica
2021-09-12  8:52                                         ` Dmitry A. Kazakov
2021-09-12 13:00                                           ` DrPi
2021-09-12 13:57                                             ` Dmitry A. Kazakov
2021-09-10 20:46                                 ` Dmitry A. Kazakov
2021-09-11  7:36                                   ` Emmanuel Briot [this message]
replies disabled

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