Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"When anyone says `theoretically,' they really mean `not really.'" -- David Parnas


devel / comp.lang.ada / GtkAda callback and event

SubjectAuthor
* GtkAda callback and eventDrPi
`* Re: GtkAda callback and eventDmitry A. Kazakov
 `* Re: GtkAda callback and eventDrPi
  `* Re: GtkAda callback and eventDmitry A. Kazakov
   `* Re: GtkAda callback and eventDrPi
    `* Re: GtkAda callback and eventDrPi
     `* Re: GtkAda callback and eventDmitry A. Kazakov
      `* Re: GtkAda callback and eventDrPi
       `* Re: GtkAda callback and eventDmitry A. Kazakov
        `* Re: GtkAda callback and eventDrPi
         `* Re: GtkAda callback and eventEmmanuel Briot
          `* Re: GtkAda callback and eventDrPi
           `* Re: GtkAda callback and eventJere
            `* Re: GtkAda callback and eventDmitry A. Kazakov
             `* Re: GtkAda callback and eventJere
              `* Re: GtkAda callback and eventDmitry A. Kazakov
               `* Re: GtkAda callback and eventEmmanuel Briot
                +* Re: GtkAda callback and eventDrPi
                |`* Re: GtkAda callback and eventDmitry A. Kazakov
                | +- Re: GtkAda callback and eventEmmanuel Briot
                | `* Re: GtkAda callback and eventDrPi
                |  +- Re: GtkAda callback and eventDmitry A. Kazakov
                |  `* Re: GtkAda callback and eventAdaMagica
                |   `* Re: GtkAda callback and eventDmitry A. Kazakov
                |    `* Re: GtkAda callback and eventDrPi
                |     `- Re: GtkAda callback and eventDmitry A. Kazakov
                `* Re: GtkAda callback and eventDmitry A. Kazakov
                 `- Re: GtkAda callback and eventEmmanuel Briot

Pages:12
GtkAda callback and event

<6133e791$0$6461$426a74cc@news.free.fr>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5809&group=comp.lang.ada#5809

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!usenet-fr.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!cleanfeed1-a.proxad.net!nnrp4-2.free.fr!not-for-mail
Newsgroups: comp.lang.ada
X-Mozilla-News-Host: news://news.free.fr:119
From: 314...@drpi.fr (DrPi)
Subject: GtkAda callback and event
Date: Sat, 4 Sep 2021 23:39:29 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: fr
Content-Transfer-Encoding: 7bit
Lines: 31
Message-ID: <6133e791$0$6461$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 04 Sep 2021 23:39:29 CEST
NNTP-Posting-Host: 82.65.30.55
X-Trace: 1630791569 news-2.free.fr 6461 82.65.30.55:49481
X-Complaints-To: abuse@proxad.net
 by: DrPi - Sat, 4 Sep 2021 21:39 UTC

Hi,

I use an event callback with user data.

I first declare a package :
package Handler_Motion_Notify is new
Gtk.Handlers.User_Return_Callback (Widget_Type =>
Gtk.Text_View.Gtk_Text_View_Record,
Return_Type => Boolean,
User_Type => t_Debug_Panel);

The function callback is declared like this :
function On_Motion_Notify (TextView : access
Gtk.Text_View.Gtk_Text_View_Record'Class;
DebugPanel : t_Debug_Panel) return Boolean;

The connection is done like this :
Handler_Motion_Notify.Connect (Widget => Panel.TextView,
Name =>
Gtk.Widget.Signal_Motion_Notify_Event,
Cb => On_Motion_Notify'Access,
User_Data => t_Debug_Panel(Panel));

This works correctly. But... I need to have access to the event in the
callback function.
How can I achieve this ?

Regards,
Nicolas

Re: GtkAda callback and event

<sh0s15$1ha4$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5810&group=comp.lang.ada#5810

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!x6YkKUCkj2qHLwbKnVEeag.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: GtkAda callback and event
Date: Sun, 5 Sep 2021 00:29:58 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sh0s15$1ha4$1@gioia.aioe.org>
References: <6133e791$0$6461$426a74cc@news.free.fr>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="50500"; posting-host="x6YkKUCkj2qHLwbKnVEeag.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Sat, 4 Sep 2021 22:29 UTC

On 2021-09-04 23:39, DrPi wrote:

> I use an event callback with user data.
>
> I first declare a package :
>    package Handler_Motion_Notify is new
> Gtk.Handlers.User_Return_Callback (Widget_Type =>
> Gtk.Text_View.Gtk_Text_View_Record,
>
>    Return_Type => Boolean,
>
>    User_Type   => t_Debug_Panel);
>
> The function callback is declared like this :
>    function On_Motion_Notify (TextView : access
> Gtk.Text_View.Gtk_Text_View_Record'Class;
>                               DebugPanel : t_Debug_Panel) return Boolean;

This is wrong. The motion-notify-event callback has the parameters:

1. Target
2. Gdk.Event.Gdk_Event_Motion
3. User data

> The connection is done like this :
>       Handler_Motion_Notify.Connect (Widget => Panel.TextView,
>                                      Name   =>
> Gtk.Widget.Signal_Motion_Notify_Event,
>                                      Cb     => On_Motion_Notify'Access,
>                                      User_Data => t_Debug_Panel(Panel));
>
> This works correctly. But... I need to have access to the event in the
> callback function.

Maybe it does not crash but it is incorrect.

> How can I achieve this ?

There is no shortcut Connect and Callback defined in
User_Return_Callback. Therefore you have to use a general-case callback
with the parameter list:

function On_Motion_Notify
( Object : access Gtk_Text_View_Record'Class;
Params : Glib.Values.GValues;
Data : t_Debug_Panel
) return Boolean;

connected as:

Handler_Motion_Notify.Connect
( Panel.TextView,
"motion-notify-event", -- = Signal_Motion_Notify_Event
On_Motion_Notify'Access,
t_Debug_Panel (Panel)
);

The parameter is accessed using the function Nth or
Gtk.Argument.Unchecked_To_Gdk_Event_Motion, e.g.

Gtk.Argument.Unchecked_To_Gdk_Event_Motion (Params, 1)

P.S. Since the target is practically never used in callbacks, you can
instantiate Gtk.Handlers.User_Return_Callback with GObject_Record. This
way you could use it with all types of widgets. That reduces the number
of instantiations.

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

Re: GtkAda callback and event

<6134cb26$0$3697$426a74cc@news.free.fr>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5819&group=comp.lang.ada#5819

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!cleanfeed1-a.proxad.net!nnrp1-1.free.fr!not-for-mail
Newsgroups: comp.lang.ada
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org>
From: 314...@drpi.fr (DrPi)
Subject: Re: GtkAda callback and event
Date: Sun, 5 Sep 2021 15:50:28 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
MIME-Version: 1.0
In-Reply-To: <sh0s15$1ha4$1@gioia.aioe.org>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Lines: 84
Message-ID: <6134cb26$0$3697$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 05 Sep 2021 15:50:30 CEST
NNTP-Posting-Host: 82.65.30.55
X-Trace: 1630849830 news-3.free.fr 3697 82.65.30.55:59179
X-Complaints-To: abuse@proxad.net
 by: DrPi - Sun, 5 Sep 2021 13:50 UTC

Le 05/09/2021 à 00:29, Dmitry A. Kazakov a écrit :
> On 2021-09-04 23:39, DrPi wrote:
>
>> I use an event callback with user data.
>>
>> I first declare a package :
>>     package Handler_Motion_Notify is new
>> Gtk.Handlers.User_Return_Callback (Widget_Type =>
>> Gtk.Text_View.Gtk_Text_View_Record,
>>
>>     Return_Type => Boolean,
>>
>>     User_Type   => t_Debug_Panel);
>>
>> The function callback is declared like this :
>>     function On_Motion_Notify (TextView : access
>> Gtk.Text_View.Gtk_Text_View_Record'Class;
>>                                DebugPanel : t_Debug_Panel) return
>> Boolean;
>
> This is wrong. The motion-notify-event callback has the parameters:
>
> 1. Target
> 2. Gdk.Event.Gdk_Event_Motion
> 3. User data
>
>> The connection is done like this :
>>        Handler_Motion_Notify.Connect (Widget => Panel.TextView,
>>                                       Name   =>
>> Gtk.Widget.Signal_Motion_Notify_Event,
>>                                       Cb     => On_Motion_Notify'Access,
>>                                       User_Data => t_Debug_Panel(Panel));
>>
>> This works correctly. But... I need to have access to the event in the
>> callback function.
>
> Maybe it does not crash but it is incorrect.
I suppose it doesn't crash because I don't use any callback parameter in
the callback itself. Just a Put_Line() to check the callback is called.

>
>> How can I achieve this ?
>
> There is no shortcut Connect and Callback defined in
> User_Return_Callback. Therefore you have to use a general-case callback
> with the parameter list:
>
>    function On_Motion_Notify
>             (  Object : access Gtk_Text_View_Record'Class;
>                Params : Glib.Values.GValues;
>                Data   : t_Debug_Panel
>             )  return Boolean;
>
So I have to use a callback with Handler profile, not Simple_Handler
profile.
I missed that.

> connected as:
>
>    Handler_Motion_Notify.Connect
>    (  Panel.TextView,
>       "motion-notify-event", -- = Signal_Motion_Notify_Event
>       On_Motion_Notify'Access,
>       t_Debug_Panel (Panel)
>    );
>
> The parameter is accessed using the function Nth or
> Gtk.Argument.Unchecked_To_Gdk_Event_Motion, e.g.
>
>    Gtk.Argument.Unchecked_To_Gdk_Event_Motion (Params, 1)
>
With "Gtk.Arguments.Unchecked_To_Gdk_Event_Motion (Params, 1);" , I get
an error :
expected private type "C_GValues" defined at glib-values.ads:53
found private type "GValues" defined at glib-values.ads:48

> P.S. Since the target is practically never used in callbacks, you can
> instantiate Gtk.Handlers.User_Return_Callback with GObject_Record. This
> way you could use it with all types of widgets. That reduces the number
> of instantiations.
>
Thanks for the tip.

Re: GtkAda callback and event

<sh2lb1$1lpq$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5820&group=comp.lang.ada#5820

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!rocksolid2!i2pn.org!aioe.org!x6YkKUCkj2qHLwbKnVEeag.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: GtkAda callback and event
Date: Sun, 5 Sep 2021 16:48:02 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sh2lb1$1lpq$1@gioia.aioe.org>
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="55098"; posting-host="x6YkKUCkj2qHLwbKnVEeag.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dmitry A. Kazakov - Sun, 5 Sep 2021 14:48 UTC

On 2021-09-05 15:50, DrPi wrote:
> Le 05/09/2021 à 00:29, Dmitry A. Kazakov a écrit :

> With "Gtk.Arguments.Unchecked_To_Gdk_Event_Motion (Params, 1);" , I get
> an error :
> expected private type "C_GValues" defined at glib-values.ads:53
> found private type "GValues" defined at glib-values.ads:48

I see, then you must to implement it yourself. It could be something
like this (not tested):

package Conversions is
new System.Address_To_Access_Conversions (Gdk_Event_Motion);

Event : Gdk_Event_Motion renames
Conversions.To_Pointer (Get_Address (Nth (Params, 1))).all;

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

Re: GtkAda callback and event

<6134db32$0$6461$426a74cc@news.free.fr>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5821&group=comp.lang.ada#5821

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!cleanfeed2-b.proxad.net!nnrp4-2.free.fr!not-for-mail
Subject: Re: GtkAda callback and event
Newsgroups: comp.lang.ada
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr>
<sh2lb1$1lpq$1@gioia.aioe.org>
From: 314...@drpi.fr (DrPi)
Date: Sun, 5 Sep 2021 16:58:57 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
MIME-Version: 1.0
In-Reply-To: <sh2lb1$1lpq$1@gioia.aioe.org>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: fr
Content-Transfer-Encoding: 8bit
Lines: 20
Message-ID: <6134db32$0$6461$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 05 Sep 2021 16:58:58 CEST
NNTP-Posting-Host: 82.65.30.55
X-Trace: 1630853938 news-2.free.fr 6461 82.65.30.55:63732
X-Complaints-To: abuse@proxad.net
 by: DrPi - Sun, 5 Sep 2021 14:58 UTC

Le 05/09/2021 à 16:48, Dmitry A. Kazakov a écrit :
> On 2021-09-05 15:50, DrPi wrote:
>> Le 05/09/2021 à 00:29, Dmitry A. Kazakov a écrit :
>
>> With "Gtk.Arguments.Unchecked_To_Gdk_Event_Motion (Params, 1);" , I
>> get an error :
>> expected private type "C_GValues" defined at glib-values.ads:53
>> found private type "GValues" defined at glib-values.ads:48
>
> I see, then you must to implement it yourself. It could be something
> like this (not tested):
>
>    package Conversions is
>       new System.Address_To_Access_Conversions (Gdk_Event_Motion);
>
>    Event : Gdk_Event_Motion renames
>            Conversions.To_Pointer (Get_Address (Nth (Params, 1))).all;
>

So, Gtk.Arguments.Unchecked_To_Gdk_Event_Motion is useless ?

Re: GtkAda callback and event

<6134dc71$0$3693$426a74cc@news.free.fr>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5822&group=comp.lang.ada#5822

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!cleanfeed2-a.proxad.net!nnrp1-1.free.fr!not-for-mail
Subject: Re: GtkAda callback and event
Newsgroups: comp.lang.ada
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr>
<sh2lb1$1lpq$1@gioia.aioe.org> <6134db32$0$6461$426a74cc@news.free.fr>
From: 314...@drpi.fr (DrPi)
Date: Sun, 5 Sep 2021 17:04:15 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
MIME-Version: 1.0
In-Reply-To: <6134db32$0$6461$426a74cc@news.free.fr>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Lines: 23
Message-ID: <6134dc71$0$3693$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 05 Sep 2021 17:04:17 CEST
NNTP-Posting-Host: 82.65.30.55
X-Trace: 1630854257 news-1.free.fr 3693 82.65.30.55:57935
X-Complaints-To: abuse@proxad.net
 by: DrPi - Sun, 5 Sep 2021 15:04 UTC

Le 05/09/2021 à 16:58, DrPi a écrit :
> Le 05/09/2021 à 16:48, Dmitry A. Kazakov a écrit :
>> On 2021-09-05 15:50, DrPi wrote:
>>> Le 05/09/2021 à 00:29, Dmitry A. Kazakov a écrit :
>>
>>> With "Gtk.Arguments.Unchecked_To_Gdk_Event_Motion (Params, 1);" , I
>>> get an error :
>>> expected private type "C_GValues" defined at glib-values.ads:53
>>> found private type "GValues" defined at glib-values.ads:48
>>
>> I see, then you must to implement it yourself. It could be something
>> like this (not tested):
>>
>>     package Conversions is
>>        new System.Address_To_Access_Conversions (Gdk_Event_Motion);
>>
>>     Event : Gdk_Event_Motion renames
>>             Conversions.To_Pointer (Get_Address (Nth (Params, 1))).all;
>>
>
> So, Gtk.Arguments.Unchecked_To_Gdk_Event_Motion is useless ?
Like all subprograms accepting C_GValues as a parameter ?

Re: GtkAda callback and event

<sh2mpb$950$2@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5823&group=comp.lang.ada#5823

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!x6YkKUCkj2qHLwbKnVEeag.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: GtkAda callback and event
Date: Sun, 5 Sep 2021 17:12:44 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sh2mpb$950$2@gioia.aioe.org>
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr>
<sh2lb1$1lpq$1@gioia.aioe.org> <6134db32$0$6461$426a74cc@news.free.fr>
<6134dc71$0$3693$426a74cc@news.free.fr>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="9376"; posting-host="x6YkKUCkj2qHLwbKnVEeag.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dmitry A. Kazakov - Sun, 5 Sep 2021 15:12 UTC

