--- gtkgl/gtkglarea.h	2009-07-17 21:29:39 +0000
+++ gtkgl/gtkglarea.h	2013-09-18 05:40:11 +0000
@@ -22,7 +22,7 @@
 
 #include <gdk/gdk.h>
 #include <gtkgl/gdkgl.h>
-#include <gtk/gtkdrawingarea.h>
+#include <gtk/gtk.h>
 
 
 G_BEGIN_DECLS
--- gtkgl/gtkglarea.c	2009-07-17 21:29:39 +0000
+++ gtkgl/gtkglarea.c	2013-09-18 08:14:15 +0000
@@ -23,9 +23,14 @@
 #include "gdkgl.h"
 #include "gtkglarea.h"
 
+
 static void gtk_gl_area_class_init    (GtkGLAreaClass *klass);
 static void gtk_gl_area_init          (GtkGLArea      *glarea);
-static void gtk_gl_area_destroy       (GtkObject      *object); /* change to finalize? */
+#if defined __GTK2__
+static void gtk_gl_area_destroy       (GtkObject      *object);
+#elif defined __GTK3__
+static void gtk_gl_area_destroy       (GtkWidget      *object);
+#endif
 
 static GtkDrawingAreaClass *parent_class = NULL;
 
@@ -60,10 +65,18 @@
 static void
 gtk_gl_area_class_init (GtkGLAreaClass *klass)
 {
-  GtkObjectClass *object_class;
+#if defined __GTK2__
+GtkObjectClass *object_class;
+#elif defined __GTK3__
+GtkWidgetClass *object_class;
+#endif
 
   parent_class = g_type_class_peek_parent(klass);
+#if defined __GTK2__
   object_class = (GtkObjectClass*) klass;
+#elif defined __GTK3__
+  object_class = (GtkWidgetClass*) klass;
+#endif
 
   object_class->destroy = gtk_gl_area_destroy;
 }
@@ -136,7 +149,7 @@
   if (glcontext == NULL)
     return NULL;
 
-#if defined GDK_WINDOWING_X11
+#if defined (GDK_WINDOWING_X11) && defined (__GTK2__)
   /* use colormap and visual suitable for OpenGL rendering */
   gtk_widget_push_colormap(gdk_colormap_new(visual,TRUE));
   gtk_widget_push_visual(visual);
@@ -145,7 +158,7 @@
   gl_area = g_object_new(GTK_TYPE_GL_AREA, NULL);
   gl_area->glcontext = glcontext;
 
-#if defined GDK_WINDOWING_X11
+#if defined (GDK_WINDOWING_X11) && defined (__GTK2__)
   /* pop back defaults */
   gtk_widget_pop_visual();
   gtk_widget_pop_colormap();
@@ -156,7 +169,11 @@
 
 
 static void
+#if defined __GTK2__
 gtk_gl_area_destroy(GtkObject *object)
+#elif defined __GTK3__
+gtk_gl_area_destroy(GtkWidget *object)
+#endif
 {
   GtkGLArea *gl_area;
 
@@ -169,8 +186,13 @@
     g_object_unref(gl_area->glcontext);
   gl_area->glcontext = NULL;
 
+#if defined __GTK2__
   if (GTK_OBJECT_CLASS (parent_class)->destroy)
     (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+#elif defined __GTK3__
+  if (GTK_WIDGET_CLASS (parent_class)->destroy)
+    (* GTK_WIDGET_CLASS (parent_class)->destroy) (object);
+#endif
 }
 
 
@@ -178,16 +200,34 @@
 {
   g_return_val_if_fail(gl_area != NULL, FALSE);
   g_return_val_if_fail(GTK_IS_GL_AREA (gl_area), FALSE);
+#if defined __GTK2__
   g_return_val_if_fail(GTK_WIDGET_REALIZED(gl_area), FALSE);
+#elif defined __GTK3__
+  g_return_val_if_fail(gtk_widget_get_realized(gl_area), FALSE);
+#endif
 
+#if defined __GTK2__
   return gdk_gl_make_current(GTK_WIDGET(gl_area)->window, gl_area->glcontext);
+#elif defined __GTK3__
+  GdkWindow *window = gtk_widget_get_window (GTK_WIDGET(gl_area));
+  return gdk_gl_make_current(window, gl_area->glcontext);
+#endif
 }
 
 void gtk_gl_area_swap_buffers(GtkGLArea *gl_area)
 {
   g_return_if_fail(gl_area != NULL);
   g_return_if_fail(GTK_IS_GL_AREA(gl_area));
+#if defined __GTK2__
   g_return_if_fail(GTK_WIDGET_REALIZED(gl_area));
+#elif defined __GTK3__
+  g_return_if_fail(gtk_widget_get_realized(gl_area));
+#endif
 
+#if defined __GTK2__
   gdk_gl_swap_buffers(GTK_WIDGET(gl_area)->window);
+#elif defined __GTK3__
+  GdkWindow *window = gtk_widget_get_window (GTK_WIDGET(gl_area));
+  gdk_gl_swap_buffers(window);
+#endif
 }
--- gtkgl/gdkgl.h	2009-07-17 21:29:39 +0000
+++ gtkgl/gdkgl.h	2013-09-18 05:40:11 +0000
@@ -90,9 +90,13 @@
 GdkGLContext *gdk_gl_context_share_new(GdkVisual *visual, GdkGLContext *sharelist, gint direct);
 GdkGLContext *gdk_gl_context_attrlist_share_new(int *attrlist, GdkGLContext *sharelist, gint direct);
 
+#if defined __GTK2__
 gint          gdk_gl_make_current(GdkDrawable *drawable, GdkGLContext *context);
 void          gdk_gl_swap_buffers(GdkDrawable *drawable);
-
+#elif defined __GTK3__
+gint          gdk_gl_make_current(GdkWindow *window, GdkGLContext *context);
+void          gdk_gl_swap_buffers(GdkWindow *window);
+#endif
 
 void          gdk_gl_wait_gdk(void);
 void          gdk_gl_wait_gl(void);
@@ -110,13 +114,21 @@
 typedef struct _GdkGLPixmap GdkGLPixmap;
 
 GType        gdk_gl_pixmap_get_type(void);
+#if defined __GTK2__
 GdkGLPixmap *gdk_gl_pixmap_new(GdkVisual *visual, GdkPixmap *pixmap);
+#elif defined __GTK3__
+GdkGLPixmap *gdk_gl_pixmap_new(GdkVisual *visual, GdkPixbuf *pixbuf);
+#endif
 
 gint         gdk_gl_pixmap_make_current(GdkGLPixmap *glpixmap, GdkGLContext *context);
 
 
 /* fonts */
+#if defined __GTK2__
 void gdk_gl_use_gdk_font(GdkFont *font, int first, int count, int list_base);
+#elif defined __GTK3__
+void gdk_gl_use_gdk_font(PangoFont *font, int first, int count, int list_base);
+#endif
 
 
 #ifndef GTKGL_DISABLE_DEPRECATED
--- gtkgl/gdkgl.c	2009-07-17 23:07:58 +0000
+++ gtkgl/gdkgl.c	2013-09-22 17:37:50 +0000
@@ -30,6 +30,10 @@
 #elif defined GDK_WINDOWING_X11
 #   include <gdk/gdkx.h>
 #   include <GL/glx.h>
+#ifdef __GTK3__
+#   include <cairo.h>
+#   include <cairo-xlib.h>
+#endif
 #   define PLATFORM "GDK_WINDOWING_X11"
 #elif defined GDK_WINDOWING_FB
 #   define PLATFORM "GDK_WINDOWING_FB"
@@ -74,11 +78,19 @@
   gboolean  initialised;
   HDC       hdc;
   HBITMAP   hbitmap;
+#if defined __GTK2__
   GdkPixmap *pixmap;
+#elif defined __GTK3__
+  GdkPixbuf *pixbuf;
+#endif
 #elif defined GDK_WINDOWING_X11
   Display   *xdisplay;
   GLXPixmap glxpixmap;
+#if defined __GTK2__
   GdkPixmap *front_left;
+#elif defined __GTK3__
+  GdkPixbuf *front_left;
+#endif
 #endif
 };
 
@@ -109,7 +121,11 @@
 #if defined GDK_WINDOWING_WIN32
   return TRUE;
 #elif defined GDK_WINDOWING_X11
+#if defined __GTK2__
   return (glXQueryExtension(GDK_DISPLAY(),NULL,NULL) == True) ? TRUE : FALSE;
+#elif defined __GTK3__
+  return (glXQueryExtension(gdk_x11_get_default_xdisplay(),NULL,NULL) == True) ? TRUE : FALSE;
+#endif
 #else
   return FALSE;
 #endif
@@ -124,9 +140,15 @@
   version = glGetString (GL_VERSION);
   extensions = glGetString (GL_EXTENSIONS);
 #elif defined GDK_WINDOWING_X11
+#if defined __GTK2__
   vendor = glXGetClientString(GDK_DISPLAY(), GLX_VENDOR);
   version = glXGetClientString(GDK_DISPLAY(), GLX_VERSION);
   extensions = glXGetClientString(GDK_DISPLAY(), GLX_EXTENSIONS);
