[gtk+] builder: Mirror GdkPixbuf abilities for GdkTexture
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] builder: Mirror GdkPixbuf abilities for GdkTexture
- Date: Sat, 4 Nov 2017 23:12:13 +0000 (UTC)
commit b12a53406d9ff87421410ed08ffb46c0409f16a8
Author: Benjamin Otte <otte redhat com>
Date: Sat Nov 4 19:09:17 2017 +0100
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 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index eda1555..a548f00 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));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]