11 Feb 2004 (updated 13 Feb 2004 at 09:49 UTC)
»
Things are getting complicated...
First the Allocate nightmare. When the user enters into a cell I call gtk_cell_renderer_start_editing and it gives me a brand new GtkCellEditable widget. Then I put it on the Grid by calling gtk_size_allocate but it is not shown properly and I can't give it the focus. Thanks to Owen who iluminated me and told me that only inside the gtk_size_allocate of the Grid it is legal to call gtk_size_allocate on the children of the grid. Yes, the GtkCellEditable widget must be a child of the Grid. First problem solved :) . You can see how nice are the GTK+ Gurus by reading this piece of IRC chat:
<lgs> is it legal to call gtk_widget_size_allocate without calling gtk_widget_size_request if we don't care about our children wishes?
<owen> lgs: No. A) The only time a custom widget is allowed to call gtk_widget_size_allocate() is in it's gtk_widget_size_allocate() handler
<owen> B) A widget must call size_request() on all children in it's size_request() handler, even if it ignores the result
<lgs> owen, what if I add a child after the size_request of the parent has been called
<owen> Actually also A') A custom widget must call gtk_widget_size_allocate() on all its children in it's size_allocate() handler
<lgs> owen, what's the equivalent to gtk_widget_queue_draw, for size issues?
<owen> lgs: When you add a child, GTK+ automatically queues a resize, so you'll
get a size_allocate()
<owen> lgs: gtk_widget_queue_resize()
<lgs> how gtk+ knows that I added a child? when I call gtk_widget_set_parent?
<owen> lgs: Yeah
<lgs> cool, thanks a lot owen
<lgs> that makes me understand a little bit more of the gtktreeview.c code
After some time playing with the key bindings of the Grid I realized that what I needed to do is to listen for key presses in the GtkCellEditable and move the focus that way. So I got moving left and right of my grid and it worked.
But moving up and down didn't work because strangely I wasn't getting up and down key press. I dived into the GtkEntry code and I discovered why: when calling gtk_cell_editable_start_editing it connect a signal handler to the key press event and check if the user press these arrows to do something special. Solution: noo to call gtk_cell_editable_start_editing. Second problem solved :)
But best of all, while I'm writing these lines people in the #gnome-hispano channel (setepo and apg) are fixing bugs and giving me suggestions (Devin). I feel the power of free software ...