weather-service: Add method to fetch info for date
This will be used by next commit to reintroduce weather data in the Month view. Patch originally made by camelCaseNick.
This commit is contained in:
@@ -1033,6 +1033,37 @@ gcal_weather_service_set_time_zone (GcalWeatherService *self,
|
||||
g_object_notify (G_OBJECT (self), "time-zone");
|
||||
}
|
||||
|
||||
/**
|
||||
* gcal_weather_service_get_weather_info_for_date:
|
||||
* @self: The #GcalWeatherService instance.
|
||||
* @date: The #GDate for which to get the current forecast.
|
||||
*
|
||||
* Retrieves the available weather information for @date.
|
||||
*
|
||||
* Returns: (transfer none)(nullable): a #GcalWeatherInfo
|
||||
*/
|
||||
GcalWeatherInfo*
|
||||
gcal_weather_service_get_weather_info_for_date (GcalWeatherService *self,
|
||||
GDate *date)
|
||||
{
|
||||
g_return_val_if_fail (GCAL_IS_WEATHER_SERVICE (self), NULL);
|
||||
|
||||
for (guint i = 0; self->weather_infos && i < self->weather_infos->len; i++)
|
||||
{
|
||||
GcalWeatherInfo *info;
|
||||
GDate weather_date;
|
||||
|
||||
info = g_ptr_array_index (self->weather_infos, i);
|
||||
|
||||
gcal_weather_info_get_date (info, &weather_date);
|
||||
|
||||
if (g_date_compare (&weather_date, date) == 0)
|
||||
return info;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gcal_weather_service_get_weather_infos:
|
||||
* @self: The #GcalWeatherService instance.
|
||||
|
||||
Reference in New Issue
Block a user