+#elif defined __GTK3__
+  vendor = glXGetClientString(gdk_x11_get_default_xdisplay(), GLX_VENDOR);
+  version = glXGetClientString(gdk_x11_get_default_xdisplay(), GLX_VERSION);
+  extensions = glXGetClientString(gdk_x11_get_default_xdisplay(), GLX_EXTENSIONS);
+#endif
 #else
   vendor = version = extensions = "unknown";
 #endif
@@ -148,12 +170,20 @@
 
   g_return_val_if_fail(attrlist != NULL, NULL);
 
+#if defined __GTK3__
+  dpy = gdk_x11_get_default_xdisplay();
+#elif defined __GTK2__
   dpy = GDK_DISPLAY();
+#endif
   vi = glXChooseVisual(dpy, DefaultScreen(dpy), attrlist);
   if (!vi)
     return NULL;
 
+#if defined __GTK2__
   visual = gdkx_visual_get(vi->visualid);
+#elif defined __GTK3__
+  visual = gdk_x11_screen_lookup_visual (gdk_screen_get_default(), vi->visualid);
+#endif
   XFree(vi);
   return visual;
 #else
@@ -172,7 +202,11 @@
 
   g_return_val_if_fail(visual != NULL, -1);
 
+#if defined __GTK3__
+  dpy = gdk_x11_get_default_xdisplay();
+#elif defined __GTK2__
   dpy = GDK_DISPLAY();
+#endif
 
   vi = get_xvisualinfo(visual);
 
@@ -319,7 +353,11 @@
   context->pfd.cDepthBits = 32;
   context->pfd.iLayerType = PFD_MAIN_PLANE;
 #elif defined GDK_WINDOWING_X11
+#if defined __GTK3__
+  dpy = gdk_x11_get_default_xdisplay();
+#elif defined __GTK2__
   dpy = GDK_DISPLAY();
+#endif
 
   vi = get_xvisualinfo(visual);
 
@@ -374,17 +412,28 @@
 #endif
 }
 
-
+#if defined __GTK2__
 gint gdk_gl_make_current(GdkDrawable *drawable, GdkGLContext *context)
