[gnome-calendar] application: Only add CSS providers once



commit 52ef8ff6bf2a978d641b815d46ab1398e5f7108e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Aug 19 14:25:13 2021 -0300

    application: Only add CSS providers once
    
    Instead of adding the color CSS provider over and over on
    every activation, only add it once. Also make sure to start
    the manager after doing that.

 src/gui/gcal-application.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)
---
diff --git a/src/gui/gcal-application.c b/src/gui/gcal-application.c
index 49ab85b9..a6f33389 100644
--- a/src/gui/gcal-application.c
+++ b/src/gui/gcal-application.c
@@ -369,16 +369,6 @@ gcal_application_activate (GApplication *application)
 
   self = GCAL_APPLICATION (application);
 
-  if (!self->provider)
-    load_css_provider (self);
-
-  if (self->colors_provider)
-    {
-      gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
-                                                 GTK_STYLE_PROVIDER (self->colors_provider),
-                                                 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 2);
-    }
-
   if (!self->window)
     {
       if (!self->initial_date)
@@ -438,11 +428,6 @@ gcal_application_startup (GApplication *app)
 
   G_APPLICATION_CLASS (gcal_application_parent_class)->startup (app);
 
-  self->colors_provider = gtk_css_provider_new ();
-
-  /* Startup the manager */
-  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)
     g_application_set_inactivity_timeout (app, 3 * 60 * 1000);
@@ -450,6 +435,17 @@ gcal_application_startup (GApplication *app)
   /*  initialize libhandy */
   hdy_init();
 
+  /* CSS */
+  load_css_provider (self);
+
+  self->colors_provider = gtk_css_provider_new ();
+  gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
+                                             GTK_STYLE_PROVIDER (self->colors_provider),
+                                             GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 2);
+
+  /* Startup the manager */
+  gcal_context_startup (self->context);
+
   GCAL_EXIT;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]