[gtk/listview-for-merge: 151/180] xxx: Add a hack to make paintables transform to/from objects



commit dcc45dfa7d73e92e4d03998153c901c7b6cb0c84
Author: Benjamin Otte <otte redhat com>
Date:   Tue Nov 26 06:09:20 2019 +0100

    xxx: Add a hack to make paintables transform to/from objects
    
    See also: https://gitlab.gnome.org/GNOME/glib/merge_requests/1251

 gdk/gdkpaintable.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
---
diff --git a/gdk/gdkpaintable.c b/gdk/gdkpaintable.c
index fc91762784..56b13bcd95 100644
--- a/gdk/gdkpaintable.c
+++ b/gdk/gdkpaintable.c
@@ -136,6 +136,16 @@ static double gdk_paintable_default_get_intrinsic_aspect_ratio (GdkPaintable *pa
   return (double) width / height;
 };
 
+static void
+g_value_object_transform_value (const GValue *src_value,
+                               GValue       *dest_value)
+{
+  if (src_value->data[0].v_pointer && g_type_is_a (G_OBJECT_TYPE (src_value->data[0].v_pointer), 
G_VALUE_TYPE (dest_value)))
+    dest_value->data[0].v_pointer = g_object_ref (src_value->data[0].v_pointer);
+  else
+    dest_value->data[0].v_pointer = NULL;
+}
+
 static void
 gdk_paintable_default_init (GdkPaintableInterface *iface)
 {
@@ -146,6 +156,9 @@ gdk_paintable_default_init (GdkPaintableInterface *iface)
   iface->get_intrinsic_height = gdk_paintable_default_get_intrinsic_height;
   iface->get_intrinsic_aspect_ratio = gdk_paintable_default_get_intrinsic_aspect_ratio;
 
+  g_value_register_transform_func (G_TYPE_OBJECT, GDK_TYPE_PAINTABLE, g_value_object_transform_value);
+  g_value_register_transform_func (GDK_TYPE_PAINTABLE, G_TYPE_OBJECT, g_value_object_transform_value);
+
   /**
    * GdkPaintable::invalidate-contents
    * @paintable: a #GdkPaintable


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]