From 7c13d3f179c6428f5fa47e3d4d218f322a400992 Mon Sep 17 00:00:00 2001 From: Mohammed Sadiq Date: Tue, 19 Jan 2021 21:19:08 +0530 Subject: [PATCH] application: Simplify loading css And fix a memory leak. --- src/calls-application.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/calls-application.c b/src/calls-application.c index 25bb960..b6ba3b8 100644 --- a/src/calls-application.c +++ b/src/calls-application.c @@ -276,31 +276,10 @@ static const GActionEntry actions[] = }; -static void -css_setup () -{ - GtkCssProvider *provider; - GFile *file; - GError *error = NULL; - - provider = gtk_css_provider_new (); - file = g_file_new_for_uri ("resource:///sm/puri/calls/style.css"); - - if (!gtk_css_provider_load_from_file (provider, file, &error)) { - g_warning ("Failed to load CSS file: %s", error->message); - g_clear_error (&error); - g_object_unref (file); - return; - } - gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), - GTK_STYLE_PROVIDER (provider), 600); - g_object_unref (file); -} - - static void startup (GApplication *application) { + g_autoptr(GtkCssProvider) provider = NULL; GtkIconTheme *icon_theme; g_autoptr(GError) error = NULL; @@ -324,7 +303,11 @@ startup (GApplication *application) G_N_ELEMENTS (actions), application); - css_setup (); + provider = gtk_css_provider_new (); + gtk_css_provider_load_from_resource (provider, "/sm/puri/calls/style.css"); + gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); }