[gnome-control-center/gbsneto/gtk4: 4/31] application: Add CSS provider on startup




commit ece398bd89694de5e44a824f8531409ac70813ba
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Oct 19 20:58:49 2021 -0300

    application: Add CSS provider on startup
    
    GTK isn't fully initialized on init, so move that to startup.

 shell/cc-application.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/shell/cc-application.c b/shell/cc-application.c
index da0237b99..11c019419 100644
--- a/shell/cc-application.c
+++ b/shell/cc-application.c
@@ -216,6 +216,7 @@ cc_application_startup (GApplication *application)
 {
   CcApplication *self = CC_APPLICATION (application);
   const gchar *help_accels[] = { "F1", NULL };
+  g_autoptr(GtkCssProvider) provider = NULL;
 
   g_action_map_add_action_entries (G_ACTION_MAP (self),
                                    cc_app_actions,
@@ -229,6 +230,12 @@ cc_application_startup (GApplication *application)
 
   self->model = cc_shell_model_new ();
   self->window = cc_window_new (GTK_APPLICATION (application), self->model);
+
+  provider = gtk_css_provider_new ();
+  gtk_css_provider_load_from_resource (provider, "/org/gnome/ControlCenter/gtk/style.css");
+  gtk_style_context_add_provider_for_display (gdk_display_get_default (),
+                                              GTK_STYLE_PROVIDER (provider),
+                                              GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 }
 
 static void
@@ -276,17 +283,9 @@ cc_application_class_init (CcApplicationClass *klass)
 static void
 cc_application_init (CcApplication *self)
 {
-  g_autoptr(GtkCssProvider) provider = NULL;
-
   cc_object_storage_initialize ();
 
   g_application_add_main_option_entries (G_APPLICATION (self), all_options);
-
-  provider = gtk_css_provider_new ();
-  gtk_css_provider_load_from_resource (provider, "/org/gnome/ControlCenter/gtk/style.css");
-  gtk_style_context_add_provider_for_display (gdk_display_get_default (),
-                                              GTK_STYLE_PROVIDER (provider),
-                                              GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 }
 
 GtkApplication *


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