+#elif defined __GTK3__
+gint gdk_gl_make_current(GdkWindow *window, GdkGLContext *context)
+#endif
 {
+#if defined __GTK2__
   g_return_val_if_fail (GDK_IS_DRAWABLE(drawable), FALSE);
+#elif defined __GTK3__
+  g_return_val_if_fail (GDK_IS_WINDOW(window), FALSE);
+#endif
   g_return_val_if_fail (GDK_IS_GL_CONTEXT(context), FALSE);
 
 #if defined GDK_WINDOWING_WIN32
   if (!context->initialised)
   {
     int pf;
+#if defined __GTK2__
     HWND hwnd = (HWND) gdk_win32_drawable_get_handle (drawable);
+#elif defined __GTK3__
+    HWND hwnd = (HWND) gdk_win32_window_get_handle (window);
+#endif
 
     context->hdc = GetDC (hwnd);
 
@@ -416,7 +465,11 @@
 
   return TRUE;
 #elif defined GDK_WINDOWING_X11
+#if defined __GTK2__
   return (glXMakeCurrent(context->xdisplay, GDK_WINDOW_XWINDOW(drawable),
+#elif defined __GTK3__
+  return (glXMakeCurrent(context->xdisplay, gdk_x11_window_get_xid(window),
+#endif
 			 context->glxcontext) == True) ? TRUE : FALSE;
 
 #if 0
@@ -427,7 +480,11 @@
     }
   else
     {
+#if defined __GTK2__
       return (glXMakeCurrent(context->xdisplay, GDK_WINDOW_XWINDOW(drawable), context->glxcontext) == True) ? TRUE : FALSE;
+#elif defined __GTK3__
+      return (glXMakeCurrent(context->xdisplay, GDK_WINDOW_XWINDOW(window), context->glxcontext) == True) ? TRUE : FALSE;
+#endif
     }
 #endif
 #else
@@ -435,17 +492,29 @@
 #endif
 }
 
+#if defined __GTK2__
 void gdk_gl_swap_buffers(GdkDrawable *drawable)
+#elif defined __GTK3__
+void gdk_gl_swap_buffers(GdkWindow *window)
+#endif
 {
 #if defined GDK_WINDOWING_WIN32
   HDC   hdc;
   HWND  hwnd;
 #endif
 
-  g_return_if_fail (GDK_IS_DRAWABLE(drawable));
+#if defined __GTK2__
+g_return_if_fail (GDK_IS_DRAWABLE(drawable));
+#elif defined __GTK3__
+g_return_if_fail (GDK_IS_WINDOW(window));
+#endif
 
 #if defined GDK_WINDOWING_WIN32
+#if defined __GTK2__
   hwnd = (HWND) gdk_win32_drawable_get_handle (drawable);
+#elif defined __GTK3__
+  hwnd = (HWND) gdk_win32_window_get_handle (window);
+#endif
   hdc  = GetDC (hwnd);
   if (hdc  == NULL)
   {
@@ -455,7 +524,11 @@
   SwapBuffers (hdc);
   ReleaseDC (hwnd, hdc);
 #elif defined GDK_WINDOWING_X11
+#if defined __GTK2__
   glXSwapBuffers(GDK_WINDOW_XDISPLAY(drawable), GDK_WINDOW_XWINDOW(drawable));
+#elif defined __GTK3__
+  glXSwapBuffers(GDK_WINDOW_XDISPLAY(window), gdk_x11_window_get_xid(window));
+#endif
 #else
   g_warning ("gdk_gl_swap_buffers not implemented on " PLATFORM);
 #endif
@@ -521,7 +594,11 @@
 #if defined GDK_WINDOWING_WIN32
   glFinish ();
   SelectObject (pixmap->hdc, pixmap->hbitmap);
+#if defined __GTK2__
   gdk_pixmap_unref (pixmap->pixmap);
+#elif defined __GTK3__
+  g_object_unref (pixmap->pixbuf);
+#endif
 #elif defined GDK_WINDOWING_X11
   if (pixmap->glxpixmap != None) {
     glXDestroyGLXPixmap(pixmap->xdisplay, pixmap->glxpixmap);
@@ -529,7 +606,11 @@
   }
   pixmap->glxpixmap = None;
   if (pixmap->front_left) {
+#if defined __GTK2__
     gdk_pixmap_unref(pixmap->front_left);
+#elif defined __GTK3__
+    g_object_unref(pixmap->front_left);
+#endif
     glXWaitX();
   }
   pixmap->front_left = NULL;
@@ -550,7 +631,11 @@
 }
 
 GdkGLPixmap *
+#if defined __GTK2__
 gdk_gl_pixmap_new(GdkVisual *visual, GdkPixmap *pixmap)
+#elif defined __GTK3__
+gdk_gl_pixmap_new(GdkVisual *visual, GdkPixbuf *pixbuf)
+#endif
 {
   GdkGLPixmap *glpixmap;
 #ifndef GDK_WINDOWING_WIN32
@@ -568,7 +653,11 @@
 #endif
 
   g_return_val_if_fail(GDK_IS_VISUAL(visual), NULL);
+#if defined __GTK2__
   g_return_val_if_fail(GDK_IS_PIXMAP(pixmap), NULL);
+#elif defined __GTK3__
+  g_return_val_if_fail(GDK_IS_PIXBUF(pixbuf), NULL);
+#endif
 
   glpixmap = g_object_new(GDK_TYPE_GL_PIXMAP, NULL);
   if (!glpixmap)
@@ -578,11 +667,29 @@
   glpixmap->initialised = FALSE;
   glpixmap->hdc = NULL;
   glpixmap->hbitmap = NULL;
+#if defined __GTK2__
   glpixmap->pixmap = gdk_pixmap_ref (pixmap);
+#elif defined __GTK3__
+  glpixmap->pixbuf = g_object_ref (pixbuf);
+#endif
 #elif defined GDK_WINDOWING_X11
+#if defined __GTK2__
   dpy = GDK_DISPLAY();
   xpixmap = (Pixmap)GDK_DRAWABLE_XID(pixmap);
-
+#elif defined __GTK3__
+  dpy = gdk_x11_get_default_xdisplay();
+  xpixmap = XCreatePixmap (dpy, RootWindow(dpy, 0), gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_width(pixbuf), 1);
+
+  cairo_t *cr;
+  cairo_surface_t *cs;
+
+  cs = cairo_xlib_surface_create_for_bitmap (dpy, xpixmap, DefaultScreenOfDisplay(dpy), gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf));
+  cr = cairo_create (cs);
+
+  gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
+  cairo_paint (cr);
+  cairo_destroy (cr);
+#endif
   g_return_val_if_fail(XGetGeometry(dpy, xpixmap, &root_return,
 				    &x_ret, &y_ret, &w_ret, &h_ret,
                                     &bw_ret, &depth_ret), NULL);
@@ -599,7 +706,11 @@
 
   glpixmap->xdisplay   = dpy;
   glpixmap->glxpixmap  = glxpixmap;
+#if defined __GTK2__
   glpixmap->front_left = gdk_pixmap_ref(pixmap);
+#elif defined __GTK3__
+  glpixmap->front_left = g_object_ref(pixbuf);
+#endif
 #endif
 
   return glpixmap;
@@ -628,7 +739,11 @@
 
     context->hdc = CreateCompatibleDC (NULL);
     glpixmap->hdc = context->hdc;
+#if defined __GTK2__
     glpixmap->hbitmap = SelectObject (context->hdc, (HBITMAP) gdk_win32_drawable_get_handle (glpixmap->pixmap));
+#elif defined __GTK3__
+    glpixmap->hbitmap = SelectObject (context->hdc, (HBITMAP) gdk_win32_drawable_get_handle (glpixmap->pixbuf));
+#endif
 
     pf = ChoosePixelFormat (context->hdc, &context->pfd);
 
@@ -670,11 +785,23 @@
  *  Font support
  */
 
+#if defined (__GTK3__) && defined (GDK_WINDOWING_WIN32)
+__declspec(dllimport) HFONT		_pango_win32_font_get_hfont         (PangoFont          *font);
+#endif
+
+#if defined __GTK2__
 void gdk_gl_use_gdk_font(GdkFont *font, int first, int count, int list_base)
+#elif defined __GTK3__
+void gdk_gl_use_gdk_font(PangoFont *font, int first, int count, int list_base)
+#endif
 {
 #if defined GDK_WINDOWING_WIN32
   HDC dc = CreateCompatibleDC (NULL);
+#if defined __GTK2__
   HFONT old_font = SelectObject (dc, (void *)gdk_font_id (font));
+#elif defined __GTK3__
+  HFONT old_font = _pango_win32_font_get_hfont (font);
+#endif
 
   wglUseFontBitmaps (dc, first, count, list_base);
 
@@ -682,7 +809,27 @@
   DeleteDC (dc);
 #elif defined GDK_WINDOWING_X11
   g_return_if_fail(font != NULL);
+#if defined __GTK2__
   glXUseXFont(gdk_font_id(font), first, count, list_base);
+#elif defined __GTK3__
+/*#include <pango/pangox.h>
+  gchar *charset = NULL;
+  PangoFontMap *fontmap;
+  PangoXSubfont subfont_id;
+  PangoXFontCache *fontcache;
+  XFontStruct *xfs;
+  gchar *xlfd = NULL;
+
+  pango_x_find_first_subfont (font, &charset, 1, &subfont_id);
+  xlfd = pango_x_font_subfont_xfld (font, subfont_id);
+  fontmap = pango_x_font_map_for_display (gdk_x11_get_default_xdisplay());
+  fontcache = pango_x_font_map_get_font_cache (fontmap);
+  xfs = pango_x_font_cache_load (fontcache, xlfd);
+  
+  glXUseXFont(xfs->fid, first, count, list_base);
+  pango_x_font_cache_unload (fontcache, xfs);*/
+  g_warning ("gdk_gl_use_gdk_font not implemented on X11 any more...");
+#endif
 #else
   g_warning ("gdk_gl_use_gdk_font not implemented on " PLATFORM);
 #endif
@@ -786,14 +933,22 @@
   XVisualInfo *vi;
   int nitems_return;
 
+#if defined __GTK3__
+  dpy = gdk_x11_get_default_xdisplay();
+#elif defined __GTK2__
   dpy = GDK_DISPLAY();
+#endif
 
   /* 'GLX uses VisualInfo records because they uniquely identify
    * a (VisualID,screen,depth) tuple.'
    */
   vinfo_template.visual   = GDK_VISUAL_XVISUAL(visual);
   vinfo_template.visualid = XVisualIDFromVisual(vinfo_template.visual);
+#if defined __GTK2__
   vinfo_template.depth    = visual->depth;
+#elif defined __GTK3__
+  vinfo_template.depth    = gdk_visual_get_depth (visual);
+#endif
   vinfo_template.screen   = DefaultScreen(dpy);
   vi = XGetVisualInfo(dpy, VisualIDMask|VisualDepthMask|VisualScreenMask,
 		      &vinfo_template, &nitems_return);
--- examples/simple.c	2009-07-17 21:29:39 +0000
+++ examples/simple.c	2013-09-18 05:40:11 +0000
@@ -21,12 +21,19 @@
 #include <gtkgl/gtkglarea.h>
 #include <GL/gl.h>
 
+
 gint init(GtkWidget *widget)
 {
+  g_print ("GTK+ version : %d.%d.%d\n", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
+
   /* OpenGL functions can be called only if make_current returns true */
   if (gtk_gl_area_make_current(GTK_GL_AREA(widget)))
     {
+#if defined __GTK2__
       glViewport(0,0, widget->allocation.width, widget->allocation.height);
+#elif defined __GTK3__
+      glViewport(0,0, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget));
+#endif
       glMatrixMode(GL_PROJECTION);
       glLoadIdentity();
       glOrtho(0,100, 100,0, -1,1);
@@ -38,16 +45,24 @@
 
 
 /* When widget is exposed it's contents are redrawn. */
+#if defined __GTK2__
 gint draw(GtkWidget *widget, GdkEventExpose *event)
+#elif defined __GTK3__
+gboolean draw(GtkWidget *widget, cairo_t *cr)
+#endif
 {
+#ifdef __GTK2__
   /* Draw only last expose. */
   if (event->count > 0)
     return TRUE;
+#endif
 
   /* OpenGL functions can be called only if make_current returns true */
   if (gtk_gl_area_make_current(GTK_GL_AREA(widget)))
     {
-
+#ifdef __GTK3__
+      glViewport(0,0, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget));
+#endif
       /* Draw simple triangle */
       glClearColor(0,0,0,1);
       glClear(GL_COLOR_BUFFER_BIT);
@@ -66,6 +81,7 @@
   return TRUE;
 }
 
+#ifdef __GTK2__
 /* When glarea widget size changes, viewport size is set to match the new size */
 gint reshape(GtkWidget *widget, GdkEventConfigure *event)
 {
@@ -76,6 +92,16 @@
     }
   return TRUE;
 }
+#endif
+
+#ifdef __GTK3__
+gboolean delete(GtkWidget *widget, GdkEvent *event)
+{
+  gtk_widget_destroy (widget);
+
+  return FALSE;
+}
+#endif
 
 
 int main(int argc, char **argv)
@@ -114,9 +140,18 @@
   gtk_container_set_border_width(GTK_CONTAINER(window), 10);
 
   /* Quit form main if got delete event */
+#if defined __GTK2__
   gtk_signal_connect(GTK_OBJECT(window), "delete_event",
 		     GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+#elif defined __GTK3__
+  g_signal_connect(GTK_WIDGET(window), "delete_event",
+		     G_CALLBACK(delete), NULL);
+  g_signal_connect(GTK_WIDGET(window), "destroy",
+		     G_CALLBACK(gtk_main_quit), NULL);
+#endif
+
 
+#ifdef __GTK2__
 
   /* You should always delete gtk_gl_area widgets before exit or else
      GLX contexts are left undeleted, this may cause problems (=core dump)
@@ -126,8 +161,11 @@
      for all your top level windows unless you are certain that they get
      destroy signal by other means.
   */
+
   gtk_quit_add_destroy(1, GTK_OBJECT(window));
 
+#endif
+
 
   /* Create new OpenGL widget. */
   glarea = GTK_WIDGET(gtk_gl_area_new(attrlist));
@@ -138,17 +176,35 @@
 
   /* Connect signal handlers */
   /* Redraw image when exposed. */
+#if defined __GTK2__
   gtk_signal_connect(GTK_OBJECT(glarea), "expose_event",
 		     GTK_SIGNAL_FUNC(draw), NULL);
+#elif defined __GTK3__
+  g_signal_connect(GTK_WIDGET(glarea), "draw",
+		     G_CALLBACK(draw), NULL);
+#endif
+
+#if defined __GTK2__
   /* When window is resized viewport needs to be resized also. */
   gtk_signal_connect(GTK_OBJECT(glarea), "configure_event",
 		     GTK_SIGNAL_FUNC(reshape), NULL);
+#endif
+
   /* Do initialization when widget has been realized. */
+#if defined __GTK2__
   gtk_signal_connect(GTK_OBJECT(glarea), "realize",
 		     GTK_SIGNAL_FUNC(init), NULL);
+#elif defined __GTK3__
+  g_signal_connect(GTK_WIDGET(glarea), "realize",
+		     G_CALLBACK(init), NULL);
+#endif
 
   /* set minimum size */
+#if defined __GTK2__
   gtk_widget_set_usize(GTK_WIDGET(glarea), 100,100);
+#elif defined __GTK3__
+  gtk_widget_set_size_request(GTK_WIDGET(glarea), 100,100);
+#endif
 
   /* put glarea into window and show it all */
   gtk_container_add(GTK_CONTAINER(window),GTK_WIDGET(glarea));
--- examples/zktor.c	2009-07-17 21:29:39 +0000
+++ examples/zktor.c	2013-09-22 17:43:45 +0000
@@ -739,19 +739,40 @@
   /* OpenGL functions can be called only if makecurrent returns true */
   if (gtk_gl_area_make_current(GTK_GL_AREA(widget))) {
 #if !defined(WIN32)
+#if defined __GTK2__
     GdkFont *font;
+#elif defined __GTK3__
+	PangoFont *font;
+#endif
 #endif
 
     /* set viewport */
+#if defined __GTK2__
     glViewport(0,0, widget->allocation.width, widget->allocation.height);
+#elif defined __GTK3__
+      glViewport(0,0, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget));
+#endif
 
 #if !defined(WIN32)
     /* generate font display lists */
+#if defined __GTK2__
     font = gdk_font_load("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*");
+#elif defined __GTK3__
+    PangoFontDescription *fontdesc;
+    PangoFontMap *fontmap;
+    PangoContext *fontcontext;
+
+    fontcontext = pango_context_new();
+    fontmap = pango_cairo_font_map_get_default();
+    fontdesc = pango_font_description_from_string("Sans 10");
+    font = pango_font_map_load_font(fontmap, fontcontext, fontdesc);
+#endif
     if (font) {
       fontbase = glGenLists( 128 );
       gdk_gl_use_gdk_font(font, 0, 128, fontbase);
-      gdk_font_unref(font);
+#ifdef __GTK2__
+      gdk_font_unref(font);  
+#endif
     }
 #endif
   }
@@ -760,21 +781,35 @@
 
 
 /* When widget is exposed it's contents are redrawn. */
+#if defined __GTK2__
 gint draw(GtkWidget *widget, GdkEventExpose *event)
+#elif defined __GTK3__
+gboolean draw(GtkWidget *widget, cairo_t *cr)
+#endif
 {
+#ifdef __GTK2__
   /* Draw only last expose. */
   if (event->count > 0)
     return TRUE;
+#endif
 
   if (gtk_gl_area_make_current(GTK_GL_AREA(widget)))
-    game_render();
+    {
+#ifdef __GTK3__
+      glViewport(0,0, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget));
+#endif
+      game_render();
 
-  /* Swap backbuffer to front */
-  gtk_gl_area_swapbuffers(GTK_GL_AREA(widget));
+      /* Swap backbuffer to front */
+      gtk_gl_area_swapbuffers(GTK_GL_AREA(widget));
+
+    }
 
   return TRUE;
 }
 
+
+#if defined __GTK2__
 /* When glarea widget size changes, viewport size is set to match the new size */
 gint reshape(GtkWidget *widget, GdkEventConfigure *event)
 {
@@ -785,10 +820,20 @@
     }
   return TRUE;
 }
+#endif
 
 
 gint key_press_event(GtkWidget *widget, GdkEventKey *event)
 {
+#ifdef __GTK3__
+#define GDK_Left GDK_KEY_Left
+#define GDK_Right GDK_KEY_Right
+#define GDK_Up GDK_KEY_Up
+#define GDK_Down GDK_KEY_Down
+#define GDK_space GDK_KEY_space
+#define GDK_r GDK_KEY_r
+#define GDK_q GDK_KEY_q
+#endif
   switch (event->keyval) {
   case GDK_Left:
     control_spin = 1;
@@ -811,17 +856,27 @@
     break;
 
 #ifdef FULLSCREEN_MESA_3DFX
+#	ifdef __GTK3__
+#	define GDK_f GDK_KEY_f
+#	endif
   case GDK_f:
     switch_fullscreen(widget);
     break;
 #endif
 
+#ifdef __GTK3__
+#define GDK_d GDK_KEY_d
+#endif
   case GDK_d:
     draw_fast = (!draw_fast);
     break;
   }
   /* prevent the default handler from being run */
+#if defined __GTK2__
   gtk_signal_emit_stop_by_name(GTK_OBJECT(widget),"key_press_event");
+#elif defined __GTK3__
+  g_signal_stop_emission_by_name(GTK_WIDGET(widget),"key_press_event");
+#endif
   return TRUE;
 }
 
@@ -843,17 +898,34 @@
     break;
   }
   /* prevent the default handler from being run */
+#if defined __GTK2__
   gtk_signal_emit_stop_by_name(GTK_OBJECT(widget),"key_release_event");
+#elif defined __GTK3__
+  g_signal_stop_emission_by_name(GTK_WIDGET(widget),"key_release_event");
+#endif
   return TRUE;
 }
 
 gint animate(GtkWidget *glarea)
 {
   game_play();
+#if defined __GTK2__
   gtk_widget_draw(GTK_WIDGET(glarea), NULL);
+#elif defined __GTK3__
+  gtk_widget_queue_draw(GTK_WIDGET(glarea));
+#endif
   return TRUE;
 }
 
+#if defined __GTK3__
+gboolean delete(GtkWidget *widget, GdkEvent *event)
+{
+  gtk_widget_destroy (widget);
+
+  return FALSE;
+}
+#endif
+
 
 int main(int argc, char **argv)
 {
@@ -893,10 +965,18 @@
   gtk_window_set_title(GTK_WINDOW(window), "Zktor");
 
   /* Quit form main if got delete event */
+#if defined __GTK2__
   gtk_signal_connect(GTK_OBJECT(window), "delete_event",
 		     GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+#elif defined __GTK3__
+  g_signal_connect(GTK_WIDGET(window), "delete_event",
+		     G_CALLBACK(delete), NULL);
+  g_signal_connect(GTK_WIDGET(window), "destroy",
+		     G_CALLBACK(gtk_main_quit), NULL);
+#endif
 
 
+#if defined __GTK2__
   /* You should always delete gtk_gl_area widgets before exit or else
      GLX contexts are left undeleted, this may cause problems (=core dump)
      in some systems.
@@ -906,9 +986,14 @@
      destroy signal by other means.
   */
   gtk_quit_add_destroy(1, GTK_OBJECT(window));
+#endif
 
 
+#if defined __GTK2__
   vbox = GTK_WIDGET(gtk_vbox_new(FALSE, 0));
+#elif defined __GTK3__
+  vbox = GTK_WIDGET(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
+#endif
   gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
 
 
@@ -930,19 +1015,38 @@
 
   /* Connect signal handlers */
   /* Redraw image when exposed. */
+#if defined __GTK2__
   gtk_signal_connect(GTK_OBJECT(glarea), "expose_event",
 		     GTK_SIGNAL_FUNC(draw), NULL);
+#elif defined __GTK3__
+  g_signal_connect(GTK_WIDGET(glarea), "draw",
+		     G_CALLBACK(draw), NULL);
+#endif
+#if defined __GTK2__
   /* When window is resized viewport needs to be resized also. */
   gtk_signal_connect(GTK_OBJECT(glarea), "configure_event",
 		     GTK_SIGNAL_FUNC(reshape), NULL);
+#endif
   /* Do initialization when widget has been realized. */
+#if defined __GTK2__
   gtk_signal_connect(GTK_OBJECT(glarea), "realize",
 		     GTK_SIGNAL_FUNC(init), NULL);
+#elif defined __GTK3__
+  g_signal_connect(GTK_WIDGET(glarea), "realize",
+		     G_CALLBACK(init), NULL);
+#endif
   /* Capture keypress events */
+#if defined __GTK2__
   gtk_signal_connect(GTK_OBJECT(glarea), "key_press_event",
 		     GTK_SIGNAL_FUNC(key_press_event), NULL);
   gtk_signal_connect(GTK_OBJECT(glarea), "key_release_event",
 		     GTK_SIGNAL_FUNC(key_release_event), NULL);
+#elif defined __GTK3__
+  g_signal_connect(GTK_WIDGET(glarea), "key_press_event",
+		     G_CALLBACK(key_press_event), NULL);
+  g_signal_connect(GTK_WIDGET(glarea), "key_release_event",
+		     G_CALLBACK(key_release_event), NULL);
+#endif
 
   /* construct widget hierarchy  */
   gtk_container_add(GTK_CONTAINER(window),GTK_WIDGET(vbox));
@@ -958,11 +1062,19 @@
   gtk_widget_show(window);
 
   /* set focus to glarea widget */
+#if defined __GTK2__
   GTK_WIDGET_SET_FLAGS(glarea, GTK_CAN_FOCUS);
+#elif defined __GTK3__
+  gtk_widget_set_can_focus(glarea, TRUE);
+#endif
   gtk_widget_grab_focus(GTK_WIDGET(glarea));
 
   /* animating */
+#if defined __GTK2__
   gtk_idle_add((GtkFunction)animate, glarea);
+#elif defined __GTK3__
+  g_idle_add((GSourceFunc)animate, glarea);
+#endif
 
   game_init();
   gtk_main();
--- examples/viewlw.c	2009-07-17 21:29:39 +0000
+++ examples/viewlw.c	2013-09-18 05:40:11 +0000
@@ -93,17 +93,27 @@
   glEnable(GL_COLOR_MATERIAL);
 }
 
-gint glarea_expose(GtkWidget *widget, GdkEventExpose *event)
+#if defined __GTK2__
+gint glarea_draw(GtkWidget *widget, GdkEventExpose *event)
+#elif defined __GTK3__
+gboolean glarea_draw(GtkWidget *widget, cairo_t *cr)
+#endif
 {
   GLfloat m[4][4];
 
   GtkGLArea *glarea = GTK_GL_AREA(widget);
+#if defined __GTK2__
   mesh_info *info = (mesh_info*)gtk_object_get_data(GTK_OBJECT(widget), "mesh_info");
+#elif defined __GTK3__
+  mesh_info *info = (mesh_info*)g_object_get_data(G_OBJECT(widget), "mesh_info");
+#endif
 
+#ifdef __GTK2__
   /* draw only last expose */
   if (event->count > 0) {
     return TRUE;
   }
+#endif
 
   /* OpenGL calls can be done only if make_current returns true */
   if (gtk_gl_area_make_current(glarea)) {
@@ -113,6 +123,11 @@
       info->do_init = FALSE;
     }
 
+#ifdef __GTK3__
+    /* reshape depending on the new window size */
+    glViewport(0,0, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget));
+#endif
+
     /* view */
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
@@ -137,6 +152,7 @@
   return TRUE;
 }
 
+#ifdef __GTK2__
 gint glarea_configure(GtkWidget *widget, GdkEventConfigure *event)
 {
   /* OpenGL calls can be done only if make_current returns true */
@@ -145,11 +161,16 @@
   }
   return TRUE;
 }
+#endif
 
 gint glarea_destroy(GtkWidget *widget)
 {
   /* delete mesh info */
+#if defined __GTK2__
   mesh_info *info = (mesh_info*)gtk_object_get_data(GTK_OBJECT(widget),"mesh_info");
+#elif defined __GTK3__
+  mesh_info *info = (mesh_info*)g_object_get_data(G_OBJECT(widget),"mesh_info");
+#endif
   if (info) {
     lw_object_free(info->lwobject);
     g_free(info);
@@ -159,7 +180,11 @@
 
 gint glarea_button_press(GtkWidget *widget, GdkEventButton *event)
 {
+#if defined __GTK2__
   mesh_info *info = (mesh_info*)gtk_object_get_data(GTK_OBJECT(widget), "mesh_info");
+#elif defined __GTK3__
+  mesh_info *info = (mesh_info*)g_object_get_data(G_OBJECT(widget), "mesh_info");
+#endif
   if (event->button == 1) {
     /* beginning of drag, reset mouse position */
     info->beginx = event->x;
@@ -172,9 +197,18 @@
 gint glarea_motion_notify(GtkWidget *widget, GdkEventMotion *event)
 {
   int x, y;
+#if defined __GTK2__
   GdkRectangle area;
+#elif defined __GTK3__
+  cairo_t *area;
+  cairo_surface_t *surface;
+#endif
   GdkModifierType state;
+#if defined __GTK2__
   mesh_info *info = (mesh_info*)gtk_object_get_data(GTK_OBJECT(widget), "mesh_info");
+#elif defined __GTK3__
+  mesh_info *info = (mesh_info*)g_object_get_data(G_OBJECT(widget), "mesh_info");
+#endif
 
   if (event->is_hint) {
     /* fix this! */
@@ -187,31 +221,67 @@
     state = event->state;
   }
 
+#if defined __GTK2__
   area.x = 0;
   area.y = 0;
   area.width  = widget->allocation.width;
   area.height = widget->allocation.height;
+#elif defined __GTK3__
+  int width = gtk_widget_get_allocated_width(widget);
+  int height = gtk_widget_get_allocated_height(widget);
+  surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
+					       CAIRO_CONTENT_COLOR,
+					       width, height);
+#endif
 
   if (state & GDK_BUTTON1_MASK) {
     /* drag in progress, simulate trackball */
     float spin_quat[4];
     trackball(spin_quat,
+#if defined __GTK2__
 	      (2.0*info->beginx -       area.width) / area.width,
 	      (     area.height - 2.0*info->beginy) / area.height,
 	      (           2.0*x -       area.width) / area.width,
 	      (     area.height -            2.0*y) / area.height);
+#elif defined __GTK3__
+	      (2.0*info->beginx -            width) / width,
+	      (          height - 2.0*info->beginy) / height,
+	      (           2.0*x -            width) / width,
+	      (          height -            2.0*y) / height);
+#endif
     add_quats(spin_quat, info->quat, info->quat);
     /* orientation has changed, redraw mesh */
+#if defined __GTK3__
+    area = cairo_create (surface);
+    cairo_set_source_rgb (area, 1, 1, 1);
+    gtk_widget_draw(widget, area);
+    cairo_paint (area);
+    cairo_destroy (area);
+#elif defined __GTK2__
     gtk_widget_draw(widget, &area);
+#endif
   }
 
   if (state & GDK_BUTTON2_MASK) {
     /* zooming drag */
+#if defined __GTK2__
     info->zoom += ((y - info->beginy) / area.height) * 40;
+#elif defined __GTK3__
+    info->zoom += ((y - info->beginy) / height) * 40;
+#endif
+
     if (info->zoom < 5) info->zoom = 5;
     if (info->zoom > 120) info->zoom = 120;
     /* zoom has changed, redraw mesh */
+#if defined __GTK3__
+    area = cairo_create (surface);
+    cairo_set_source_rgb (area, 1, 1, 1);
+    gtk_widget_draw(widget, area);
+    cairo_paint (area);
+    cairo_destroy (area);
+#elif defined __GTK2__
     gtk_widget_draw(widget, &area);
+#endif
   }
   info->beginx = x;
   info->beginy = y;
@@ -222,16 +292,30 @@
 
 
 
-
+#if defined __GTK2__
 gint popup_menu_handler(GtkWidget *widget, GdkEventButton *event)
+#elif defined __GTK3__
+gint popup_menu_handler(GtkWidget *widget, GdkEventButton *event, gpointer data)
+#endif
 {
   if (event->button == 3) {
+#if defined __GTK2__
     gtk_menu_popup(GTK_MENU(widget), NULL, NULL, NULL, NULL,
+#elif defined __GTK3__
+    gtk_menu_popup(GTK_MENU(data), NULL, NULL, NULL, NULL,
+#endif
 		   event->button, event->time);
     return TRUE;
   }
   return FALSE;
 }
+#ifdef __GTK3__
+gint popup_menu_quit_all_handler(GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+  gtk_main_quit ();
+  return FALSE;
+}
+#endif
 void popup_menu_detacher(GtkWidget *attach_widget,GtkMenu *menu)
 {
 }
@@ -242,19 +326,28 @@
   GtkWidget *quit_item     = gtk_menu_item_new_with_label("Quit");
   GtkWidget *quit_all_item = gtk_menu_item_new_with_label("Quit All");
 
+#if defined __GTK2__
   gtk_menu_append(GTK_MENU(menu), open_item);
   gtk_menu_append(GTK_MENU(menu), quit_item);
   gtk_menu_append(GTK_MENU(menu), quit_all_item);
+#elif defined __GTK3__
+  gtk_menu_shell_append(GTK_MENU_SHELL(menu), open_item);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menu), quit_all_item);
+#endif
 
   gtk_widget_show(open_item);
+#ifdef __GTK2__
   gtk_widget_show(quit_item);
+#endif
   gtk_widget_show(quit_all_item);
 
   gtk_menu_attach_to_widget(GTK_MENU(menu),GTK_WIDGET(widget),popup_menu_detacher);
+
+#if defined __GTK2__
   gtk_signal_connect_object(GTK_OBJECT(widget), "destroy",
 			    GTK_SIGNAL_FUNC(gtk_menu_detach), GTK_OBJECT(menu));
 
- gtk_signal_connect_object(GTK_OBJECT(widget), "button_press_event",
+  gtk_signal_connect_object(GTK_OBJECT(widget), "button_press_event",
 			    GTK_SIGNAL_FUNC(popup_menu_handler), GTK_OBJECT(menu));
 
 
@@ -266,6 +359,20 @@
 
   gtk_signal_connect(GTK_OBJECT(quit_all_item), "activate",
 		     GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+#elif defined __GTK3__
+  g_signal_connect_object(GTK_WIDGET(widget), "destroy",
+			  G_CALLBACK(gtk_menu_detach), GTK_WIDGET(menu), 0);
+
+  g_signal_connect_object(GTK_WIDGET(widget), "button_press_event",
+			  G_CALLBACK(popup_menu_handler), GTK_WIDGET(menu), 0);
+
+
+  g_signal_connect(GTK_WIDGET(open_item), "activate",
+		   G_CALLBACK(select_lwobject), NULL);
+
+  g_signal_connect(GTK_WIDGET(quit_all_item), "activate",
+		   G_CALLBACK(popup_menu_quit_all_handler), NULL);
+#endif
 }
 
 
@@ -273,6 +380,10 @@
 gint window_count = 0; /* number of windows on screen */
 gint window_destroy(GtkWidget *widget)
 {
+#ifdef __GTK3__
+  gtk_widget_destroy(widget);
+#endif
+
   /* if this was last window quit */
   if (--window_count == 0)
     gtk_main_quit();
@@ -321,18 +432,39 @@
 			GDK_BUTTON_RELEASE_MASK|
 			GDK_POINTER_MOTION_MASK|
 			GDK_POINTER_MOTION_HINT_MASK);
+#if defined __GTK2__
   gtk_signal_connect (GTK_OBJECT(glarea), "expose_event",
-		      GTK_SIGNAL_FUNC(glarea_expose), NULL);
+		      GTK_SIGNAL_FUNC(glarea_draw), NULL);
   gtk_signal_connect (GTK_OBJECT(glarea), "motion_notify_event",
 		      GTK_SIGNAL_FUNC(glarea_motion_notify), NULL);
   gtk_signal_connect (GTK_OBJECT(glarea), "button_press_event",
 		      GTK_SIGNAL_FUNC(glarea_button_press), NULL);
+#elif defined __GTK3__
+  g_signal_connect (GTK_WIDGET(glarea), "draw",
+		    G_CALLBACK(glarea_draw), NULL);
+  g_signal_connect (GTK_WIDGET(glarea), "motion_notify_event",
+		    G_CALLBACK(glarea_motion_notify), NULL);
+  g_signal_connect (GTK_WIDGET(glarea), "button_press_event",
+		    G_CALLBACK(glarea_button_press), NULL);
+#endif
+#ifdef __GTK2__
   gtk_signal_connect (GTK_OBJECT(glarea), "configure_event",
 		      GTK_SIGNAL_FUNC(glarea_configure), NULL);
+#endif
+#if defined __GTK2__
   gtk_signal_connect (GTK_OBJECT(glarea), "destroy",
 		      GTK_SIGNAL_FUNC (glarea_destroy), NULL);
+#elif defined __GTK3__
+  g_signal_connect (GTK_WIDGET(glarea), "destroy",
+		    G_CALLBACK (glarea_destroy), NULL);
+#endif
 
-  gtk_widget_set_usize(glarea, 200,200/VIEW_ASPECT); /* minimum size */
+  /* minimum size */
+#if defined __GTK2__
+  gtk_widget_set_usize(glarea, 200,200/VIEW_ASPECT);
+#elif defined __GTK3__
+  gtk_widget_set_size_request(glarea, 200,200/VIEW_ASPECT);
+#endif
 
   /* set up mesh info */
   info = (mesh_info*)g_malloc(sizeof(mesh_info));
@@ -342,7 +474,11 @@
   info->beginy = 0;
   info->zoom   = 45;
   trackball(info->quat , 0.0, 0.0, 0.0, 0.0);
+#if defined __GTK2__
   gtk_object_set_data(GTK_OBJECT(glarea), "mesh_info", info);
+#elif defined __GTK3__
+  g_object_set_data(G_OBJECT(glarea), "mesh_info", info);
+#endif
 
 
   /* create new top level window */
@@ -350,12 +486,19 @@
   gtk_window_set_title(GTK_WINDOW(window), lwobject_name);
   gtk_container_set_border_width(GTK_CONTAINER(window), 10);
   create_popup_menu(window); /* add popup menu to window */
+#if defined __GTK2__
   gtk_signal_connect (GTK_OBJECT(window), "destroy",
 		      GTK_SIGNAL_FUNC(window_destroy), NULL);
+#elif defined __GTK3__
+  g_signal_connect (GTK_WIDGET(window), "destroy",
+		    G_CALLBACK(window_destroy), NULL);
+#endif
   window_count++;
 
+#ifdef __GTK2__
   /* destroy this window when exiting from gtk_main() */
   gtk_quit_add_destroy(1, GTK_OBJECT(window));
+#endif
 
 
   /* put glarea into window and show it all */
@@ -371,13 +514,18 @@
 
 gint filew_ok(GtkWidget *widget, GtkWidget *filew)
 {
+#if defined __GTK2__
   if (show_lwobject(gtk_file_selection_get_filename(GTK_FILE_SELECTION(filew))) == TRUE)
+#elif defined __GTK3__
+  if (show_lwobject(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filew))) == TRUE)
+#endif
     gtk_widget_destroy(filew);
   return TRUE;
 }
 
 void select_lwobject()
 {
+#if defined __GTK2__
   GtkWidget *filew = gtk_file_selection_new("Select LightWave 3D object");
 
   gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION (filew)->ok_button), "clicked",
@@ -388,9 +536,23 @@
 
   gtk_signal_connect (GTK_OBJECT(filew), "destroy",
 		      GTK_SIGNAL_FUNC(window_destroy), NULL);
+
   window_count++;
 
   gtk_widget_show(filew);
+#elif defined __GTK3__
+  GtkFileChooserDialog *filew = gtk_file_chooser_dialog_new("Select LightWave 3D object",
+							     NULL,
+							     GTK_FILE_CHOOSER_ACTION_OPEN,
+							     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+							     GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+							     NULL);
+
+  if ((gtk_dialog_run (filew)) == GTK_RESPONSE_ACCEPT)
+	filew_ok ((GtkWidget *)filew, (GtkWidget *)filew);
+  else
+    gtk_widget_destroy(filew);
+#endif
 }
 
 
