summaryrefslogtreecommitdiff
path: root/gdk/gdktexture.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-09-14 08:52:35 -0400
committerBenjamin Otte <otte@redhat.com>2021-09-17 00:25:22 +0200
commitf2ca9ebbd7d5ff0b92d47c1f56b2d4a25d52bb16 (patch)
treea647c350e1e2cae29072556086f468a7c6627013 /gdk/gdktexture.c
parent577bf104c0a086e254634c26a1c4fb534dc69f1b (diff)
downloadgtk+-f2ca9ebbd7d5ff0b92d47c1f56b2d4a25d52bb16.tar.gz
texture: Avoid pixbufs when loading resources
We can just use our own loaders here now.
Diffstat (limited to 'gdk/gdktexture.c')
-rw-r--r--gdk/gdktexture.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/gdk/gdktexture.c b/gdk/gdktexture.c
index ea186a8bc0..261652ec41 100644
--- a/gdk/gdktexture.c
+++ b/gdk/gdktexture.c
@@ -354,18 +354,23 @@ gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf)
GdkTexture *
gdk_texture_new_from_resource (const char *resource_path)
{
- GError *error = NULL;
+ GBytes *bytes;
GdkTexture *texture;
- GdkPixbuf *pixbuf;
+ GError *error = NULL;
g_return_val_if_fail (resource_path != NULL, NULL);
- pixbuf = gdk_pixbuf_new_from_resource (resource_path, &error);
- if (pixbuf == NULL)
- g_error ("Resource path %s is not a valid image: %s", resource_path, error->message);
+ bytes = g_resources_lookup_data (resource_path, 0, &error);
+ if (bytes != NULL)
+ {
+ texture = gdk_texture_new_from_bytes (bytes, &error);
+ g_bytes_unref (bytes);
+ }
+ else
+ texture = NULL;
- texture = gdk_texture_new_for_pixbuf (pixbuf);
- g_object_unref (pixbuf);
+ if (texture == NULL)
+ g_error ("Resource path %s s not a valid image: %s", resource_path, error->message);
return texture;
}