changeset 2035:4321c486aec7

use cairo for drawing cairo is the only supported drawing method in gtk3
author Vladimir Nadvornik <nadvornik@suse.cz>
date Thu, 02 Aug 2012 00:15:16 +0200
parents 9297985567b5
children 472c094c0154
files src/bar_exif.c src/bar_histogram.c src/cellrenderericon.c src/cellrenderericon.h src/collect-table.c src/dnd.c src/image.c src/layout.c src/layout_image.c src/logwindow.c src/main.c src/options.c src/pixbuf-renderer.c src/pixbuf-renderer.h src/pixbuf_util.c src/rcfile.c src/renderer-tiles.c src/renderer-tiles.h src/ui_bookmark.c src/ui_misc.c src/ui_tree_edit.c
diffstat 21 files changed, 434 insertions(+), 94 deletions(-) [+]
line wrap: on
line diff
--- a/src/bar_exif.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/bar_exif.c	Thu Aug 02 00:15:16 2012 +0200
@@ -712,6 +712,7 @@
 	g_free(ped);
 }
 
+#if !GTK_CHECK_VERSION(3,0,0)
 static void bar_pane_exif_size_request(GtkWidget *pane, GtkRequisition *requisition, gpointer data)
 {
 	PaneExifData *ped = data;
@@ -720,11 +721,15 @@
 		requisition->height = ped->min_height;
 		}
 }
+#endif
 
 static void bar_pane_exif_size_allocate(GtkWidget *pane, GtkAllocation *alloc, gpointer data)
 {
 	PaneExifData *ped = data;
 	ped->min_height = alloc->height;
+#if GTK_CHECK_VERSION(3,0,0)
+	gtk_widget_set_size_request(ped->widget, -1, ped->min_height);
+#endif
 }
 
 static GtkWidget *bar_pane_exif_new(const gchar *id, const gchar *title, gboolean expanded)
@@ -751,8 +756,12 @@
 	g_object_set_data(G_OBJECT(ped->widget), "pane_data", ped);
 	g_signal_connect_after(G_OBJECT(ped->widget), "destroy",
 			       G_CALLBACK(bar_pane_exif_destroy), ped);
+#if GTK_CHECK_VERSION(3,0,0)
+	gtk_widget_set_size_request(ped->widget, -1, ped->min_height);
+#else
 	g_signal_connect(G_OBJECT(ped->widget), "size-request",
 			 G_CALLBACK(bar_pane_exif_size_request), ped);
+#endif
 	g_signal_connect(G_OBJECT(ped->widget), "size-allocate",
 			 G_CALLBACK(bar_pane_exif_size_allocate), ped);
 	
--- a/src/bar_histogram.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/bar_histogram.c	Thu Aug 02 00:15:16 2012 +0200
@@ -144,6 +144,26 @@
 		}
 }
 
+#if GTK_CHECK_VERSION(3,0,0)
+static gboolean bar_pane_histogram_draw_cb(GtkWidget *widget, cairo_t *cr, gpointer data)
+{
+	PaneHistogramData *phd = data;
+	if (!phd) return TRUE;
+	
+	if (phd->need_update)
+		{
+		bar_pane_histogram_update(phd);
+		}
+	
+	if (!phd->pixbuf) return TRUE;
+	
+	gdk_cairo_set_source_pixbuf(cr, phd->pixbuf, 0, 0);
+	cairo_paint (cr);
+
+	return TRUE;
+}
+
+#else
 static gboolean bar_pane_histogram_expose_event_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
 {
 	PaneHistogramData *phd = data;
@@ -163,6 +183,7 @@
 
 	return TRUE;
 }
+#endif
 
 static void bar_pane_histogram_size_cb(GtkWidget *widget, GtkAllocation *allocation, gpointer data)
 {
@@ -304,8 +325,13 @@
 	g_signal_connect_after(G_OBJECT(phd->drawing_area), "size_allocate",
                                G_CALLBACK(bar_pane_histogram_size_cb), phd);
 
+#if GTK_CHECK_VERSION(3,0,0)
+	g_signal_connect(G_OBJECT(phd->drawing_area), "draw",  
+			 G_CALLBACK(bar_pane_histogram_draw_cb), phd);
+#else
 	g_signal_connect(G_OBJECT(phd->drawing_area), "expose_event",  
 			 G_CALLBACK(bar_pane_histogram_expose_event_cb), phd);
+#endif
 			 
 	gtk_box_pack_start(GTK_BOX(phd->widget), phd->drawing_area, TRUE, TRUE, 0);
 	gtk_widget_show(phd->drawing_area);
--- a/src/cellrenderericon.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/cellrenderericon.c	Thu Aug 02 00:15:16 2012 +0200
@@ -49,6 +49,14 @@
 					    gint		*y_offset,
 					    gint		*width,
 					    gint		*height);
+#if GTK_CHECK_VERSION(3,0,0)
+static void gqv_cell_renderer_icon_render(GtkCellRenderer *cell, 
+					   cairo_t *cr, 
+					   GtkWidget *widget, 
+					   const GdkRectangle *background_area, 
+					   const GdkRectangle *cell_area, 
+					   GtkCellRendererState flags);
+#else
 static void gqv_cell_renderer_icon_render(GtkCellRenderer	*cell,
 					   GdkWindow		*window,
 					   GtkWidget		*widget,
@@ -56,6 +64,8 @@
 					   GdkRectangle		*cell_area,
 					   GdkRectangle		*expose_area,
 					   GtkCellRendererState	flags);
