Pass around an Arun_Builder_Record through handlers instead of Gtkada_Builder_Record

This commit is contained in:
R. Tyler Croy 2017-01-13 11:58:09 -08:00
parent 7a1fa9e447
commit 3dd82d1fcb
No known key found for this signature in database
GPG Key ID: 1426C7DC3F51E16F
3 changed files with 23 additions and 22 deletions

View File

@ -31,6 +31,7 @@ with Gtkada.Builder; use Gtkada.Builder;
with Arun;
with Arun.Launchers.Unix;
with Arun.View; use Arun.View;
package body Arun.Handlers is
@ -59,14 +60,15 @@ package body Arun.Handlers is
Widget : Gtk_Search_Entry := Gtk_Search_Entry (Get_Object (Object, "commandEntry"));
Command : constant String := Widget.Get_Text;
--Full_Path : aliased constant String := Arun.Launcher.Find_Full_Path (Command);
B : Arun.View.Arun_Builder_Record renames Arun.View.Arun_Builder_Record (Object.all);
L : Arun.Launchers.Unix.UnixLauncher renames Arun.Launchers.Unix.UnixLauncher (B.Launcher);
Full_Path : aliased constant String := L.Find_Full_Path (Command);
begin
-- if Full_Path /= "" then
-- Put_Line ("Should Execute: " & Command);
-- --Arun.Launcher.Execute (Full_Path);
-- end if;
if Full_Path /= "" then
Put_Line ("Should Execute: " & Command);
L.Execute (Full_Path);
end if;
Gtk.Main.Main_Quit;
end Execute_Command;

View File

@ -26,6 +26,8 @@ with Gdk.Event;
with Arun.Launchers.Unix;
with Arun.View; use Arun.View;
package Arun.Handlers is
procedure Quit (Object : access Gtkada_Builder_Record'Class);

View File

@ -17,36 +17,33 @@
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
------------------------------------------------------------------------------
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 Gtkada.Builder; use Gtkada.Builder;
with Ada.Text_IO;
with Arun.Handlers;
with Arun.View;
package body Arun is
procedure Main is
Builder : Gtkada_Builder;
use Ada.Text_IO;
use Gtkada.Builder;
use Arun.View;
Builder : Arun_Builder;
Error : aliased Glib.Error.GError;
Return_Code : Guint;
use Ada.Text_IO;
use Gtkada.Builder;
begin
Gtk.Main.Init;
Put_Line ("Starting arun");
Gtk_New (Builder);
Builder := new Arun_Builder_Record;
Gtkada.Builder.Initialize (Builder);
Builder.Launcher.Initialize;
Return_Code := Add_From_Resource (Builder => Builder,
Resource_Path => "/io/lasagna/arun/arun.glade",
@ -68,18 +65,18 @@ package body Arun is
Register_Handler (Builder => Builder,
Handler_Name => "commandEntry_activate_cb",
Handler => Arun.Handlers.Execute_Command'Access);
Do_Connect (Builder);
-- Connect commandEntry specific signals
declare
Command_Entry : Gtk_Widget := Gtk_Widget (Get_Object (builder, "commandEntry"));
Command_Entry : Gtk_Widget := Builder.From_Object ("commandEntry");
begin
Command_Entry.On_Key_Release_Event (Call => Arun.Handlers.Search_KeyPress'Access,
After => False);
end;
Gtk.Widget.Show_All ( Gtk_Widget (Get_Object (Builder, "commandWindow")));
Gtk.Main.Main;
Gtk.Widget.Show_All (Builder.From_Object ("commandWindow"));
Gtk.Main.Main;
Unref (Builder);
end Main;