commit 35b17986d4adb45ed91f8ecfc94f37f846f5a59e Author: R. Tyler Croy Date: Sat Jan 7 13:52:23 2017 -0800 Add a basic "Arun"Glade3 + GtkAda project It's produced "A run" silly diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..617f2e1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.sw* +obj/ +*.glade~ diff --git a/arun.glade b/arun.glade new file mode 100644 index 0000000..0077bee --- /dev/null +++ b/arun.glade @@ -0,0 +1,46 @@ + + + + + + False + center + + + + True + False + vertical + + + True + False + Run a command + + + False + True + 0 + + + + + True + True + True + True + edit-find-symbolic + False + False + Enter a command to run + + + False + True + 1 + + + + + + diff --git a/arun.gpr b/arun.gpr new file mode 100644 index 0000000..6a5fb1a --- /dev/null +++ b/arun.gpr @@ -0,0 +1,19 @@ +with "gtkada"; + +project Arun is + + for Source_Dirs use ("src"); + for Object_Dir use "obj"; + for Main use ("main.adb"); + + package Builder is + for Executable ("main.adb") use "arun"; + end Builder; + + -- Enable Ada 2005. + package Compiler is + for Switches ("ada") use ("-gnat2012"); + end Compiler; + +end Arun; + diff --git a/src/arun-handlers.adb b/src/arun-handlers.adb new file mode 100644 index 0000000..2ed723d --- /dev/null +++ b/src/arun-handlers.adb @@ -0,0 +1,17 @@ +--- +-- Basic GtkAda handlers for Arun +--- + +with Ada.Text_IO; +with Gtk.Main; +with Gtkada.Builder; + +package body Arun.Handlers is + + procedure Quit (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class) is + pragma Unreferenced (Object); + begin + Ada.Text_IO.Put_Line ("Exiting arun"); + Gtk.Main.Main_Quit; + end Quit; +end Arun.Handlers; diff --git a/src/arun-handlers.ads b/src/arun-handlers.ads new file mode 100644 index 0000000..7643f17 --- /dev/null +++ b/src/arun-handlers.ads @@ -0,0 +1,11 @@ +--- +-- Basic GtkAda handlers for Arun +--- + +with Gtkada.Builder; + +package Arun.Handlers is + + procedure Quit (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class); + +end Arun.Handlers; diff --git a/src/arun.adb b/src/arun.adb new file mode 100644 index 0000000..1296739 --- /dev/null +++ b/src/arun.adb @@ -0,0 +1,60 @@ +with Gtk; use Gtk; +with Gtk.Box; use Gtk.Box; + +with Gtk.Label; use Gtk.Label; +with Gtk.Widget; use Gtk.Widget; + +with Glib; use Glib; +with Glib.Error; use Glib.Error; +with Gtk.Main; use Gtk.Main; +with Gtk.Window; use Gtk.Window; + +with Ada.Text_IO; +with Arun.Handlers; + +with Gtkada.Builder; use Gtkada.Builder; + +package body Arun is + procedure Main is + Builder : Gtkada_Builder; + Error : aliased Glib.Error.GError; + Return_Code : Guint; + + use Ada.Text_IO; + begin + -- Initialize GtkAda. + Gtk.Main.Init; + Put_Line ("Starting arun"); + + -- Create a window with a size of 400x400 + Gtk_New (Builder); + + + Return_Code := Add_From_File (Builder => Builder, + Filename => "arun.glade", + Error => Error'Access); + if Error /= null then + Put_Line ("Error : " & Get_Message (Error)); + Error_Free (Error); + return; + end if; + -- Step 2: add calls to "Register_Handler" to associate your + -- handlers with your callbacks. + Register_Handler (Builder => Builder, + Handler_Name => "Main_Quit", + Handler => Arun.Handlers.Quit'Access); + + -- Step 3: call Do_Connect. Once to connect all registered handlers + Do_Connect (Builder); + + -- Find our main window, then display it and all of its children. + Gtk.Widget.Show_All ( Gtk_Widget (Gtkada.Builder.Get_Object (Builder, "commandWindow"))); + Gtk.Main.Main; + + -- Step 4: when the application terminates or all Windows described through + -- your builder should be closed, call Unref to free memory + -- associated with the Builder. + Unref (Builder); + end Main; + +end Arun; diff --git a/src/arun.ads b/src/arun.ads new file mode 100644 index 0000000..b7bad2c --- /dev/null +++ b/src/arun.ads @@ -0,0 +1,5 @@ + + +package Arun is + procedure Main; +end Arun; diff --git a/src/main.adb b/src/main.adb new file mode 100644 index 0000000..af7b340 --- /dev/null +++ b/src/main.adb @@ -0,0 +1,7 @@ + +with Arun; + +procedure Main is +begin + Arun.Main; +end Main;