From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.6 X-Received: by 2002:ac8:da:: with SMTP id d26mr1190634qtg.401.1631345781624; Sat, 11 Sep 2021 00:36:21 -0700 (PDT) X-Received: by 2002:a5b:58e:: with SMTP id l14mr2061632ybp.143.1631345781232; Sat, 11 Sep 2021 00:36:21 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 11 Sep 2021 00:36:20 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=87.88.29.208; posting-account=6yLzewoAAABoisbSsCJH1SPMc9UrfXBH NNTP-Posting-Host: 87.88.29.208 References: <6133e791$0$6461$426a74cc@news.free.fr> <6134cb26$0$3697$426a74cc@news.free.fr> <6134db32$0$6461$426a74cc@news.free.fr> <6134dc71$0$3693$426a74cc@news.free.fr> <6134e03d$0$3372$426a74cc@news.free.fr> <61352d42$0$3749$426a74cc@news.free.fr> <944e2cf6-2e24-480e-b7f7-0e0e0f5082e7n@googlegroups.com> <6139be6f$0$12704$426a74cc@news.free.fr> <757da468-7b58-43c2-95e6-917b3212f7b2n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <59b164ed-f32a-4786-bed7-78504714dfden@googlegroups.com> Subject: Re: GtkAda callback and event From: Emmanuel Briot Injection-Date: Sat, 11 Sep 2021 07:36:21 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:62696 List-Id: > 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).