Efficient spectral-Galerkin methods for fractional partial differential equations with variable coefficients