--- examples/gtkglarea_demo.c	2009-07-17 21:29:39 +0000
+++ examples/gtkglarea_demo.c	2013-09-18 05:40:11 +0000
@@ -51,7 +51,11 @@
 gint       glarea_button_release (GtkWidget*, GdkEventButton*);
 gint       glarea_button_press   (GtkWidget*, GdkEventButton*);
 gint       glarea_motion_notify  (GtkWidget*, GdkEventMotion*);
+#if defined __GTK2__
 gint       glarea_draw           (GtkWidget*, GdkEventExpose*);
+#elif defined __GTK3__
+gint       glarea_draw           (GtkWidget*, cairo_t*);
+#endif
 gint       glarea_reshape        (GtkWidget*, GdkEventConfigure*);
 gint       glarea_init           (GtkWidget*);
 gint       glarea_destroy        (GtkWidget*);
@@ -137,48 +141,84 @@
   /* button_release_event - The user has released one of the  */
   /*                        mouse buttons in the window.      */
 
+#if defined __GTK2__
   gtk_signal_connect (GTK_OBJECT(glarea), "button_release_event",
                       GTK_SIGNAL_FUNC(glarea_button_release), NULL);
+#elif defined __GTK3__
+  g_signal_connect (GTK_WIDGET(glarea), "button_release_event",
+                    G_CALLBACK(glarea_button_release), NULL);
+#endif
 
   /* button_press_event - The user has pressed one of the     */
   /*                      mouse buttons in the window.        */
 
