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=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!x6YkKUCkj2qHLwbKnVEeag.user.46.165.242.91.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Gtk.Message_Dialog Date: Wed, 8 Sep 2021 17:02:51 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <296e83e5-5855-4732-94ba-ed9c05f3dd6dn@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="2066"; 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 Xref: reader02.eternal-september.org comp.lang.ada:62673 List-Id: On 2021-09-08 15:52, AdaMagica wrote: > I need a two page message for a help button, so I have the callback > > procedure Help (Self: access Gtk.Button.Gtk_Button_Record'Class) is > begin > Show ("Page 1"); > Show ("Page 2"); > end Help; > > where > > procedure Show (Message: Glib.UTF8_String) is > Dialog : Gtk.Message_Dialog.Gtk_Message_Dialog; > Response: Gtk.Dialog.Gtk_Response_Type; > begin > Gtk.Message_Dialog.Gtk_New (Dialog, > Parent => Parent, > Flags => Modal, > The_Type => Message_Info, > Buttons => Buttons_Close, > Message => Message); > Response := Gtk.Message_Dialog.Run (Dialog); > Gtk.Message_Dialog.Close (Dialog); > end Show; > > The problem is: When the first dialog's Close button is pressed, the next page appears, but the first is not closed. When the second page's Close is pressed, the window disappers, but the first dialog window is still there. Only pressing the red cross on the window's right upper edge closes the dialog. > > What's wrong with my code? You must call Destroy on the dialog to kill its window. P.S. Note, that when the object reference is "floating" you have to sink it first before calling Destroy. However, in your case after Run all references must be OK. P.P.S. Modal dialogs is the root of all evil... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de