summaryrefslogtreecommitdiff
path: root/libedataserverui/gtk-compat.h
blob: e444ffb089fab7e13c4fe22a1885861d4982ca1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef __GTK_COMPAT_H__
#define __GTK_COMPAT_H__

#include <gtk/gtk.h>

/* Provide a compatibility layer for accessor functions introduced
 * in GTK+ 2.21.1 which we need to build with sealed GDK.
 * That way it is still possible to build with GTK+ 2.20.
 */

#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 21) \
	|| (GTK_MINOR_VERSION == 21 && GTK_MICRO_VERSION < 1)

#define gdk_drag_context_get_actions(context)          (context)->actions
#define gdk_drag_context_get_suggested_action(context) (context)->suggested_action
#define gdk_drag_context_get_selected_action(context)  (context)->action

#endif

#if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION == 21 && GTK_MICRO_VERSION == 1
#define gdk_drag_context_get_selected_action(context)  gdk_drag_context_get_action(context)
#endif

#if !GTK_CHECK_VERSION (2,23,0)
#define gtk_combo_box_text_new			gtk_combo_box_new_text
#define gtk_combo_box_text_append_text		gtk_combo_box_append_text
#define gtk_combo_box_text_get_active_text	gtk_combo_box_get_active_text
#define GTK_COMBO_BOX_TEXT			GTK_COMBO_BOX

/* The below can be used only once in sources */
#define ENSURE_GTK_COMBO_BOX_TEXT_TYPE						\
	GType gtk_combo_box_text_get_type (void);				\
	typedef struct _GtkComboBoxText GtkComboBoxText;			\
	typedef struct _GtkComboBoxTextClass GtkComboBoxTextClass;		\
										\
	struct _GtkComboBoxText {						\
		GtkComboBox parent;						\
	};									\
										\
	struct _GtkComboBoxTextClass {						\
		GtkComboBoxClass parent_class;					\
	};									\
										\
										\
	G_DEFINE_TYPE (GtkComboBoxText, gtk_combo_box_text, GTK_TYPE_COMBO_BOX)	\
										\
	static void gtk_combo_box_text_init (GtkComboBoxText *cbt) {}		\
	static void gtk_combo_box_text_class_init (GtkComboBoxTextClass *kl) {}

#endif

#if GTK_CHECK_VERSION (2,90,5)

/* Recreate GdkRegion until we drop GTK2 compatibility. */

#define GdkRegion cairo_region_t

#define gdk_region_destroy(region) \
	(cairo_region_destroy (region))

#define gdk_region_point_in(region, x, y) \
	(cairo_region_contains_point ((region), (x), (y)))

#define gdk_region_rectangle(rectangle) \
	(((rectangle)->width <= 0 || (rectangle->height <= 0)) ? \
	cairo_region_create () : cairo_region_create_rectangle (rectangle))

#endif

#endif /* __GTK_COMPAT_H__ */