Re: combo widget



Chris De Maeyer wrote:

Implemented a combo text widget with a rather large amount of strngs
inside (approx. 5000). Is it normal that it gets so slow, what
alternatively can cope with such amount of strings to select from?
Strings themselves are not too big (2 to 5 chars max). If possible
post example. 

I keep asking myself if you really do users a favour if they have to
select one particular entry out of a list of ~5000, especially if
they're such short (and probably abstract) ones?

Anyway, I don't think there are simple ways to improve speed of
GtkCombos with very large lists. You will likely have to consider
unconventional approaches.

One solution could be to reduce the size of the selection list by
requiring at least the first character of the requested list entry to be
typed in. So initially both the entry and the list of the GtkCombo would
be empty. After the first letter of the requested entry has been typed
in the list would be dynamically created, including only those entries
which begin with the given first letter. The list would likely be
significantly smaller (and faster to manage / open) then. For such
manipulations of the normal behaviour of GtkCombos see:

http://developer.gnome.org/doc/API/2.0/gtk/GtkEntry.html#GtkEntry-insert-at-cursor
http://developer.gnome.org/doc/API/2.0/gtk/GtkList.html

Note: GtkList is deprecated but unless there are alternatives for
GtkCombo manipulation (there don't seem to be any) it should be okay to
still use it.

The only other solution which avoids this inconvenience for the users of
having to both type and select is likely be to write an own Combo widget
class. The goals of GTK+ widgets are flexibility and strictness,
regarding its object oriented programming model. These goals stand in
contrast of highest possible execution speed, especially when dealing
with large amounts of data / large lists.

You could write an own Combo widget class, optimized for speed. It could
bypass most GTK+ based object classes. For instance, you could just
store your short strings as a linear array of data like "char my_list
[5000][8];" and let your custom Combo access it directly. Creating a
custom visual representation for such a list, including navigation
features, isn't an easy task, however. GtkVScrollbars, GtkVBoxes and
GtkLabels *may* be helpful on that. You could bypass even those and
concentrate on GDK only, doing all of the necessary I/O to gain the
absolute maximum performance.

I admit, both suggestions are more or less ugly.



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