On 2021-09-05 17:04, DrPi wrote:
> Le 05/09/2021 à 16:58, DrPi a écrit :
>> Le 05/09/2021 à 16:48, Dmitry A. Kazakov a écrit :
>>> On 2021-09-05 15:50, DrPi wrote:
>>>> Le 05/09/2021 à 00:29, Dmitry A. Kazakov a écrit :
>>>
>>>> With "Gtk.Arguments.Unchecked_To_Gdk_Event_Motion (Params, 1);" , I
>>>> get an error :
>>>> expected private type "C_GValues" defined at glib-values.ads:53
>>>> found private type "GValues" defined at glib-values.ads:48
>>>
>>> I see, then you must to implement it yourself. It could be something
>>> like this (not tested):
>>>
>>>     package Conversions is
>>>        new System.Address_To_Access_Conversions (Gdk_Event_Motion);
>>>
>>>     Event : Gdk_Event_Motion renames
>>>             Conversions.To_Pointer (Get_Address (Nth (Params, 1))).all;
>>>
>>
>> So, Gtk.Arguments.Unchecked_To_Gdk_Event_Motion is useless ?
> Like all subprograms accepting C_GValues as a parameter ?

It is a part of GValues object. But you could create a child package
that would have access to the internals of GValue and get access to
C_GValues in GValue.

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

Re: GtkAda callback and event

<6134e03d$0$3372$426a74cc@news.free.fr>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5824&group=comp.lang.ada#5824

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!cleanfeed3-a.proxad.net!nnrp1-1.free.fr!not-for-mail
Subject: Re: GtkAda callback and event
Newsgroups: comp.lang.ada
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr>
<sh2lb1$1lpq$1@gioia.aioe.org> <6134db32$0$6461$426a74cc@news.free.fr>
<6134dc71$0$3693$426a74cc@news.free.fr> <sh2mpb$950$2@gioia.aioe.org>
From: 314...@drpi.fr (DrPi)
Date: Sun, 5 Sep 2021 17:20:27 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
MIME-Version: 1.0
In-Reply-To: <sh2mpb$950$2@gioia.aioe.org>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: fr
Content-Transfer-Encoding: 8bit
Lines: 36
Message-ID: <6134e03d$0$3372$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 05 Sep 2021 17:20:29 CEST
NNTP-Posting-Host: 82.65.30.55
X-Trace: 1630855229 news-2.free.fr 3372 82.65.30.55:57960
X-Complaints-To: abuse@proxad.net
 by: DrPi - Sun, 5 Sep 2021 15:20 UTC

Le 05/09/2021 à 17:12, Dmitry A. Kazakov a écrit :
> On 2021-09-05 17:04, DrPi wrote:
>> Le 05/09/2021 à 16:58, DrPi a écrit :
>>> Le 05/09/2021 à 16:48, Dmitry A. Kazakov a écrit :
>>>> On 2021-09-05 15:50, DrPi wrote:
>>>>> Le 05/09/2021 à 00:29, Dmitry A. Kazakov a écrit :
>>>>
>>>>> With "Gtk.Arguments.Unchecked_To_Gdk_Event_Motion (Params, 1);" , I
>>>>> get an error :
>>>>> expected private type "C_GValues" defined at glib-values.ads:53
>>>>> found private type "GValues" defined at glib-values.ads:48
>>>>
>>>> I see, then you must to implement it yourself. It could be something
>>>> like this (not tested):
>>>>
>>>>     package Conversions is
>>>>        new System.Address_To_Access_Conversions (Gdk_Event_Motion);
>>>>
>>>>     Event : Gdk_Event_Motion renames
>>>>             Conversions.To_Pointer (Get_Address (Nth (Params, 1))).all;
>>>>
>>>
>>> So, Gtk.Arguments.Unchecked_To_Gdk_Event_Motion is useless ?
>> Like all subprograms accepting C_GValues as a parameter ?
>
> It is a part of GValues object. But you could create a child package
> that would have access to the internals of GValue and get access to
> C_GValues in GValue.
>
I didn't know I can create a child Package of a GtkAda Package myself.

Thanks for all these explanations Dmitry.

Regards,
Nicolas

Re: GtkAda callback and event

<sh2p61$1dll$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5825&group=comp.lang.ada#5825

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!rocksolid2!i2pn.org!aioe.org!x6YkKUCkj2qHLwbKnVEeag.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: GtkAda callback and event
Date: Sun, 5 Sep 2021 17:53:39 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sh2p61$1dll$1@gioia.aioe.org>
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr>
<sh2lb1$1lpq$1@gioia.aioe.org> <6134db32$0$6461$426a74cc@news.free.fr>
<6134dc71$0$3693$426a74cc@news.free.fr> <sh2mpb$950$2@gioia.aioe.org>
<6134e03d$0$3372$426a74cc@news.free.fr>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="46773"; posting-host="x6YkKUCkj2qHLwbKnVEeag.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Sun, 5 Sep 2021 15:53 UTC

On 2021-09-05 17:20, DrPi wrote:
> Le 05/09/2021 à 17:12, Dmitry A. Kazakov a écrit :

>> It is a part of GValues object. But you could create a child package
>> that would have access to the internals of GValue and get access to
>> C_GValues in GValue.
>>
> I didn't know I can create a  child Package of a GtkAda Package myself.

Of course you can:

package Glib.Values.My_Stuff is
function Get_C_Values (List : GValues) return C_GValues;
end Glib.Values.My_Stuff;

package body Glib.Values.My_Stuff is
function Get_C_Values (List : GValues) return C_GValues is
begin
return List.Arr;
end Get_C_Values;
end Glib.Values.My_Stuff;

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

Re: GtkAda callback and event

<61352d42$0$3749$426a74cc@news.free.fr>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5830&group=comp.lang.ada#5830

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!cleanfeed1-a.proxad.net!nnrp1-1.free.fr!not-for-mail
Newsgroups: comp.lang.ada
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr>
<sh2lb1$1lpq$1@gioia.aioe.org> <6134db32$0$6461$426a74cc@news.free.fr>
<6134dc71$0$3693$426a74cc@news.free.fr> <sh2mpb$950$2@gioia.aioe.org>
<6134e03d$0$3372$426a74cc@news.free.fr> <sh2p61$1dll$1@gioia.aioe.org>
From: 314...@drpi.fr (DrPi)
Subject: Re: GtkAda callback and event
Date: Sun, 5 Sep 2021 22:49:03 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
MIME-Version: 1.0
In-Reply-To: <sh2p61$1dll$1@gioia.aioe.org>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Lines: 36
Message-ID: <61352d42$0$3749$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 05 Sep 2021 22:49:06 CEST
NNTP-Posting-Host: 82.65.30.55
X-Trace: 1630874946 news-2.free.fr 3749 82.65.30.55:60382
X-Complaints-To: abuse@proxad.net
 by: DrPi - Sun, 5 Sep 2021 20:49 UTC

Le 05/09/2021 à 17:53, Dmitry A. Kazakov a écrit :
> On 2021-09-05 17:20, DrPi wrote:
>> Le 05/09/2021 à 17:12, Dmitry A. Kazakov a écrit :
>
>>> It is a part of GValues object. But you could create a child package
>>> that would have access to the internals of GValue and get access to
>>> C_GValues in GValue.
>>>
>> I didn't know I can create a  child Package of a GtkAda Package myself.
>
> Of course you can:
>
>    package Glib.Values.My_Stuff is
>       function Get_C_Values (List : GValues) return C_GValues;
>    end Glib.Values.My_Stuff;
>
>    package body Glib.Values.My_Stuff is
>       function Get_C_Values (List : GValues) return C_GValues is
>       begin
>          return List.Arr;
>       end Get_C_Values;
>    end Glib.Values.My_Stuff;
>
That's what I did after you told me it's possible.

My first attempt was with an expression function like the following :

package Glib.Values.User is
function Get_C_GValues (Val : GValues) return C_GValues is
(Val.Arr);
end Glib.Values.User;

But that didn't work. The compiler complained about something I don't
remember.
I then used the classical function implementation and all went well.

