Re: Problems with GtkComboBoxEntry



On Tue, 2004-10-05 at 18:04, Carlo Agrusti wrote:
Martyn Russell ha scritto lo scorso 05/10/2004 17:45:

If you use the following code:

        gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_box));

        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer,
                                        "text", 0,
                                        NULL);
        
or

        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer,
                                        "text", 0,
                                        NULL);
        
        gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo_box), renderer, 0);
        
does it make any difference? 


With this code added after the call to gtk_combo_box_entry_set_model the 
combo box (created with gtk_combo_box_entry_new) displays correctly all 
entries described by the model (both with and without a 
gtk_cell_layout_reorder call). 

Yea, I found that you can either call the gtk_cell_layout_clear ()
function or use gtk_cell_layout_reorder () .  However, without looking
at the source, I would guess the reorder function merely pushes other
renderers to the back of the queue so to speak so long as the renderer
passed is in the right position.

Is the use of the cell renderer mandatory 
for this kind of combo box manipulation?

No I don't think so, but I found this problem while implementing
multiple cell renderers being packed into a layout for a combo box (i.e.
an image and text together).  

I think the problem is that if you use glade and have some predetermined
text entries, glade uses the following code to set up the combo box:

        combo_box = gtk_combo_box_new_text ();
        gtk_widget_show (combo_box);
        gtk_box_pack_start (GTK_BOX (hbox), combo_box, TRUE, TRUE, 0);
        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), "text");
        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), "etc");
        
When using this code, GTK must internally create a renderer for the text
entries and expects you to use the gtk_combo_box_append_text () and
associated functions.

When you set a new model to the combo box, it must still have a resident
cell renderer attributes and layouts.

Matthias, have I got that about right? any comments to add?

If you use my test case you can play with adding/removing the above code
and see how things differ.

-- 
Regards,
Martyn



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