/**
 * gweather_timezone_menu_get_tzid:
 * @menu: a #GWeatherTimezoneMenu
 *
 * Gets @menu's timezone id.
 *
 * Return value: (allow-none): @menu's tzid, or %NULL if no timezone
 * is selected.
 **/
const char *
gweather_timezone_menu_get_tzid (GWeatherTimezoneMenu *menu)
{
    g_return_val_if_fail (GWEATHER_IS_TIMEZONE_MENU (menu), NULL);

    if (!menu->zone)
	return NULL;
    return gweather_timezone_get_tzid (menu->zone);
}
Example #2
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);
}
static gboolean
check_tzid (GtkTreeModel *model, GtkTreePath *path,
	    GtkTreeIter *iter, gpointer data)
{
    SetTimezoneData *tzd = data;
    GWeatherTimezone *zone;
    gboolean ok;

    gtk_tree_model_get (model, iter,
			GWEATHER_TIMEZONE_MENU_ZONE, &zone,
			-1);
    if (!zone)
	return FALSE;

    if (!strcmp (gweather_timezone_get_tzid (zone), tzd->tzid)) {
	gtk_combo_box_set_active_iter (tzd->combo, iter);
	ok = TRUE;
    } else
	ok = FALSE;

    gweather_timezone_unref (zone);
    return ok;
}
Example #4
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);

}