Problems in attaching GtkScrolledWindow to GtkList



Hi
I am doing a project that involves the use of GtkList.
I am trying to attach scroll bars to the lists but am not very successful.
I then tried to do a simple program to see where I was going wrong ..... The program ran .. but I got this error on the console
 
Gtk-CRITICAL **: file gtkscrolledwindow.c: line 951 (gtk_scrolled_window_add_with_viewport): assertion `child->parent == NULL' failed.
 
Any Idea what is going wrong here?
 
Thanks in advance
David
 
The code is as follows:
//////////////////////////////////////////////////////////////////////////////////////////////////
GtkWidget * create_window1 (void)
{
  GtkWidget *window1;
  GtkWidget *fixed1;
  GtkWidget *list2;
  GList   *list_items = NULL;
  gint   count;
  gchar   buff[3];
  GtkWidget *scrolled_window = NULL;
 
  window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_object_set_data (GTK_OBJECT (window1), "window1", window1);
  gtk_window_set_title (GTK_WINDOW (window1), "window1");
 
  fixed1 = gtk_fixed_new ();
  gtk_widget_ref (fixed1);
  gtk_object_set_data_full (GTK_OBJECT (window1), "fixed1", fixed1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (fixed1);
  gtk_container_add (GTK_CONTAINER (window1), fixed1);
 
  list2 = gtk_list_new ();
  gtk_widget_ref (list2);
  gtk_object_set_data_full (GTK_OBJECT (window1), "list2", list2,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (list2);
  gtk_fixed_put (GTK_FIXED (fixed1), list2, 40, 16);
  gtk_widget_set_uposition (list2, 40, 16);
  gtk_widget_set_usize (list2, 104, 136);
 
  for(count = 0; count <10 ; count++)
 {
  sprintf(buff, "%d", count);
  list_items = g_list_prepend(list_items, gtk_list_item_new_with_label(buff));
 }
  g_print("\nafter scrolled window4\n");
 gtk_list_append_items(GTK_LIST(list2), list_items);
 g_print("\nafter scrolled window5\n");
 gtk_widget_show_all(list2);
 
 scrolled_window = gtk_scrolled_window_new(NULL,NULL);
 if(scrolled_window == NULL)
  g_print("\nscroll = NULL\n");
 gtk_widget_set_usize(scrolled_window, 200,200);
 gtk_scrolled_window_add_with_viewport(GTK_CONTAINER(scrolled_window),list2);
 gtk_container_set_focus_hadjustment(GTK_CONTAINER(list2),gtk_scrolled_window_get_hadjustment GTK_SCROLLED_WINDOW(scrolled_window)));

 gtk_container_set_focus_vadjustment(GTK_CONTAINER(list2),gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrolled_window)));
 g_print("\nafter scrolled window3\n");
 
  return window1;
}
 
//////////////////////////////////////////////////////////////////////////////////////////////////


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