Eliminate usage of GTK_WIDGET_REALIZED, GTK_WIDGET_TOPLEVEL, and GTK_WIDGET_NO_WINDOW for compatibility with Gtk+ >= 2.20
obtained from http://pkgs.fedoraproject.org/cgit/gtkglext.git/tree/gtkglext-1.2.0-bz677457.diff
see also https://bugzilla.redhat.com/show_bug.cgi?id=677457
diff -Naur gtkglext-1.2.0.orig/gtk/gtkglwidget.c gtkglext-1.2.0/gtk/gtkglwidget.c
--- gtkglext-1.2.0.orig/gtk/gtkglwidget.c	2004-02-20 10:38:36.000000000 +0100
+++ gtkglext-1.2.0/gtk/gtkglwidget.c	2011-02-16 19:06:48.383730534 +0100
@@ -16,7 +16,9 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA.
  */
 
-#include <gtk/gtkmain.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
 
 #include "gtkglprivate.h"
 #include "gtkglwidget.h"
@@ -68,6 +70,7 @@
 gtk_gl_widget_realize (GtkWidget       *widget,
                        GLWidgetPrivate *private)
 {
+  GdkWindow *window;
   GdkGLWindow *glwindow;
 
   GTK_GL_NOTE_FUNC_PRIVATE ();
@@ -77,9 +80,10 @@
    * handlers.
    */
 
-  if (!gdk_window_is_gl_capable (widget->window))
+  window = gtk_widget_get_window (widget);
+  if (!gdk_window_is_gl_capable (window))
     {
-      glwindow = gdk_window_set_gl_capability (widget->window,
+      glwindow = gdk_window_set_gl_capability (window,
                                                private->glconfig,
                                                NULL);
       if (glwindow == NULL)
@@ -127,9 +131,9 @@
    * Synchronize OpenGL and window resizing request streams.
    */
 
-  if (GTK_WIDGET_REALIZED (widget) && private->is_realized)
+  if (gtk_widget_get_realized (widget) && private->is_realized)
     {
-      gldrawable = gdk_window_get_gl_drawable (widget->window);
+      gldrawable = gdk_window_get_gl_drawable (gtk_widget_get_window (widget));
       gdk_gl_drawable_wait_gdk (gldrawable);
     }
 }
@@ -146,7 +150,7 @@
 
   if (private->glcontext != NULL)
     {
-      gdk_gl_context_destroy (private->glcontext);
+      g_object_unref (private->glcontext);
       private->glcontext = NULL;
     }
 
@@ -154,8 +158,8 @@
    * Remove OpenGL-capability from widget->window.
    */
 
-  if (GTK_WIDGET_REALIZED (widget))
-    gdk_window_unset_gl_capability (widget->window);
+  if (gtk_widget_get_realized (widget))
+    gdk_window_unset_gl_capability (gtk_widget_get_window (widget));
 
   private->is_realized = FALSE;
 }
@@ -174,7 +178,7 @@
    */
 
   toplevel = gtk_widget_get_toplevel (widget);
-  if (GTK_WIDGET_TOPLEVEL (toplevel) && !GTK_WIDGET_REALIZED (toplevel))
+  if (gtk_widget_is_toplevel (toplevel) && !gtk_widget_get_realized (toplevel))
     {
       GTK_GL_NOTE (MISC,
         g_message (" - Install colormap to the top-level window."));
@@ -188,23 +192,27 @@
                          GtkStyle  *previous_style,
                          gpointer   user_data)
 {
+  GdkWindow *window;
+
   GTK_GL_NOTE_FUNC_PRIVATE ();
 
   /* 
    * Set a background of "None" on window to avoid AIX X server crash.
    */
 
-  if (GTK_WIDGET_REALIZED (widget))
+  if (gtk_widget_get_realized (widget))
     {
+      window = gtk_widget_get_window (widget);
+
       GTK_GL_NOTE (MISC,
         g_message (" - window->bg_pixmap = %p",
-                   ((GdkWindowObject *) (widget->window))->bg_pixmap));
+                   ((GdkWindowObject *) window)->bg_pixmap));
 
-      gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
+      gdk_window_set_back_pixmap (window, NULL, FALSE);
 
       GTK_GL_NOTE (MISC,
         g_message (" - window->bg_pixmap = %p",
-                   ((GdkWindowObject *) (widget->window))->bg_pixmap));
+                   ((GdkWindowObject *) window)->bg_pixmap));
     }
 }
 
@@ -250,8 +258,8 @@
   GTK_GL_NOTE_FUNC ();
 
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
-  g_return_val_if_fail (!GTK_WIDGET_NO_WINDOW (widget), FALSE);
-  g_return_val_if_fail (!GTK_WIDGET_REALIZED (widget), FALSE);
+  g_return_val_if_fail (gtk_widget_get_has_window (widget), FALSE);
+  g_return_val_if_fail (!gtk_widget_get_realized (widget), FALSE);
   g_return_val_if_fail (GDK_IS_GL_CONFIG (glconfig), FALSE);
 
   /* 
@@ -432,9 +440,9 @@
   GTK_GL_NOTE_FUNC ();
 
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-  g_return_val_if_fail (GTK_WIDGET_REALIZED (widget), NULL);
+  g_return_val_if_fail (gtk_widget_get_realized (widget), NULL);
 
-  gldrawable = gdk_window_get_gl_drawable (widget->window);
+  gldrawable = gdk_window_get_gl_drawable (gtk_widget_get_window (widget));
   if (gldrawable == NULL)
     return NULL;
 
@@ -474,7 +482,7 @@
   GLWidgetPrivate *private;
 
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-  g_return_val_if_fail (GTK_WIDGET_REALIZED (widget), NULL);
+  g_return_val_if_fail (gtk_widget_get_realized (widget), NULL);
 
   private = g_object_get_qdata (G_OBJECT (widget), quark_gl_private);
   if (private == NULL)
@@ -501,7 +509,7 @@
 gtk_widget_get_gl_window (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-  g_return_val_if_fail (GTK_WIDGET_REALIZED (widget), NULL);
+  g_return_val_if_fail (gtk_widget_get_realized (widget), NULL);
 
-  return gdk_window_get_gl_window (widget->window);
+  return gdk_window_get_gl_window (gtk_widget_get_window (widget));
 }