+#endif
+
 
 static gint gqv_cell_renderer_icon_activate(GtkCellRenderer      *cell,
 					    GdkEvent             *event,
@@ -125,7 +135,7 @@
 static void
 gqv_cell_renderer_icon_init(GQvCellRendererIcon *cellicon)
 {
-	GTK_CELL_RENDERER(cellicon)->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE;
+	g_object_set(G_OBJECT(cellicon), "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL);
 	gtk_cell_renderer_set_padding(GTK_CELL_RENDERER(cellicon), 2, 2);
 }
 
@@ -553,7 +563,7 @@
 	gint calc_width;
 	gint calc_height;
 	gint xpad, ypad;
-	gint xalign, yalign;
+	gfloat xalign, yalign;
 	
 	gtk_cell_renderer_get_padding(cell, &xpad, &ypad);
 	gtk_cell_renderer_get_alignment(cell, &xalign, &yalign);
@@ -619,6 +629,17 @@
 	if (height) *height = calc_height;
 }
 
+#if GTK_CHECK_VERSION(3,0,0)
+static void gqv_cell_renderer_icon_render(GtkCellRenderer *cell, 
+					   cairo_t *cr, 
+					   GtkWidget *widget, 
+					   const GdkRectangle *background_area, 
+					   const GdkRectangle *cell_area, 
+					   GtkCellRendererState flags)
+
+{
+	GtkStyleContext *context = gtk_widget_get_style_context(widget);
+#else
 static void
 gqv_cell_renderer_icon_render(GtkCellRenderer		*cell,
 			      GdkWindow			*window,
@@ -629,6 +650,8 @@
 			      GtkCellRendererState	flags)
 
 {
+	cairo_t *cr = gdk_cairo_create(window);
+#endif
 	GQvCellRendererIcon *cellicon = (GQvCellRendererIcon *) cell;
 	GdkPixbuf *pixbuf;
 	const gchar *text;
@@ -676,6 +699,10 @@
 			state = GTK_STATE_NORMAL;
 		}
 
+#if GTK_CHECK_VERSION(3,0,0)
+	gtk_style_context_set_state(context, state);
+#endif
+
 	if (pixbuf)
 		{
 		GdkRectangle pix_rect;
@@ -695,13 +722,24 @@
 			pix_rect.y = cell_area->y + cell_rect.y;
 			}
 
-		if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) &&
-		    gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect))
+		if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) 
+#if !GTK_CHECK_VERSION(3,0,0)
+		    && gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect)
+#endif
+		   )
 			{
+			gdk_cairo_set_source_pixbuf(cr, pixbuf, pix_rect.x, pix_rect.y);
+			cairo_rectangle (cr,
+					draw_rect.x,
+					draw_rect.y,
+					draw_rect.width,
+					draw_rect.height);
+
+			cairo_fill (cr);
+/*			
 			gdk_draw_pixbuf(window,
 					widget->style->black_gc,
 					pixbuf,
-					/* pixbuf 0, 0 is at pix_rect.x, pix_rect.y */
 					draw_rect.x - pix_rect.x,
 					draw_rect.y - pix_rect.y,
 					draw_rect.x,
@@ -710,6 +748,7 @@
 					draw_rect.height,
 					GDK_RGB_DITHER_NORMAL,
 					0, 0);
+*/
 			}
 		}
 
@@ -719,7 +758,6 @@
 		PangoRectangle text_rect;
 		GdkRectangle pix_rect;
 		GdkRectangle draw_rect;
-
 		layout = gqv_cell_renderer_icon_get_layout(cellicon, widget, TRUE);
 		pango_layout_get_pixel_extents(layout, NULL, &text_rect);
 
@@ -733,17 +771,24 @@
 			pix_rect.y -= TOGGLE_SPACING;
 			}
 
-		if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) &&
-		    gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect))
+		if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect)
+#if !GTK_CHECK_VERSION(3,0,0)
+		    && gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect)
+#endif
+		    )
 			{
-			gtk_paint_layout(widget->style, window,
+#if GTK_CHECK_VERSION(3,0,0)
+			gtk_render_layout(context, cr, pix_rect.x - text_rect.x, pix_rect.y, layout);
+#else
+
+			gtk_paint_layout(gtk_widget_get_style(widget), window,
 					 state, TRUE,
 					 cell_area, widget,
 					 "cellrenderertext",
 					 pix_rect.x - text_rect.x, pix_rect.y,
 					 layout);
+#endif
 			}
-
 		g_object_unref(layout);
 		}
 
@@ -758,17 +803,48 @@
 		pix_rect.x = cell_area->x + xpad + (cell_rect.width - pix_rect.width + 1) / 2 + (TOGGLE_SPACING - TOGGLE_WIDTH) / 2;
 		pix_rect.y = cell_area->y + ypad + (cell_rect.height - pix_rect.height) + (TOGGLE_SPACING - TOGGLE_WIDTH) / 2;
 		
-		if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) &&
-		    gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect))
+		if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect)
+#if !GTK_CHECK_VERSION(3,0,0)
+		    && gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect)
+#endif
+		    )
 			{
 			for (i = 0; i < cellicon->num_marks; i++)
 				{
-				gtk_paint_check(widget->style, window,
+#if GTK_CHECK_VERSION(3,0,0)
+  				state &= ~(GTK_STATE_FLAG_ACTIVE);
+
+				if ((cellicon->marks & (1 << i)))
+					state |= GTK_STATE_FLAG_ACTIVE;
+
+				cairo_save (cr);
+
+				cairo_rectangle(cr, 
+						pix_rect.x + i * TOGGLE_SPACING + (TOGGLE_WIDTH - TOGGLE_SPACING) / 2,
+						pix_rect.y,
+						TOGGLE_WIDTH, TOGGLE_WIDTH);
+				cairo_clip (cr);
+
+				gtk_style_context_save(context);
+				gtk_style_context_set_state(context, state);
+
+				gtk_style_context_add_class(context, GTK_STYLE_CLASS_CHECK);
+
+				gtk_render_check(context, cr,
+					 pix_rect.x + i * TOGGLE_SPACING + (TOGGLE_WIDTH - TOGGLE_SPACING) / 2,
+					 pix_rect.y,
+					 TOGGLE_WIDTH, TOGGLE_WIDTH);
+				gtk_style_context_restore(context);
+				cairo_restore(cr);
+
+#else
+				gtk_paint_check(gtk_widget_get_style(widget), window,
 					 state, (cellicon->marks & (1 << i)) ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
 					 cell_area, widget, "cellcheck",
 					 pix_rect.x + i * TOGGLE_SPACING + (TOGGLE_WIDTH - TOGGLE_SPACING) / 2,
 					 pix_rect.y,
 					 TOGGLE_WIDTH, TOGGLE_WIDTH);
+#endif
 				}
 			}
                 }
@@ -779,13 +855,19 @@
 	if (cellicon->focused && GTK_WIDGET_HAS_FOCUS(widget))
 #endif
 		{
-		gtk_paint_focus(widget->style, window,
+#if GTK_CHECK_VERSION(3,0,0)
+#else
+		gtk_paint_focus(gtk_widget_get_style(widget), window,
 				state,
 				cell_area, widget,
 				"cellrendererfocus",
 				cell_area->x, cell_area->y,
 				cell_area->width, cell_area->height);
+#endif
 		}
+#if !GTK_CHECK_VERSION(3,0,0)
+	cairo_destroy(cr);
+#endif
 }
 
 static gint
--- a/src/cellrenderericon.h	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/cellrenderericon.h	Thu Aug 02 00:15:16 2012 +0200
@@ -22,8 +22,6 @@
 #ifndef __GQV_CELL_RENDERER_ICON_H__
 #define __GQV_CELL_RENDERER_ICON_H__
 
