diff options
author | Benjamin Otte <otte@redhat.com> | 2017-11-04 19:09:17 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2017-11-05 00:07:17 +0100 |
commit | b12a53406d9ff87421410ed08ffb46c0409f16a8 (patch) | |
tree | 34a2c1708449e345925763f070544ae4c2ba546a /gtk/gtkbuilder.c | |
parent | 2d959553e9de3dd11778c7fc22b8d759de90b729 (diff) | |
download | gtk+-b12a53406d9ff87421410ed08ffb46c0409f16a8.tar.gz |
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.
Diffstat (limited to 'gtk/gtkbuilder.c')
-rw-r--r-- | gtk/gtkbuilder.c | 15 |
1 files 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)); } |