css: Simplify theme loading

There is no need to do a detour through a GFile here.
Just load the resource.
This commit is contained in:
Matthias Clasen 2024-09-05 23:08:50 -04:00
parent 3f7f9b705e
commit c033de9b83

View File

@ -1418,25 +1418,18 @@ gtk_css_provider_load_from_path (GtkCssProvider *css_provider,
*/
void
gtk_css_provider_load_from_resource (GtkCssProvider *css_provider,
const char *resource_path)
const char *resource_path)
{
GFile *file;
char *uri, *escaped;
GBytes *bytes;
g_return_if_fail (GTK_IS_CSS_PROVIDER (css_provider));
g_return_if_fail (resource_path != NULL);
escaped = g_uri_escape_string (resource_path,
G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, FALSE);
uri = g_strconcat ("resource://", escaped, NULL);
g_free (escaped);
bytes = g_resources_lookup_data (resource_path, G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
file = g_file_new_for_uri (uri);
g_free (uri);
gtk_css_provider_load_from_bytes (css_provider, bytes);
gtk_css_provider_load_from_file (css_provider, file);
g_object_unref (file);
g_bytes_unref (bytes);
}
char *