+#if defined __GTK2__
   gtk_signal_connect (GTK_OBJECT(glarea), "button_press_event",
                       GTK_SIGNAL_FUNC(glarea_button_press), NULL);
+#elif defined __GTK3__
+  g_signal_connect (GTK_WIDGET(glarea), "button_press_event",
+                    G_CALLBACK(glarea_button_press), NULL);
+#endif
 
   /* motion_notify_event - The mouse is moving in the window. */
 
+#if defined __GTK2__
   gtk_signal_connect (GTK_OBJECT(glarea), "motion_notify_event",
                       GTK_SIGNAL_FUNC(glarea_motion_notify), NULL);
+#elif defined __GTK3__
+  g_signal_connect (GTK_WIDGET(glarea), "motion_notify_event",
+                    G_CALLBACK(glarea_motion_notify), NULL);
+#endif
 
   /* expose_event - The window was exposed and the contents   */
   /*                need to be redrawn.                       */
 
+#if defined __GTK2__
   gtk_signal_connect (GTK_OBJECT(glarea), "expose_event",
                       GTK_SIGNAL_FUNC(glarea_draw), NULL);
+#elif defined __GTK3__
+  g_signal_connect(GTK_WIDGET(glarea), "draw",
+		   G_CALLBACK(glarea_draw), NULL);
+#endif
 
   /* configure_event - The window has been resized. You will  */
   /*                   probably want to call your reshape     */
   /*                   function here.                         */
 
