Permalink
Browse files

Add a basic "Arun"Glade3 + GtkAda project

It's produced "A run" silly
  • Loading branch information...
rtyler committed Jan 7, 2017
0 parents commit 35b17986d4adb45ed91f8ecfc94f37f846f5a59e
Showing with 168 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +46 −0 arun.glade
  3. +19 −0 arun.gpr
  4. +17 −0 src/arun-handlers.adb
  5. +11 −0 src/arun-handlers.ads
  6. +60 −0 src/arun.adb
  7. +5 −0 src/arun.ads
  8. +7 −0 src/main.adb
@@ -0,0 +1,3 @@
*.sw*
obj/
*.glade~
@@ -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>
@@ -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;

@@ -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;
@@ -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;
@@ -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;
@@ -0,0 +1,5 @@


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

with Arun;

procedure Main is
begin
Arun.Main;
end Main;

0 comments on commit 35b1798

Please sign in to comment.