Add a basic "Arun"Glade3 + GtkAda project

It's produced "A run" silly
This commit is contained in:
R. Tyler Croy 2017-01-07 13:52:23 -08:00
commit 35b17986d4
No known key found for this signature in database
GPG Key ID: 1426C7DC3F51E16F
8 changed files with 168 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*.sw*
obj/
*.glade~

46
arun.glade Normal file
View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkWindow" id="commandWindow">
<property name="can_focus">False</property>
<property name="window_position">center</property>
<signal name="destroy" handler="Main_Quit" swapped="no"/>
<child>
<object class="GtkBox" id="commandBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="boxLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Run a command</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSearchEntry" id="commandEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="receives_default">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
<property name="placeholder_text" translatable="yes">Enter a command to run</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

19
arun.gpr Normal file
View File

@ -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;

17
src/arun-handlers.adb Normal file
View File

@ -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;

11
src/arun-handlers.ads Normal file
View File

@ -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;

60
src/arun.adb Normal file
View File

@ -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;

5
src/arun.ads Normal file
View File

@ -0,0 +1,5 @@
package Arun is
procedure Main;
end Arun;

7
src/main.adb Normal file
View File

@ -0,0 +1,7 @@
with Arun;
procedure Main is
begin
Arun.Main;
end Main;