+#ifdef __GTK2__
   gtk_signal_connect (GTK_OBJECT(glarea), "configure_event",
                       GTK_SIGNAL_FUNC(glarea_reshape), NULL);
+#endif
 
   /* realize - The window has been created, this is where you */
   /*           can hook up your initialization routines.      */
 
+#if defined __GTK2__
   gtk_signal_connect (GTK_OBJECT(glarea), "realize",
                       GTK_SIGNAL_FUNC(glarea_init), NULL);
+#elif defined __GTK3__
+  g_signal_connect (GTK_WIDGET(glarea), "realize",
+                    G_CALLBACK(glarea_init), NULL);
+#endif
 
   /* destroy - The window has received a destroy event, this  */
   /*           is where you should do any cleanup that needs  */
   /*           to happen, such as de-allocating data objects  */
   /*           that you have added to your GtkGLArea.         */
 
+#if defined __GTK2__
   gtk_signal_connect (GTK_OBJECT(glarea), "destroy",
                       GTK_SIGNAL_FUNC (glarea_destroy), NULL);
+#elif defined __GTK3__
+  g_signal_connect (GTK_WIDGET(glarea), "destroy",
+                    G_CALLBACK (glarea_destroy), NULL);
+#endif
 
+#if defined __GTK2__
   gtk_widget_set_usize(GTK_WIDGET(glarea), 256, 256);
+#elif defined __GTK3__
+  gtk_widget_set_size_request(GTK_WIDGET(glarea), 256, 256);
+#endif
 
   return (glarea);
 
@@ -306,13 +346,20 @@
 /*                                                                           */
 /*****************************************************************************/
 
