From da3a903d1eb0b7229480470707ae8aa461384998 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Thu, 25 Apr 2019 16:26:35 -0300 Subject: [PATCH] application: Delay context initialization --- src/gcal-application.c | 3 ++- src/gcal-context-private.h | 29 +++++++++++++++++++++++++++++ src/gcal-context.c | 13 +++++++++++-- 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 src/gcal-context-private.h diff --git a/src/gcal-application.c b/src/gcal-application.c index 779ae430..f099498a 100644 --- a/src/gcal-application.c +++ b/src/gcal-application.c @@ -23,6 +23,7 @@ #include "css-code.h" #include "gcal-application.h" +#include "gcal-context-private.h" #include "gcal-debug.h" #include "gcal-log.h" #include "gcal-shell-search-provider.h" @@ -311,7 +312,7 @@ gcal_application_startup (GApplication *app) self->colors_provider = gtk_css_provider_new (); /* Startup the manager */ - gcal_manager_startup (gcal_context_get_manager (self->context)); + gcal_context_startup (self->context); /* We're assuming the application is called as a service only by the shell search system */ if ((g_application_get_flags (app) & G_APPLICATION_IS_SERVICE) != 0) diff --git a/src/gcal-context-private.h b/src/gcal-context-private.h new file mode 100644 index 00000000..db163624 --- /dev/null +++ b/src/gcal-context-private.h @@ -0,0 +1,29 @@ +/* gcal-context-private.h + * + * Copyright 2019 Georges Basile Stavracas Neto + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include "gcal-context.h" + +G_BEGIN_DECLS + +void gcal_context_startup (GcalContext *self); + +G_END_DECLS diff --git a/src/gcal-context.c b/src/gcal-context.c index 2eacdde9..a49365bb 100644 --- a/src/gcal-context.c +++ b/src/gcal-context.c @@ -245,8 +245,6 @@ gcal_context_init (GcalContext *self) self->settings = g_settings_new ("org.gnome.calendar"); self->weather_service = gcal_weather_service_new (); - self->night_light_monitor = gcal_night_light_monitor_new (self); - self->timezone_monitor = gcal_time_zone_monitor_new (); g_signal_connect_object (self->timezone_monitor, "notify::timezone", @@ -382,3 +380,14 @@ gcal_context_get_weather_service (GcalContext *self) return self->weather_service; } + +void +gcal_context_startup (GcalContext *self) +{ + g_return_if_fail (GCAL_IS_CONTEXT (self)); + + /* Night Light requires GTK to be initialized */ + self->night_light_monitor = gcal_night_light_monitor_new (self); + + gcal_manager_startup (self->manager); +}