Question

I have code where I populate combo box models by text but first time I see strange behavior.

I use Blade GUI editir to create *.ui file where i generate single empty combobox.

After, I fetch combo from methods and modify/fill my combo.

This is my snippets of code:

GtkWidget *combo_screen_share;

GtkTreeModel *model;

// here I get empty combobox
combo_screen_share=myprog_gtk_get_widget(call_view,"window_screen_stream");

        GtkCellRenderer *renderer=gtk_cell_renderer_text_new();

        model=GTK_TREE_MODEL((store=gtk_list_store_new(1,G_TYPE_STRING)));

        int i;
        for(i=0; i<200; i++){
            gtk_list_store_append(store,&iter);
            gtk_list_store_set(store,&iter,0,"Full Screen",-1);
        }

        gtk_combo_box_set_model(GTK_COMBO_BOX(combo_screen_share),model);
        g_object_unref(G_OBJECT(model));


        gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_screen_share),renderer,FALSE);
        gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_screen_share),renderer,"text",0,NULL);


        gtk_combo_box_set_active(GTK_COMBO_BOX(combo_screen_share),0);

                    // bind 'onChange' with other method as callback 
        g_signal_connect(G_OBJECT(combo_screen_share),"changed",(GCallback)gtk_combo_box_new_with_model,NULL);

It should create 200 rows of "Full Screen" string.

However when I click on combobox, I get empty half screen as gap/space and only after all my 200 items.

If I run the loop for 100, space is going to be smaller.

enter image description here

Did someone meet the same thing and know how to fix it?

Thank you,

Était-ce utile?

La solution

What you're seeing isn't a "bug" exactly, it's just the way Gtk does combo boxes and you'll have to live with it.

Try another app if you don't believe me --

  • Open a Gtk app (I used The Gimp)
  • Find a combo box with several options
  • Drag the window so that the combo box is near the bottom of the screen
  • Click on it

When the combo box appears it will have a big empty space at the top, just like yours.

I don't believe there's a fix without patching Gtk itself. For more discussion/rants on this issue see this Launchpad bug and this Gnome Buzilla bug.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top