[gnome-calendar/wip/flb/weather-forecast: 14/50] weather: Pin weather services to applications.
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/wip/flb/weather-forecast: 14/50] weather: Pin weather services to applications.
- Date: Tue, 31 Oct 2017 08:19:00 +0000 (UTC)
commit 0d950578c0646817b5a6d0e971dcfb135e84f5ae
Author: Florian Brosch <flo brosch gmail com>
Date: Thu Oct 12 23:51:57 2017 +0200
weather: Pin weather services to applications.
src/gcal-application.c | 30 +++++++++++++++++++++++++++++-
src/gcal-application.h | 3 +++
2 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/src/gcal-application.c b/src/gcal-application.c
index 1aa9ca0..ce74883 100644
--- a/src/gcal-application.c
+++ b/src/gcal-application.c
@@ -37,6 +37,9 @@
#define CSS_FILE "/org/gnome/calendar/gtk-styles.css"
+#define WEATHER_CHECK_INTERVAL 7200 /* seconds */
+#define FORECAST_MAX_DAYS 3
+
struct _GcalApplication
{
GtkApplication parent;
@@ -51,6 +54,12 @@ struct _GcalApplication
gchar *uuid;
icaltimetype *initial_date;
+ /* Weather service exists as long as #GcalApplication.
+ * However, it only runs if #GcalApplicatoin->window
+ * is available.
+ */
+ GcalWeatherService *weather_service; /* owned */
+
GcalShellSearchProvider *search_provider;
};
@@ -169,6 +178,7 @@ gcal_application_finalize (GObject *object)
g_clear_object (&self->colors_provider);
g_clear_object (&self->manager);
+ g_clear_object (&self->weather_service);
g_clear_object (&self->search_provider);
G_OBJECT_CLASS (gcal_application_parent_class)->finalize (object);
@@ -391,7 +401,9 @@ gcal_application_init (GcalApplication *self)
self->manager = gcal_manager_new ();
g_signal_connect_swapped (self->manager, "source-added", G_CALLBACK (process_sources), self);
g_signal_connect_swapped (self->manager, "source-changed", G_CALLBACK (process_sources), self);
-
+ self->weather_service = gcal_weather_service_new (NULL, /* in prep. for configurable time zones */
+ FORECAST_MAX_DAYS,
+ WEATHER_CHECK_INTERVAL);
self->search_provider = gcal_shell_search_provider_new ();
gcal_shell_search_provider_connect (self->search_provider, self->manager);
}
@@ -516,6 +528,22 @@ gcal_application_get_manager (GcalApplication *self)
return self->manager;
}
+/**
+ * gcal_application_get_weather_service:
+ * @self: A #GcalApplication
+ *
+ * Provides the #GcalWeatherService used by this application.
+ *
+ * Returns: (transfer none): A #GcalWeatehrService
+ */
+GcalWeatherService*
+gcal_application_get_weather_service (GcalApplication *self)
+{
+ g_return_val_if_fail (GCAL_IS_APPLICATION (self), NULL);
+
+ return self->weather_service;
+}
+
void
gcal_application_set_uuid (GcalApplication *self,
const gchar *app_uuid)
diff --git a/src/gcal-application.h b/src/gcal-application.h
index 9dc369d..224f192 100644
--- a/src/gcal-application.h
+++ b/src/gcal-application.h
@@ -20,6 +20,7 @@
#ifndef _GCAL_APPLICATION_H_
#define _GCAL_APPLICATION_H_
+#include "gcal-weather-service.h"
#include "gcal-manager.h"
#include <gtk/gtk.h>
@@ -34,6 +35,8 @@ GcalApplication* gcal_application_new (void);
GcalManager* gcal_application_get_manager (GcalApplication *self);
+GcalWeatherService* gcal_application_get_weather_service (GcalApplication *self);
+
void gcal_application_set_uuid (GcalApplication *self,
const gchar *app_uuid);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]