[GTK3] Efficiently ordering GtkEntryCompletion items
- From: D Gowers <finticemo gmail com>
- To: gtk-list gnome org
- Subject: [GTK3] Efficiently ordering GtkEntryCompletion items
- Date: Fri, 12 Sep 2014 14:39:45 +0930
As part of that, I am attempting to implement a GtkEntry which auto-completes tag names, with candidates sorted by similarity to the fragment being completed.
The way I am currently doing this is very slow, even though I have simplified the sort comparison function as far as possible.
It takes 2-5 seconds each time I type anything, for the display to catch up and the completion to update.
When initializing the completion, I do:
completion.get_model().set_sort_func(NAME_COLUMN, compare_name_and_desc, 'foo')
completion.get_model().set_sort_func(DESC_COLUMN, compare_name_and_desc, 'foo')
completion.get_model().set_sort_column_id(NAME_COLUMN, gtk.SortType.DESCENDING)
Then I connect the entry's 'change' signal to this function, which simply resets the sort function to use the new key.
def resort(entry):
m = entry.get_completion().get_model()
t = entry.get_text()
# The delay is probably caused by this line:
m.set_sort_func(NAME_COLUMN, compare_name_and_desc, t )
print('sort reset to %r' % t)
Is there any faster way to do this?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]