1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-12 15:47:35 +00:00

application: Simplify loading css

And fix a memory leak.
This commit is contained in:
Mohammed Sadiq 2021-01-19 21:19:08 +05:30 committed by Guido Gunther
parent acbbe4697f
commit 7c13d3f179

View file

@ -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 static void
startup (GApplication *application) startup (GApplication *application)
{ {
g_autoptr(GtkCssProvider) provider = NULL;
GtkIconTheme *icon_theme; GtkIconTheme *icon_theme;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
@ -324,7 +303,11 @@ startup (GApplication *application)
G_N_ELEMENTS (actions), G_N_ELEMENTS (actions),
application); 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);
} }