@@ -33,12 +33,14 @@ public class Applications.Sidebar : Gtk.Box {
3333 margin_end = 6,
3434 hexpand = true
3535 };
36+ search_entry.set_key_capture_widget (this );
3637
3738 var search_revealer = new Gtk .Revealer () {
3839 child = search_entry
3940 };
4041
4142 var search_toggle = new Gtk .ToggleButton () {
43+ action_name = " sidebar.search" ,
4244 icon_name = " edit-find-symbolic" ,
4345 tooltip_text = _ ("Search Apps ")
4446 };
@@ -92,19 +94,31 @@ public class Applications.Sidebar : Gtk.Box {
9294 }
9395 });
9496
95- search_entry.search_changed.connect (() => {
96- listbox . invalidate_filter ();
97- } );
97+ var search_action = new SimpleAction .stateful ( " search " , null , new Variant .boolean ( false ));
98+ search_action.change_state.connect (( value ) => {
99+ search_action . set_state ( value );
98100
99- search_toggle.bind_property (" active ", search_revealer , " reveal - child " );
101+ search_revealer. reveal_child = value . get_boolean ( );
100102
101- search_revealer.notify["child-revealed"].connect (() => {
102- if (search_revealer. child_revealed) {
103+ if (value . get_boolean ()) {
103104 search_entry. grab_focus ();
104105 } else {
105106 search_entry. text = " " ;
106107 }
107108 });
109+
110+ var action_group = new SimpleActionGroup ();
111+ action_group.add_action (search_action );
112+
113+ insert_action_group ("sidebar ", action_group );
114+
115+ search_entry.search_changed.connect (() => {
116+ if (search_entry. text != " " ) {
117+ search_action. change_state (new Variant .boolean (true ));
118+ }
119+
120+ listbox. invalidate_filter ();
121+ });
108122 }
109123
110124 private bool filter_function (Gtk .ListBoxRow row ) {
0 commit comments