Browse Source

auto search when typing in search bar

tags/v5.1.2
guinux 3 years ago
parent
commit
bb6f38b4f4
2 changed files with 16 additions and 3 deletions
  1. +1
    -1
      resources/manager_window.ui
  2. +15
    -2
      src/manager_window.vala

+ 1
- 1
resources/manager_window.ui 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>


+ 15
- 2
src/manager_window.vala 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) {


Loading…
Cancel
Save