weather-settings: Improve start/stop logic

This commit is contained in:
Georges Basile Stavracas Neto
2018-01-27 21:56:58 -02:00
parent 5dddff9939
commit 6dc3d9ee39
+16 -13
View File
@@ -16,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#define G_LOG_DOMAIN "GcalWeatherSettings"
#include "gcal-debug.h"
#include "gcal-manager.h" #include "gcal-manager.h"
#include "gcal-utils.h" #include "gcal-utils.h"
#include "gcal-weather-service.h" #include "gcal-weather-service.h"
@@ -178,30 +181,30 @@ get_checked_fixed_location (GcalWeatherSettings *self)
static void static void
manage_weather_service (GcalWeatherSettings *self) manage_weather_service (GcalWeatherSettings *self)
{
GCAL_ENTRY;
if (gtk_switch_get_active (self->show_weather_switch))
{ {
g_autoptr (GWeatherLocation) location = NULL; g_autoptr (GWeatherLocation) location = NULL;
gcal_weather_service_stop (self->weather_service); if (!gtk_switch_get_active (self->weather_auto_location_switch))
if (!gtk_switch_get_active (self->show_weather_switch))
return;
if (gtk_switch_get_active (self->weather_auto_location_switch))
{ {
gcal_weather_service_run (self->weather_service, NULL);
return;
}
location = get_checked_fixed_location (self); location = get_checked_fixed_location (self);
if (!location) if (!location)
{
/* TODO: this one should get reported to users */
g_warning ("Unknown location '%s' selected", gtk_entry_get_text (GTK_ENTRY (self->weather_location_entry))); g_warning ("Unknown location '%s' selected", gtk_entry_get_text (GTK_ENTRY (self->weather_location_entry)));
return;
} }
gcal_weather_service_run (self->weather_service, location); gcal_weather_service_run (self->weather_service, location);
} }
else
{
gcal_weather_service_stop (self->weather_service);
}
GCAL_EXIT;
}
/* /*