static void
insert_locations (GtkTreeStore *store, GWeatherLocation *loc)
{
    int i;

    if (gweather_location_get_level (loc) < GWEATHER_LOCATION_COUNTRY) {
	GWeatherLocation **children;

	children = gweather_location_get_children (loc);
	for (i = 0; children[i]; i++)
	    insert_locations (store, children[i]);
    } else {
	GWeatherTimezone **zones;
	GtkTreeIter iter;

	zones = gweather_location_get_timezones (loc);
	if (zones[1]) {
	    gtk_tree_store_append (store, &iter, NULL);
	    gtk_tree_store_set (store, &iter,
				GWEATHER_TIMEZONE_MENU_NAME, gweather_location_get_name (loc),
				-1);

	    for (i = 0; zones[i]; i++) {
                insert_location (store, zones[i], NULL, &iter);
	    }
	} else if (zones[0]) {
            insert_location (store, zones[0], gweather_location_get_name (loc), NULL);
	}

	gweather_location_free_timezones (loc, zones);
    }
}
static void
fill_location_entry_model (ClutterModel *store, GWeatherLocation *loc,
			   const char *parent_display_name,
			   const char *parent_compare_name,
			   const char *parent_sort_name)
{
    GWeatherLocation **children;
    char *display_name, *compare_name, *sort_name;
    int i;

    children = gweather_location_get_children (loc);

    switch (gweather_location_get_level (loc)) {
    case GWEATHER_LOCATION_WORLD:
    case GWEATHER_LOCATION_REGION:
    case GWEATHER_LOCATION_ADM2:
	/* Ignore these levels of hierarchy; just recurse, passing on
	 * the names from the parent node.
	 */
	for (i = 0; children[i]; i++) {
	    fill_location_entry_model (store, children[i],
				       parent_display_name,
				       parent_compare_name,
				       parent_sort_name);
	}
	break;

    case GWEATHER_LOCATION_COUNTRY:
	/* Recurse, initializing the names to the country name */
	for (i = 0; children[i]; i++) {
	    fill_location_entry_model (store, children[i],
				       gweather_location_get_name (loc),
				       gweather_location_get_sort_name (loc),
				       gweather_location_get_sort_name (loc));
	}
	break;

    case GWEATHER_LOCATION_ADM1:
	/* Recurse, adding the ADM1 name to the country name */
	display_name = g_strdup_printf ("%s, %s", gweather_location_get_name (loc), parent_display_name);
	compare_name = g_strdup_printf ("%s, %s", gweather_location_get_sort_name (loc), parent_compare_name);

	for (i = 0; children[i]; i++) {
	    fill_location_entry_model (store, children[i],
				       display_name, compare_name, parent_sort_name);
	}

	g_free (display_name);
	g_free (compare_name);
	break;

    case GWEATHER_LOCATION_CITY:
	if (children[0] && children[1]) {
	    /* If there are multiple (<location>) children, add a line
	     * for each of them.
	     */

	    for (i = 0; children[i]; i++) {
		display_name = g_strdup_printf ("%s (%s), %s",
						gweather_location_get_name (loc),
						gweather_location_get_name (children[i]),
						parent_display_name);
		compare_name = g_strdup_printf ("%s (%s), %s",
						gweather_location_get_sort_name (loc),
						gweather_location_get_sort_name (children[i]),
						parent_compare_name);

	    	sort_name = g_strdup_printf ("%s:%s",
					    gweather_location_get_sort_name (loc),
					    parent_sort_name);

		clutter_model_prepend(store, 
				    GWEATHER_LOCATION_ENTRY_COL_LOCATION, children[i],
				    GWEATHER_LOCATION_ENTRY_COL_DISPLAY_NAME, display_name,
				    GWEATHER_LOCATION_ENTRY_COL_COMPARE_NAME, compare_name,
				    GWEATHER_LOCATION_ENTRY_COL_SORT_NAME, sort_name,
				    -1);

		g_free (display_name);
		g_free (compare_name);
	    }
	} else if (children[0]) {
	    /* Else there's only one location. This is a mix of the
	     * city-with-multiple-location case above and the
	     * location-with-no-city case below.
	     */
	    display_name = g_strdup_printf ("%s, %s",
					    gweather_location_get_name (loc),
					    parent_display_name);
	    compare_name = g_strdup_printf ("%s, %s",
					    gweather_location_get_sort_name (loc),
					    parent_compare_name);
	    sort_name = g_strdup_printf ("%s:%s",
					    gweather_location_get_sort_name (loc),
					    parent_sort_name);

	    clutter_model_prepend(store, 
				GWEATHER_LOCATION_ENTRY_COL_LOCATION, children[0],
				GWEATHER_LOCATION_ENTRY_COL_DISPLAY_NAME, display_name,
				GWEATHER_LOCATION_ENTRY_COL_COMPARE_NAME, compare_name,
				GWEATHER_LOCATION_ENTRY_COL_SORT_NAME, sort_name,
				-1);

	    g_free (display_name);
	    g_free (compare_name);
	}
	break;

    case GWEATHER_LOCATION_WEATHER_STATION:
	/* <location> with no parent <city>, or <city> with a single
	 * child <location>.
	 */
	display_name = g_strdup_printf ("%s, %s",
					gweather_location_get_name (loc),
					parent_display_name);
	compare_name = g_strdup_printf ("%s, %s",
					gweather_location_get_sort_name (loc),
					parent_compare_name);
	clutter_model_prepend(store, 		
			    GWEATHER_LOCATION_ENTRY_COL_LOCATION, loc,
			    GWEATHER_LOCATION_ENTRY_COL_DISPLAY_NAME, display_name,
			    GWEATHER_LOCATION_ENTRY_COL_COMPARE_NAME, compare_name,
			    GWEATHER_LOCATION_ENTRY_COL_SORT_NAME, parent_sort_name,
			    -1);

	g_free (display_name);
	g_free (compare_name);
	break;
    }

}