1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_GFX_GTK_COMPAT_H_
6 #define UI_GFX_GTK_COMPAT_H_
10 // Google Chrome must depend on GTK 2.18, at least until the next LTS drops
11 // (and we might have to extend which version of GTK we want to target due to
12 // RHEL). To make our porting job for GTK3 easier, we define all the methods
13 // that replace deprecated APIs in this file and then include it everywhere.
15 // This file is organized first by version, and then with each version,
16 // alphabetically by method.
18 // For Google Chrome builds, we want to support RHEL 6, which uses GTK 2.18,
19 // but the official builder is Ubuntu Lucid with GTK 2.20. Thus for Google
20 // Chrome builds, we define the GTK 2.20.0 compatibility functions even though
21 // the system GTK provides the functions.
23 #if !GTK_CHECK_VERSION(2, 20, 0) || defined(GOOGLE_CHROME_BUILD)
24 inline gboolean
gtk_widget_get_mapped(GtkWidget
* widget
) {
25 return GTK_WIDGET_MAPPED(widget
);
28 inline gboolean
gtk_widget_get_realized(GtkWidget
* widget
) {
29 return GTK_WIDGET_REALIZED(widget
);
32 inline gboolean
gtk_widget_is_toplevel(GtkWidget
* widget
) {
33 return GTK_WIDGET_TOPLEVEL(widget
);
36 inline void gtk_widget_set_mapped(GtkWidget
* widget
,
39 GTK_WIDGET_SET_FLAGS(widget
, GTK_MAPPED
);
41 GTK_WIDGET_UNSET_FLAGS(widget
, GTK_MAPPED
);
44 inline void gtk_widget_set_realized(GtkWidget
* widget
,
47 GTK_WIDGET_SET_FLAGS(widget
, GTK_REALIZED
);
49 GTK_WIDGET_UNSET_FLAGS(widget
, GTK_REALIZED
);
52 inline void gtk_widget_style_attach(GtkWidget
* widget
) {
53 widget
->style
= gtk_style_attach(widget
->style
, widget
->window
);
55 #endif // !GTK_CHECK_VERSION(2, 20, 0) || defined(GOOGLE_CHROME_BUILD)
57 #if !GTK_CHECK_VERSION(2, 22, 0)
58 inline GdkWindow
* gdk_drag_context_get_source_window(GdkDragContext
*context
) {
59 return context
->source_window
;
62 inline gint
gdk_visual_get_depth(GdkVisual
* visual
) {
66 inline GdkWindow
* gtk_button_get_event_window(GtkButton
* button
) {
67 return button
->event_window
;
69 #endif // !GTK_CHECK_VERSION(2, 22, 0)
71 #if !GTK_CHECK_VERSION(2, 24, 0)
72 inline void gdk_pixmap_get_size(GdkPixmap
* pixmap
, gint
* width
, gint
* height
) {
73 gdk_drawable_get_size(GDK_DRAWABLE(pixmap
), width
, height
);
76 inline GdkDisplay
* gdk_window_get_display(GdkWindow
* window
) {
77 return gdk_drawable_get_display(GDK_DRAWABLE(window
));
80 inline int gdk_window_get_height(GdkWindow
* window
) {
82 gdk_drawable_get_size(GDK_DRAWABLE(window
), NULL
, &height
);
86 inline GdkScreen
* gdk_window_get_screen(GdkWindow
* window
) {
87 return gdk_drawable_get_screen(GDK_DRAWABLE(window
));
90 inline int gdk_window_get_width(GdkWindow
* window
) {
92 gdk_drawable_get_size(GDK_DRAWABLE(window
), &width
, NULL
);
95 #endif // !GTK_CHECK_VERSION(2, 24, 0)
97 #endif // UI_GFX_GTK_COMPAT_H_