Deutsch English Français Italiano |
<2d7ae0f0-603d-405b-ae05-df8ec6de9cecn@googlegroups.com> View for Bookmarking (what is this?) Look up another Usenet article |
X-Received: by 2002:ac8:4089:: with SMTP id p9mr104267qtl.363.1632099077029; Sun, 19 Sep 2021 17:51:17 -0700 (PDT) X-Received: by 2002:a9d:592:: with SMTP id 18mr5963813otd.347.1632099076788; Sun, 19 Sep 2021 17:51:16 -0700 (PDT) Path: ...!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: fr.comp.lang.ada Date: Sun, 19 Sep 2021 17:51:16 -0700 (PDT) In-Reply-To: <ba295165-4f5f-46da-aa73-dc8fddc0703bn@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=102.142.83.190; posting-account=rdYO6wkAAAAd45iu4u7Y67MQUwG0Eumn NNTP-Posting-Host: 102.142.83.190 References: <e0c35ed1-c15f-419f-a724-07a3c3bf5d2an@googlegroups.com> <shv0d7$1sv$1@dont-email.me> <ba295165-4f5f-46da-aa73-dc8fddc0703bn@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2d7ae0f0-603d-405b-ae05-df8ec6de9cecn@googlegroups.com> Subject: Re: Les Callback en Ada From: Danielle Mandi Mayagha <dmandimayagha@gmail.com> Injection-Date: Mon, 20 Sep 2021 00:51:17 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Bytes: 5626 Lines: 159 Le vendredi 17 septembre 2021 =C3=A0 00:20:50 UTC+1, Danielle Mandi Mayagha= a =C3=A9crit=C2=A0: > Le jeudi 16 septembre 2021 =C3=A0 09:48:41 UTC+1, J-P. Rosen a =C3=A9crit= :=20 > > Le 16/09/2021 =C3=A0 04:29, Danielle Mandi Mayagha a =C3=A9crit :=20 > > > Salut Salut Je viens avec un tout petit (un gros enfaite) probl=C3=A8= me qui me sauf un peu le cerveau. bon voila! j'essaie de faire un Callback = avec un Bouton mais le souci c'est que ce bon vieux Gnat me dit ceci ( pour= info je suis carr=C3=A9ment nul en anglais=F0=9F=98=8A=F0=9F=98=9B) :=20 > > > Instantiation error at gtk-handlers.ads : 1039=20 > > > Subprogram must not be deeper than access type.=20 > > >=20 > > [...]=20 > > > voici mon code :=20 > > >=20 > > > WITH Gtk.Main; USE Gtk.Main;=20 > > > WITH Gtk.Widget; USE Gtk.Widget;=20 > > > WITH Gtk.Window; USE Gtk.Window;=20 > > > WITH Gtk.Enums; USE Gtk.Enums;=20 > > > WITH Gtk.Button; USE Gtk.Button;=20 > > > WITH Gtk.Handlers;=20 > > >=20 > > > Procedure Test is=20 > > >=20 > > > Package P_Callback is new Gtk.Handlers.Callback (Gtk_Widget_Record);= =20 > > > USE P_Callback;=20 > > >=20 > > > Procedure Stop_Program ( Emetteur : Gtk_Widget_Record'Class ) is=20 > > > Pragma Unreferenced (Emetteur);=20 > > > begin=20 > > > Main_Quit;=20 > > >=20 > > > end Stop_Program;=20 > > Ici, Stop_Program est un sous-programme interne =C3=A0 la proc=C3=A9dur= e Test=20 > > >=20 > > > Win : Gtk_Window;=20 > > > Bouton : Gtk_Button;=20 > > >=20 > > > begin=20 > > > Init;=20 > > >=20 > > > Gtk_New (Win);=20 > > > Win.Set_Default_Size (600,400);=20 > > >=20 > > > Gtk_New (Bouton,"Le Bouton");=20 > > >=20 > > >=20 > > > Win.Add (Bouton);=20 > > >=20 > > > P_Callback.Connect (Bouton,"Clicked", To_marshaller (Stop_Program'Acc= ess));=20 > > Le type attendu par To_Marshaller est un pointeur global. On ne peut lu= i=20 > > passer un sous-programme local, car il y aurait un risque de pouvoir=20 > > acc=C3=A9der au sous-programme apr=C3=A8s =C3=AAtre sorti de sa port=C3= =A9e.=20 > >=20 > > Le plus simple: sors Stop_Program de Test en le mettant dans un fichier= =20 > > s=C3=A9par=C3=A9. (bien s=C3=BBr, pour pouvoir y acc=C3=A9der, Test dev= ra faire un "with=20 > > Stop_Program;")=20 > >=20 > >=20 > > --=20 > > J-P. Rosen=20 > > Adalog=20 > > 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX=20 > > Tel: +33 1 45 29 21 52=20 > > https://www.adalog.fr > merci beaucoup =C3=A7a fonctionne tres bien maintenant Salut d=C3=A9sol=C3=A9 encore si je d=C3=A9range mais j'ai un second souci = que j'arrive pas =C3=A0 r=C3=A9soudre( voila je donne un exemple du code ap= res j'explique le probleme) ficfier.ads with Gtk.File_chooser_dialog; use gtk.file_file_chooser_dialog; with gtk.widget; use gtk.widget; with gtk.handlers; package P_fichier is type T_Type is record F : Gtk_file_chooser_dialog; end record; package Callback is new gtk.handlers.user_callback (gtk_widget_record, P_fi= chier.T_Type); use Callback; Procedure Stop_Program ( emetteur : access gtk_widget_record; object : out P_fichier.T_Ty= pe ); end P_fichier; fichier.adb package body P_fichier is Procedure Stop_Program is (emetteur : access gtk_widget_record; object : out P_fichier.T= _type ) is pragma Unreferenced (emetteur); begin gtk_new (Object.F, "ajout du fichier", action_Save, null); end Stop_Program; end P_fichier; main_program.adb with gtk.main; use gtk.main; with gtk.window; use gtk.window; with gtk.button; use gtk.button; with P_fichier; use P_fichier; Procedure main_Program is win : gtk_window; bouton : gtk_button; begin=20 init; gtk_new (win); win.set_default_size (600,400); gtk_new (bouton,"ouvrir le fichier"); declare Object : T_Type; begin P_fichier.callback.connect (bouton,s signal_clicked, callback.to_marshalle= r (stop_program' access, Object, false ); end ; win.Add (bouton); win.show_all; main; end main_program; voila le probleme est que le programme affiche le meme message d'erreur que= precedent pourtant j'ai bien mis Stop_Program dans un fichier separe. mais= je ne comprend pas j'ai essay=C3=A9 avec Object_connect mais c'est toujour= s pareil.