auto search when typing in search bar

This commit is contained in:
guinux 2016-03-11 09:51:45 +01:00
parent 654a50daf4
commit bb6f38b4f4
2 changed files with 16 additions and 3 deletions

View File

@ -189,7 +189,7 @@
<property name="caps_lock_warning">False</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<signal name="activate" handler="on_search_entry_activate" swapped="no"/>
<signal name="icon-press" handler="on_search_entry_icon_press" swapped="no"/>
<signal name="changed" handler="on_search_entry_changed" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>

View File

@ -134,6 +134,8 @@ namespace Pamac {
bool refreshing;
uint search_entry_timeout_id;
public ManagerWindow (Gtk.Application application) {
Object (application: application);
@ -1462,9 +1464,20 @@ namespace Pamac {
}
}
[GtkCallback]
void on_search_entry_icon_press () {
bool search_entry_timeout_callback () {
on_search_entry_activate ();
search_entry_timeout_id = 0;
return false;
}
[GtkCallback]
void on_search_entry_changed () {
if (search_entry.get_text () != "") {
if (search_entry_timeout_id != 0) {
Source.remove (search_entry_timeout_id);
}
search_entry_timeout_id = Timeout.add (750, search_entry_timeout_callback);
}
}
async Alpm.List<unowned Alpm.Package?> search_all_dbs (string search_string) {