From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,2339842f2a89f4a9 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.74.41 with SMTP id q9mr3242165pav.41.1343789444719; Tue, 31 Jul 2012 19:50:44 -0700 (PDT) Path: g9ni9241255pbo.0!nntp.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nrc-news.nrc.ca!goblin1!goblin.stu.neva.ru!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Thu, 26 Jul 2012 17:00:46 -0500 Message-ID: Date: Thu, 26 Jul 2012 22:59:20 +0100 From: Jack Mitchell Newsgroups: comp.lang.ada Subject: Re: Closing a program with GTK References: <4e7a8d90$0$5570$703f8584@news.kpn.nl> <4e7b0d07$0$2638$703f8584@news.kpn.nl> <4e7b2b6d$0$2601$703f8584@news.kpn.nl> <79iy1peuceu9$.bzuvizc9yuhz.dlg@40tude.net> MIME-Version: 1.0 User-Agent: Turnpike/6.06-U () X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-AaAhzUkaQ1jF/X8haxieeuxd6UW7e+4PPHgq2RdmdU3azcdRe48/cj5OmsdG0YRMODx/1gyfxlcfrkH!vCRf2I7izX4WwHUgBhAZYoFyS8J+prH0QqAgmErBprKUqVWWZn9e/dfXDp2T6gOB7iDu92U= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3149 X-Received-Bytes: 3446 Content-Type: text/plain;charset=us-ascii;format=flowed Date: 2012-07-26T22:59:20+01:00 List-Id: In message <79iy1peuceu9$.bzuvizc9yuhz.dlg@40tude.net>, Dmitry A. Kazakov writes >On Thu, 22 Sep 2011 14:36:36 +0200, ldries46 wrote: > >> The routine On_Window_Destroy is the >> one that closes the window and ends the program. > >According to the code you posted On_Window_Destroy is a signal handler >connected to the "destroy" event. The intended use of such handler in Gtk >is to free all resources associated with the widget which are not managed >by Gtk. > >In Gtk you shall never call any handlers explicitly. > >> I need that routine carried out. I don't think it is a good idea to alter >> the gtk.object.destroy routine so what can I do? > >Destroy emits the "destroy" event, which in turn notifies all handlers of >the signal, all reference holders release the reference which then lead to >deallocation of the widget. > Try something like :- -- Here we just set a handler for delete_event that immediately exits GTK. MY_PROG_PACKAGE.Return_Handlers.Connect (Window, "delete_event", MY_PROG_PACKAGE.Return_Handlers.To_Marshaller ( MY_PROG_Package.Delete_Event'Access ) ); -- more setup GTK.WINDOW.Show( Window ); -- All GtkAda applications must have a Main. Control ends here -- and waits for an event to occur (like a key press or mouse event). GTK.Main.Main; end MY_PROG; with Gdk.Event; with Gtk.Widget; with Gtk.Handlers; with GLIB; package MY_PROG_Package is package Handlers is new Gtk.Handlers.User_Callback (Widget_Type => gtk.Widget.Gtk_Widget_Record, User_Type => String_Access); package Return_Handlers is new Gtk.Handlers.Return_Callback (Widget_Type => gtk.Widget.Gtk_Widget_Record, Return_Type => Boolean); function Delete_Event (Widget : access gtk.Widget.Gtk_Widget_Record'Class; Event : Gdk.Event.Gdk_Event) return Boolean; end MY_PROG_PACKAGE; -- Jack Mitchell