GNOME Bugzilla – Bug 668978
Add timeout to search entry.
Last modified: 2018-01-04 21:49:37 UTC
When input a string in search entry, devhelp will search every time when you input and add a character, even when you input it fast, this is not very convenient. The normal way should be only search after you input over the whole string. Add a timeout to the search entry can solve this problem. Some example code: ===== gboolean on_word_change_timeout(gpointer data) { // Do real search. } on_entry_changed() { if (word_change_timeout_id) { // stop word change timer g_source_remove(word_change_timeout_id); word_change_timeout_id = 0; } int word_change_timeout = conf->get_int_at("main_window/word_change_timeout"); // Default 300. if(word_change_timeout > 0) { word_change_timeout_id = g_timeout_add(word_change_timeout, on_word_change_timeout, NULL); } else { //Allow word_change_timeout to be 0, so do an immediate search. on_word_change_timeout(NULL); } } ===== A configure in preferences dialog on word_change_timeout would be nice! StarDict has this feature! Thanks!
Do this to add a clear icon is recommended too! gtk_entry_set_icon_from_stock (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
GtkSearchEntry is now used, so for the timeout it would be a better idea to use the GtkSearchEntry::search-changed signal.
Done with commit f4186c4581f9ea552e0eed3e17040f6b4ebf4ef0.