-#include <gtk/gtkcellrenderer.h>
-
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
--- a/src/collect-table.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/collect-table.c	Thu Aug 02 00:15:16 2012 +0200
@@ -1383,21 +1383,12 @@
 
 	if (!ct->marker_window)
 		{
-		GdkWindow *parent;
+		GdkWindow *parent = gtk_tree_view_get_bin_window(GTK_TREE_VIEW(ct->listview));
 		GdkWindowAttr attributes;
 		gint attributes_mask;
-		GdkPixmap *pixmap;
-		GdkBitmap *mask;
-		GdkPixbuf *pb;
-		gint w, h;
-
-		parent = gtk_tree_view_get_bin_window(GTK_TREE_VIEW(ct->listview));
-
-		pb = gdk_pixbuf_new_from_xpm_data((const gchar **)marker_xpm);
-		gdk_pixbuf_render_pixmap_and_mask(pb, &pixmap, &mask, 128);
-		g_object_unref(pb);
-
-		gdk_pixmap_get_size(pixmap, &w, &h);
+		GdkPixbuf *pb = gdk_pixbuf_new_from_xpm_data((const gchar **)marker_xpm);
+		gint w = gdk_pixbuf_get_width(pb);
+		gint h = gdk_pixbuf_get_height(pb);
 
 		attributes.window_type = GDK_WINDOW_CHILD;
 		attributes.wclass = GDK_INPUT_OUTPUT;
@@ -1407,11 +1398,34 @@
 		attributes_mask = 0;
 
 		ct->marker_window = gdk_window_new(parent, &attributes, attributes_mask);
+
+#if GTK_CHECK_VERSION(3,0,0)
+		cairo_region_t *mask;
+		cairo_pattern_t *pattern;
+		cairo_surface_t *img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
+		cairo_t *cr = cairo_create(img);
+		gdk_cairo_set_source_pixbuf(cr, pb, 0, 0);
+		cairo_paint(cr);
+		pattern = cairo_pattern_create_for_surface(img);
+		mask = gdk_cairo_region_create_from_surface(img);
+		gdk_window_shape_combine_region(ct->marker_window, mask, 0, 0);
+		gdk_window_set_background_pattern(ct->marker_window, pattern);
+		cairo_region_destroy(mask);
+		cairo_pattern_destroy(pattern);
+		cairo_destroy(cr);
+		cairo_surface_destroy(img);
+#else
+		GdkPixmap *pixmap;
+		GdkBitmap *mask;
+		gdk_pixbuf_render_pixmap_and_mask(pb, &pixmap, &mask, 128);
+
 		gdk_window_set_back_pixmap(ct->marker_window, pixmap, FALSE);
 		gdk_window_shape_combine_mask(ct->marker_window, mask, 0, 0);
 
 		g_object_unref(pixmap);
 		if (mask) g_object_unref(mask);
+#endif
+		g_object_unref(pb);
 		}
 
 	if (info)
@@ -1434,7 +1448,9 @@
 		y = cell.y + (cell.height / 2) - (h / 2);
 
 		gdk_window_move(ct->marker_window, x, y);
+#if !GTK_CHECK_VERSION(3,0,0)
 		gdk_window_clear(ct->marker_window);
+#endif
 		if (!gdk_window_is_visible(ct->marker_window)) gdk_window_show(ct->marker_window);
 		}
 	else
@@ -2448,7 +2464,7 @@
 
 	if (ct->popup)
 		{
-		g_signal_handlers_disconnect_matched(GTK_OBJECT(ct->popup), G_SIGNAL_MATCH_DATA,
+		g_signal_handlers_disconnect_matched(G_OBJECT(ct->popup), G_SIGNAL_MATCH_DATA,
 						     0, 0, 0, NULL, ct);
 		gtk_widget_destroy(ct->popup);
 		}
--- a/src/dnd.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/dnd.c	Thu Aug 02 00:15:16 2012 +0200
@@ -17,6 +17,7 @@
 #include "collect.h"
 #include "image.h"
 #include "ui_fileops.h"
+#include "pixbuf_util.h"
 
 
 GtkTargetEntry dnd_file_drag_types[] = {
@@ -72,6 +73,7 @@
 		}
 }
 
+/*
 static void pixbuf_draw_rect(GdkPixbuf *pixbuf, gint x, gint y, gint w, gint h, guint8 val)
 {
 	gboolean alpha;
@@ -96,7 +98,7 @@
 			}
 		}
 }
-
+*/
 void dnd_set_drag_icon(GtkWidget *widget, GdkDragContext *context, GdkPixbuf *pixbuf, gint items)
 {
 	GdkPixbuf *dest;
@@ -146,7 +148,7 @@
 		lw = CLAMP(lw, 0, w - x - 1);
 		lh = CLAMP(lh, 0, h - y - 1);
 
-		pixbuf_draw_rect(dest, x, y, lw, lh, 128);
+		pixbuf_draw_rect_fill(dest, x, y, lw, lh, 128, 128, 128, 255);
 		}
 
 	if (layout)
--- a/src/image.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/image.c	Thu Aug 02 00:15:16 2012 +0200
@@ -896,7 +896,7 @@
 
 	GtkAllocation allocation;
 	gtk_widget_get_allocation(widget, &allocation);
-
+#if !GTK_CHECK_VERSION(3,0,0)
 	if (has_focus)
 		{
 		gtk_paint_focus(gtk_widget_get_style(widget), gtk_widget_get_window(widget), GTK_STATE_ACTIVE,
@@ -911,6 +911,7 @@
 				 allocation.x, allocation.y,
 				 allocation.width - 1, allocation.height - 1);
 		}
+#endif
 }
 
 static gboolean image_focus_expose(GtkWidget *widget, GdkEventExpose *event, gpointer data)
@@ -1622,6 +1623,7 @@
 
 void image_to_root_window(ImageWindow *imd, gboolean scaled)
 {
+#if !GTK_CHECK_VERSION(3,0,0)
 	GdkScreen *screen;
 	GdkWindow *rootwindow;
 	GdkPixmap *pixmap;
@@ -1636,7 +1638,7 @@
 
 	screen = gtk_widget_get_screen(imd->widget);
 	rootwindow = gdk_screen_get_root_window(screen);
-	if (gdk_drawable_get_visual(rootwindow) != gdk_visual_get_system()) return;
+	if (gdk_window_get_visual(rootwindow) != gdk_visual_get_system()) return;
 
 	if (scaled)
 		{
@@ -1657,6 +1659,7 @@
 	g_object_unref(pixmap);
 
 	gdk_flush();
+#endif
 }
 
 void image_select(ImageWindow *imd, gboolean select)
@@ -1765,7 +1768,7 @@
 	g_free(imd);
 }
 
