Weather: Change weather update signal.
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
0248cf918e
commit
c5c832241e
+36
-13
@@ -37,7 +37,8 @@ G_BEGIN_DECLS
|
|||||||
* freed by gcal_weather_service_stop().
|
* freed by gcal_weather_service_stop().
|
||||||
* @location_cancellable: Used to deal with async location service construction.
|
* @location_cancellable: Used to deal with async location service construction.
|
||||||
* @locaton_running: Whether location service is active.
|
* @locaton_running: Whether location service is active.
|
||||||
* @weather_info: The weather info to query.
|
* @weather_infos: List of #GcalWeatherInfo objects.
|
||||||
|
* @gweather_info: The weather info to query.
|
||||||
* @max_days: Number of days we want weather information for.
|
* @max_days: Number of days we want weather information for.
|
||||||
* @weather_service_running: True if weather service is active.
|
* @weather_service_running: True if weather service is active.
|
||||||
*
|
*
|
||||||
@@ -69,6 +70,7 @@ struct _GcalWeatherService
|
|||||||
gboolean location_service_running;
|
gboolean location_service_running;
|
||||||
|
|
||||||
/* weather: */
|
/* weather: */
|
||||||
|
GSList *weather_infos; /* owned[owned] */
|
||||||
GWeatherInfo *gweather_info; /* owned, nullable */
|
GWeatherInfo *gweather_info; /* owned, nullable */
|
||||||
guint max_days;
|
guint max_days;
|
||||||
gboolean weather_service_running;
|
gboolean weather_service_running;
|
||||||
@@ -181,6 +183,8 @@ gcal_weather_service_finalize (GObject *object)
|
|||||||
g_cancellable_cancel (self->location_cancellable);
|
g_cancellable_cancel (self->location_cancellable);
|
||||||
g_clear_object (&self->location_cancellable);
|
g_clear_object (&self->location_cancellable);
|
||||||
|
|
||||||
|
g_slist_free_full (self->weather_infos, g_object_unref);
|
||||||
|
|
||||||
if (self->gweather_info != NULL)
|
if (self->gweather_info != NULL)
|
||||||
g_clear_object (&self->gweather_info);
|
g_clear_object (&self->gweather_info);
|
||||||
|
|
||||||
@@ -294,10 +298,11 @@ gcal_weather_service_class_init (GcalWeatherServiceClass *klass)
|
|||||||
/**
|
/**
|
||||||
* GcalWeatherService::weather-changed:
|
* GcalWeatherService::weather-changed:
|
||||||
* @sender: The #GcalWeatherService
|
* @sender: The #GcalWeatherService
|
||||||
* @gwi: A SList containing updated #GcalWeatherInfos.
|
|
||||||
* @self: data pointer.
|
* @self: data pointer.
|
||||||
*
|
*
|
||||||
* Triggered on weather changes.
|
* Triggered on weather changes. Call
|
||||||
|
* gcal_weather_service_get_weather_infos() to
|
||||||
|
* retrieve predictions.
|
||||||
*/
|
*/
|
||||||
gcal_weather_service_signals[SIG_WEATHER_CHANGED]
|
gcal_weather_service_signals[SIG_WEATHER_CHANGED]
|
||||||
= g_signal_new ("weather-changed",
|
= g_signal_new ("weather-changed",
|
||||||
@@ -306,10 +311,9 @@ gcal_weather_service_class_init (GcalWeatherServiceClass *klass)
|
|||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
g_cclosure_marshal_VOID__POINTER,
|
g_cclosure_marshal_VOID__VOID,
|
||||||
G_TYPE_NONE,
|
G_TYPE_NONE,
|
||||||
1,
|
0);
|
||||||
G_TYPE_POINTER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -323,6 +327,7 @@ gcal_weather_service_init (GcalWeatherService *self)
|
|||||||
self->location_cancellable = g_cancellable_new ();
|
self->location_cancellable = g_cancellable_new ();
|
||||||
self->location_service_running = FALSE;
|
self->location_service_running = FALSE;
|
||||||
self->location_service = NULL;
|
self->location_service = NULL;
|
||||||
|
self->weather_infos = NULL;
|
||||||
self->gweather_info = NULL;
|
self->gweather_info = NULL;
|
||||||
self->weather_service_running = FALSE;
|
self->weather_service_running = FALSE;
|
||||||
self->max_days = 0;
|
self->max_days = 0;
|
||||||
@@ -918,12 +923,14 @@ static void
|
|||||||
gcal_weather_service_update_weather (GWeatherInfo *info,
|
gcal_weather_service_update_weather (GWeatherInfo *info,
|
||||||
GcalWeatherService *self)
|
GcalWeatherService *self)
|
||||||
{
|
{
|
||||||
GSList *gcinfos = NULL; /* owned[owned] */
|
|
||||||
|
|
||||||
g_return_if_fail (info == NULL || GWEATHER_IS_INFO (info));
|
g_return_if_fail (info == NULL || GWEATHER_IS_INFO (info));
|
||||||
g_return_if_fail (GCAL_IS_WEATHER_SERVICE (self));
|
g_return_if_fail (GCAL_IS_WEATHER_SERVICE (self));
|
||||||
|
|
||||||
/* Compute a list of weather infos. */
|
/* Free previously received weather infos */
|
||||||
|
g_slist_free_full (self->weather_infos, g_object_unref);
|
||||||
|
self->weather_infos = NULL;
|
||||||
|
|
||||||
|
/* Compute a list of newly received weather infos. */
|
||||||
if (info == NULL)
|
if (info == NULL)
|
||||||
{
|
{
|
||||||
g_debug ("Could not retrieve valid weather");
|
g_debug ("Could not retrieve valid weather");
|
||||||
@@ -935,7 +942,7 @@ gcal_weather_service_update_weather (GWeatherInfo *info,
|
|||||||
g_debug ("Received valid weather information");
|
g_debug ("Received valid weather information");
|
||||||
|
|
||||||
gwforecast = gweather_info_get_forecast_list (info);
|
gwforecast = gweather_info_get_forecast_list (info);
|
||||||
gcinfos = preprocess_gweather_reports (self, gwforecast);
|
self->weather_infos = preprocess_gweather_reports (self, gwforecast);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -943,8 +950,7 @@ gcal_weather_service_update_weather (GWeatherInfo *info,
|
|||||||
g_debug ("Could not retrieve valid weather for location '%s'", location_name);
|
g_debug ("Could not retrieve valid weather for location '%s'", location_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_emit (self, gcal_weather_service_signals[SIG_WEATHER_CHANGED], 0, gcinfos);
|
g_signal_emit (self, gcal_weather_service_signals[SIG_WEATHER_CHANGED], 0);
|
||||||
g_slist_free_full (gcinfos, g_object_unref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1189,7 +1195,8 @@ gcal_weather_service_get_time_zone (GcalWeatherService *self)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* gcal_weather_service_set_time_zone:
|
/**
|
||||||
|
* gcal_weather_service_set_time_zone:
|
||||||
* @self: The #GcalWeatherService instance.
|
* @self: The #GcalWeatherService instance.
|
||||||
* @days: Number of days.
|
* @days: Number of days.
|
||||||
*
|
*
|
||||||
@@ -1235,3 +1242,19 @@ gcal_weather_service_get_check_interval (GcalWeatherService *self)
|
|||||||
|
|
||||||
return self->check_interval;
|
return self->check_interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gcal_weather_service_get_weather_infos:
|
||||||
|
* @self: The #GcalWeatherService instance.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): list of known weather reports.
|
||||||
|
*/
|
||||||
|
GSList*
|
||||||
|
gcal_weather_service_get_weather_infos (GcalWeatherService *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GCAL_IS_WEATHER_SERVICE (self), NULL);
|
||||||
|
|
||||||
|
return self->weather_infos;
|
||||||
|
}
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ GcalWeatherService* gcal_weather_service_new (GTimeZone
|
|||||||
|
|
||||||
GTimeZone* gcal_weather_service_get_time_zone (GcalWeatherService *self);
|
GTimeZone* gcal_weather_service_get_time_zone (GcalWeatherService *self);
|
||||||
|
|
||||||
void gcal_weather_service_set_time_zone (GcalWeatherService *self,
|
void gcal_weather_service_set_time_zone (GcalWeatherService *self,
|
||||||
GTimeZone *value);
|
GTimeZone *value);
|
||||||
|
|
||||||
void gcal_weather_service_run (GcalWeatherService *self,
|
void gcal_weather_service_run (GcalWeatherService *self,
|
||||||
GWeatherLocation *location);
|
GWeatherLocation *location);
|
||||||
@@ -50,6 +50,8 @@ guint gcal_weather_service_get_max_days (GcalWeatherService
|
|||||||
|
|
||||||
guint gcal_weather_service_get_check_interval (GcalWeatherService *self);
|
guint gcal_weather_service_get_check_interval (GcalWeatherService *self);
|
||||||
|
|
||||||
|
GSList* gcal_weather_service_get_weather_infos (GcalWeatherService *self);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user