application: Add CSS provider on startup

GTK isn't fully initialized on init, so move that to startup.
This commit is contained in:
Georges Basile Stavracas Neto 2021-10-19 20:58:49 -03:00
parent e42a819723
commit 15a67221a0

View file

@ -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 *