[GTK3] Efficiently ordering GtkEntryCompletion items

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm a new subscriber, and I'm working on a GUI for TMSU (https://bitbucket.org/oniony/tmsu/), a CLI-based file tagging system.

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)

full code is at 'https://bpaste.net/show/aa03e47d9bdd'. It requires Levenshtein module.



Is there any faster way to do this?




_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux