From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: GtkAda : Trying to derive a widget Date: Fri, 9 Apr 2021 00:27:26 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <606f5938$0$27421$426a74cc@news.free.fr> NNTP-Posting-Host: 5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader02.eternal-september.org comp.lang.ada:61761 List-Id: On 2021-04-08 21:27, DrPi wrote: > I'm trying to create a GtkAda widget derived from a standard widget. > > -- debug_panel.ads > with Gtk.Scrolled_Window; use Gtk.Scrolled_Window; > with Gtk.Text_View;       use Gtk.Text_View; > > package Debug_Panel is > >   type Debug_Panel_Record is new Gtk_Scrolled_Window_Record with private; >   type Debug_Panel is access all Debug_Panel_Record'Class; > > >   procedure Gtk_New (Panel : in out Debug_Panel); >   procedure Initialize (Panel : not null access Debug_Panel_Record'Class); > > private > >   type Debug_Panel_Record is new Gtk_Scrolled_Window_Record with record >      Text       : Gtk_Text_View; >   end record; > > end Debug_Panel; > > > -- debug_panel.adb > package body Debug_Panel is > >   procedure Gtk_New (Panel : in out Debug_Panel) is >   begin >      Panel := new Debug_Panel_Record; >      Initialize (Panel); Debug_Panel.Initialize (Panel); Another way would be to remove "use Gtk.Scrolled_Window" and declare as type Debug_Panel_Record is new Gtk.Scrolled_Window.Gtk_Scrolled_Window_Record with private; Without "use" Initialize is unambiguous. P.S. When you create new widget it is better to use a more general ancestor hiding insufficient details, e.g. type Debug_Panel_Record is new Gtk.Widget.Gtk_Widget_Record with private; ... private type Debug_Panel_Record is new Gtk.Scrolled_Window.Gtk_Scrolled_Window_Record with record ... end record; This makes the code less fragile if you later decide to choose another container widget for the base. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de