gtk_list widget bug.



Hello,

The program included below shows what I believe to be a bug in gtk. Here's what 
it does (basically): create a gtk_list widget, with some items in it. Show that 
widget. (You can now see the items in it.) Set up a timed callback. Enter 
gtk_main. In the timed callback: hide the widget, remove the items, add some 
new items, show the widget. Now you _can't_ see the items. Why not? Checking 
GTK_LIST( list )->children shows that it does have the appropriate number of 
children.

If you remove the gtk_widget_hide call in the function called idler, the one 
marked /* THIS ONE */, the items _do_ show.

Regards,

Johannes.

--8<-CUT-HERE-8<--
#include <gtk/gtk.h>

GtkWidget *window;
GtkWidget *list;

void set_items( )
{
  GtkWidget *item;
  GList *items = NULL;

  gtk_list_clear_items( GTK_LIST( list ), 0, -1 );

  item = gtk_list_item_new_with_label( "Foo!" );
  gtk_widget_show( item );
  items = g_list_append( items, item );

  gtk_list_prepend_items( GTK_LIST( list ), items );
}

int idler( gpointer data )
{
  gtk_widget_hide( window ); /* THIS ONE */
  set_items( );
  gtk_widget_show( window );
  
  return 0;
}

int main( int argc, char **argv )
{
  gtk_init( &argc, &argv );

  window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
  gtk_widget_show( window );

  list = gtk_list_new( );
  gtk_container_add( GTK_CONTAINER( window ), list );
  gtk_widget_show( list );

  set_items( );

  gtk_timeout_add( 400, idler, NULL );

  gtk_main( );

  return 0;
}




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