[evolution] Work around sudden disappearance of GdkRegion in GTK+ 2.90.5.



commit fc3123dc43dbe510efbff54baf7278ed2e607553
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Jun 29 20:37:25 2010 -0400

    Work around sudden disappearance of GdkRegion in GTK+ 2.90.5.
    
    API was deprecated and removed in less than two hours!  Sheesh!

 calendar/gui/e-day-view-main-item.c   |    2 +
 calendar/gui/e-week-view-event-item.c |    2 +
 e-util/gtk-compat.h                   |   51 +++++++++++++++++++++++++++++++++
 widgets/table/e-cell-text.c           |    1 +
 widgets/text/e-text.c                 |    1 +
 5 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c
index 5de9b76..0229f51 100644
--- a/calendar/gui/e-day-view-main-item.c
+++ b/calendar/gui/e-day-view-main-item.c
@@ -41,6 +41,8 @@
 #include "comp-util.h"
 #include "calendar-config.h"
 
+#include "e-util/gtk-compat.h"
+
 #define E_DAY_VIEW_MAIN_ITEM_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE \
 	((obj), E_TYPE_DAY_VIEW_MAIN_ITEM, EDayViewMainItemPrivate))
diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c
index ae3fadf..4aa2cb0 100644
--- a/calendar/gui/e-week-view-event-item.c
+++ b/calendar/gui/e-week-view-event-item.c
@@ -40,6 +40,8 @@
 
 #include <text/e-text.h>
 
+#include "e-util/gtk-compat.h"
+
 #define E_WEEK_VIEW_EVENT_ITEM_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE \
 	((obj), E_TYPE_WEEK_VIEW_EVENT_ITEM, EWeekViewEventItemPrivate))
diff --git a/e-util/gtk-compat.h b/e-util/gtk-compat.h
index 6b93eed..b01b8c5 100644
--- a/e-util/gtk-compat.h
+++ b/e-util/gtk-compat.h
@@ -24,4 +24,55 @@
 #define gdk_drag_context_get_selected_action(context)  gdk_drag_context_get_action(context)
 #endif
 
+#if GTK_CHECK_VERSION (2,90,5)
+
+/* Recreate GdkRegion until we drop GTK2 compatibility. */
+
+typedef enum {
+	GDK_OVERLAP_RECTANGLE_IN,
+	GDK_OVERLAP_RECTANGLE_OUT,
+	GDK_OVERLAP_RECTANGLE_PART
+} GdkOverlapType;
+
+#define GdkRegion cairo_region_t
+
+#define gdk_region_new() \
+	(cairo_region_create ())
+
+#define gdk_region_destroy(region) \
+	(cairo_region_destroy (region))
+
+#define gdk_region_intersect(source1, source2) \
+	(cairo_region_intersect ((source1), (source2)))
+
+#define gdk_region_rect_in(region, rectangle) \
+	(cairo_region_contains_rectangle ((region), (rectangle)))
+
+#define gdk_region_rectangle(rectangle) \
+	(((rectangle)->width <= 0 || (rectangle)->height <= 0) ? \
+	cairo_region_create () : cairo_region_create_rectangle (rectangle))
+
+#define gdk_region_get_rectangles(region, rectangles, n_rectangles) \
+	G_STMT_START { \
+		GdkRectangle *__rects; \
+		gint __i, __n; \
+		\
+		__n = cairo_region_num_rectangles (region); \
+		__rects = g_new (GdkRectangle, __n); \
+		\
+		for (__i = 0; __i < __n; __i++) \
+			cairo_region_get_rectangle ((region), __i, &__rects[__i]); \
+		\
+		*(n_rectangles) = __n; \
+		*(rectangles) = __rects; \
+	} G_STMT_END
+
+#define gdk_region_union_with_rect(region, rect) \
+	G_STMT_START { \
+		if ((rect)->width > 0 && (rect)->height > 0) \
+			cairo_region_union_rectangle ((region), (rect)); \
+	} G_STMT_END
+
+#endif
+
 #endif /* __GTK_COMPAT_H__ */
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index 077357c..ae4b31d 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -54,6 +54,7 @@
 #include "e-util/e-util.h"
 #include "misc/e-canvas.h"
 #include "e-util/e-unicode.h"
+#include "e-util/gtk-compat.h"
 
 #include "e-table.h"
 #include "e-cell-text.h"
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index 92fc67c..bb55b87 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -53,6 +53,7 @@
 #include <glib/gi18n.h>
 #include "e-util/e-text-event-processor-emacs-like.h"
 #include "e-util/e-util.h"
+#include "e-util/gtk-compat.h"
 
 #include "e-text.h"
 



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