-gint glarea_draw (GtkWidget* widget, GdkEventExpose* event) {
+#if defined __GTK2__
+gint glarea_draw (GtkWidget* widget, GdkEventExpose* event)
+#elif defined __GTK3__
+gboolean glarea_draw(GtkWidget *widget, cairo_t *cr)
+#endif
+{
 
+#ifdef __GTK2__
   /* Draw only on the last expose event. */
 
   if (event->count > 0) {
     return(TRUE);
   }
+#endif
 
   g_print ("Expose Event\n");
 
@@ -321,6 +368,10 @@
 
   if (gtk_gl_area_make_current(GTK_GL_AREA(widget))) {
 
+#ifdef __GTK3__
+      glViewport(0,0, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget));
+#endif
+
     /* Clear the drawing color buffer and depth buffers */
     /* before drawing.                                  */
 
@@ -353,6 +404,7 @@
 /*                                                                           */
 /*****************************************************************************/
 
+#ifdef __GTK2__
 gint glarea_reshape (GtkWidget* widget, GdkEventConfigure* event) {
 
   int w = widget->allocation.width;
@@ -381,6 +433,7 @@
   return (TRUE);
 
 }
+#endif
 
 /*****************************************************************************/
 /*                                                                           */
@@ -428,6 +481,15 @@
 
 }
 
+#ifdef __GTK3__
+gboolean delete(GtkWidget *widget, GdkEvent *event)
+{
+  gtk_widget_destroy (widget);
+
+  return FALSE;
+}
+#endif
+
 /*****************************************************************************/
 /*                                                                           */
 /* Function: main (int, char**)                                              */
@@ -448,7 +510,11 @@
 
   /* Main widget container */
 
+#if defined __GTK2__
   box_main = gtk_vbox_new (FALSE, 10);
+#elif defined __GTK3__
+  box_main = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
+#endif
 
   /* GTK GL Area */
 
@@ -458,8 +524,13 @@
 
   button_quit = gtk_button_new_with_label ("Quit");
 
+#if defined __GTK2__
   gtk_signal_connect (GTK_OBJECT(button_quit), "clicked",
                       GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+#elif defined __GTK3__
+  g_signal_connect (GTK_WIDGET(button_quit), "clicked",
+                    G_CALLBACK(gtk_main_quit), NULL);
+#endif
 
   /* Main window */
 
@@ -469,13 +540,23 @@
 
   /* destroy this window when exiting from gtk_main() */
 
+#ifdef __GTK2__
   gtk_quit_add_destroy (1, GTK_OBJECT(window));
+#endif
 
+#if defined __GTK2__
   gtk_signal_connect (GTK_OBJECT(window), "delete_event",
                       GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
 
   gtk_signal_connect (GTK_OBJECT (window), "destroy",
                       GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+#elif defined __GTK3__
+  g_signal_connect (GTK_WIDGET(window), "delete_event",
+                    G_CALLBACK(delete), NULL);
+
+  g_signal_connect (GTK_WIDGET (window), "destroy",
+                    G_CALLBACK(gtk_main_quit), NULL);
+#endif
 
   gtk_container_set_border_width (GTK_CONTAINER(window), 10);
 
--- examples/gdkfont.c	2009-07-17 21:29:39 +0000
+++ examples/gdkfont.c	2013-09-22 17:49:45 +0000
@@ -34,27 +34,57 @@
 gint init(GtkWidget *widget)
 {
   if (gtk_gl_area_make_current(GTK_GL_AREA(widget))) {
+#if defined __GTK2__
     GdkFont *font;
+#elif defined __GTK3__
+    PangoFont *font;
+    PangoFontDescription *fontdesc;
+    PangoFontMap *fontmap;
+    PangoFontMetrics *fontmetrics;
+    PangoLanguage *fontlanguage;
+    PangoContext *fontcontext;
+#endif
 
     /* set viewport */
+#if defined __GTK2__
     glViewport(0,0, widget->allocation.width, widget->allocation.height);
+#elif defined __GTK3__
+    glViewport(0,0, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget));
+#endif
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
+#if defined __GTK2__
     glOrtho(0,widget->allocation.width, 0,widget->allocation.height, -1.0, 1.0);
+#elif defined __GTK3__
+    glOrtho(0,gtk_widget_get_allocated_width(widget), 0,gtk_widget_get_allocated_height(widget), -1.0, 1.0);
+#endif
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
 
     /* generate font display lists */
     fontbase = glGenLists( 128 );
+#if defined __GTK2__
     font = gdk_font_load(fontname);
+#elif defined __GTK3__
+    fontcontext = pango_context_new();
+    fontmap = pango_cairo_font_map_get_default();
+    fontdesc = pango_font_description_from_string(fontname);
+    font = pango_font_map_load_font(fontmap, fontcontext, fontdesc);
+#endif
     if (!font) {
       g_print("Can't load font '%s'\n", fontname);
-      gtk_exit(1);
+      exit(1);
     }
 
     gdk_gl_use_gdk_font(font, 0, 128, fontbase);
+#if defined __GTK2__
     fontheight = font->ascent+font->descent;
     gdk_font_unref(font);
+#elif defined __GTK3__
+    fontlanguage = pango_language_get_default();
+    fontmetrics = pango_font_get_metrics(font, fontlanguage);
+    fontheight = pango_font_metrics_get_ascent(fontmetrics) + pango_font_metrics_get_descent (fontmetrics);
+#endif
 
   }
   return TRUE;
@@ -64,14 +94,20 @@
 /* When widget is exposed it's contents are redrawn. */
 gint draw(GtkWidget *widget, GdkEventExpose *event)
 {
+#ifdef __GTK2__
   /* Draw only last expose. */
   if (event->count > 0) {
     return TRUE;
   }
+#endif
 
   if (gtk_gl_area_make_current(GTK_GL_AREA(widget))) {
     int i,j;
 
+#ifdef __GTK3__
+      glViewport(0,0, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget));
+#endif
+
     /* clear screen */
     glClearColor(0,0,1,1);
     glClear(GL_COLOR_BUFFER_BIT);
@@ -79,7 +115,11 @@
     /* Draw some text */
     glColor3f(1,1,1);
     for (i=1; i<5; i++) {
+#if defined __GTK2__
       glRasterPos2f(10, widget->allocation.height-i*fontheight);
+#elif defined __GTK3__
+      glRasterPos2f(10, (gtk_widget_get_allocated_height(widget))-i*fontheight);
+#endif
       for (j=' '; j<='Z'; j++) {
 	glCallList(fontbase+j);
       }
@@ -97,6 +137,7 @@
   return TRUE;
 }
 
+#ifdef __GTK2__
 /* When glarea widget size changes, viewport size is set to match the new size */
 gint reshape(GtkWidget *widget, GdkEventConfigure *event)
 {
@@ -112,6 +153,16 @@
   }
   return TRUE;
 }
+#endif
+
+#ifdef __GTK3__
+gboolean delete(GtkWidget *widget, GdkEvent *event)
+{
+  gtk_widget_destroy (widget);
+
+  return FALSE;
+}
+#endif
 
 
 int main(int argc, char **argv)
@@ -121,7 +172,11 @@
   gtk_init(&argc, &argv);
 
   if (argc == 1) {
+#if defined __GTK2__
     fontname = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*";
+#elif defined __GTK3__
+    fontname = "Sans 10";
+#endif
   } else if (argc == 2) {
     fontname = argv[1];
   } else if (argc > 2) {
@@ -142,11 +197,20 @@
   gtk_container_set_border_width(GTK_CONTAINER(window), 10);
 
   /* Quit form main if got delete event */
+#if defined __GTK2__
   gtk_signal_connect(GTK_OBJECT(window), "delete_event",
 		     GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+#elif defined __GTK3__
+  g_signal_connect(GTK_WIDGET(window), "delete_event",
+		     G_CALLBACK(delete), NULL);
+  g_signal_connect(GTK_WIDGET(window), "destroy",
+		     G_CALLBACK(gtk_main_quit), NULL);
+#endif
 
+#ifdef __GTK2__
   /* Delete  widget before exit */
   gtk_quit_add_destroy(1, GTK_OBJECT(window));
+#endif
 
   /* Create new OpenGL widget. */
   glarea = GTK_WIDGET(gtk_gl_area_new_vargs(NULL,
@@ -162,14 +226,30 @@
 			GDK_BUTTON_PRESS_MASK);
 
   /* Connect signal handlers */
+#if defined __GTK2__
   gtk_signal_connect(GTK_OBJECT(glarea), "expose_event",
 		     GTK_SIGNAL_FUNC(draw), NULL);
+#elif defined __GTK3__
+  g_signal_connect(GTK_WIDGET(glarea), "draw",
+		     G_CALLBACK(draw), NULL);
+#endif
+#ifdef __GTK2__
   gtk_signal_connect(GTK_OBJECT(glarea), "configure_event",
 		     GTK_SIGNAL_FUNC(reshape), NULL);
+#endif
+#if defined __GTK2__
   gtk_signal_connect(GTK_OBJECT(glarea), "realize",
 		     GTK_SIGNAL_FUNC(init), NULL);
+#elif defined __GTK3__
+  g_signal_connect(GTK_WIDGET(glarea), "realize",
+		     G_CALLBACK(init), NULL);
+#endif
 
+#if defined __GTK2__
   gtk_widget_set_usize(GTK_WIDGET(glarea), 450,100);
+#elif defined __GTK3__
+  gtk_widget_set_size_request(GTK_WIDGET(glarea), 100,100);
+#endif
 
   /* put glarea into window and show it all */
   gtk_container_add(GTK_CONTAINER(window),GTK_WIDGET(glarea));
--- examples/glpixmap.c	2009-07-17 21:29:39 +0000
+++ examples/glpixmap.c	2013-09-19 02:09:57 +0000
@@ -40,9 +40,13 @@
 
 int main(int argc, char **argv)
 {
-  GtkWidget *window,*pixmapwidget;
+  GtkWidget *window, *pixmapwidget;
   GdkVisual *visual;
+#if defined __GTK2__
   GdkPixmap *pixmap;
+#elif defined __GTK3__
+  GdkPixbuf *pixmap;
+#endif
   GdkGLPixmap *glpixmap;
   GdkGLContext *context;
 
@@ -60,21 +64,34 @@
     g_print("Can't get visual\n");
     return 0;
   }
+#if defined __GTK2__
   gtk_widget_set_default_colormap(gdk_colormap_new(visual, TRUE));
   gtk_widget_set_default_visual(visual);
+#endif
 
   /* top level window. */
   window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title(GTK_WINDOW(window), "glpixmap");
   gtk_container_set_border_width(GTK_CONTAINER(window), 10);
+#if defined __GTK2__
   gtk_signal_connect(GTK_OBJECT(window), "delete_event",
 		     GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
   gtk_widget_set_usize(window, 100,100);
+#elif defined __GTK3__
+  g_signal_connect(GTK_WIDGET(window), "delete_event",
+		   G_CALLBACK(gtk_main_quit), NULL);
+  gtk_widget_set_size_request(window, 100,100);
+#endif
   gtk_widget_show(window);
 
   /* pixmap */
   context  = gdk_gl_context_new(visual);
+#if defined __GTK2__
   pixmap = gdk_pixmap_new(NULL, 80,80, visual->depth);
+#elif defined __GTK3__
+  pixmap = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE,
+                          8, 80,80);
+#endif
   glpixmap = gdk_gl_pixmap_new(visual, pixmap);
   if (gdk_gl_pixmap_make_current(glpixmap, context)) {
     glMatrixMode(GL_PROJECTION);
@@ -97,8 +114,13 @@
 
 
   /* pixmapwidget */
+#if defined __GTK2__
   pixmapwidget = gtk_pixmap_new( pixmap, NULL );
   gdk_pixmap_unref(pixmap);
+#elif defined __GTK3__
+  pixmapwidget = gtk_image_new_from_pixbuf(pixmap);
+  g_object_unref(G_OBJECT(pixmap));
+#endif
 
   gtk_container_add(GTK_CONTAINER(window), pixmapwidget);
   gtk_widget_show(pixmapwidget);
--- examples/shaders.c	2009-07-17 21:29:39 +0000
+++ examples/shaders.c	2013-09-18 08:40:15 +0000
@@ -246,19 +246,38 @@
 
   gtk_widget_set_events(GTK_WIDGET(glarea), GDK_EXPOSURE_MASK);
 
+#if defined __GTK2__
   gtk_signal_connect (GTK_OBJECT(glarea), "expose_event",
                       GTK_SIGNAL_FUNC(glarea_draw), NULL);
+#elif defined __GTK3__
+  g_signal_connect (GTK_WIDGET(glarea), "draw",
+                    G_CALLBACK(glarea_draw), NULL);
+#endif
 
+#ifdef __GTK2__
   gtk_signal_connect (GTK_OBJECT(glarea), "configure_event",
                       GTK_SIGNAL_FUNC(glarea_reshape), NULL);
+#endif
 
+#if defined __GTK2__
   gtk_signal_connect (GTK_OBJECT(glarea), "realize",
                       GTK_SIGNAL_FUNC(glarea_init), NULL);
 
   gtk_signal_connect (GTK_OBJECT(glarea), "destroy",
                       GTK_SIGNAL_FUNC (glarea_destroy), NULL);
+#elif defined __GTK3__
+  g_signal_connect (GTK_WIDGET(glarea), "realize",
+                    G_CALLBACK(glarea_init), NULL);
+
+  g_signal_connect (GTK_WIDGET(glarea), "destroy",
+                    G_CALLBACK (glarea_destroy), NULL);
+#endif
 
+#if defined __GTK2__
   gtk_widget_set_usize(GTK_WIDGET(glarea), 256, 256);
+#elif defined __GTK3__
+  gtk_widget_set_size_request(GTK_WIDGET(glarea), 256, 256);
+#endif
 
   return (glarea);
 
@@ -322,6 +341,7 @@
 /*                                                                           */
 /*****************************************************************************/
 
+#ifdef __GTK2__
 gint glarea_reshape (GtkWidget* widget, GdkEventConfigure* event) {
 
   int w = widget->allocation.width;
@@ -340,6 +360,7 @@
   return (TRUE);
 
 }
+#endif
 
 /*****************************************************************************/
 /*                                                                           */
@@ -400,6 +421,15 @@
 
 }
 
+#ifdef __GTK3__
+gboolean delete(GtkWidget *widget, GdkEvent *event)
+{
+  gtk_widget_destroy (widget);
+
+  return FALSE;
+}
+#endif
+
 /*****************************************************************************/
 /*                                                                           */
 /* Function: main (int, char**)                                              */
@@ -421,7 +451,11 @@
 
   /* Main widget container */
 
+#if defined __GTK2__
   box_main = gtk_vbox_new (FALSE, 10);
+#elif defined __GTK3__
+  box_main = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
+#endif
 
   /* GTK GL Area */
 
@@ -437,8 +471,13 @@
 
   button_quit = gtk_button_new_with_label ("Quit");
 
+#if defined __GTK2__
   gtk_signal_connect (GTK_OBJECT(button_quit), "clicked",
                       GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+#elif defined __GTK3__
+  g_signal_connect (GTK_WIDGET(button_quit), "clicked",
+                    G_CALLBACK(gtk_main_quit), NULL);
+#endif
 
   /* Main window */
 
@@ -448,13 +487,23 @@
 
   /* destroy this window when exiting from gtk_main() */
 
+#ifdef __GTK2__
   gtk_quit_add_destroy (1, GTK_OBJECT(window));
+#endif
 
+#if defined __GTK2__
   gtk_signal_connect (GTK_OBJECT(window), "delete_event",
                       GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
 
   gtk_signal_connect (GTK_OBJECT (window), "destroy",
                       GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+#elif defined __GTK3__
+  g_signal_connect (GTK_WIDGET(window), "delete_event",
+                    G_CALLBACK(delete), NULL);
+
+  g_signal_connect (GTK_WIDGET (window), "destroy",
+                    G_CALLBACK(gtk_main_quit), NULL);
+#endif
 
   gtk_container_set_border_width (GTK_CONTAINER(window), 10);
 
--- AUTHORS	2009-07-18 09:12:24 +0000
+++ AUTHORS	2013-09-22 17:53:05 +0000
@@ -15,4 +15,9 @@
  Jussi Löf <jussi.lof@pirko.fi> (LightWave objects)
  Andrew Marriott <raytrace@lillee.cs.curtin.edu.au> (original win32 port)
  Chris Abernethy <chris65536@home.com> (gtkglarea_demo.c)
+ Manuel Bachmann <tarnyko@tarnyko.net> (gtk+3 port)
+
+Contributors licensing
+----------------------
+ Manuel Bachmann : all contributions placed under the WTFPL license ;-)
 
--- configure.ac	2009-07-18 10:02:36 +0000
+++ configure.ac	2013-09-18 05:40:11 +0000
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(gtkglarea, 2.0.1)
+AC_INIT(gtkglarea, 2.0.2)
 AC_CONFIG_AUX_DIR(.auto)
 AC_CONFIG_HEADER(config.h)
 AM_INIT_AUTOMAKE([no-define])
@@ -56,8 +56,18 @@
 dnl
 dnl  Check for GTK libraries
 dnl
-GTK_REQUIRED_VERSION=2.0.0
-PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION gmodule-2.0 >= $GTK_REQUIRED_VERSION)
+AC_ARG_WITH(gtk,  [  --with-gtk=2/3             Use GTK+2 or GTK+3])
+GMODULE_REQUIRED_VERSION=2.0.0
+
+if test "x$with_gtk" = "x2" ; then
+ GTK_REQUIRED_VERSION=2.0.0
+ PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION gmodule-2.0 >= $GMODULE_REQUIRED_VERSION)
+ CFLAGS="$CFLAGS -D__GTK2__"
+else
+ GTK_REQUIRED_VERSION=3.0.0
+ PKG_CHECK_MODULES(GTK, gtk+-3.0 >= $GTK_REQUIRED_VERSION gmodule-2.0 >= $GMODULE_REQUIRED_VERSION)
+ CFLAGS="$CFLAGS -D__GTK3__"
+fi
 
 AC_SUBST(GTK_CFLAGS)
 AC_SUBST(GTK_LIBS)