-static void image_destroy_cb(GtkObject *widget, gpointer data)
+static void image_destroy_cb(GtkWidget *widget, gpointer data)
 {
 	ImageWindow *imd = data;
 	image_free(imd);
@@ -1775,7 +1778,7 @@
 {
 	GtkAllocation allocation;
 	gtk_widget_get_allocation(widget, &allocation);
-	
+#if !GTK_CHECK_VERSION(3,0,0)	
 	gtk_paint_flat_box(gtk_widget_get_style(widget),
 			   gtk_widget_get_window(widget),
 			   gtk_widget_get_state(widget),
@@ -1786,7 +1789,7 @@
 			   allocation.x + 3, allocation.y + 3,
 			   allocation.width - 6, allocation.height - 6);
 
-
+#endif
 	return FALSE;
 }
 
--- a/src/layout.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/layout.c	Thu Aug 02 00:15:16 2012 +0200
@@ -1038,20 +1038,35 @@
 
 gboolean layout_geometry_get_dividers(LayoutWindow *lw, gint *h, gint *v)
 {
+	GtkAllocation h_allocation;
+	GtkAllocation v_allocation;
+	
 	if (!layout_valid(&lw)) return FALSE;
-
-	if (lw->h_pane && gtk_paned_get_child1(GTK_PANED(lw->h_pane))->allocation.x >= 0)
+	
+	if (lw->h_pane)
 		{
-		*h = gtk_paned_get_child1(GTK_PANED(lw->h_pane))->allocation.width;
+		GtkWidget *child = gtk_paned_get_child1(GTK_PANED(lw->h_pane));
+		gtk_widget_get_allocation(child, &h_allocation);
+		}
+
+	if (lw->v_pane)
+		{
+		GtkWidget *child = gtk_paned_get_child1(GTK_PANED(lw->v_pane));
+		gtk_widget_get_allocation(child, &v_allocation);
+		}
+
+	if (lw->h_pane && h_allocation.x >= 0)
+		{
+		*h = h_allocation.width;
 		}
 	else if (h != &lw->options.main_window.hdivider_pos)
 		{
 		*h = lw->options.main_window.hdivider_pos;
 		}
 
-	if (lw->v_pane && gtk_paned_get_child1(GTK_PANED(lw->v_pane))->allocation.x >= 0)
+	if (lw->v_pane && v_allocation.x >= 0)
 		{
-		*v = gtk_paned_get_child1(GTK_PANED(lw->v_pane))->allocation.height;
+		*v = v_allocation.height;
 		}
 	else if (v != &lw->options.main_window.vdivider_pos)
 		{
@@ -1146,6 +1161,7 @@
 gboolean layout_geometry_get_tools(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h, gint *divider_pos)
 {
 	GdkWindow *window;
+	GtkAllocation allocation;
 	if (!layout_valid(&lw)) return FALSE;
 
 #if GTK_CHECK_VERSION(2,20,0)
@@ -1165,14 +1181,15 @@
 	gdk_window_get_root_origin(window, x, y);
 	*w = gdk_window_get_width(window);
 	*h = gdk_window_get_height(window);
+	gtk_widget_get_allocation(gtk_paned_get_child1(GTK_PANED(lw->tools_pane)), &allocation);
 
 	if (GTK_IS_VPANED(lw->tools_pane))
 		{
-		*divider_pos = gtk_paned_get_child1(GTK_PANED(lw->tools_pane))->allocation.height;
+		*divider_pos = allocation.height;
 		}
 	else
 		{
-		*divider_pos = gtk_paned_get_child1(GTK_PANED(lw->tools_pane))->allocation.width;
+		*divider_pos = allocation.width;
 		}
 
 	return TRUE;
--- a/src/layout_image.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/layout_image.c	Thu Aug 02 00:15:16 2012 +0200
@@ -567,7 +567,7 @@
 {
 	LayoutWindow *lw = data;
 
-	gdk_window_get_origin(lw->image->pr->window, x, y);
+	gdk_window_get_origin(gtk_widget_get_window(lw->image->pr), x, y);
 	popup_menu_position_clamp(menu, x, y, 0);
 }
 
--- a/src/logwindow.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/logwindow.c	Thu Aug 02 00:15:16 2012 +0200
@@ -111,13 +111,15 @@
 static void log_window_init(LogWindow *logwin)
 {
 	GtkTextBuffer *buffer;
+#if !GTK_CHECK_VERSION(3,0,0)
 	GdkColormap *colormap;
+#endif
 	gboolean success[LOG_COUNT];
 	gint i;
 
 	g_assert(logwin != NULL);
 	g_assert(logwin->colors != NULL);
-
+#if !GTK_CHECK_VERSION(3,0,0)
 	for (i = LOG_NORMAL; i < LOG_COUNT; i++)
 		{
 		gboolean ok = gdk_color_parse(logdefs[i].color, &logwin->colors[i]);
@@ -144,7 +146,7 @@
 			break;
 			}
 		}
-
+#endif
 	buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text));
 	for (i = LOG_NORMAL; i < LOG_COUNT; i++)
 		gtk_text_buffer_create_tag(buffer, logdefs[i].tag,
--- a/src/main.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/main.c	Thu Aug 02 00:15:16 2012 +0200
@@ -19,6 +19,7 @@
 #ifdef G_OS_UNIX
 #include <pwd.h>
 #endif
+#include <locale.h>
 
 #include "main.h"
 
--- a/src/options.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/options.c	Thu Aug 02 00:15:16 2012 +0200
@@ -63,7 +63,7 @@
 	options->fullscreen.screen = -1;
 
 	memset(&options->image.border_color, 0, sizeof(options->image.border_color));
-	options->image.dither_quality = GDK_RGB_DITHER_NORMAL;
+//	options->image.dither_quality = GDK_RGB_DITHER_NORMAL;
 	options->image.enable_read_ahead = TRUE;
 	options->image.exif_rotate_enable = TRUE;
 	options->image.fit_window_to_image = FALSE;
--- a/src/pixbuf-renderer.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/pixbuf-renderer.c	Thu Aug 02 00:15:16 2012 +0200
@@ -121,7 +121,11 @@
 					 const GValue *value, GParamSpec *pspec);
 static void pixbuf_renderer_get_property(GObject *object, guint prop_id,
 					 GValue *value, GParamSpec *pspec);
+#if GTK_CHECK_VERSION(3,0,0)
+static gboolean pixbuf_renderer_draw(GtkWidget *widget, cairo_t *cr);
+#else
 static gboolean pixbuf_renderer_expose(GtkWidget *widget, GdkEventExpose *event);
+#endif
 
 static void pr_scroller_timer_set(PixbufRenderer *pr, gboolean start);
 
@@ -182,7 +186,11 @@
 
 	gobject_class->finalize = pixbuf_renderer_finalize;
 
-	widget_class->expose_event = pixbuf_renderer_expose;
+#if GTK_CHECK_VERSION(3,0,0)
+	widget_class->draw = pixbuf_renderer_draw;
+#else
+  	widget_class->expose_event = pixbuf_renderer_expose;
+#endif
 
 	g_object_class_install_property(gobject_class,
 					PROP_ZOOM_MIN,
@@ -229,7 +237,7 @@
 							     NULL,
 							     FALSE,
 							     G_PARAM_READABLE | G_PARAM_WRITABLE));
-
+#if !GTK_CHECK_VERSION(3,0,0)
 	g_object_class_install_property(gobject_class,
 					PROP_DITHER_QUALITY,
 					g_param_spec_uint("dither_quality",
@@ -239,7 +247,7 @@
 							  GDK_RGB_DITHER_MAX,
 							  GDK_RGB_DITHER_NORMAL,
 							  G_PARAM_READABLE | G_PARAM_WRITABLE));
-
+#endif
 	g_object_class_install_property(gobject_class,
 					PROP_SCROLL_RESET,
 					g_param_spec_uint("scroll_reset",
@@ -412,7 +420,9 @@
 	pr->scale = 1.0;
 	pr->aspect_ratio = 1.0;
 
+#if !GTK_CHECK_VERSION(3,0,0)
 	pr->dither_quality = GDK_RGB_DITHER_NORMAL;
+#endif
 
 	pr->scroll_reset = PR_SCROLL_RESET_TOPLEFT;
 
@@ -489,9 +499,11 @@
 		case PROP_ZOOM_EXPAND:
 			pr->zoom_expand = g_value_get_boolean(value);
 			break;
+#if !GTK_CHECK_VERSION(3,0,0)
 		case PROP_DITHER_QUALITY:
 			pr->dither_quality = g_value_get_uint(value);
 			break;
+#endif
 		case PROP_SCROLL_RESET:
 			pr->scroll_reset = g_value_get_uint(value);
 			break;
@@ -555,9 +567,11 @@
 		case PROP_ZOOM_EXPAND:
 			g_value_set_boolean(value, pr->zoom_expand);
 			break;
+#if !GTK_CHECK_VERSION(3,0,0)
 		case PROP_DITHER_QUALITY:
 			g_value_set_uint(value, pr->dither_quality);
 			break;
+#endif
 		case PROP_SCROLL_RESET:
 			g_value_set_uint(value, pr->scroll_reset);
 			break;
@@ -597,6 +611,26 @@
 		}
 }
 
+#if GTK_CHECK_VERSION(3,0,0)
+
+static gboolean pixbuf_renderer_draw(GtkWidget *widget, cairo_t *cr)
+{
+	if (gtk_widget_is_drawable(widget))
+		{
+		if (gtk_widget_get_has_window(widget))
+			{
+			GdkRectangle area;
+			if (gdk_cairo_get_clip_rectangle(cr, &area))
+				{
+				pixbuf_renderer_paint(PIXBUF_RENDERER(widget), &area);
+				}
+			}
+		}
+
+	return FALSE;
+}
+
+#else
 static gboolean pixbuf_renderer_expose(GtkWidget *widget, GdkEventExpose *event)
 {
 #if GTK_CHECK_VERSION(2,20,0)
@@ -616,7 +650,6 @@
 				GdkRectangle area;
 
 				gdk_window_get_position(event->window, &area.x, &area.y);
-
 				area.x += event->area.x;
 				area.y += event->area.y;
 				area.width = event->area.width;
@@ -632,6 +665,7 @@
 
 	return FALSE;
 }
+#endif
 
 /*
  *-------------------------------------------------------------------
@@ -2455,7 +2489,9 @@
 		if (GTK_WIDGET_REALIZED(box))
 #endif
 			{
+#if !GTK_CHECK_VERSION(3,0,0)
 			gdk_window_clear(gtk_widget_get_window(box));
+#endif
 			pr->renderer->overlay_draw(pr->renderer, 0, 0, pr->viewport_width, pr->viewport_height);
 			if (pr->renderer2) pr->renderer2->overlay_draw(pr->renderer2, 0, 0, pr->viewport_width, pr->viewport_height);
 			}
--- a/src/pixbuf-renderer.h	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/pixbuf-renderer.h	Thu Aug 02 00:15:16 2012 +0200
@@ -13,10 +13,6 @@
 #ifndef PIXBUF_RENDERER_H
 #define PIXBUF_RENDERER_H
 
-#include <gtk/gtkeventbox.h>
-#include <gtk/gtkwindow.h>
-
-
 #define TYPE_PIXBUF_RENDERER		(pixbuf_renderer_get_type())
 #define PIXBUF_RENDERER(obj)		(G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_PIXBUF_RENDERER, PixbufRenderer))
 #define PIXBUF_RENDERER_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST((klass), TYPE_PIXBUF_RENDERER, PixbufRendererClass))
@@ -145,7 +141,9 @@
 	gboolean zoom_2pass;
 	gboolean zoom_expand;
 
+#if !GTK_CHECK_VERSION(3,0,0)
 	GdkRgbDither dither_quality;
+#endif
 
 	PixbufRendererScrollResetType scroll_reset;
 
--- a/src/pixbuf_util.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/pixbuf_util.c	Thu Aug 02 00:15:16 2012 +0200
@@ -782,7 +782,6 @@
 {
 	GdkPixbuf *buffer;
 	gint w, h;
-	GdkGC *gc;
 	gint sx, sy;
 	gint dw, dh;
 	cairo_surface_t *source;
--- a/src/rcfile.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/rcfile.c	Thu Aug 02 00:15:16 2012 +0200
@@ -618,7 +618,9 @@
 		if (READ_INT(*options, image.tile_cache_max)) continue;
 		if (READ_INT(*options, image.image_cache_max)) continue;
 		if (READ_UINT_CLAMP(*options, image.zoom_quality, GDK_INTERP_NEAREST, GDK_INTERP_HYPER)) continue;
+#if !GTK_CHECK_VERSION(3,0,0)
 		if (READ_UINT_CLAMP(*options, image.dither_quality, GDK_RGB_DITHER_NONE, GDK_RGB_DITHER_MAX)) continue;
+#endif
 		if (READ_INT(*options, image.zoom_increment)) continue;
 		if (READ_BOOL(*options, image.enable_read_ahead)) continue;
 		if (READ_BOOL(*options, image.exif_rotate_enable)) continue;
--- a/src/renderer-tiles.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/renderer-tiles.c	Thu Aug 02 00:15:16 2012 +0200
@@ -59,7 +59,7 @@
 
 struct _ImageTile
 {
-	GdkPixmap *pixmap;	/* off screen buffer */
+	cairo_surface_t *surface;	/* off screen buffer */
 	GdkPixbuf *pixbuf;	/* pixbuf area for zooming */
 	gint x;			/* x offset into image */
 	gint y;			/* y offset into image */
@@ -126,7 +126,7 @@
 	GList *draw_queue_2pass;/* list when 2 pass is enabled */
 
 	GList *overlay_list;
-	GdkPixmap *overlay_buffer;
+	cairo_surface_t *overlay_buffer;
 	
 	guint draw_idle_id; /* event source id */
 
@@ -194,11 +194,17 @@
 {
 	PixbufRenderer *pr = rt->pr;
 	GtkWidget *box;
+	GdkWindow *window;
 	gint rx, ry, rw, rh;
+	cairo_t *cr;
 
 	box = GTK_WIDGET(pr);
+	window = gtk_widget_get_window(box);
 
-	if (!box->window) return;
+	if (!window) return;
+
+	cr = gdk_cairo_create(window);
+
 
 	if (!pr->pixbuf && !pr->source_tiles_enabled)
 		{
@@ -207,7 +213,10 @@
 				   pr->viewport_width, pr->viewport_height,
 				   &rx, &ry, &rw, &rh))
 			{
-			gdk_window_clear_area(box->window, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
+			cairo_set_source_rgb(cr, 0, 0, 0);
+			cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
+			cairo_fill(cr);
+			cairo_destroy(cr);
 			rt_overlay_draw(rt, rx, ry, rw, rh, NULL);
 			}
 		return;
@@ -221,7 +230,9 @@
 				   pr->x_offset, pr->viewport_height,
 				   &rx, &ry, &rw, &rh))
 			{
-			gdk_window_clear_area(box->window, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
+			cairo_set_source_rgb(cr, 0, 0, 0);
+			cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
+			cairo_fill(cr);
 			rt_overlay_draw(rt, rx, ry, rw, rh, NULL);
 			}
 		if (pr->viewport_width - pr->vis_width - pr->x_offset > 0 &&
@@ -230,7 +241,9 @@
 				   pr->viewport_width - pr->vis_width - pr->x_offset, pr->viewport_height,
 				   &rx, &ry, &rw, &rh))
 			{
-			gdk_window_clear_area(box->window, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
+			cairo_set_source_rgb(cr, 0, 0, 0);
+			cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
+			cairo_fill(cr);
 			rt_overlay_draw(rt, rx, ry, rw, rh, NULL);
 			}
 		}
