New widget proposal: GtkLiveSearch
- From: Xavier Claessens <xclaesse gmail com>
- To: gtk-devel-list gnome org
- Subject: New widget proposal: GtkLiveSearch
- Date: Sat, 12 Jun 2010 19:30:52 +0200
Hello,
I've been working on the HildonLiveSearch widget you can see on N900.
This is the entry you see when typing on the keyboard to filter your
contact list for example.
Felix Kaser and I ported that widget to Empathy's main window. The code
is in git master[1]. I would like to propose that widget to become
GtkLiveSearch[2].
How it works: GtkLiveSearch is a widget you can pack anywhere in your
window. It contains a GtkEntry and is hidden by default. You give a
hook-widget to it, and it will listen for "key-press-event" on the hook
widget, and it forward events to the hidden entry. Once the entry got a
typed text, it gets shown automatically and the signal "notify::text" is
emitted on the GtkLiveSearch. The UI you want to filter (probably a
GtkTreeView using a GtkTreeModelFilter) can listen to that signal and
refilter the model, for each row it can then call
gtk_live_search_match(live_search, text_of_that_row); and that will tell
if the text of that row should be visible. That match function does some
UTF8 manipulations, to accept the row "élève" if the text searched is
"ele" for example. This is making the implementation of the visible_func
of your GtkTreeModelFilter really easy.
This feature is a bit redundant with the interactive search we already
have on GtkTreeView, but it has advantage of having a much nicer user
experience (smart matching algorithm, and filter the view instead of
searching in it). And also GtkLiveSearch does not depends on
GtkTreeView, you could use it your own way with any widget where it
makes sense to search/filter.
If you agree that would be a great widget to have inside GTK, I can
rename EmpathyLiveSearch to GtkLiveSearch and push it in a gtk branch,
and start reviews (yes, gtk-doc is missing atm). Of course I'm open to
any suggestion to improve it.
[1]
http://git.gnome.org/browse/empathy/tree/libempathy-gtk/empathy-live-search.c
[2] https://bugzilla.gnome.org/show_bug.cgi?id=621393
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]