From c033de9b83315abf1688fe5b3689461e30d9ffc7 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 5 Sep 2024 23:08:50 -0400 Subject: [PATCH] css: Simplify theme loading There is no need to do a detour through a GFile here. Just load the resource. --- gtk/gtkcssprovider.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 34ab188987..0c1e7e0a57 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -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 *