with Gtk.Box; use Gtk.Box; with Gtk.Button; use Gtk.Button; with Gtk.Label; use Gtk.Label; with Gtk.Widget; use Gtk.Widget; with Gtk.Main; with Gtk.Window; use Gtk.Window; with Gtk.GEntry; use Gtk.GEntry; with Handlery; with Gtkada.Handlers; use Gtkada.Handlers; with Glib; with Gtkada.Dialogs; with Gtk.Enums; procedure Main is Win : Gtk_Window; Label : Gtk_Label; VBox : Gtk_Vbox; Button1, Button2, Button3, Btn_Quit, Btn_Dlg : Gtk_Button; HBox1, HBox2 : Gtk_Hbox; Edit1, Edit2, Edit3 : Gtk_GEntry; UData : handlery.My_Data_Access; Dlg_btn : Gtkada.Dialogs.Message_Dialog_Buttons; procedure View_Edit (Widget : access Gtk_Widget_Record'Class) is begin Edit2.Set_Text (Edit1.Get_Text); end View_Edit; procedure Handle_Edit (Widget : access Gtk_Widget_Record'Class) is Pos : Glib.Gint := 0; begin Edit3.Insert_Text (New_Text => Edit2.Get_Text, New_Text_Length => 20, Position => Pos); end Handle_Edit; procedure Show_Dialog (Widget : access Gtk_Widget_Record'Class) is begin Dlg_btn := Gtkada.Dialogs.Message_Dialog (Msg => "Text Dialogu", Dialog_Type => Gtkada.Dialogs.Warning, Buttons => Gtkada.Dialogs.Message_Dialog_Buttons(0), Default_Button => Gtkada.Dialogs.Button_OK, Help_Msg => "Pomocný text dialogu", Title => "Titulek dialogového okna", Justification => Gtk.Enums.Justify_Center, Parent => null); Edit2.Set_Text (Dlg_btn'Img); end Show_Dialog; begin Gtk.Main.Init; Gtk_New (Win); Win.Set_Default_Size (400, 400); -- handlery.Handlers.Connect ( Win, "destroy", handlery.Handlers.To_Marshaller (handlery.Destroy'Access)); Widget_Callback.Connect ( Win, "destroy", Widget_Callback.To_Marshaller (handlery.Destroy'Access)); Gtk_New_Vbox (VBox); Gtk_New_Hbox (HBox1); Gtk_New_Hbox (HBox2); Gtk_New (Label, "Hello world."); VBox.Add(Label); Gtk_New(Button1,"Button1"); HBox1.Add(Button1); Gtk_New(Button2,"Button2"); HBox1.Add(Button2); Gtk_New(Button3); Button3.Set_Label("Button3"); HBox1.Add(Button3); Gtk_New(Edit1); Edit1.Set_Editable(False); HBox2.Add(Edit1); Gtk_New(Edit2); HBox2.Add(Edit2); Gtk_New(Edit3); Edit3.Set_Editable(False); HBox2.Add(Edit3); Gtk_New(Btn_Dlg, "Show Dialog"); Gtk_New(Btn_Quit, "Quit Application"); -- handlery.Handlers.Connect (Btn_Quit, "clicked", handlery.Handlers.To_Marshaller (handlery.Destroy'Access)); Widget_Callback.Connect(Btn_Quit, "clicked", Widget_Callback.To_Marshaller(handlery.Destroy'Access)); handlery.User_Handlers.Connect (Button1, "clicked", handlery.User_Handlers.To_Marshaller(handlery.Edit_Field'Access), Edit1); UData := new handlery.My_Data' (Edit => Edit3, Text => handlery.UStr.To_Unbounded_String("Ahoj_světe!!!")); handlery.Handle_Edit.Connect(Button3, "clicked", handlery.Handle_Edit.To_Marshaller (handlery.Edit_Edit'Access), UData); Widget_Callback.Connect (Widget => Button2, Name => "clicked", Marsh => Widget_Callback.To_Marshaller(View_Edit'Unrestricted_Access)); Widget_Callback.Connect (Widget => Edit2, Name => "activate", Marsh => Widget_Callback.To_Marshaller(Handle_Edit'Unrestricted_Access)); Widget_Callback.Connect (Btn_Dlg, "clicked", Widget_Callback.To_Marshaller(Show_Dialog'Unrestricted_Access)); VBox.Add(HBox1); VBox.Add(HBox2); VBox.Add(Btn_Dlg); VBox.Add(Btn_Quit); Win.Add (VBox); Win.Show_All; Gtk.Main.Main; end Main;