I've created a program "freedisk" to display some data in a Gtk3 grid. A new window is filled with some boxes for layout and labelling purposes, with the main content, intended to be updateable, filling the grid, itself within a VBox.
The display of the data works fine; the problem is with the update process. I intended to destroy the child widgets within the grid, and create them anew with new data.
A button exists which should trigger the update, when clicked it passes the name of the VBox (called in the program "Content_Box") through a handler which then runs the appropriate subprogram to destroy Content_Box children and recreate them.
The simplified code is as follows (handler package first):
Freedisk_Cb.ads
package Freedisk_Cb is
package User_Callback is new Gtk.Handlers.User_Callback
(Gtk_Widget_Record, Gtk_Box);
procedure Refresh_Clicked
(Self : access Gtk_Widget_Record'Class;
Data : in out Gtk_Box);
end Freedisk_Cb;
Freedisk_Cb.adb
package body Freedisk_Cb is
procedure Refresh_Clicked
(Self : access Gtk_Widget_Record'Class;
Data : in out Gtk_Box)
is
begin
Make_Table (Data);
end Refresh_Clicked;
end Freedisk_Cb;
Make_Table is the subprogram which calculates and displays the data; I've left it out for the moment to try and keep things as brief as possible.
The main program code (again heavily simplified) is:
freedisk.adb
Gtk_New (Win);
Gtk_New_VBox (Content_Box, False, 0);
Gtk_New (Refresh_Button, "Refresh");
User_Callback.Object_Connect
(Refresh_Button, "clicked",
User_Callback.To_Marshaller (Refresh_Clicked'Access),
Slot_Object => Win, User_Data => Content_Box);
So, when I try to build it, I get the following errors:
freedisk.adb:103:20: no candidate interpretations match the actuals:
freedisk.adb:103:51: expected type "Handler" defined at gtk-marshallers.ads:546, instance at gtk-handlers.ads:1164, instance at freedisk_cb.ads:13
freedisk.adb:103:51: found type access to procedure "Refresh_Process" defined at line 103
freedisk.adb:103:51: ==> in call to "To_Marshaller" at gtk-handlers.ads:1205, instance at freedisk_cb.ads:13
freedisk.adb:103:51: ==> in call to "To_Marshaller" at gtk-handlers.ads:1200, instance at freedisk_cb.ads:13
freedisk.adb:103:51: ==> in call to "To_Marshaller" at gtk-handlers.ads:1195, instance at freedisk_cb.ads:13
etc, etc.
If the VBox "Data" passed to the callback is not an in out variable, I don't get this problem, but it's not of much use that way. Obviously missing something fundamental.
I've looked at the examples in the signals page of the Gtkada documentation http://docs.adacore.com/live/wave/gtkada/html/gtkada_ug/signals.html -- the examples there are mentioned as having their code listed in a directory examples/user_data which unfortunately I've not been able to locate (I downloaded the binary and source distributions of Gtkada).
Thanks, in advance. Any help appreciated.
I've now upload the complete code here: https://sourceforge.net/projects/tx82/files/
Individual files can be downloaded or a full tarball.
It's built using 2016 GPL Gnat, Gprbuild, and Gtkada, on Slackware 14.2 x64.
The error message says it expects a type
Handler
but found an access to procedureRefresh_Process
(although based on the code you've provided, I would expect the compiler to findRefresh_Clicked
?), which means the parameter profile is incompatible.Looking at the examples in the link you gave, the callback expects the
Data
to be of modein
. Try changing your callback to