weather: Pin weather services to applications.

This commit is contained in:
Florian Brosch
2017-12-11 21:25:16 -02:00
committed by Georges Basile Stavracas Neto
parent 4ffbf68b23
commit 950a2cda8f
2 changed files with 32 additions and 1 deletions
+29 -1
View File
@@ -35,6 +35,9 @@
#include <gio/gio.h>
#include <glib/gi18n.h>
#define WEATHER_CHECK_INTERVAL 7200 /* seconds */
#define FORECAST_MAX_DAYS 3
struct _GcalApplication
{
GtkApplication parent;
@@ -49,6 +52,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;
};
@@ -198,6 +207,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);
@@ -412,7 +422,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);
}
@@ -537,6 +549,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)
+3
View File
@@ -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);