forked from AuroraMiddleware/gtk
texture: Avoid pixbufs when loading resources
We can just use our own loaders here now.
This commit is contained in:
parent
577bf104c0
commit
f2ca9ebbd7
@ -354,18 +354,23 @@ gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf)
|
|||||||
GdkTexture *
|
GdkTexture *
|
||||||
gdk_texture_new_from_resource (const char *resource_path)
|
gdk_texture_new_from_resource (const char *resource_path)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GBytes *bytes;
|
||||||
GdkTexture *texture;
|
GdkTexture *texture;
|
||||||
GdkPixbuf *pixbuf;
|
GError *error = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (resource_path != NULL, NULL);
|
g_return_val_if_fail (resource_path != NULL, NULL);
|
||||||
|
|
||||||
pixbuf = gdk_pixbuf_new_from_resource (resource_path, &error);
|
bytes = g_resources_lookup_data (resource_path, 0, &error);
|
||||||
if (pixbuf == NULL)
|
if (bytes != NULL)
|
||||||
g_error ("Resource path %s is not a valid image: %s", resource_path, error->message);
|
{
|
||||||
|
texture = gdk_texture_new_from_bytes (bytes, &error);
|
||||||
|
g_bytes_unref (bytes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
texture = NULL;
|
||||||
|
|
||||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
if (texture == NULL)
|
||||||
g_object_unref (pixbuf);
|
g_error ("Resource path %s s not a valid image: %s", resource_path, error->message);
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user