Re: GtkAda callback and event

<944e2cf6-2e24-480e-b7f7-0e0e0f5082e7n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5856&group=comp.lang.ada#5856

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:5290:: with SMTP id s16mr1395964qtn.412.1631170618683;
Wed, 08 Sep 2021 23:56:58 -0700 (PDT)
X-Received: by 2002:a05:6902:124c:: with SMTP id t12mr1873668ybu.91.1631170618301;
Wed, 08 Sep 2021 23:56:58 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!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: Wed, 8 Sep 2021 23:56:58 -0700 (PDT)
In-Reply-To: <61352d42$0$3749$426a74cc@news.free.fr>
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> <sh0s15$1ha4$1@gioia.aioe.org>
<6134cb26$0$3697$426a74cc@news.free.fr> <sh2lb1$1lpq$1@gioia.aioe.org>
<6134db32$0$6461$426a74cc@news.free.fr> <6134dc71$0$3693$426a74cc@news.free.fr>
<sh2mpb$950$2@gioia.aioe.org> <6134e03d$0$3372$426a74cc@news.free.fr>
<sh2p61$1dll$1@gioia.aioe.org> <61352d42$0$3749$426a74cc@news.free.fr>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <944e2cf6-2e24-480e-b7f7-0e0e0f5082e7n@googlegroups.com>
Subject: Re: GtkAda callback and event
From: briot.em...@gmail.com (Emmanuel Briot)
Injection-Date: Thu, 09 Sep 2021 06:56:58 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 25
 by: Emmanuel Briot - Thu, 9 Sep 2021 06:56 UTC

You could perhaps consider using some of the higher-level event handling functions that
are generated as part of the binding. For instance, `gtk-widget.ads` has:

```
type Cb_Gtk_Widget_Gdk_Event_Motion_Boolean is not null access function
(Self : access Gtk_Widget_Record'Class;
Event : Gdk.Event.Gdk_Event_Motion) return Boolean;

type Cb_GObject_Gdk_Event_Motion_Boolean is not null access function
(Self : access Glib.Object.GObject_Record'Class;
Event : Gdk.Event.Gdk_Event_Motion) return Boolean;

Signal_Motion_Notify_Event : constant Glib.Signal_Name := "motion-notify-event";
procedure On_Motion_Notify_Event
(Self : not null access Gtk_Widget_Record;
Call : Cb_Gtk_Widget_Gdk_Event_Motion_Boolean;
After : Boolean := False);
procedure On_Motion_Notify_Event
(Self : not null access Gtk_Widget_Record;
Call : Cb_GObject_Gdk_Event_Motion_Boolean;
Slot : not null access Glib.Object.GObject_Record'Class;
After : Boolean := False);
```

This ensures the proper list of parameters for the callback, and automatically gets you
the Event, for instance.

Re: GtkAda callback and event

<6139be6f$0$12704$426a74cc@news.free.fr>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5857&group=comp.lang.ada#5857

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!cleanfeed2-a.proxad.net!nnrp1-2.free.fr!not-for-mail
Subject: Re: GtkAda callback and event
Newsgroups: comp.lang.ada
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr>
<sh2lb1$1lpq$1@gioia.aioe.org> <6134db32$0$6461$426a74cc@news.free.fr>
<6134dc71$0$3693$426a74cc@news.free.fr> <sh2mpb$950$2@gioia.aioe.org>
<6134e03d$0$3372$426a74cc@news.free.fr> <sh2p61$1dll$1@gioia.aioe.org>
<61352d42$0$3749$426a74cc@news.free.fr>
<944e2cf6-2e24-480e-b7f7-0e0e0f5082e7n@googlegroups.com>
From: 314...@drpi.fr (DrPi)
Date: Thu, 9 Sep 2021 09:57:29 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
MIME-Version: 1.0
In-Reply-To: <944e2cf6-2e24-480e-b7f7-0e0e0f5082e7n@googlegroups.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: fr
Content-Transfer-Encoding: 8bit
Lines: 31
Message-ID: <6139be6f$0$12704$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 09 Sep 2021 09:57:35 CEST
NNTP-Posting-Host: 82.65.30.55
X-Trace: 1631174255 news-2.free.fr 12704 82.65.30.55:63622
X-Complaints-To: abuse@proxad.net
 by: DrPi - Thu, 9 Sep 2021 07:57 UTC

Le 09/09/2021 à 08:56, Emmanuel Briot a écrit :
> You could perhaps consider using some of the higher-level event handling functions that
> are generated as part of the binding. For instance, `gtk-widget.ads` has:
>
> ```
> type Cb_Gtk_Widget_Gdk_Event_Motion_Boolean is not null access function
> (Self : access Gtk_Widget_Record'Class;
> Event : Gdk.Event.Gdk_Event_Motion) return Boolean;
>
> type Cb_GObject_Gdk_Event_Motion_Boolean is not null access function
> (Self : access Glib.Object.GObject_Record'Class;
> Event : Gdk.Event.Gdk_Event_Motion) return Boolean;
>
> Signal_Motion_Notify_Event : constant Glib.Signal_Name := "motion-notify-event";
> procedure On_Motion_Notify_Event
> (Self : not null access Gtk_Widget_Record;
> Call : Cb_Gtk_Widget_Gdk_Event_Motion_Boolean;
> After : Boolean := False);
> procedure On_Motion_Notify_Event
> (Self : not null access Gtk_Widget_Record;
> Call : Cb_GObject_Gdk_Event_Motion_Boolean;
> Slot : not null access Glib.Object.GObject_Record'Class;
> After : Boolean := False);
> ```
>
> This ensures the proper list of parameters for the callback, and automatically gets you
> the Event, for instance.
>
The problem with these functions is that you can't pass a user record to
the callback.

Re: GtkAda callback and event

<757da468-7b58-43c2-95e6-917b3212f7b2n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5860&group=comp.lang.ada#5860

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:5802:: with SMTP id g2mr4237112qtg.391.1631212911421;
Thu, 09 Sep 2021 11:41:51 -0700 (PDT)
X-Received: by 2002:a05:6902:1549:: with SMTP id r9mr5781600ybu.204.1631212911229;
Thu, 09 Sep 2021 11:41:51 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!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: Thu, 9 Sep 2021 11:41:50 -0700 (PDT)
In-Reply-To: <6139be6f$0$12704$426a74cc@news.free.fr>
Injection-Info: google-groups.googlegroups.com; posting-host=98.118.241.166; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf
NNTP-Posting-Host: 98.118.241.166
References: <6133e791$0$6461$426a74cc@news.free.fr> <sh0s15$1ha4$1@gioia.aioe.org>
<6134cb26$0$3697$426a74cc@news.free.fr> <sh2lb1$1lpq$1@gioia.aioe.org>
<6134db32$0$6461$426a74cc@news.free.fr> <6134dc71$0$3693$426a74cc@news.free.fr>
<sh2mpb$950$2@gioia.aioe.org> <6134e03d$0$3372$426a74cc@news.free.fr>
<sh2p61$1dll$1@gioia.aioe.org> <61352d42$0$3749$426a74cc@news.free.fr>
<944e2cf6-2e24-480e-b7f7-0e0e0f5082e7n@googlegroups.com> <6139be6f$0$12704$426a74cc@news.free.fr>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <757da468-7b58-43c2-95e6-917b3212f7b2n@googlegroups.com>
Subject: Re: GtkAda callback and event
From: jhb.c...@gmail.com (Jere)
Injection-Date: Thu, 09 Sep 2021 18:41:51 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 32
 by: Jere - Thu, 9 Sep 2021 18:41 UTC

On Thursday, September 9, 2021 at 3:57:37 AM UTC-4, DrPi wrote:
> Le 09/09/2021 à 08:56, Emmanuel Briot a écrit :
> > You could perhaps consider using some of the higher-level event handling functions that
> > are generated as part of the binding. For instance, `gtk-widget.ads` has:
> >
> > ```
> > <SNIPPED>
> > ```
> >
> > This ensures the proper list of parameters for the callback, and automatically gets you
> > the Event, for instance.
> >
> The problem with these functions is that you can't pass a user record to
> the callback.