@@ -242,7 +255,9 @@
 				   pr->vis_width, pr->y_offset,
 				   &rx, &ry, &rw, &rh))
 			{
-			gdk_window_clear_area(box->window, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
+			cairo_set_source_rgb(cr, 0, 0, 0);
+			cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
+			cairo_fill(cr);
 			rt_overlay_draw(rt, rx, ry, rw, rh, NULL);
 			}
 		if (pr->viewport_height - pr->vis_height - pr->y_offset > 0 &&
@@ -251,10 +266,13 @@
 				   pr->vis_width, pr->viewport_height - pr->vis_height - pr->y_offset,
 				   &rx, &ry, &rw, &rh))
 			{
-			gdk_window_clear_area(box->window, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
+			cairo_set_source_rgb(cr, 0, 0, 0);
+			cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
+			cairo_fill(cr);
 			rt_overlay_draw(rt, rx, ry, rw, rh, NULL);
 			}
 		}
+	cairo_destroy(cr);
 }
 
 static void rt_border_clear(RendererTiles *rt)
@@ -291,7 +309,7 @@
 	if (!it) return;
 
 	if (it->pixbuf) g_object_unref(it->pixbuf);
-	if (it->pixmap) g_object_unref(it->pixmap);
+	if (it->surface) cairo_surface_destroy(it->surface);
 
 	g_free(it);
 }
