From b12a53406d9ff87421410ed08ffb46c0409f16a8 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 4 Nov 2017 19:09:17 +0100 Subject: [PATCH] builder: Mirror GdkPixbuf abilities for GdkTexture In particular, allow specifying a filename for a GDK_TYPE_TEXTURE property. This makes it easy to transition properties from Pixbuf type to Texture type without having to touch resource files. --- gtk/gtkbuilder.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c index eda155563c..a548f00582 100644 --- a/gtk/gtkbuilder.c +++ b/gtk/gtkbuilder.c @@ -530,6 +530,7 @@ gtk_builder_get_parameters (GtkBuilder *builder, if (G_IS_PARAM_SPEC_OBJECT (prop->pspec) && (G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_PIXBUF) && + (G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_TEXTURE) && (G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != G_TYPE_FILE)) { GObject *object = g_hash_table_lookup (builder->priv->objects, @@ -2084,7 +2085,8 @@ gtk_builder_value_from_string_type (GtkBuilder *builder, break; case G_TYPE_OBJECT: case G_TYPE_INTERFACE: - if (G_VALUE_HOLDS (value, GDK_TYPE_PIXBUF)) + if (G_VALUE_HOLDS (value, GDK_TYPE_PIXBUF) || + G_VALUE_HOLDS (value, GDK_TYPE_TEXTURE)) { gchar *filename; GError *tmp_error = NULL; @@ -2136,7 +2138,16 @@ gtk_builder_value_from_string_type (GtkBuilder *builder, if (pixbuf) { - g_value_set_object (value, pixbuf); + if (G_VALUE_HOLDS (value, GDK_TYPE_TEXTURE)) + { + GdkTexture *texture = gdk_texture_new_for_pixbuf (pixbuf); + g_value_set_object (value, texture); + g_object_unref (texture); + } + else + { + g_value_set_object (value, pixbuf); + } g_object_unref (G_OBJECT (pixbuf)); }