diff options
author | Kjell Ahlstedt <kjell.ahlstedt@bredband.net> | 2015-04-21 09:05:26 +0200 |
---|---|---|
committer | Kjell Ahlstedt <kjell.ahlstedt@bredband.net> | 2015-04-21 09:05:26 +0200 |
commit | 2495edc9fdd604fa9f052b4003a492d2b7230d37 (patch) | |
tree | 9722d0f1395b4569d8326b6543ef477815b4ebc6 /gdk/gdkrectangle.c | |
parent | 557e8aa5480f9661caed4d88e8a42cc702431686 (diff) | |
download | gtk+-2495edc9fdd604fa9f052b4003a492d2b7230d37.tar.gz |
GtkPopover:pointing-to: GdkRectangle instead of cairo_rectangle_int_t
cairo_rectangle_int_t was replaced by GdkRectangle in commit
552c29b488ecd7bcc3303dd5514ce6dbfff04437, but the type of the pointing-to
property was not changed.
To avoid breaking old code that sets or gets the property with a GValue
of type CAIRO_GOBJECT_TYPE_RECTANGLE_INT, transformation functions between
CAIRO_GOBJECT_TYPE_RECTANGLE_INT and GDK_TYPE_RECTANGLE are registered on
the first call to gdk_rectangle_get_type().
https://bugzilla.gnome.org/show_bug.cgi?id=723394
Diffstat (limited to 'gdk/gdkrectangle.c')
-rw-r--r-- | gdk/gdkrectangle.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/gdk/gdkrectangle.c b/gdk/gdkrectangle.c index 919c3a2a30..404ffcad79 100644 --- a/gdk/gdkrectangle.c +++ b/gdk/gdkrectangle.c @@ -25,6 +25,7 @@ #include "config.h" #include "gdkrectangle.h" +#include <cairo-gobject.h> /** @@ -141,6 +142,36 @@ gdk_rectangle_copy (const GdkRectangle *rectangle) return result; } -G_DEFINE_BOXED_TYPE (GdkRectangle, gdk_rectangle, - gdk_rectangle_copy, - g_free) +/* Transforms between identical boxed types. + */ +static void +gdk_rectangle_value_transform_rect (const GValue *src_value, GValue *dest_value) +{ + g_value_set_boxed (dest_value, g_value_get_boxed (src_value)); +} + +/* Allow GValue transformation between the identical structs + * cairo_rectangle_int_t and GdkRectangle. + */ +static void +gdk_rectangle_register_value_transform_funcs (GType gtype_gdk_rectangle) +{ + /* This function is called from the first call to gdk_rectangle_get_type(), + * before g_once_init_leave() has been called. + * If gdk_rectangle_get_type() is called from here (e.g. via + * GDK_TYPE_RECTANGLE), the program will wait indefinitely at + * g_once_init_enter() in gdk_rectangle_get_type(). + */ + g_value_register_transform_func (CAIRO_GOBJECT_TYPE_RECTANGLE_INT, + gtype_gdk_rectangle, + gdk_rectangle_value_transform_rect); + g_value_register_transform_func (gtype_gdk_rectangle, + CAIRO_GOBJECT_TYPE_RECTANGLE_INT, + gdk_rectangle_value_transform_rect); +} + +G_DEFINE_BOXED_TYPE_WITH_CODE (GdkRectangle, gdk_rectangle, + gdk_rectangle_copy, + g_free, + gdk_rectangle_register_value_transform_funcs (g_define_type_id)) + |