@@ -466,29 +484,31 @@
 	return rt_tile_add(rt, x, y);
 }
 
-static gint pixmap_calc_size(GdkPixmap *pixmap)
+static gint pixmap_calc_size(cairo_surface_t *surface)
 {
-	gint w, h, d;
+//	gint w, h, d;
 
-	d = gdk_drawable_get_depth(pixmap);
-	gdk_drawable_get_size(pixmap, &w, &h);
-	return w * h * (d / 8);
+//	d = gdk_drawable_get_depth(pixmap);
+//	gdk_drawable_get_size(pixmap, &w, &h);
+	return PR_TILE_SIZE * PR_TILE_SIZE * 4 / 8;
 }
 
 static void rt_tile_prepare(RendererTiles *rt, ImageTile *it)
 {
 	PixbufRenderer *pr = rt->pr;
-	if (!it->pixmap)
+	if (!it->surface)
 		{
-		GdkPixmap *pixmap;
+		cairo_surface_t *surface;
 		guint size;
 
-		pixmap = gdk_pixmap_new(((GtkWidget *)pr)->window, rt->tile_width, rt->tile_height, -1);
+		surface = gdk_window_create_similar_surface(gtk_widget_get_window((GtkWidget *)pr),
+		                                            CAIRO_CONTENT_COLOR,
+		                                            rt->tile_width, rt->tile_height);
 
-		size = pixmap_calc_size(pixmap);
+		size = pixmap_calc_size(surface);
 		rt_tile_free_space(rt, size, it);
 
-		it->pixmap = pixmap;
+		it->surface = surface;
 		it->size += size;
 		rt->tile_cache_size += size;
 		}
@@ -553,7 +573,7 @@
 	attributes.event_mask = GDK_EXPOSURE_MASK;
 	attributes_mask = 0;
 
-	od->window = gdk_window_new(GTK_WIDGET(pr)->window, &attributes, attributes_mask);
+	od->window = gdk_window_new(gtk_widget_get_window(GTK_WIDGET(pr)), &attributes, attributes_mask);
 	gdk_window_set_user_data(od->window, pr);
 	gdk_window_move(od->window, px + rt->stereo_off_x, py + rt->stereo_off_y);
 	gdk_window_show(od->window);
@@ -585,11 +605,33 @@
 			{
 			if (!rt->overlay_buffer)
 				{
-				rt->overlay_buffer = gdk_pixmap_new(((GtkWidget *)pr)->window, rt->tile_width, rt->tile_height, -1);
+				rt->overlay_buffer = gdk_window_create_similar_surface(gtk_widget_get_window((GtkWidget *)pr),
+		                                            CAIRO_CONTENT_COLOR,
+		                                            rt->tile_width, rt->tile_height);
 				}
 
 			if (it)
 				{
+				cairo_t *cr;
+
+				cr = cairo_create(rt->overlay_buffer);
+				cairo_set_source_surface(cr, it->surface, (pr->x_offset + (it->x - rt->x_scroll)) - rx, (pr->y_offset + (it->y - rt->y_scroll)) - ry);
+				cairo_rectangle(cr, 0, 0, rw, rh);
+				cairo_fill_preserve(cr);
+				
+				gdk_cairo_set_source_pixbuf(cr, od->pixbuf, px - rx, py - ry);
+				cairo_fill (cr);
+				cairo_destroy (cr);
+				
+				cr = gdk_cairo_create(od->window);
+				cairo_set_source_surface(cr, rt->overlay_buffer, rx - px, ry - py);
+				cairo_rectangle (cr, rx - px, ry - py, rw, rh);
+				cairo_fill (cr);
+				cairo_destroy (cr);
+
+#if 0
+				
+				
 #if GTK_CHECK_VERSION(2,20,0)
 				gdk_draw_drawable(rt->overlay_buffer, box->style->fg_gc[gtk_widget_get_state(box)],
 #else
@@ -617,6 +659,7 @@
 						  rt->overlay_buffer,
 						  0, 0,
 						  rx - px, ry - py, rw, rh);
+#endif
 				}
 			else
 				{
@@ -627,10 +670,27 @@
 				    for (sy = ry; sy < ry + rh; sy += rt->tile_height)
 					{
 					gint sw, sh;
+					cairo_t *cr;
 
 					sw = MIN(rx + rw - sx, rt->tile_width);
 					sh = MIN(ry + rh - sy, rt->tile_height);
 
+					cr = cairo_create(rt->overlay_buffer);
+					cairo_set_source_rgb(cr, 0, 0, 0);
+					cairo_rectangle(cr, 0, 0, sw, sh);
+					cairo_fill_preserve(cr);
+				
+					gdk_cairo_set_source_pixbuf(cr, od->pixbuf, px - sx, py - sy);
+					cairo_fill (cr);
+					cairo_destroy (cr);
+				
+					cr = gdk_cairo_create(od->window);
+					cairo_set_source_surface(cr, rt->overlay_buffer, sx - px, sy - py);
+					cairo_rectangle (cr, sx - px, sy - py, sw, sh);
+					cairo_fill(cr);
+					cairo_destroy(cr);
+
+#if 0
 					gdk_draw_rectangle(rt->overlay_buffer,
 #if GTK_CHECK_VERSION(2,20,0)
 							   box->style->bg_gc[gtk_widget_get_state(box)], TRUE,
@@ -656,6 +716,7 @@
 							  rt->overlay_buffer,
 							  0, 0,
 							  sx - px, sy - py, sw, sh);
+#endif
 					}
 				}
 			}
@@ -776,7 +837,7 @@
 
 	if (!rt->overlay_list && rt->overlay_buffer)
 		{
-		g_object_unref(rt->overlay_buffer);
+		cairo_surface_destroy(rt->overlay_buffer);
 		rt->overlay_buffer = NULL;
 		}
 }
