[gtk/wip/otte/listview: 37/44] xxx: Add a hack to make paintables transform to/from objects



commit c9f68c49eb006213a920daf949440b9f4a572c82
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 5f708d77ee..4b3bfc5d33 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]