Created
April 12, 2023 03:33
-
-
Save andrew-shvets/ed7112944c8a3cb2478f63730d57d4b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with Ada.Text_IO; | |
with Glib; use Glib; | |
with Glib.Error; | |
with Gtk.Main; | |
package body Glade_Example is | |
procedure Run is | |
Error : aliased Glib.Error.GError; | |
Success : GUint; | |
begin | |
Gtk.Main.Init; | |
GtkAda.Builder.Gtk_New(Builder); | |
Success := Builder.Add_From_File("simple_editor.glade", Error'Access); | |
if Success = 0 then | |
Ada.Text_IO.Put_Line("failed to read Glade file"); | |
Glib.Error.Error_Free(Error); | |
return; | |
end if; | |
Open_File := Gtk.Image_Menu_Item.Gtk_Image_Menu_Item(Builder.Get_Object("imagemenuitem2")); | |
Gtk.Image_Menu_Item.Show(Widget => Open_File); | |
Open_File.On_Activate(On_Open_File'access); | |
Save_File := Gtk.Image_Menu_Item.Gtk_Image_Menu_Item(Builder.Get_Object("imagemenuitem3")); | |
Gtk.Image_Menu_Item.Show(Widget => Save_File); | |
Save_File.On_Activate(On_Open_File'access); | |
Exit_App := Gtk.Image_Menu_Item.Gtk_Image_Menu_Item(Builder.Get_Object("imagemenuitem5")); | |
Gtk.Image_Menu_Item.Show(Widget => Exit_App); | |
Exit_App.On_Activate(On_Open_File'access); | |
Main_Window := Gtk.Window.Gtk_Window(Builder.Get_Object("window1")); | |
Main_Window.On_Destroy(On_Exit_Application'Access); | |
Main_Window.Show_All; | |
Gtk.Main.Main; | |
end Run; | |
procedure On_Open_File( | |
Object : access Gtk.Menu_Item.Gtk_Menu_Item_Record'Class) is | |
pragma Unreferenced(Object); | |
begin | |
Ada.Text_IO.Put_Line("aaaaaaaaaaaaaaaaaaaaaaaaaaa"); | |
end On_Open_File; | |
procedure On_Save_File( | |
Object : access Gtk.Menu_Item.Gtk_Menu_Item_Record'Class) is | |
pragma Unreferenced(Object); | |
begin | |
Ada.Text_IO.Put_Line("bbbbbbbbbbbbbbbbbbbbbbbbbb"); | |
end On_Save_File; | |
procedure On_Exit_App( | |
Object : access Gtk.Menu_Item.Gtk_Menu_Item_Record'Class) is | |
pragma Unreferenced(Object); | |
begin | |
Gtk.Main.Main_Quit; | |
end On_Exit_App; | |
procedure On_Exit_Application( | |
Object : access Gtk.Widget.Gtk_Widget_Record'Class) is | |
pragma Unreferenced(Object); | |
begin | |
Gtk.Main.Main_Quit; | |
end On_Exit_Application; | |
end Glade_Example; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment