Use g_path_get_basename() instead of manually filtering the path name. Big advantage: g_path_get_basename() cannot fail.