Re: Auto-completion API proposal for GtkEntry



I discussed this proposal some with Kris on IRC, and my main
concern was:

>   [temporary weird layout to fit things in 80 columns]
>   GtkTreeViewColumn *gtk_entry_completion_get_column (GtkEntry *entry);
>   void gtk_entry_completion_get_model (GtkEntry      *entry,
>                                        GtkTreeModel **model,
>                                        gint          *list_column);

This looks to me like implementation details spilling out into
the public interface. Furthermore, it isn't clear to me how it
interacts with the auto-setup that occurs normally.

It seems that the real problem is that we have objects similar
to GtkTreeViewColumn in multiple places ... EggComboBox,
here and GtkTreeViewColumn itself that need different internal
implementations.

In otherwords, an interface. Kris proposed the name GtkCellLayout,
which sounds reasonable to me.

GtkCellLayout would have have at least, the:

 gtk_cell_layout_pack_start()
 gtk_cell_layout_pack_end()
 gtk_cell_layout_set_attributes()
 gtk_cell_layout_clear()

That are in EggComboBox now.

The way this would be hooked up to GtkEntry for completion is
with a separate object ... making GtkEntry itself implement
GtkCellLayout would be a bit weird.

 completion = gtk_entry_completion_new();
 gtk_entry_completion_set_model (completion, model);
 gtk_entry_completion_set_func (completion, func, data, destroy);
 gtk_cell_layout_pack_start (completion, renderer);
 gtk_cell_layout_set_attributes (completion, renderer, ...);
 gtk_entry_set_completion (entry, completion);

There would also be convenience functions for simpler cases.
One possibility we discussed is to have:

 gtk_entry_completion_set_list_column (entry, completion, 
                                       model_column);

Which hooks everything up for the simple case of a single
text column in the model displayed with a single cell renderer.

Or, you might want instead gtk_entry_completion_new_text(),
gtk_entry_completion_append_text() to handle the 
90% case _really_ easily.

 completion = gtk_entry_completion_new_text ()
 gtk_entry_completion_append_text (completion, "foo");
 gtk_entry_completion_append_text (completion, "bar");
 gtk_entry_set_completion (entry, completion);

A lot of details here to be worked out if this is the right
way to go, but something along these lines seems cleaner
and more flexible to me than exposing the cell renderer
directly.

Regards,
                                Owen





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