mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 05:31:07 +00:00
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:
parent
3f7f9b705e
commit
c033de9b83
@ -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 *
|
||||
|
Loading…
Reference in New Issue
Block a user