I'm not as versed in GtkAda, but it looks like those have 'Class types so if
it is like most of the other GUI frameworks out there, you typically would
extend the type that you are doing the handler for and your user data would
be fields of the new record type. Since the handler uses 'Class you could just
cast the parameter to your new type and have access to the user data.

Otherwise I'm not sure what you mean. The GUI work loop doesn't generally
pass user data to a callback, just the event and the listener to the event. All
user data in most GUI frameworks is handled on the listener side, which is
why a lot of them rely on type extension of the listener type.

Re: GtkAda callback and event

<shdp09$87k$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5862&group=comp.lang.ada#5862

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!x6YkKUCkj2qHLwbKnVEeag.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: GtkAda callback and event
Date: Thu, 9 Sep 2021 21:58:03 +0200
Organization: Aioe.org NNTP Server
Message-ID: <shdp09$87k$1@gioia.aioe.org>
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr>
<sh2lb1$1lpq$1@gioia.aioe.org> <6134db32$0$6461$426a74cc@news.free.fr>
<6134dc71$0$3693$426a74cc@news.free.fr> <sh2mpb$950$2@gioia.aioe.org>
<6134e03d$0$3372$426a74cc@news.free.fr> <sh2p61$1dll$1@gioia.aioe.org>
<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>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="8436"; posting-host="x6YkKUCkj2qHLwbKnVEeag.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Thu, 9 Sep 2021 19:58 UTC

On 2021-09-09 20:41, Jere wrote:

> I'm not as versed in GtkAda, but it looks like those have 'Class types so if
> it is like most of the other GUI frameworks out there, you typically would
> extend the type that you are doing the handler for and your user data would
> be fields of the new record type. Since the handler uses 'Class you could just
> cast the parameter to your new type and have access to the user data.

The problem is that GtkAda uses generics instead of tagged types. And,
as I frequently say, generics are lousy.

Here is the design, very simplified:

generic
type Widget_Type is new Glib.Object.GObject_Record with private; -
type User_Type (<>) is private;
package User_Callback is
type Int_Handler is access procedure
( Widget : access Widget_Type'Class;
Param : GInt;
User_Data : User_Type
);
procedure Connect
( ...,
Int_Handler
...
);
type GUInt_Handler is access procedure
( Widget : access Widget_Type'Class;
Param : GUInt;
User_Data : User_Type
);
procedure Connect
( ...,
Int_Handler
...
);
... -- An so on for each parameter type

In reality it is much messier because handlers are created per generic
instances. But you see the problem. For each combination of parameters
you need a handler type and a connect procedure.

Furthermore, observe, that this is inherently type unsafe as you could
attach any handler from a generic instance to any event regardless the
parameters of the event.

Welcome to generics, enjoy.

Handlers without user data are non-generic and exist for each event
because GtkAda is generated. So, it is possible to generate a
non-generic handler/connect pair for each of hundreds of events per each
widget. This is what Emmanuel suggested:

Cb_GObject_Gdk_Event_Motion_Boolean

But, no user data.

You could not do same and stuff thousands of cases in a single generic
handler package! There is only one for all widgets-events.

There is much hatred towards OO design in Ada community which is
possibly was a motive behind this.

An OO design would be to create an abstract base type for each event
with a primitive operation handle the event. The target widget type
would be fixed class-wide, but since it is practically never used, that
is no problem.

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

Re: GtkAda callback and event

<f4291006-ea19-4896-b7bc-96ce3c102955n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5863&group=comp.lang.ada#5863

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ad4:55eb:: with SMTP id bu11mr5081439qvb.57.1631221311984;
Thu, 09 Sep 2021 14:01:51 -0700 (PDT)
X-Received: by 2002:a05:6902:124c:: with SMTP id t12mr6375214ybu.91.1631221311842;
Thu, 09 Sep 2021 14:01:51 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!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: Thu, 9 Sep 2021 14:01:51 -0700 (PDT)
In-Reply-To: <shdp09$87k$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=98.118.241.166; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf
NNTP-Posting-Host: 98.118.241.166
References: <6133e791$0$6461$426a74cc@news.free.fr> <sh0s15$1ha4$1@gioia.aioe.org>
<6134cb26$0$3697$426a74cc@news.free.fr> <sh2lb1$1lpq$1@gioia.aioe.org>
<6134db32$0$6461$426a74cc@news.free.fr> <6134dc71$0$3693$426a74cc@news.free.fr>
<sh2mpb$950$2@gioia.aioe.org> <6134e03d$0$3372$426a74cc@news.free.fr>
<sh2p61$1dll$1@gioia.aioe.org> <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> <shdp09$87k$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f4291006-ea19-4896-b7bc-96ce3c102955n@googlegroups.com>
Subject: Re: GtkAda callback and event
From: jhb.c...@gmail.com (Jere)
Injection-Date: Thu, 09 Sep 2021 21:01:51 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 52
 by: Jere - Thu, 9 Sep 2021 21:01 UTC

On Thursday, September 9, 2021 at 3:58:06 PM UTC-4, Dmitry A. Kazakov wrote:
> On 2021-09-09 20:41, Jere wrote:
>
> > I'm not as versed in GtkAda, but it looks like those have 'Class types so if
> > it is like most of the other GUI frameworks out there, you typically would
> > extend the type that you are doing the handler for and your user data would
> > be fields of the new record type. Since the handler uses 'Class you could just
> > cast the parameter to your new type and have access to the user data.
>
> <SNIPPED>
>
> Handlers without user data are non-generic and exist for each event
> because GtkAda is generated. So, it is possible to generate a
> non-generic handler/connect pair for each of hundreds of events per each
> widget. This is what Emmanuel suggested:
>
> Cb_GObject_Gdk_Event_Motion_Boolean
>
> But, no user data.
>
> You could not do same and stuff thousands of cases in a single generic
> handler package! There is only one for all widgets-events.
Okie dokie! After reading this chain I took a look at the GtkAda manual and
saw that they had separate high level events for things like button clicks and
such and that they used access to 'Class types so I was hoping that meant
for the OP that they could, for example do something like:

type My_Button is new Gtk.Whatever_Path.Button_Type with record
User_Data : User_Data_Type;
end record;

