To edit a ROS package using CodeBlocks, one can generate the project file using cmake:
roscd <your_package>
mkdir build_codeblocks
cd build_codeblocks
cmake -G "CodeBlocks - Unix Makefiles" ..
According to http://www.cmake.org/Wiki/CMake_Generator_Specific_Information ,
you need cmake version at least 2.6.
Start CodeBlocks from Terminal directly rather than click on the app launcher.
In this way, codeblocks will inherit all ROS_* variable from bash shell.
Then open the your_package.cbp using CodeBlocks. You should be able to compile without any problem.
When Run, remember to choose the right target, <your_pacakge> not the default "all"
HTH