Out of scope and gtk variable



Hi! I'm having trouble explaining a code(gtk 1.2). My application has a top window which
contains a GtkList widget. I 've also created a function(fill_list_with_items())
which populates the clist widget with 50 list items.


GList *fill_list_with_items(GtkWidget *list)
{  int i;
   GList *list_items;
   list_items = NULL;
   for(i = 1; i <= 50; i++)
   {
      list_items = g_list_prepend(list_items,
            populate_row(list, i));
   }
   list_items = g_list_reverse(list_items);

   gtk_list_append_items(GTK_LIST(list), list_items);
   return list_items;
}

int main(int argc, char *argv[])
{


 .....
 gtk_widget_show(list);
 .....
 

populate_row() function create GtkListItem for each row and populate with vbox which
contains a GtkLabel widget. My question is: in the above code GList *list_items
does not exist beyond the function fill_list_with_items(). So how come the compiler
doesn not complain about it when i later view clist?

Thanks.

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