Add a search-changed handler and dump the context of the search box

This commit is contained in:
R. Tyler Croy 2017-01-07 14:11:06 -08:00
parent 35b17986d4
commit e34d21d874
No known key found for this signature in database
GPG Key ID: 1426C7DC3F51E16F
4 changed files with 25 additions and 4 deletions

View File

@ -33,6 +33,7 @@
<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>
<signal name="search-changed" handler="commandEntry_search_changed_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>

View File

@ -4,14 +4,28 @@
with Ada.Text_IO;
with Gtk.Main;
with Gtkada.Builder;
with Gtk.Widget;
with Gtk.Search_Entry;
with Gtkada.Builder; use Gtkada.Builder;
package body Arun.Handlers is
procedure Quit (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class) is
procedure Quit (Object : access Gtkada_Builder_Record'Class) is
pragma Unreferenced (Object);
begin
Ada.Text_IO.Put_Line ("Exiting arun");
Gtk.Main.Main_Quit;
end Quit;
procedure Search_Changed (Object : access Gtkada_Builder_Record'Class) is
use Ada.Text_IO;
use Gtk.Search_Entry;
use Gtkada.Builder;
Widget : Gtk_Search_Entry := Gtk_Search_Entry (Get_Object (Object, "commandEntry"));
begin
Put_Line ("Searching for " & Widget.Get_Text);
end Search_Changed;
end Arun.Handlers;

View File

@ -2,10 +2,12 @@
-- Basic GtkAda handlers for Arun
---
with Gtkada.Builder;
with Gtkada.Builder; use Gtkada.Builder;
package Arun.Handlers is
procedure Quit (Object : access Gtkada.Builder.Gtkada_Builder_Record'Class);
procedure Quit (Object : access Gtkada_Builder_Record'Class);
procedure Search_Changed (Object : access Gtkada_Builder_Record'Class);
end Arun.Handlers;

View File

@ -38,11 +38,15 @@ package body Arun is
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);
Register_Handler (Builder => Builder,
Handler_Name => "commandEntry_search_changed_cb",
Handler => Arun.Handlers.Search_Changed'Access);
-- Step 3: call Do_Connect. Once to connect all registered handlers
Do_Connect (Builder);