In using GtkAda.Builder under GtkAda 20.1, I can't figure out how to capture event data.
with Gtk.Widget; use Gtk.Widget;
with Gtk.Main; use Gtk.Main;
with Gtkada.Builder; use Gtkada.Builder;
with Glib.Error; use Glib.Error;
with Callbacks;
with Glib; use type Glib.Guint;
with Ada.Text_IO;
procedure Main is
Builder : Gtkada_Builder;
Error : aliased GError;
Err_Num : Glib.Guint;
begin
Init;
Gtk_New (Builder);
Err_Num := Add_From_File (Builder, "data/main_window.glade", Error'Access);
if Err_Num = 0 then
Ada.Text_IO.Put_Line ("Error : " & Get_Message (Error));
Error_Free (Error);
return;
end if;
Register_Handler
(Builder => Builder,
Handler_Name => "on_main_window_destroy",
Handler => Callbacks.Main_Window_Destroy'Access); -- Works fine
Register_Handler
(Builder => Builder,
Handler_Name => "on_key_pressed",
Handler => Callbacks.Key_Pressed'Access); -- but wait
Show_All (Gtk_Widget(Get_Object (Builder, "main_window")));
Main;
Unref (Builder);
end Main;
package Callbacks is
procedure Main_Window_Destroy
(Object : access Gtkada_Builder_Record'Class);
function Key_Pressed
(Object : access Gtkada_Builder_Record'Class)
return Boolean;
-- how do I get a Gdk.Event.Gdk_Event_Key from this????
end Callbacks;
As shown in the example, the GtkAda_Builder will only access two prototypes for callbacks, a procedure or a function, both of which take the Builder as an argument. How do I use this to examine the event that fired in the case of a key_press event? Or a draw event for that matter? There are no examples in testgtkada or anywhere that I've found which deal with this and I can't figure out how to do it. Is this just a toy class?