summaryrefslogtreecommitdiff
path: root/gdk/gdktexture.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2021-09-15 22:08:33 +0200
committerBenjamin Otte <otte@redhat.com>2021-09-16 23:59:37 +0200
commit75dfb4d63b955420fa82d4b5e89f6f9e6c4caa68 (patch)
tree58ed682bb548214e91f2d90ff773eaf82d5d72e8 /gdk/gdktexture.c
parent64acaf99fb7ab2218d0da62dc7db495c259eb76a (diff)
downloadgtk+-75dfb4d63b955420fa82d4b5e89f6f9e6c4caa68.tar.gz
API: Add gdk_texture_new_from_filename()
There are quite a few places where we can make use of it, in particular in the testsuite and icontheme.
Diffstat (limited to 'gdk/gdktexture.c')
-rw-r--r--gdk/gdktexture.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gdk/gdktexture.c b/gdk/gdktexture.c
index edcf7a9d9c..ec03c72370 100644
--- a/gdk/gdktexture.c
+++ b/gdk/gdktexture.c
@@ -442,6 +442,39 @@ gdk_texture_new_from_bytes (GBytes *bytes,
}
/**
+ * gdk_texture_new_from_filename:
+ * @path: (type filename): the filename to load
+ * @error: Return location for an error
+ *
+ * Creates a new texture by loading an image from a file.
+ *
+ * The file format is detected automatically. The supported formats
+ * are PNG and JPEG, though more formats might be available.
+ *
+ * If %NULL is returned, then @error will be set.
+ *
+ * Return value: A newly-created `GdkTexture`
+ */
+GdkTexture *
+gdk_texture_new_from_filename (const char *path,
+ GError **error)
+{
+ GdkTexture *texture;
+ GFile *file;
+
+ g_return_val_if_fail (path, NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ file = g_file_new_for_path (path);
+
+ texture = gdk_texture_new_from_file (file, error);
+
+ g_object_unref (file);
+
+ return texture;
+}
+
+/**
* gdk_texture_get_width: (attributes org.gtk.Method.get_property=width)
* @texture: a `GdkTexture`
*