Here is script that I use to compile gtk+ on slackware:
#!/bin/bash
INSTALL_DIR=/opt/gtk
GLIB_VER=2.21.1
ATK_VER=1.26.0
CAIRO_VER=1.8.6
PANGO_VER=1.24.2
GTK_VER=2.17.1
GOOCANVAS_VER=0.15
mkdir -p ${INSTALL_DIR}
CPPFLAGS="-I${INSTALL_DIR}/usr/include"
LDFLAGS="-L${INSTALL_DIR}/usr/lib"
PKG_CONFIG_PATH="${INSTALL_DIR}/usr/lib/pkgconfig"
LD_LIBRARY_PATH="${INSTALL_DIR}/usr/lib"
PATH="${INSTALL_DIR}/usr/bin:$PATH"
export CPPFLAGS LDFLAGS PKG_CONFIG_PATH LD_LIBRARY_PATH PATH
#glib
tar zxvf glib-${GLIB_VER}.tar.gz
cd glib-${GLIB_VER}
./configure --prefix=${INSTALL_DIR}/usr --sysconfdir=${INSTALL_DIR}/etc && make && make install
cd ..
#atk
tar zxvf atk-${ATK_VER}.tar.gz
cd atk-${ATK_VER}
./configure --prefix=${INSTALL_DIR}/usr --sysconfdir=${INSTALL_DIR}/etc && make && make install
cd ..
#cairo
tar zxvf cairo-${CAIRO_VER}.tar.gz
cd cairo-${CAIRO_VER}
./configure --prefix=${INSTALL_DIR}/usr --sysconfdir=${INSTALL_DIR}/etc && make && make install
cd ..
#pango
tar zxvf pango-${PANGO_VER}.tar.gz
cd pango-${PANGO_VER}
./configure --prefix=${INSTALL_DIR}/usr --sysconfdir=${INSTALL_DIR}/etc && make && make install
cd ..
#gtk
tar zxvf gtk+-${GTK_VER}.tar.gz
cd gtk+-${GTK_VER}
./configure --prefix=${INSTALL_DIR}/usr --sysconfdir=${INSTALL_DIR}/etc && make && make install
cd ..
Put this script and needed files in same dir. For gtk 2.17.1 needed files are:
glib-2.21.1.tar.gz
atk-1.26.0.tar.gz
cairo-1.8.6.tar.gz
pango-1.24.2.tar.gz
gtk+-2.17.1.tar.gz
You must compile this in this order if you want it to work. Also, new gtk version will be installed in /opt/gtk so it doesn't bother gtk installed by default.
If you want to compile (and run) program which uses new gtk, you simply need to put this in your /home/user/.bashrc file:
INSTALL_DIR=/opt/gtk
PKG_CONFIG_PATH="${INSTALL_DIR}/usr/lib/pkgconfig"
LD_LIBRARY_PATH="${INSTALL_DIR}/usr/lib"
PATH="${INSTALL_DIR}/usr/bin:$PATH"
export PKG_CONFIG_PATH LD_LIBRARY_PATH PATH
and that's it.