From 3c219bf968fe698269e54896715066acba23db16 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 18 Oct 2019 07:46:52 -0500 Subject: [PATCH] Add another symbolic pixbuf helper --- gtk/gdkpixbufutilsprivate.h | 5 +++++ gtk/tools/gdkpixbufutils.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/gtk/gdkpixbufutilsprivate.h b/gtk/gdkpixbufutilsprivate.h index 592bc9ea59..bd6125ea52 100644 --- a/gtk/gdkpixbufutilsprivate.h +++ b/gtk/gdkpixbufutilsprivate.h @@ -63,6 +63,11 @@ GdkPixbuf *gtk_make_symbolic_pixbuf_from_file (GFile *file, int height, double scale, GError **error); +GdkPixbuf *gtk_make_symbolic_pixbuf_from_path (const char *path, + int width, + int height, + double scale, + GError **error); GdkPixbuf *gtk_make_symbolic_pixbuf_from_resource (const char *path, int width, int height, diff --git a/gtk/tools/gdkpixbufutils.c b/gtk/tools/gdkpixbufutils.c index a572f48a82..ae2684adb2 100644 --- a/gtk/tools/gdkpixbufutils.c +++ b/gtk/tools/gdkpixbufutils.c @@ -425,6 +425,27 @@ gtk_make_symbolic_pixbuf_from_resource (const char *path, return pixbuf; } +GdkPixbuf * +gtk_make_symbolic_pixbuf_from_path (const char *path, + int width, + int height, + double scale, + GError **error) +{ + char *data; + gsize size; + GdkPixbuf *pixbuf; + + if (!g_file_get_contents (path, &data, &size, error)) + return NULL; + + pixbuf = gtk_make_symbolic_pixbuf_from_data (data, size, width, height, scale, error); + + g_free (data); + + return pixbuf; +} + GdkPixbuf * gtk_make_symbolic_pixbuf_from_file (GFile *file, int width,