@@ -796,7 +857,7 @@
 {
 	GList *work;
 
-	if (rt->overlay_buffer) g_object_unref(rt->overlay_buffer);
+	if (rt->overlay_buffer) cairo_surface_destroy(rt->overlay_buffer);
 	rt->overlay_buffer = NULL;
 
 	work = rt->overlay_list;
@@ -1140,13 +1201,22 @@
 					   it->x + x, it->y + y, w, h,
 					   &rx, &ry, &rw, &rh))
 				{
+				cairo_t *cr;
+				cr = cairo_create(it->surface);
+				cairo_rectangle (cr, rx - st->x, ry - st->y, rw, rh);
+
 				if (st->blank)
 					{
+					cairo_set_source_rgb(cr, 0, 0, 0);
+#if 0
 					gdk_draw_rectangle(it->pixmap, box->style->black_gc, TRUE,
 							   rx - st->x, ry - st->y, rw, rh);
+#endif
 					}
 				else /* (pr->zoom == 1.0 || pr->scale == 1.0) */
 					{
+					gdk_cairo_set_source_pixbuf(cr, st->pixbuf, it->x + st->x, it->y + st->y);
+#if 0
 					gdk_draw_pixbuf(it->pixmap,
 #if GTK_CHECK_VERSION(2,20,0)
 							box->style->fg_gc[gtk_widget_get_state(box)],
@@ -1158,7 +1228,10 @@
 							rx - it->x, ry - it->y,
 							rw, rh,
 							pr->dither_quality, rx, ry);
+#endif
 					}
+				cairo_fill (cr);
+				cairo_destroy (cr);
 				}
 			}
 		}
