strange behavior of combobox with composite list items



Hi all,

i have this nasty problem with a combobox (gtk 2.0.7):

the list items are composite, and (image+arrow+text label)
and the combobox's size is set to an explicit width.
when the text label of a list of the combo is too long, a scroll
bar appears and it can be scrolled, everything is ok.
the strange thing is that if i reduce the width of the text label
by just using a shorter text string so that it shouldn't need
this scrollbar, the scrollbar appears anyway instead of the
text.

below the code. should the problem be unclear, ask me for
partial screenshots to illustrate. since it is related to an
explicit size setting, your theme might lead to a situation that
doesn't reproduce this problem. however i'm relatively positive
that this is a problem inside combo and not theme-related
in itself. the scroll bar shouldn't appear.
/*--------------------*/

GtkWidget* megacombo()
{
  GtkWidget *combo, *item, *hbox, *arrow, *label,*image;
	
  combo= gtk_combo_new();

  hbox = gtk_hbox_new (FALSE, 3);
	
image = gtk_image_new_from_file("/usr/share/eazel-engine/scroller-arrow-down.png");

  gtk_widget_show(image);
  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);

  arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
  gtk_widget_show (arrow);
  gtk_box_pack_start (GTK_BOX (hbox), arrow, FALSE, FALSE, 0);

  label = gtk_label_new ("TestTestTe");
  /* if you add a letter or more, it wouldn't fit inside the fixed
     width specified below and the problem disappears. the strange
     thing is that when the text string is short enough to fit
     inside the list item without scrolling, there's still a scroll
     bar, and it covers the text. should be: text and no scroll bar */
	
  gtk_widget_show (label);
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
	
  gtk_widget_show (hbox);
	
  item = gtk_list_item_new();
gtk_combo_set_item_string (GTK_COMBO (combo), GTK_ITEM (item), "1st Item");
  gtk_container_add (GTK_CONTAINER (item), hbox);
  /* add a listitem with a hbox containing image, arrow, label */
  gtk_widget_show (item);

  gtk_container_add (GTK_CONTAINER (GTK_COMBO (combo)->list), item);
	
  /*here we set an explicit width*/
  gtk_widget_set_size_request(combo,110,-1);
  gtk_widget_show(combo);
  return combo;
}

/*---------------------------------------------------------*/




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