procedure On_Button_Click(Self : access to Button_Type'Class) is
A_Button : My_Button renames My_Button(Self.all); -- forget if this is allowed or not
begin
-- use A_Button.User_Data.???
end On_Button_Click;

and attach that as the handler. But based on what you said it sounds like this is not
actually an option. (And of course the OP isn't using buttons, but just an example).

>
> There is much hatred towards OO design in Ada community which is
> possibly was a motive behind this.
>
> An OO design would be to create an abstract base type for each event
> with a primitive operation handle the event. The target widget type
> would be fixed class-wide, but since it is practically never used, that
> is no problem.

This is the design I see most often in GUI frameworks (though usually an
interface (if you like OO) or a trait object (if you don't care for OO) instead
of an abstract class, but about the same). I was hoping the GtkAda
framework offered this as well so the OP could have something to work with.

Re: GtkAda callback and event

<sheugb$lop$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5864&group=comp.lang.ada#5864

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!Hx95GBhnJb0Xc8StPhH8AA.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: GtkAda callback and event
Date: Fri, 10 Sep 2021 08:38:02 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sheugb$lop$1@gioia.aioe.org>
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr>
<sh2lb1$1lpq$1@gioia.aioe.org> <6134db32$0$6461$426a74cc@news.free.fr>
<6134dc71$0$3693$426a74cc@news.free.fr> <sh2mpb$950$2@gioia.aioe.org>
<6134e03d$0$3372$426a74cc@news.free.fr> <sh2p61$1dll$1@gioia.aioe.org>
<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>
<shdp09$87k$1@gioia.aioe.org>
<f4291006-ea19-4896-b7bc-96ce3c102955n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="22297"; posting-host="Hx95GBhnJb0Xc8StPhH8AA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dmitry A. Kazakov - Fri, 10 Sep 2021 06:38 UTC

On 2021-09-09 23:01, Jere wrote:

> Okie dokie! After reading this chain I took a look at the GtkAda manual and
> saw that they had separate high level events for things like button clicks and
> such and that they used access to 'Class types so I was hoping that meant
> for the OP that they could, for example do something like:
>
> type My_Button is new Gtk.Whatever_Path.Button_Type with record
> User_Data : User_Data_Type;
> end record;

type My_Button is new Get_Button_Record with record
User_Data : User_Data_Type;
end record;

> procedure On_Button_Click(Self : access to Button_Type'Class) is
> A_Button : My_Button renames My_Button(Self.all); -- forget if this is allowed or not
> begin
> -- use A_Button.User_Data.???
> end On_Button_Click;
>
> and attach that as the handler. But based on what you said it sounds like this is not
> actually an option. (And of course the OP isn't using buttons, but just an example).

This works perfectly well in GtkAda. Unfortunately is not what is needed
in most cases.

User data is a property of the event not of the button. E.g. consider a
button to save file. The user data would be some Ada object responsible
for dealing with the file. What about other buttons? What about
life-times of buttons? User data usually have a longer life span etc.

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

Re: GtkAda callback and event

<c9395f4d-e1d3-4c33-80f1-ff86c0cdf7fan@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5865&group=comp.lang.ada#5865

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:e301:: with SMTP id y1mr6192250qki.475.1631256981692; Thu, 09 Sep 2021 23:56:21 -0700 (PDT)
X-Received: by 2002:a25:3086:: with SMTP id w128mr9130867ybw.139.1631256981427; Thu, 09 Sep 2021 23:56:21 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.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: Thu, 9 Sep 2021 23:56:21 -0700 (PDT)
In-Reply-To: <sheugb$lop$1@gioia.aioe.org>
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> <sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr> <sh2lb1$1lpq$1@gioia.aioe.org> <6134db32$0$6461$426a74cc@news.free.fr> <6134dc71$0$3693$426a74cc@news.free.fr> <sh2mpb$950$2@gioia.aioe.org> <6134e03d$0$3372$426a74cc@news.free.fr> <sh2p61$1dll$1@gioia.aioe.org> <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> <shdp09$87k$1@gioia.aioe.org> <f4291006-ea19-4896-b7bc-96ce3c102955n@googlegroups.com> <sheugb$lop$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c9395f4d-e1d3-4c33-80f1-ff86c0cdf7fan@googlegroups.com>
Subject: Re: GtkAda callback and event
From: briot.em...@gmail.com (Emmanuel Briot)
Injection-Date: Fri, 10 Sep 2021 06:56:21 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 40
 by: Emmanuel Briot - Fri, 10 Sep 2021 06:56 UTC

> > type My_Button is new Gtk.Whatever_Path.Button_Type with record
> > User_Data : User_Data_Type;
> > end record;

This is indeed the recommended approach. In practice, most widgets have a single callback per event type (so one for motion_notify, one for click, and so on). All that's needed is the `Self` parameter which contains all relevant information. At least this was my experience based on the GPS source code, which is a relatively extensive GUI application. I don't remember the stats exactly, but there were just a few cases where this approach did not work. And this is why we implemented the higher-level approach in GtkAda, where there are no possible errors in the type of parameters for callbacks.

There are a few cases where you want to share the same callback subprogram for multiple events, or multiple types of widgets for instance. In these cases, you might have to fallback to using the generics to connect, along with specifying a user data. As much as possible, I would recommend not using this approach if you can avoid it.

I do not share Dmitry's distrust of generics, but for GUI applications I 100% agree that an OO approach works much better indeed. The performance cost is negligible in such contexts, and the flexibility is much needed.

> User data is a property of the event not of the button. E.g. consider a
> button to save file. The user data would be some Ada object responsible
> for dealing with the file. What about other buttons? What about
> life-times of buttons? User data usually have a longer life span etc.

Presumably you would have one callback procedure to deal with the file, another one to exit the application, another one to ask the user's name and whatever else. For all of these, you do not need user data and the high-level callbacks provided by GtkAda are much easier to use.

One contrived example where user data might be used is for instance: we have one callback responsible for moving the cursor in an editor, and the user data is used to pass UP, DOWN, LEFT or RIGHT to indicate which direction to move. But even in such a case, I would argue it is better to have four small callbacks that call the same shared procedure, and still use the high-level callbacks of GtkAda.

Re: GtkAda callback and event

<613bc32d$0$27421$426a74cc@news.free.fr>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5871&group=comp.lang.ada#5871

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!cleanfeed2-b.proxad.net!nnrp1-2.free.fr!not-for-mail
Subject: Re: GtkAda callback and event
Newsgroups: comp.lang.ada
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr>
<sh2lb1$1lpq$1@gioia.aioe.org> <6134db32$0$6461$426a74cc@news.free.fr>
<6134dc71$0$3693$426a74cc@news.free.fr> <sh2mpb$950$2@gioia.aioe.org>
<6134e03d$0$3372$426a74cc@news.free.fr> <sh2p61$1dll$1@gioia.aioe.org>
<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>
<shdp09$87k$1@gioia.aioe.org>
<f4291006-ea19-4896-b7bc-96ce3c102955n@googlegroups.com>
<sheugb$lop$1@gioia.aioe.org>
<c9395f4d-e1d3-4c33-80f1-ff86c0cdf7fan@googlegroups.com>
From: 314...@drpi.fr (DrPi)
Date: Fri, 10 Sep 2021 22:42:19 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
MIME-Version: 1.0
In-Reply-To: <c9395f4d-e1d3-4c33-80f1-ff86c0cdf7fan@googlegroups.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Lines: 26
Message-ID: <613bc32d$0$27421$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 10 Sep 2021 22:42:21 CEST
NNTP-Posting-Host: 82.65.30.55
X-Trace: 1631306541 news-3.free.fr 27421 82.65.30.55:54274
X-Complaints-To: abuse@proxad.net
 by: DrPi - Fri, 10 Sep 2021 20:42 UTC

Le 10/09/2021 à 08:56, Emmanuel Briot a écrit :
>>> type My_Button is new Gtk.Whatever_Path.Button_Type with record
>>> User_Data : User_Data_Type;
>>> end record;
>
> This is indeed the recommended approach. In practice, most widgets have a single callback per event type (so one for motion_notify, one for click, and so on). All that's needed is the `Self` parameter which contains all relevant information. At least this was my experience based on the GPS source code, which is a relatively extensive GUI application. I don't remember the stats exactly, but there were just a few cases where this approach did not work. And this is why we implemented the higher-level approach in GtkAda, where there are no possible errors in the type of parameters for callbacks.
>
> There are a few cases where you want to share the same callback subprogram for multiple events, or multiple types of widgets for instance. In these cases, you might have to fallback to using the generics to connect, along with specifying a user data. As much as possible, I would recommend not using this approach if you can avoid it.
>
> I do not share Dmitry's distrust of generics, but for GUI applications I 100% agree that an OO approach works much better indeed. The performance cost is negligible in such contexts, and the flexibility is much needed.
>
>> User data is a property of the event not of the button. E.g. consider a
>> button to save file. The user data would be some Ada object responsible
>> for dealing with the file. What about other buttons? What about
>> life-times of buttons? User data usually have a longer life span etc.
>
> Presumably you would have one callback procedure to deal with the file, another one to exit the application, another one to ask the user's name and whatever else. For all of these, you do not need user data and the high-level callbacks provided by GtkAda are much easier to use.
>
> One contrived example where user data might be used is for instance: we have one callback responsible for moving the cursor in an editor, and the user data is used to pass UP, DOWN, LEFT or RIGHT to indicate which direction to move. But even in such a case, I would argue it is better to have four small callbacks that call the same shared procedure, and still use the high-level callbacks of GtkAda.
>

That's very interesting.
I didn't think I can extend the widget type to add my own parameters.
Thanks all for your help.

Nicolas

Re: GtkAda callback and event

<shgg7j$1lu0$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5872&group=comp.lang.ada#5872

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!Hx95GBhnJb0Xc8StPhH8AA.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: GtkAda callback and event
Date: Fri, 10 Sep 2021 22:46:45 +0200
Organization: Aioe.org NNTP Server
Message-ID: <shgg7j$1lu0$1@gioia.aioe.org>
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr>
<sh2lb1$1lpq$1@gioia.aioe.org> <6134db32$0$6461$426a74cc@news.free.fr>
<6134dc71$0$3693$426a74cc@news.free.fr> <sh2mpb$950$2@gioia.aioe.org>
<6134e03d$0$3372$426a74cc@news.free.fr> <sh2p61$1dll$1@gioia.aioe.org>
<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>
<shdp09$87k$1@gioia.aioe.org>
<f4291006-ea19-4896-b7bc-96ce3c102955n@googlegroups.com>
<sheugb$lop$1@gioia.aioe.org>
<c9395f4d-e1d3-4c33-80f1-ff86c0cdf7fan@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="55232"; posting-host="Hx95GBhnJb0Xc8StPhH8AA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Fri, 10 Sep 2021 20:46 UTC

On 2021-09-10 08:56, Emmanuel Briot wrote:

>> User data is a property of the event not of the button. E.g. consider a
>> button to save file. The user data would be some Ada object responsible
>> for dealing with the file. What about other buttons? What about
>> life-times of buttons? User data usually have a longer life span etc.
>
> Presumably you would have one callback procedure to deal with the file, another one to exit the application, another one to ask the user's name and whatever else. For all of these, you do not need user data and the high-level callbacks provided by GtkAda are much easier to use.
>
> One contrived example where user data might be used is for instance: we have one callback responsible for moving the cursor in an editor, and the user data is used to pass UP, DOWN, LEFT or RIGHT to indicate which direction to move. But even in such a case, I would argue it is better to have four small callbacks that call the same shared procedure, and still use the high-level callbacks of GtkAda.

These are rather unrealistic examples. For a real example take an
application with a tree view. There are lots of events you would need to
process by the in widget derived from Get_Tree_View.

Almost none of them will be emitted by the tree view!

1. The tree view refers/contain other objects like selection. These
objects emit events, not the tree view.

2. The buttons, menus etc having effect on the tree view, e.g. a button
to collapse the tree view. These will emit events for the tree view
unrelated to it from the GTK point of view.

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.

An OO alternative to Gtk.Handlers.User_Callback would be for example,
taking Button for simplicity:

type Gtk_Button_Record is new Gtk_Bin_Record with null record;
type Gtk_Button is access all Gtk_Button_Record'Class;

...

type Button_Void_Handler is limited interface;
procedure Handle
( Handler : in out Button_Void_Handler ;
Button : access Gtk_Button_Record'Class
) is abstract;

procedure On_Clicked
( Self : not null access Gtk_Button_Record;
Handler : not null access Button_Void_Handler'Class;
After : Boolean := False
);
procedure On_Enter
( Self : not null access Gtk_Button_Record;
Handler : not null access Button_Void_Handler'Class;
After : Boolean := False
);
...

This is type-safe and can be generated the way On_Clicked with
Cb_Gtk_Button_Void is generated.

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

Re: GtkAda callback and event

<shggst$nv$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5873&group=comp.lang.ada#5873

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!Hx95GBhnJb0Xc8StPhH8AA.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: GtkAda callback and event
Date: Fri, 10 Sep 2021 22:58:06 +0200
Organization: Aioe.org NNTP Server
Message-ID: <shggst$nv$1@gioia.aioe.org>
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr>
<sh2lb1$1lpq$1@gioia.aioe.org> <6134db32$0$6461$426a74cc@news.free.fr>
<6134dc71$0$3693$426a74cc@news.free.fr> <sh2mpb$950$2@gioia.aioe.org>
<6134e03d$0$3372$426a74cc@news.free.fr> <sh2p61$1dll$1@gioia.aioe.org>
<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>
<shdp09$87k$1@gioia.aioe.org>
<f4291006-ea19-4896-b7bc-96ce3c102955n@googlegroups.com>
<sheugb$lop$1@gioia.aioe.org>
<c9395f4d-e1d3-4c33-80f1-ff86c0cdf7fan@googlegroups.com>
<613bc32d$0$27421$426a74cc@news.free.fr>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="767"; posting-host="Hx95GBhnJb0Xc8StPhH8AA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dmitry A. Kazakov - Fri, 10 Sep 2021 20:58 UTC

On 2021-09-10 22:42, DrPi wrote:

> I didn't think I can extend the widget type to add my own parameters.

Not only for parameters.

Even more frequent purpose is a composite widget. E.g. consider a text
edit widget with a scroll bar, a menu, some buttons etc. Typically, you
would take some existing widget and derive your widget from there.

In the Initialize you will create all other widgets and pack them into
the widget (if it is a container) or Ref them otherwise. In Gtk_New you
will have custom parameters.

This new widget you could use just as any built-in widget.

Moreover, you can create a new class for your derived widget and add new
events, properties and styles for external parametrization etc. The
styles can be set via CSS.

It is a very powerful and versatile mechanism GtkAda offers.

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

Re: GtkAda callback and event

<59b164ed-f32a-4786-bed7-78504714dfden@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5874&group=comp.lang.ada#5874

  copy link   Newsgroups: comp.lang.ada
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: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!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: <shgg7j$1lu0$1@gioia.aioe.org>
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> <sh0s15$1ha4$1@gioia.aioe.org>
<6134cb26$0$3697$426a74cc@news.free.fr> <sh2lb1$1lpq$1@gioia.aioe.org>
<6134db32$0$6461$426a74cc@news.free.fr> <6134dc71$0$3693$426a74cc@news.free.fr>
<sh2mpb$950$2@gioia.aioe.org> <6134e03d$0$3372$426a74cc@news.free.fr>
<sh2p61$1dll$1@gioia.aioe.org> <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> <shdp09$87k$1@gioia.aioe.org>
<f4291006-ea19-4896-b7bc-96ce3c102955n@googlegroups.com> <sheugb$lop$1@gioia.aioe.org>
<c9395f4d-e1d3-4c33-80f1-ff86c0cdf7fan@googlegroups.com> <shgg7j$1lu0$1@gioia.aioe.org>
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: briot.em...@gmail.com (Emmanuel Briot)
Injection-Date: Sat, 11 Sep 2021 07:36:21 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 19
 by: Emmanuel Briot - Sat, 11 Sep 2021 07:36 UTC

> 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).

Re: GtkAda callback and event

<c94f1faa-3275-4f49-a99b-e3385687b540n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5875&group=comp.lang.ada#5875

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:7d88:: with SMTP id c8mr1209439qtd.208.1631345888115;
Sat, 11 Sep 2021 00:38:08 -0700 (PDT)
X-Received: by 2002:a25:4789:: with SMTP id u131mr2163583yba.531.1631345887874;
Sat, 11 Sep 2021 00:38:07 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!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:38:07 -0700 (PDT)
In-Reply-To: <shggst$nv$1@gioia.aioe.org>
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> <sh0s15$1ha4$1@gioia.aioe.org>
<6134cb26$0$3697$426a74cc@news.free.fr> <sh2lb1$1lpq$1@gioia.aioe.org>
<6134db32$0$6461$426a74cc@news.free.fr> <6134dc71$0$3693$426a74cc@news.free.fr>
<sh2mpb$950$2@gioia.aioe.org> <6134e03d$0$3372$426a74cc@news.free.fr>
<sh2p61$1dll$1@gioia.aioe.org> <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> <shdp09$87k$1@gioia.aioe.org>
<f4291006-ea19-4896-b7bc-96ce3c102955n@googlegroups.com> <sheugb$lop$1@gioia.aioe.org>
<c9395f4d-e1d3-4c33-80f1-ff86c0cdf7fan@googlegroups.com> <613bc32d$0$27421$426a74cc@news.free.fr>
<shggst$nv$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c94f1faa-3275-4f49-a99b-e3385687b540n@googlegroups.com>
Subject: Re: GtkAda callback and event
From: briot.em...@gmail.com (Emmanuel Briot)
Injection-Date: Sat, 11 Sep 2021 07:38:08 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 10
 by: Emmanuel Briot - Sat, 11 Sep 2021 07:38 UTC

> Even more frequent purpose is a composite widget. E.g. consider a text
> edit widget with a scroll bar, a menu, some buttons etc. Typically, you
> would take some existing widget and derive your widget from there.
>
> In the Initialize you will create all other widgets and pack them into
> the widget (if it is a container) or Ref them otherwise. In Gtk_New you
> will have custom parameters.

I agree this is exactly the right design and the way we intended GtkAda to be
used (supporting this was not completely trivial at first, though later versions of gtk+
made that simpler).

Re: GtkAda callback and event

<613cca39$0$29491$426a34cc@news.free.fr>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5886&group=comp.lang.ada#5886

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!cleanfeed2-a.proxad.net!nnrp1-1.free.fr!not-for-mail
Newsgroups: comp.lang.ada
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr>
<sh2lb1$1lpq$1@gioia.aioe.org> <6134db32$0$6461$426a74cc@news.free.fr>
<6134dc71$0$3693$426a74cc@news.free.fr> <sh2mpb$950$2@gioia.aioe.org>
<6134e03d$0$3372$426a74cc@news.free.fr> <sh2p61$1dll$1@gioia.aioe.org>
<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>
<shdp09$87k$1@gioia.aioe.org>
<f4291006-ea19-4896-b7bc-96ce3c102955n@googlegroups.com>
<sheugb$lop$1@gioia.aioe.org>
<c9395f4d-e1d3-4c33-80f1-ff86c0cdf7fan@googlegroups.com>
<613bc32d$0$27421$426a74cc@news.free.fr> <shggst$nv$1@gioia.aioe.org>
From: 314...@drpi.fr (DrPi)
Subject: Re: GtkAda callback and event
Date: Sat, 11 Sep 2021 17:24:41 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
MIME-Version: 1.0
In-Reply-To: <shggst$nv$1@gioia.aioe.org>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Lines: 37
Message-ID: <613cca39$0$29491$426a34cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 11 Sep 2021 17:24:41 CEST
NNTP-Posting-Host: 82.65.30.55
X-Trace: 1631373881 news-4.free.fr 29491 82.65.30.55:51627
X-Complaints-To: abuse@proxad.net
 by: DrPi - Sat, 11 Sep 2021 15:24 UTC

Le 10/09/2021 à 22:58, Dmitry A. Kazakov a écrit :
> On 2021-09-10 22:42, DrPi wrote:
>
>> I didn't think I can extend the widget type to add my own parameters.
>
> Not only for parameters.
>
> Even more frequent purpose is a composite widget. E.g. consider a text
> edit widget with a scroll bar, a menu, some buttons etc. Typically, you
> would take some existing widget and derive your widget from there.
>
> In the Initialize you will create all other widgets and pack them into
> the widget (if it is a container) or Ref them otherwise. In Gtk_New you
> will have custom parameters.
>
> This new widget you could use just as any built-in widget.

I already do this.
I don't know why I didn't think to apply this to my own parameters.

>
> Moreover, you can create a new class for your derived widget and add new
> events, properties and styles for external parametrization etc. The
> styles can be set via CSS.
Interesting.
Any pointer on how to use CSS styles ?

>
> It is a very powerful and versatile mechanism GtkAda offers.
>

Even if I just started using GtkAda, I find it very powerful.
The big problem is documentation. Of course, there are the reference
manual and the (small) user guide but I miss a document explaining the
use of all these functionalities.
I found a tutorial in French which is very helpful for starting but it
is outdated.

Re: GtkAda callback and event

<shijih$kff$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5887&group=comp.lang.ada#5887

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!Hx95GBhnJb0Xc8StPhH8AA.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: GtkAda callback and event
Date: Sat, 11 Sep 2021 17:56:02 +0200
Organization: Aioe.org NNTP Server
Message-ID: <shijih$kff$1@gioia.aioe.org>
References: <6133e791$0$6461$426a74cc@news.free.fr>
<sh0s15$1ha4$1@gioia.aioe.org> <6134cb26$0$3697$426a74cc@news.free.fr>
<sh2lb1$1lpq$1@gioia.aioe.org> <6134db32$0$6461$426a74cc@news.free.fr>
<6134dc71$0$3693$426a74cc@news.free.fr> <sh2mpb$950$2@gioia.aioe.org>
<6134e03d$0$3372$426a74cc@news.free.fr> <sh2p61$1dll$1@gioia.aioe.org>
<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>
<shdp09$87k$1@gioia.aioe.org>
<f4291006-ea19-4896-b7bc-96ce3c102955n@googlegroups.com>
<sheugb$lop$1@gioia.aioe.org>
<c9395f4d-e1d3-4c33-80f1-ff86c0cdf7fan@googlegroups.com>
<613bc32d$0$27421$426a74cc@news.free.fr> <shggst$nv$1@gioia.aioe.org>
<613cca39$0$29491$426a34cc@news.free.fr>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="20975"; posting-host="Hx95GBhnJb0Xc8StPhH8AA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Sat, 11 Sep 2021 15:56 UTC

On 2021-09-11 17:24, DrPi wrote:

> Interesting.
> Any pointer on how to use CSS styles ?

This is GTK documentation of CSS:

https://docs.gtk.org/gtk3/css-overview.html

Here is an example of a custom button that uses CSS for label, icon,
tool tip etc.


http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm#Gtk.Generic_Style_Button

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

Re: GtkAda callback and event

<e23f19ef-5f39-4260-b625-f49176cb8f70n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5890&group=comp.lang.ada#5890

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:8f04:: with SMTP id r4mr4631560qkd.351.1631430540280;
Sun, 12 Sep 2021 00:09:00 -0700 (PDT)
X-Received: by 2002:a25:d497:: with SMTP id m145mr7953293ybf.389.1631430540124;
Sun, 12 Sep 2021 00:09:00 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sun, 12 Sep 2021 00:08:59 -0700 (PDT)
In-Reply-To: <613cca39$0$29491$426a34cc@news.free.fr>
Injection-Info: google-groups.googlegroups.com; posting-host=94.31.101.123; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf
NNTP-Posting-Host: 94.31.101.123
References: <6133e791$0$6461$426a74cc@news.free.fr> <sh0s15$1ha4$1@gioia.aioe.org>
<6134cb26$0$3697$426a74cc@news.free.fr> <sh2lb1$1lpq$1@gioia.aioe.org>
<6134db32$0$6461$426a74cc@news.free.fr> <6134dc71$0$3693$426a74cc@news.free.fr>
<sh2mpb$950$2@gioia.aioe.org> <6134e03d$0$3372$426a74cc@news.free.fr>
<sh2p61$1dll$1@gioia.aioe.org> <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> <shdp09$87k$1@gioia.aioe.org>
<f4291006-ea19-4896-b7bc-96ce3c102955n@googlegroups.com> <sheugb$lop$1@gioia.aioe.org>
<c9395f4d-e1d3-4c33-80f1-ff86c0cdf7fan@googlegroups.com> <613bc32d$0$27421$426a74cc@news.free.fr>
<shggst$nv$1@gioia.aioe.org> <613cca39$0$29491$426a34cc@news.free.fr>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e23f19ef-5f39-4260-b625-f49176cb8f70n@googlegroups.com>
Subject: Re: GtkAda callback and event
From: christ-u...@t-online.de (AdaMagica)
Injection-Date: Sun, 12 Sep 2021 07:09:00 +0000
Content-Type: text/plain; charset="UTF-8"
 by: AdaMagica - Sun, 12 Sep 2021 07:08 UTC

DrPi schrieb am Samstag, 11. September 2021 um 17:24:45 UTC+2:
> Even if I just started using GtkAda, I find it very powerful.
> The big problem is documentation. Of course, there are the reference
> manual and the (small) user guide but I miss a document explaining the
> use of all these functionalities.

A good introduction into GtkAda is direly needed. Trial and error cost me
enormously much time.
The GtkAda UG and RM are a bad joke.

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor