summaryrefslogtreecommitdiff
path: root/gtk/tools
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-02-08 10:22:54 -0500
committerMatthias Clasen <mclasen@redhat.com>2020-02-08 10:22:54 -0500
commit2f17ab3ce76266062be180ca022ce2fbbc3fea02 (patch)
tree0ced3c5a37c7c3d7f7593131426acc941c1a6c72 /gtk/tools
parent55b60f6da90ac279ffb62081144f20f726a9a8ce (diff)
downloadgtk+-2f17ab3ce76266062be180ca022ce2fbbc3fea02.tar.gz
Avoid mime sniffing where possible
When we are loading symbolic pngs or svgs, we know that we need to the png or svg loader, so there is no need to go through (surprisingly expensive) mime sniffing to find the right loader.
Diffstat (limited to 'gtk/tools')
-rw-r--r--gtk/tools/gdkpixbufutils.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/gtk/tools/gdkpixbufutils.c b/gtk/tools/gdkpixbufutils.c
index c706d720a8..1bbde140ba 100644
--- a/gtk/tools/gdkpixbufutils.c
+++ b/gtk/tools/gdkpixbufutils.c
@@ -561,6 +561,19 @@ gtk_make_symbolic_pixbuf_from_file (GFile *file,
}
GdkTexture *
+gtk_load_symbolic_texture_from_resource (const char *path)
+{
+ GdkPixbuf *pixbuf;
+ GdkTexture *texture;
+
+ pixbuf = _gdk_pixbuf_new_from_resource (path, "png", NULL);
+ texture = gdk_texture_new_for_pixbuf (pixbuf);
+ g_object_unref (pixbuf);
+
+ return texture;
+}
+
+GdkTexture *
gtk_make_symbolic_texture_from_resource (const char *path,
int width,
int height,
@@ -581,6 +594,28 @@ gtk_make_symbolic_texture_from_resource (const char *path,
}
GdkTexture *
+gtk_load_symbolic_texture_from_file (GFile *file)
+{
+ GdkPixbuf *pixbuf;
+ GdkTexture *texture;
+ GInputStream *stream;
+
+ stream = G_INPUT_STREAM (g_file_read (file, NULL, NULL));
+ if (stream == NULL)
+ return NULL;
+
+ pixbuf = _gdk_pixbuf_new_from_stream (stream, "png", NULL, NULL);
+ g_object_unref (stream);
+ if (pixbuf == NULL)
+ return NULL;
+
+ texture = gdk_texture_new_for_pixbuf (pixbuf);
+ g_object_unref (pixbuf);
+
+ return texture;
+}
+
+GdkTexture *
gtk_make_symbolic_texture_from_file (GFile *file,
int width,
int height,