weather-service: More small refactorings
Now it appears to be fully funcitonal again!
This commit is contained in:
@@ -724,9 +724,7 @@ on_gclue_simple_creation_cb (GClueSimple *_source,
|
|||||||
{
|
{
|
||||||
g_assert_null (self->location_service);
|
g_assert_null (self->location_service);
|
||||||
|
|
||||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||||
/* Cancelled during creation. Silently fail. */;
|
|
||||||
else
|
|
||||||
g_warning ("Could not create GCLueSimple: %s", error->message);
|
g_warning ("Could not create GCLueSimple: %s", error->message);
|
||||||
|
|
||||||
GCAL_RETURN ();
|
GCAL_RETURN ();
|
||||||
@@ -754,16 +752,15 @@ on_gclue_simple_creation_cb (GClueSimple *_source,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_gclue_client_stop (GClueClient *client,
|
on_gclue_client_stopped_cb (GClueClient *client,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GClueSimple *simple)
|
GClueSimple *simple)
|
||||||
{
|
{
|
||||||
g_autoptr (GError) error = NULL;
|
g_autoptr (GError) error = NULL;
|
||||||
gboolean stopped;
|
gboolean stopped;
|
||||||
|
|
||||||
stopped = gclue_client_call_stop_finish (client,
|
stopped = gclue_client_call_stop_finish (client, res, &error);
|
||||||
res,
|
|
||||||
&error);
|
|
||||||
if (error)
|
if (error)
|
||||||
g_warning ("Could not stop location service: %s", error->message);
|
g_warning ("Could not stop location service: %s", error->message);
|
||||||
else if (!stopped)
|
else if (!stopped)
|
||||||
@@ -1323,11 +1320,12 @@ gcal_weather_service_run (GcalWeatherService *self,
|
|||||||
|
|
||||||
g_debug ("Starting weather service");
|
g_debug ("Starting weather service");
|
||||||
|
|
||||||
|
self->weather_service_running = TRUE;
|
||||||
|
|
||||||
if (!location)
|
if (!location)
|
||||||
{
|
{
|
||||||
/* Start location and weather service: */
|
/* Start location and weather service: */
|
||||||
self->location_service_running = TRUE;
|
self->location_service_running = TRUE;
|
||||||
self->weather_service_running = TRUE;
|
|
||||||
|
|
||||||
g_cancellable_cancel (self->location_cancellable);
|
g_cancellable_cancel (self->location_cancellable);
|
||||||
g_cancellable_reset (self->location_cancellable);
|
g_cancellable_reset (self->location_cancellable);
|
||||||
@@ -1336,13 +1334,11 @@ gcal_weather_service_run (GcalWeatherService *self,
|
|||||||
GCLUE_ACCURACY_LEVEL_EXACT,
|
GCLUE_ACCURACY_LEVEL_EXACT,
|
||||||
self->location_cancellable,
|
self->location_cancellable,
|
||||||
(GAsyncReadyCallback) on_gclue_simple_creation_cb,
|
(GAsyncReadyCallback) on_gclue_simple_creation_cb,
|
||||||
g_object_ref (self));
|
self);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Use the given location to retrieve weather information: */
|
|
||||||
self->location_service_running = FALSE;
|
self->location_service_running = FALSE;
|
||||||
self->weather_service_running = TRUE;
|
|
||||||
|
|
||||||
/*_update_location starts timer if necessary */
|
/*_update_location starts timer if necessary */
|
||||||
update_location (self, location);
|
update_location (self, location);
|
||||||
@@ -1383,8 +1379,10 @@ gcal_weather_service_stop (GcalWeatherService *self)
|
|||||||
{
|
{
|
||||||
gclue_client_call_stop (gclue_simple_get_client (self->location_service),
|
gclue_client_call_stop (gclue_simple_get_client (self->location_service),
|
||||||
self->location_cancellable,
|
self->location_cancellable,
|
||||||
(GAsyncReadyCallback) on_gclue_client_stop,
|
(GAsyncReadyCallback) on_gclue_client_stopped_cb,
|
||||||
g_steal_pointer (&self->location_service));
|
self->location_service);
|
||||||
|
|
||||||
|
self->location_service = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
GCAL_EXIT;
|
GCAL_EXIT;
|
||||||
|
|||||||
@@ -382,8 +382,10 @@ gcal_weather_settings_set_weather_service (GcalWeatherSettings *self,
|
|||||||
{
|
{
|
||||||
g_return_if_fail (GCAL_IS_WEATHER_SETTINGS (self));
|
g_return_if_fail (GCAL_IS_WEATHER_SETTINGS (self));
|
||||||
|
|
||||||
|
GCAL_ENTRY;
|
||||||
|
|
||||||
if (!g_set_object (&self->weather_service, service))
|
if (!g_set_object (&self->weather_service, service))
|
||||||
return;
|
GCAL_RETURN ();
|
||||||
|
|
||||||
/* Recover weather settings */
|
/* Recover weather settings */
|
||||||
load_weather_settings (self);
|
load_weather_settings (self);
|
||||||
@@ -391,4 +393,6 @@ gcal_weather_settings_set_weather_service (GcalWeatherSettings *self,
|
|||||||
manage_weather_service (self);
|
manage_weather_service (self);
|
||||||
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_WEATHER_SERVICE]);
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_WEATHER_SERVICE]);
|
||||||
|
|
||||||
|
GCAL_EXIT;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user