Hello! I have following C function: gint apply_properties_to_menu(GList* widgets, GMenuModel* menu) { GList* l; GMenuModel* menu_link; GtkWidget* menuw; int len = g_menu_model_get_n_items(menu); int i, j ,ret; for (i=0, l=widgets; (i<len) && (l!= NULL); i++,l = l->next) { while (GTK_IS_SEPARATOR_MENU_ITEM(l->data)) l = l->next; menuw = gtk_menu_item_get_submenu(GTK_MENU_ITEM(l->data)); menu_link = g_menu_model_get_item_link(menu,i,"submenu"); if (menuw && menu_link) {
apply_properties_to_menu(gtk_container_get_children(GTK_CONTAINER(menuw)),menu_link); g_object_unref(menu_link); } menu_link = g_menu_model_get_item_link(menu,i,"section"); if (menu_link) { ret = apply_properties_to_menu(l,menu_link); for (j = 0; j < ret; j++) l=l->next; g_object_unref(menu_link); } /* Apply some properties */ } return i-1; } It works as expected. But straightforward rewrite to vala (below) is not: public static int apply_menu_properties(List<Widget> widgets, MenuModel menu) { var len = menu.get_n_items(); unowned List<Widget> l; int i = 0; for(i = 0, l = widgets;(i<len)&&(l!=null);i++,l=l.next) { while (l.data is SeparatorMenuItem) l = l.next; var menuw = ( l.data as Gtk.MenuItem).get_submenu() as Gtk.Menu; var submenu = menu.get_item_link(i,"submenu"); if (menuw !=null && submenu !=null) apply_menu_properties(menuw.get_children(),submenu); var section = menu.get_item_link(i,"section"); //Here is some strange vala behaviour, that I cannot catch if (section != null) { var ret = apply_menu_properties(l,section); for (var j=0;j<ret;j++) l = l.next; } //end here /* Apply some properties */ } return i-1; } _______________________________________________ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list