コード例 #1
0
static void
location_changed (GObject *object, GParamSpec *param, gpointer tzmenu)
{
    GWeatherLocationEntry *entry = GWEATHER_LOCATION_ENTRY (object);
    GWeatherLocation *loc;
    GWeatherTimezone *zone;

    loc = gweather_location_entry_get_location (entry);
    if (loc == NULL)
      return;

    zone = gweather_location_get_timezone (loc);
    if (zone)
	gweather_timezone_menu_set_tzid (tzmenu, gweather_timezone_get_tzid (zone));
    else
	gweather_timezone_menu_set_tzid (tzmenu, NULL);
    if (zone)
	gweather_timezone_unref (zone);
    gweather_location_unref (loc);
}
コード例 #2
0
static void
add_location_tile(MnpWorldClock *world_clock, const char *display, gboolean priority)
{
    GWeatherLocation *location;
    MnpClockTile *tile;
    MnpZoneLocation *loc = g_new0(MnpZoneLocation, 1);
    const GWeatherTimezone *tzone;
    MnpWorldClockPrivate *priv = GET_PRIVATE (world_clock);
    int i;

    if (!priv->zones_model)
        priv->zones_model = mnp_get_world_timezones();

    location = (GWeatherLocation *) mnp_utils_get_location_from_display (priv->zones_model, display);
    if (!location)
        return;

    printf("Adding location: %s\n", display);
    loc->display = g_strdup(display);
    loc->city = g_strdup(gweather_location_get_city_name (location));
    tzone =  gweather_location_get_timezone (location);
    loc->tzid = g_strdup(gweather_timezone_get_tzid ((GWeatherTimezone *)tzone));
    loc->local = FALSE;

    for (i=0; i< priv->zones->len; i++) {
        MnpZoneLocation *cmp = priv->zones->pdata[i];

        if (strcmp (loc->tzid, cmp->tzid) == 0 &&
                strcmp (loc->city, cmp->city) == 0) {
            /* We already have this. So don't add. */
            g_free (loc->tzid);
            g_free (loc->city);
            g_free (loc->display);
            g_free (loc);
            printf("Not adding %s, as it is already there\n",
                   loc->city);

            return;
        }
    }

    if (priority) {
        priv->location_tile = TRUE;
        loc->local = TRUE;
    }

    g_ptr_array_add (priv->zones, loc);
    mnp_save_zones(priv->zones);

    mx_entry_set_text (priv->search_location, "");

    tile = mnp_clock_tile_new (loc, mnp_clock_area_get_time(priv->area), priority);
    mnp_clock_area_add_tile (priv->area, tile);

    priv->search_text = "asd";
    g_signal_emit_by_name (priv->zones_model, "filter-changed");

    if (priv->zones->len >= 4)
        clutter_actor_hide (priv->entry_box);

}