@@ -1203,10 +1276,19 @@
 					   it->x + x, it->y + y, w, h,
 					   &rx, &ry, &rw, &rh))
 				{
+
 				if (st->blank)
 					{
+					cairo_t *cr;
+					cr = cairo_create(it->surface);
+					cairo_rectangle (cr, rx - st->x, ry - st->y, rw, rh);
+					cairo_set_source_rgb(cr, 0, 0, 0);
+					cairo_fill (cr);
+					cairo_destroy (cr);
+#if 0					
 					gdk_draw_rectangle(it->pixmap, box->style->black_gc, TRUE,
 							   rx - st->x, ry - st->y, rw, rh);
+#endif
 					}
 				else
 					{
@@ -1298,7 +1380,7 @@
 	gboolean draw = FALSE;
 	gint orientation = rt_get_orientation(rt);
 
-	if (it->render_todo == TILE_RENDER_NONE && it->pixmap && !new_data) return;
+	if (it->render_todo == TILE_RENDER_NONE && it->surface && !new_data) return;
 
 	if (it->render_done != TILE_RENDER_ALL)
 		{
@@ -1330,8 +1412,16 @@
 	if (it->blank)
 		{
 		/* no data, do fast rect fill */
+		cairo_t *cr;
+		cr = cairo_create(it->surface);
+		cairo_rectangle (cr, 0, 0, it->w, it->h);
+		cairo_set_source_rgb(cr, 0, 0, 0);
+		cairo_fill (cr);
+		cairo_destroy (cr);
+#if 0
 		gdk_draw_rectangle(it->pixmap, box->style->black_gc, TRUE,
 				   0, 0, it->w, it->h);
+#endif
 		}
 	else if (pr->source_tiles_enabled)
 		{
@@ -1345,6 +1435,14 @@
 		 !(rt->stereo_mode & PR_STEREO_ANAGLYPH))
 		{
 		/* special case: faster, simple, scale 1.0, base orientation, no postprocessing */
+		cairo_t *cr;
+		cr = cairo_create(it->surface);
+		cairo_rectangle (cr, x, y, w, h);
+		gdk_cairo_set_source_pixbuf(cr, pr->pixbuf, -it->x - GET_RIGHT_PIXBUF_OFFSET(rt), -it->y);
+		cairo_fill (cr);
+		cairo_destroy (cr);
+
+#if 0
 		gdk_draw_pixbuf(it->pixmap, 
 #if GTK_CHECK_VERSION(2,20,0)
 				box->style->fg_gc[gtk_widget_get_state(box)],
@@ -1356,6 +1454,7 @@
 				x, y,
 				w, h,
 				pr->dither_quality, it->x + x, it->y + y);
+#endif
 		}
 	else
 		{
@@ -1427,10 +1526,17 @@
 
 	if (draw && it->pixbuf && !it->blank)
 		{
+		cairo_t *cr;
 
 		if (pr->func_post_process && !(pr->post_process_slow && fast))
 			pr->func_post_process(pr, &it->pixbuf, x, y, w, h, pr->post_process_user_data);
 
+		cr = cairo_create(it->surface);
+		cairo_rectangle (cr, x, y, w, h);
+		gdk_cairo_set_source_pixbuf(cr, it->pixbuf, 0, 0);
+		cairo_fill (cr);
+		cairo_destroy (cr);
+#if 0
 		gdk_draw_pixbuf(it->pixmap,
 #if GTK_CHECK_VERSION(2,20,0)
 				box->style->fg_gc[gtk_widget_get_state(box)],
@@ -1442,6 +1548,7 @@
 				x, y,
 				w, h,
 				pr->dither_quality, it->x + x, it->y + y);
+#endif
 		}
 
 #if 0
@@ -1460,6 +1567,8 @@
 {
 	PixbufRenderer *pr = rt->pr;
 	GtkWidget *box;
+	GdkWindow *window;
+	cairo_t *cr;
 
 	/* clamp to visible */
 	if (it->x + x < rt->x_scroll)
@@ -1486,14 +1595,23 @@
 	rt_tile_render(rt, it, x, y, w, h, new_data, fast);
 
 	box = GTK_WIDGET(pr);
+	window = gtk_widget_get_window(box);
 
+	cr = gdk_cairo_create(window);
+	cairo_set_source_surface(cr, it->surface, pr->x_offset + (it->x - rt->x_scroll) + rt->stereo_off_x, pr->y_offset + (it->y - rt->y_scroll) + rt->stereo_off_y);
+	cairo_rectangle (cr, pr->x_offset + (it->x - rt->x_scroll) + x + rt->stereo_off_x, pr->y_offset + (it->y - rt->y_scroll) + y + rt->stereo_off_y, w, h);
+	cairo_fill (cr);
+	cairo_destroy (cr);
+
+#if 0
 #if GTK_CHECK_VERSION(2,20,0)
-	gdk_draw_drawable(box->window, box->style->fg_gc[gtk_widget_get_state(box)],
+	gdk_draw_drawable(window, box->style->fg_gc[gtk_widget_get_state(box)],
 #else
-	gdk_draw_drawable(box->window, box->style->fg_gc[GTK_WIDGET_STATE(box)],
+	gdk_draw_drawable(window, box->style->fg_gc[GTK_WIDGET_STATE(box)],
 #endif
 			  it->pixmap, x, y,
 			  pr->x_offset + (it->x - rt->x_scroll) + x + rt->stereo_off_x, pr->y_offset + (it->y - rt->y_scroll) + y + rt->stereo_off_y, w, h);
+#endif
 
 	if (rt->overlay_list)
 		{
@@ -1628,7 +1746,7 @@
 			{
 			/* if new pixel data, and we already have a pixmap, update the tile */
 			qd->it->blank = FALSE;
-			if (qd->it->pixmap && qd->it->render_done == TILE_RENDER_ALL)
+			if (qd->it->surface && qd->it->render_done == TILE_RENDER_ALL)
 				{
 				rt_tile_render(rt, qd->it, qd->x, qd->y, qd->w, qd->h, qd->new_data, fast);
 				}
@@ -1904,8 +2022,11 @@
 		gint x1, y1;
 		gint x2, y2;
 		GtkWidget *box;
-		GdkGC *gc;
+		GdkWindow *window;
+//		GdkGC *gc;
 		GdkEvent *event;
+		cairo_t *cr;
+		cairo_surface_t *surface;
 
 		if (x_off < 0)
 			{
@@ -1930,14 +2051,31 @@
 			}
 
 		box = GTK_WIDGET(pr);
+		window = gtk_widget_get_window(box);
 
-		gc = gdk_gc_new(box->window);
+		cr = gdk_cairo_create(window);
+		surface = cairo_get_target(cr);
+		/* clipping restricts the intermediate surface's size, so it's a good idea
+		 * to use it. */
+		cairo_rectangle(cr, x1 + pr->x_offset + rt->stereo_off_x, y1 + pr->y_offset + rt->stereo_off_y, w, h);
+		cairo_clip (cr);
+		/* Now push a group to change the target */
+		cairo_push_group (cr);
+		cairo_set_source_surface(cr, surface, x1 - x2, y1 - y2);
+		cairo_paint(cr);
+		/* Now copy the intermediate target back */
+		cairo_pop_group_to_source(cr);
+		cairo_paint(cr);
+		cairo_destroy(cr);
+#if 0
+		gc = gdk_gc_new(window);
 		gdk_gc_set_exposures(gc, TRUE);
-		gdk_draw_drawable(box->window, gc,
-				  box->window,
+		gdk_draw_drawable(window, gc,
+				  window,
 				  x2 + pr->x_offset + rt->stereo_off_x, y2 + pr->y_offset + rt->stereo_off_y,
 				  x1 + pr->x_offset + rt->stereo_off_x, y1 + pr->y_offset + rt->stereo_off_y, w, h);
 		g_object_unref(gc);
+#endif
 
 		rt_overlay_queue_all(rt, x2, y2, x1, y1);
 
@@ -1960,7 +2098,7 @@
 
 		/* process exposures here, "expose_event" seems to miss a few with obstructed windows */
 #if ! GTK_CHECK_VERSION(2,18,0)
-		while ((event = gdk_event_get_graphics_expose(box->window)) != NULL)
+		while ((event = gdk_event_get_graphics_expose(window)) != NULL)
 			{
         		renderer_redraw((void *) rt, event->expose.area.x, event->expose.area.y, event->expose.area.width, event->expose.area.height,
                               FALSE, TILE_RENDER_ALL, FALSE, FALSE);
--- a/src/renderer-tiles.h	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/renderer-tiles.h	Thu Aug 02 00:15:16 2012 +0200
@@ -13,9 +13,6 @@
 #ifndef RENDERER_TILES_H
 #define RENDERER_TILES_H
 
-#include <gtk/gtkeventbox.h>
-#include <gtk/gtkwindow.h>
-
 #include <pixbuf-renderer.h>
 
 
--- a/src/ui_bookmark.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/ui_bookmark.c	Thu Aug 02 00:15:16 2012 +0200
@@ -510,10 +510,11 @@
 
 	pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
 				allocation.width, allocation.height);
+#if !GTK_CHECK_VERSION(3,0,0)
 	gdk_pixbuf_get_from_drawable(pixbuf, gtk_widget_get_window(button), NULL,
 				     allocation.x, allocation.y,
 				     0, 0, allocation.width, allocation.height);
-
+#endif
 	gdk_window_get_pointer(gtk_widget_get_window(button), &x, &y, &mask);
 
 	gtk_drag_set_icon_pixbuf(context, pixbuf,
--- a/src/ui_misc.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/ui_misc.c	Thu Aug 02 00:15:16 2012 +0200
@@ -1387,7 +1387,6 @@
 	GtkStateType state;
 	GtkAllocation allocation;
 
-	gdk_region_get_clipbox(event->region, &clip);
 
 	if (sd->position & SIZER_POS_LEFT || sd->position & SIZER_POS_RIGHT)
 		{
@@ -1408,11 +1407,21 @@
 		}
 
 	gtk_widget_get_allocation(widget, &allocation);
+#if GTK_CHECK_VERSION(3,0,0)
+	cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget));
+
+	gtk_render_handle (gtk_widget_get_style_context (widget),
+	                   cr, allocation.x, allocation.y, allocation.width, allocation.height);    
+	cairo_destroy(cr);
+#else
+	gdk_region_get_clipbox(event->region, &clip);
+
 	gtk_paint_handle(gtk_widget_get_style(widget), gtk_widget_get_window(widget), state,
 			 GTK_SHADOW_NONE, &clip, widget, "paned",
 			 0, 0,
 			 allocation.width, allocation.height,
 			 orientation);
+#endif
 
 	return TRUE;
 }
--- a/src/ui_tree_edit.c	Wed Aug 01 00:17:18 2012 +0200
+++ b/src/ui_tree_edit.c	Thu Aug 02 00:15:16 2012 +0200
@@ -285,7 +285,11 @@
 	if (gtk_tree_view_get_headers_visible(widget))
 		{
 		GtkAllocation allocation;
+#if GTK_CHECK_VERSION(3,0,0)
+		gtk_widget_get_allocation(gtk_tree_view_column_get_button(tv_column), &allocation);
+#else
 		gtk_widget_get_allocation(tv_column->button, &allocation);
+#endif
 		header_size = allocation.height;
 		}
 	else