From b8b33d1f364bf8a635a24eb617d0ea6a99e4c42a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 30 Nov 2017 07:54:27 -0500 Subject: [PATCH] Make texture variants of some pixbuf utils This will let us avoid direct pixbuf use in some places. --- gtk/gdkpixbufutils.c | 34 ++++++++++++++++++++++++++++++++++ gtk/gdkpixbufutilsprivate.h | 12 +++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/gtk/gdkpixbufutils.c b/gtk/gdkpixbufutils.c index ae57455d7f..b47ebf9df8 100644 --- a/gtk/gdkpixbufutils.c +++ b/gtk/gdkpixbufutils.c @@ -355,3 +355,37 @@ gtk_make_symbolic_pixbuf_from_file (GFile *file, return pixbuf; } + +GdkTexture * +gtk_make_symbolic_texture_from_resource (const char *path, + int width, + int height, + double scale, + GError **error) +{ + GdkPixbuf *pixbuf; + GdkTexture *texture; + + pixbuf = gtk_make_symbolic_pixbuf_from_resource (path, width, height, scale, error); + 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, + double scale, + GError **error) +{ + GdkPixbuf *pixbuf; + GdkTexture *texture; + + pixbuf = gtk_make_symbolic_pixbuf_from_file (file, width, height, scale, error); + texture = gdk_texture_new_for_pixbuf (pixbuf); + g_object_unref (pixbuf); + + return texture; +} diff --git a/gtk/gdkpixbufutilsprivate.h b/gtk/gdkpixbufutilsprivate.h index 8e398e1be0..a11ce9bc96 100644 --- a/gtk/gdkpixbufutilsprivate.h +++ b/gtk/gdkpixbufutilsprivate.h @@ -18,7 +18,7 @@ #ifndef __GDK_PIXBUF_UTILS_PRIVATE_H__ #define __GDK_PIXBUF_UTILS_PRIVATE_H__ -#include +#include G_BEGIN_DECLS @@ -46,6 +46,16 @@ GdkPixbuf *gtk_make_symbolic_pixbuf_from_resource (const char *path, int height, double scale, GError **error); +GdkTexture *gtk_make_symbolic_texture_from_file (GFile *file, + int width, + int height, + double scale, + GError **error); +GdkTexture *gtk_make_symbolic_texture_from_resource (const char *path, + int width, + int height, + double scale, + GError **error); G_END_DECLS #endif /* __GDK_PIXBUF_UTILS_PRIVATE_H__ */