[nautilus/gtk3-happyness: 15/20] [libnautilus-private] Port to rendering-cleanup-next



commit 1a9e5993d95532da62bcb6bd3a9f49dee9db0f57
Author: Christian Persch <chpe gnome org>
Date:   Thu Sep 16 17:13:08 2010 +0200

    [libnautilus-private] Port to rendering-cleanup-next

 libnautilus-private/nautilus-icon-canvas-item.c    |  159 ++++++++++----------
 libnautilus-private/nautilus-icon-canvas-item.h    |    4 +-
 libnautilus-private/nautilus-icon-container.c      |   24 +---
 libnautilus-private/nautilus-icon-dnd.c            |   60 +++-----
 libnautilus-private/nautilus-tree-view-drag-dest.c |   38 +++---
 5 files changed, 127 insertions(+), 158 deletions(-)
---
diff --git a/libnautilus-private/nautilus-icon-canvas-item.c b/libnautilus-private/nautilus-icon-canvas-item.c
index e4ee7f0..e92c31f 100644
--- a/libnautilus-private/nautilus-icon-canvas-item.c
+++ b/libnautilus-private/nautilus-icon-canvas-item.c
@@ -208,7 +208,7 @@ G_DEFINE_TYPE_WITH_CODE (NautilusIconCanvasItem, nautilus_icon_canvas_item, EEL_
 
 /* private */
 static void     draw_label_text                      (NautilusIconCanvasItem        *item,
-						      GdkDrawable                   *drawable,
+						      cairo_t                       *cr,
 						      gboolean                       create_mask,
 						      EelIRect                       icon_rect);
 static void     measure_label_text                   (NautilusIconCanvasItem        *item);
@@ -223,14 +223,14 @@ static gboolean emblem_layout_next                   (EmblemLayout
 						      EelIRect                      *emblem_rect,
 						      gboolean			     is_rtl);
 static void     draw_pixbuf                          (GdkPixbuf                     *pixbuf,
-						      GdkDrawable                   *drawable,
+						      cairo_t                       *cr,
 						      int                            x,
 						      int                            y);
 static PangoLayout *get_label_layout                 (PangoLayout                  **layout,
 						      NautilusIconCanvasItem        *item,
 						      const char                    *text);
 static void     draw_label_layout                    (NautilusIconCanvasItem        *item,
-						      GdkDrawable                   *drawable,
+						      cairo_t                       *cr,
 						      PangoLayout                   *layout,
 						      gboolean                       highlight,
 						      GdkColor                      *label_color,
@@ -240,7 +240,7 @@ static gboolean hit_test_stretch_handle              (NautilusIconCanvasItem
 						      EelIRect                       canvas_rect,
 						      GtkCornerType *corner);
 static void      draw_embedded_text                  (NautilusIconCanvasItem        *icon_item,
-						      GdkDrawable                   *drawable,
+                                                      cairo_t                       *cr,
 						      int                            x,
 						      int                            y);
 
@@ -506,13 +506,11 @@ nautilus_icon_canvas_item_get_property (GObject        *object,
 		break;
 	}
 }
-      
-GdkPixmap *
-nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
-				     GdkBitmap **mask,
-				     GdkColormap *colormap)
+
+cairo_surface_t *
+nautilus_icon_canvas_item_get_drag_surface (NautilusIconCanvasItem *item)
 {
-	GdkPixmap *pixmap;
+	cairo_surface_t *surface;
 	EelCanvas *canvas;
 	GdkScreen *screen;
 	int width, height;
@@ -529,7 +527,7 @@ nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
 	g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), NULL);
 
 	canvas = EEL_CANVAS_ITEM (item)->canvas;
-	screen = gdk_colormap_get_screen (colormap);
+	screen = gtk_widget_get_screen (GTK_WIDGET (canvas));
 
 	/* Assume we're updated so canvas item data is right */
 
@@ -545,11 +543,10 @@ nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
 	/* Calculate the width of the item */
 	width = EEL_CANVAS_ITEM (item)->x2 - EEL_CANVAS_ITEM (item)->x1;
 	height = EEL_CANVAS_ITEM (item)->y2 - EEL_CANVAS_ITEM (item)->y1;
-	
-	pixmap = gdk_pixmap_new (gdk_screen_get_root_window (screen),
-				 width,	height,
-				 gdk_visual_get_depth (gdk_colormap_get_visual (colormap)));
-	gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), colormap);
+
+        surface = gdk_window_create_similar_surface (gdk_screen_get_root_window (screen),
+                                                     CAIRO_CONTENT_COLOR_ALPHA,
+                                                     width, height);
 
 	pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
 				 TRUE,
@@ -584,30 +581,32 @@ nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
 	}
 
 	/* draw pixbuf to mask and pixmap */
-	cr = gdk_cairo_create (pixmap);
+        cr = cairo_create (surface);
 	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
 	gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
 	cairo_paint (cr);
+
+        draw_embedded_text (item, cr,
+                            item_offset_x, item_offset_y);
+        draw_label_text (item, cr, FALSE, icon_rect);
 	cairo_destroy (cr);
 
-	*mask = gdk_pixmap_new (gdk_screen_get_root_window (screen),
-				width, height,
-				1);
-	cr = gdk_cairo_create (*mask);
+#if 0
+	*mask = gdk_window_create_similar_surface (gdk_screen_get_root_window (screen),
+                                                   CAIRO_CONTENT_ALPHA, width, height);
+	cr = cairo_create (*mask);
 	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
 	gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
 	cairo_paint (cr);
-	cairo_destroy (cr);
 
-	draw_embedded_text (item, GDK_DRAWABLE (pixmap),
-			    item_offset_x, item_offset_y);
+	draw_label_text (item, cr, TRUE, icon_rect);
 
-	draw_label_text (item, GDK_DRAWABLE (pixmap), FALSE, icon_rect);
-	draw_label_text (item, GDK_DRAWABLE (*mask), TRUE, icon_rect);
+        cairo_destroy (cr);
+#endif
 
 	g_object_unref (pixbuf);
 
-	return pixmap;
+	return surface;
 }
 
 void
@@ -952,7 +951,7 @@ make_round_rect (cairo_t *cr,
 
 static void
 draw_frame (NautilusIconCanvasItem *item,
-	    GdkDrawable *drawable,
+	    cairo_t *cr,
 	    guint color,
 	    gboolean create_mask,
 	    int x, 
@@ -961,12 +960,10 @@ draw_frame (NautilusIconCanvasItem *item,
 	    int height)
 {
 	NautilusIconContainer *container;
-	cairo_t *cr;
 
 	container = NAUTILUS_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas);
 
-	/* Get a cairo context */
-	cr = gdk_cairo_create (drawable);	
+        cairo_save (cr);
 	
 	/* Set the rounded rect clip region. Magic rounding value taken
 	 * from old code. 
@@ -988,9 +985,8 @@ draw_frame (NautilusIconCanvasItem *item,
 	
 	/* Paint into drawable now that we have set up the color and opacity */	
 	cairo_fill (cr);
-	
-	/* Clean up now that drawing is complete */
-	cairo_destroy (cr);		 
+
+        cairo_restore (cr);
 }
 
 /* Keep these for a bit while we work on performance of draw_or_measure_label_text. */
@@ -1267,7 +1263,7 @@ measure_label_text (NautilusIconCanvasItem *item)
 
 static void
 draw_label_text (NautilusIconCanvasItem *item,
-		 GdkDrawable *drawable,
+                 cairo_t *cr,
 		 gboolean create_mask,
 		 EelIRect icon_rect)
 {
@@ -1316,7 +1312,7 @@ draw_label_text (NautilusIconCanvasItem *item,
 	/* if the icon is highlighted, do some set-up */
 	if (needs_highlight && !details->is_renaming) {
 		draw_frame (item,
-			    drawable,
+                            cr,
 			    gtk_widget_has_focus (GTK_WIDGET (container)) ? container->details->highlight_color_rgba : container->details->active_color_rgba,
 			    create_mask,
 			    is_rtl_label_beside ? text_rect.x0 + item->details->text_dx : text_rect.x0,
@@ -1327,11 +1323,23 @@ draw_label_text (NautilusIconCanvasItem *item,
 		   (details->is_prelit ||
 		    details->is_highlighted_as_keyboard_focus)) {
 		/* clear the underlying icons, where the text or overlaps them. */
+                cairo_save (cr);
+                /* FIMXEchpe draw the background here? */
+                cairo_set_source_rgb (cr, 1., 1., 1.);
+                cairo_rectangle (cr,
+                                 text_rect.x0,
+                                 text_rect.y0,
+                                 text_rect.x1 - text_rect.x0,
+                                 text_rect.y1 - text_rect.y0);
+                cairo_fill (cr);
+                cairo_restore (cr);
+        #if 0
 		gdk_window_clear_area (gtk_layout_get_bin_window (&EEL_CANVAS (container)->layout),
 				       text_rect.x0,
 				       text_rect.y0,
 				       text_rect.x1 - text_rect.x0,
 				       text_rect.y1 - text_rect.y0);
+        #endif
 	}
 
 	if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
@@ -1351,7 +1359,7 @@ draw_label_text (NautilusIconCanvasItem *item,
 		if (needs_frame && !needs_highlight && details->text_width > 0 && details->text_height > 0) {
 			if (!(prelight_label && item->details->is_prelit)) {
 				draw_frame (item, 
-					    drawable,
+					    cr,
 					    container->details->normal_color_rgba,
 					    create_mask,
 					    text_rect.x0,
@@ -1360,7 +1368,7 @@ draw_label_text (NautilusIconCanvasItem *item,
 					    text_rect.y1 - text_rect.y0);
 			} else {
 				draw_frame (item, 
-					    drawable,
+					    cr,
 					    container->details->prelight_color_rgba,
 					    create_mask,
 					    text_rect.x0,
@@ -1375,7 +1383,7 @@ draw_label_text (NautilusIconCanvasItem *item,
 			 &label_color, TRUE, needs_highlight,
 			 prelight_label & item->details->is_prelit);
 
-		draw_label_layout (item, drawable,
+		draw_label_layout (item, cr,
 				   editable_layout, needs_highlight,
 				   label_color,
 				   x,
@@ -1391,7 +1399,7 @@ draw_label_text (NautilusIconCanvasItem *item,
 			 &label_color, FALSE, needs_highlight,
 			 FALSE);
 		
-		draw_label_layout (item, drawable,
+		draw_label_layout (item, cr,
 				   additional_layout, needs_highlight,
 				   label_color,
 				   x,
@@ -1400,9 +1408,8 @@ draw_label_text (NautilusIconCanvasItem *item,
 
 	if (!create_mask && item->details->is_highlighted_as_keyboard_focus) {
 		gtk_paint_focus (gtk_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas)),
-				 drawable,
+				 cr,
 				 needs_highlight ? GTK_STATE_SELECTED : GTK_STATE_NORMAL,
-				 NULL,
 				 GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas),
 				 "icon-container",
 				 text_rect.x0,
@@ -1475,14 +1482,14 @@ get_knob_pixbuf (void)
 }
 
 static void
-draw_stretch_handles (NautilusIconCanvasItem *item, GdkDrawable *drawable,
+draw_stretch_handles (NautilusIconCanvasItem *item,
+                      cairo_t *cr,
 		      const EelIRect *rect)
 {
 	GtkWidget *widget;
 	GdkPixbuf *knob_pixbuf;
 	int knob_width, knob_height;
 	double dash = { 2.0 };
-	cairo_t *cr;
 
 	if (!item->details->show_stretch_handles) {
 		return;
@@ -1490,7 +1497,7 @@ draw_stretch_handles (NautilusIconCanvasItem *item, GdkDrawable *drawable,
 
 	widget = GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas);
 
-	cr = gdk_cairo_create (drawable);
+        cairo_save (cr);
 	knob_pixbuf = get_knob_pixbuf ();
 	knob_width = gdk_pixbuf_get_width (knob_pixbuf);
 	knob_height = gdk_pixbuf_get_height (knob_pixbuf);
@@ -1506,13 +1513,13 @@ draw_stretch_handles (NautilusIconCanvasItem *item, GdkDrawable *drawable,
 			 rect->y1 - rect->y0 - 1);
 	cairo_stroke (cr);
 
-	cairo_destroy (cr);
+        cairo_restore (cr);
 
 	/* draw the stretch handles themselves */
-	draw_pixbuf (knob_pixbuf, drawable, rect->x0, rect->y0);
-	draw_pixbuf (knob_pixbuf, drawable, rect->x0, rect->y1 - knob_height);
-	draw_pixbuf (knob_pixbuf, drawable, rect->x1 - knob_width, rect->y0);
-	draw_pixbuf (knob_pixbuf, drawable, rect->x1 - knob_width, rect->y1 - knob_height);
+	draw_pixbuf (knob_pixbuf, cr, rect->x0, rect->y0);
+	draw_pixbuf (knob_pixbuf, cr, rect->x0, rect->y1 - knob_height);
+	draw_pixbuf (knob_pixbuf, cr, rect->x1 - knob_width, rect->y0);
+	draw_pixbuf (knob_pixbuf, cr, rect->x1 - knob_width, rect->y1 - knob_height);
 
 	g_object_unref (knob_pixbuf);
 }
@@ -1665,14 +1672,14 @@ emblem_layout_next (EmblemLayout *layout,
 }
 
 static void
-draw_pixbuf (GdkPixbuf *pixbuf, GdkDrawable *drawable, int x, int y)
+draw_pixbuf (GdkPixbuf *pixbuf,
+             cairo_t *cr,
+             int x, int y)
 {
-	cairo_t *cr = gdk_cairo_create (drawable);
-
+        cairo_save (cr);
 	gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
 	cairo_paint (cr);
-
-	cairo_destroy (cr);
+        cairo_restore (cr);
 }
 
 /* shared code to highlight or dim the passed-in pixbuf */
@@ -1827,13 +1834,12 @@ map_pixbuf (NautilusIconCanvasItem *icon_item)
 
 static void
 draw_embedded_text (NautilusIconCanvasItem *item,
-		    GdkDrawable *drawable,
+                    cairo_t *cr,
 		    int x, int y)
 {
 	PangoLayout *layout;
 	PangoContext *context;
 	PangoFontDescription *desc;
-	cairo_t *cr;
 	
 	if (item->details->embedded_text == NULL ||
 	    item->details->embedded_text_rect.width == 0 ||
@@ -1856,8 +1862,8 @@ draw_embedded_text (NautilusIconCanvasItem *item,
 			item->details->embedded_text_layout = g_object_ref (layout);
 		}
 	}
-	
-	cr = gdk_cairo_create (drawable);
+
+	cairo_save (cr);
 
 	cairo_rectangle (cr,
 			 x + item->details->embedded_text_rect.x,
@@ -1872,13 +1878,14 @@ draw_embedded_text (NautilusIconCanvasItem *item,
 		       y + item->details->embedded_text_rect.y);
 	pango_cairo_show_layout (cr, layout);
 
-	cairo_destroy (cr);
+	cairo_restore (cr);
 }
 
 /* Draw the icon item for non-anti-aliased mode. */
 static void
-nautilus_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
-				GdkEventExpose *expose)
+nautilus_icon_canvas_item_draw (EelCanvasItem *item,
+                                cairo_t *cr,
+                                cairo_region_t *region)
 {
 	NautilusIconCanvasItem *icon_item;
 	NautilusIconCanvasItemDetails *details;
@@ -1887,7 +1894,6 @@ nautilus_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
 	GdkPixbuf *emblem_pixbuf, *temp_pixbuf;
 	GdkRectangle pixbuf_rect;
 	gboolean is_rtl;
-	cairo_t *cr;
 			
 	icon_item = NAUTILUS_ICON_CANVAS_ITEM (item);
 	details = icon_item->details;
@@ -1907,30 +1913,28 @@ nautilus_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
 	pixbuf_rect.width = gdk_pixbuf_get_width (temp_pixbuf);
 	pixbuf_rect.height = gdk_pixbuf_get_height (temp_pixbuf);
 
-	cr = gdk_cairo_create (drawable);
-	gdk_cairo_rectangle (cr, &expose->area);
-	cairo_clip (cr);
+        cairo_save (cr);
 	gdk_cairo_set_source_pixbuf (cr, temp_pixbuf, pixbuf_rect.x, pixbuf_rect.y);
 	gdk_cairo_rectangle (cr, &pixbuf_rect);
 	cairo_fill (cr);
-	cairo_destroy (cr);
+	cairo_restore (cr);
 	g_object_unref (temp_pixbuf);
 
-	draw_embedded_text (icon_item, drawable,  icon_rect.x0, icon_rect.y0);
+	draw_embedded_text (icon_item, cr, icon_rect.x0, icon_rect.y0);
 	
 	is_rtl = nautilus_icon_container_is_layout_rtl (NAUTILUS_ICON_CONTAINER (item->canvas));
 
 	/* Draw the emblem pixbufs. */
 	emblem_layout_reset (&emblem_layout, icon_item, icon_rect, is_rtl);
 	while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect, is_rtl)) {
-		draw_pixbuf (emblem_pixbuf, drawable, emblem_rect.x0, emblem_rect.y0);
+		draw_pixbuf (emblem_pixbuf, cr, emblem_rect.x0, emblem_rect.y0);
 	}
 	
 	/* Draw stretching handles (if necessary). */
-	draw_stretch_handles (icon_item, drawable, &icon_rect);
+	draw_stretch_handles (icon_item, cr, &icon_rect);
 	
 	/* Draw the label text. */
-	draw_label_text (icon_item, drawable, FALSE, icon_rect);
+	draw_label_text (icon_item, cr, FALSE, icon_rect);
 }
 
 #define ZERO_WIDTH_SPACE "\xE2\x80\x8B"
@@ -2034,35 +2038,30 @@ get_label_layout (PangoLayout **layout_cache,
 
 static void
 draw_label_layout (NautilusIconCanvasItem *item,
-		   GdkDrawable *drawable,
+		   cairo_t *cr,
 		   PangoLayout *layout,
 		   gboolean highlight,
 		   GdkColor *label_color,
 		   int x,
 		   int y)
 {
-	if (drawable == NULL) {
-		return;
-	}
-
 	if (item->details->is_renaming) {
 		return;
 	}
 
 	if (!highlight && (NAUTILUS_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas)->details->use_drop_shadows)) {
 		/* draw a drop shadow */
-		eel_gdk_draw_layout_with_drop_shadow (drawable,
+		eel_cairo_draw_layout_with_drop_shadow (cr,
 						      label_color,
 						      &gtk_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas))->black,
 						      x, y,
 						      layout);
 	} else {
-		cairo_t *cr = gdk_cairo_create (drawable);
-
+                cairo_save (cr);
 		gdk_cairo_set_source_color (cr, label_color);
 		cairo_move_to (cr, x, y);
 		pango_cairo_show_layout (cr, layout);
-		cairo_destroy (cr);
+		cairo_restore (cr);
 	}
 }
 
diff --git a/libnautilus-private/nautilus-icon-canvas-item.h b/libnautilus-private/nautilus-icon-canvas-item.h
index 7a74b7b..c6ba6f1 100644
--- a/libnautilus-private/nautilus-icon-canvas-item.h
+++ b/libnautilus-private/nautilus-icon-canvas-item.h
@@ -69,9 +69,7 @@ GType       nautilus_icon_canvas_item_get_type                 (void);
 /* attributes */
 void        nautilus_icon_canvas_item_set_image                (NautilusIconCanvasItem       *item,
 								GdkPixbuf                    *image);
-GdkPixmap * nautilus_icon_canvas_item_get_image                (NautilusIconCanvasItem       *item,
-								GdkBitmap                   **mask,
-								GdkColormap		     *colormap);
+cairo_surface_t* nautilus_icon_canvas_item_get_drag_surface    (NautilusIconCanvasItem       *item);
 void        nautilus_icon_canvas_item_set_emblems              (NautilusIconCanvasItem       *item,
 								GList                        *emblem_pixbufs);
 void        nautilus_icon_canvas_item_set_show_stretch_handles (NautilusIconCanvasItem       *item,
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index 019377c..8df697a 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -4775,7 +4775,7 @@ nautilus_icon_container_search_position_func (NautilusIconContainer *container,
 
 
 	cont_window = gtk_widget_get_window (GTK_WIDGET (container));
-	screen = gdk_drawable_get_screen (cont_window);
+	screen = gdk_window_get_screen (cont_window);
 
 	monitor_num = gdk_screen_get_monitor_at_window (screen, cont_window);
 	gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
@@ -4783,9 +4783,10 @@ nautilus_icon_container_search_position_func (NautilusIconContainer *container,
 	gtk_widget_realize (search_dialog);
 
 	gdk_window_get_origin (cont_window, &cont_x, &cont_y);
-	gdk_drawable_get_size (cont_window, &cont_width, &cont_height);
-	gtk_size_request_get_size (GTK_SIZE_REQUEST (search_dialog),
-				   &requisition, NULL);
+        cont_width = gdk_window_get_width (cont_window);
+        cont_height = gdk_window_get_height (cont_window);
+
+	gtk_widget_size_request (search_dialog, &requisition);
 
 	if (cont_x + cont_width - requisition.width > gdk_screen_get_width (screen)) {
 		x = gdk_screen_get_width (screen) - requisition.width;
@@ -5560,24 +5561,12 @@ popup_menu (GtkWidget *widget)
 
 static void
 draw_canvas_background (EelCanvas *canvas,
-			int x, int y, int width, int height)
+                        cairo_t   *cr)
 {
 	/* Don't chain up to the parent to avoid clearing and redrawing */
 }
 
 
-static gboolean
-expose_event (GtkWidget      *widget,
-	      GdkEventExpose *event)
-{
-/*	g_warning ("Expose Icon Container %p '%d,%d: %d,%d'",
-		   widget,
-		   event->area.x, event->area.y,
-		   event->area.width, event->area.height); */
-	
-	return GTK_WIDGET_CLASS (nautilus_icon_container_parent_class)->expose_event (widget, event);
-}
-
 static AtkObject *
 get_accessible (GtkWidget *widget)
 {
@@ -6025,7 +6014,6 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class)
 	widget_class->popup_menu = popup_menu;
 	widget_class->get_accessible = get_accessible;
 	widget_class->style_set = style_set;
-	widget_class->expose_event = expose_event;
 	widget_class->grab_notify = grab_notify_cb;
 
 	canvas_class = EEL_CANVAS_CLASS (class);
diff --git a/libnautilus-private/nautilus-icon-dnd.c b/libnautilus-private/nautilus-icon-dnd.c
index 5fa9ab1..7ae13fa 100644
--- a/libnautilus-private/nautilus-icon-dnd.c
+++ b/libnautilus-private/nautilus-icon-dnd.c
@@ -1281,38 +1281,19 @@ drag_begin_callback (GtkWidget      *widget,
 		     gpointer        data)
 {
 	NautilusIconContainer *container;
-	GdkScreen *screen;
-	GdkColormap *colormap;
-	GdkPixmap *pixmap;
-	GdkBitmap *mask;
+	cairo_surface_t *surface;
 	double x1, y1, x2, y2, winx, winy;
 	int x_offset, y_offset;
 	int start_x, start_y;
-	gboolean use_mask;
 
 	container = NAUTILUS_ICON_CONTAINER (widget);
 
-	screen = gtk_widget_get_screen (widget);
-	colormap = NULL;
-	if (gdk_screen_is_composited (screen)) {
-		colormap = gdk_screen_get_rgba_colormap (screen);
-		if (colormap != NULL) {
-			use_mask = FALSE;
-		}
-	}
-	
-	/* Fall back on using the same colormap as the widget */
-	if (colormap == NULL) {
-		colormap = gtk_widget_get_colormap (widget);		
-		use_mask = TRUE;
-	}
-
 	start_x = container->details->dnd_info->drag_info.start_x + gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container)));
 	start_y = container->details->dnd_info->drag_info.start_y + gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container)));
 
         /* create a pixmap and mask to drag with */
-        pixmap = nautilus_icon_canvas_item_get_image (container->details->drag_icon->item, &mask, colormap);
-    
+        surface = nautilus_icon_canvas_item_get_drag_surface (container->details->drag_icon->item);
+
     	/* we want to drag semi-transparent pixbufs, but X is too slow dealing with
 	   stippled masks, so we had to remove the code; this comment is left as a memorial
 	   to it, with the hope that we get it back someday as X Windows improves */
@@ -1325,6 +1306,11 @@ drag_begin_callback (GtkWidget      *widget,
         x_offset = start_x - winx;
         y_offset = start_y - winy;
 
+        cairo_surface_set_device_offset (surface, x_offset, y_offset);
+        gtk_drag_set_icon_surface (context, surface);
+        cairo_surface_destroy (surface);
+
+#if 0
 	if (!use_mask && pixmap != NULL) {
 		cairo_t *cr;
 
@@ -1340,6 +1326,7 @@ drag_begin_callback (GtkWidget      *widget,
 				  colormap,
 				  pixmap, (use_mask ? mask : NULL),
 				  x_offset, y_offset);
+#endif
 }
 
 void
@@ -1374,31 +1361,30 @@ nautilus_icon_dnd_begin_drag (NautilusIconContainer *container,
 }
 
 static gboolean
-drag_highlight_expose (GtkWidget      *widget,
-		       GdkEventExpose *event,
-		       gpointer        data)
+drag_highlight_draw (GtkWidget *widget,
+                     cairo_t   *cr,
+                     gpointer   user_data)
 {
 	gint x, y, width, height;
 	GdkWindow *window;
-	cairo_t *cr;
 	
 	x = gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (widget)));
 	y = gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (widget)));
-	gdk_drawable_get_size (gtk_widget_get_window (widget), &width, &height);
 
-	window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
-	
-	gtk_paint_shadow (gtk_widget_get_style (widget), window,
+        window = gtk_widget_get_window (widget);
+        width = gdk_window_get_width (window);
+        height = gdk_window_get_height (window);
+
+	gtk_paint_shadow (gtk_widget_get_style (widget),
+                          cr,
 			  GTK_STATE_NORMAL, GTK_SHADOW_OUT,
-			  NULL, widget, "dnd",
+			  widget, "dnd",
 			  x, y, width, height);
-  
-	cr = gdk_cairo_create (window);
+
 	cairo_set_line_width (cr, 1.0);
 	cairo_set_source_rgb (cr, 0, 0, 0);
 	cairo_rectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1);
 	cairo_stroke (cr);
-	cairo_destroy (cr);
 
 	return FALSE;
 }
@@ -1454,8 +1440,8 @@ start_dnd_highlight (GtkWidget *widget)
 
 	if (!dnd_info->highlighted) {
 		dnd_info->highlighted = TRUE;
-		g_signal_connect_after (widget, "expose_event",
-					G_CALLBACK (drag_highlight_expose),
+		g_signal_connect_after (widget, "draw",
+					G_CALLBACK (drag_highlight_draw),
 					NULL);
 		dnd_highlight_queue_redraw (widget);
 	}
@@ -1470,7 +1456,7 @@ stop_dnd_highlight (GtkWidget *widget)
 
 	if (dnd_info->highlighted) {
 		g_signal_handlers_disconnect_by_func (widget,
-						      drag_highlight_expose,
+						      drag_highlight_draw,
 						      NULL);
 		dnd_highlight_queue_redraw (widget);
 		dnd_info->highlighted = FALSE;
diff --git a/libnautilus-private/nautilus-tree-view-drag-dest.c b/libnautilus-private/nautilus-tree-view-drag-dest.c
index c211067..96962ce 100644
--- a/libnautilus-private/nautilus-tree-view-drag-dest.c
+++ b/libnautilus-private/nautilus-tree-view-drag-dest.c
@@ -172,29 +172,27 @@ remove_expand_timeout (NautilusTreeViewDragDest *dest)
 }
 
 static gboolean
-highlight_expose (GtkWidget *widget,
-		  GdkEventExpose *event,
-		  gpointer data)
+highlight_draw (GtkWidget *widget,
+		cairo_t   *cr,
+                gpointer data)
 {
 	GdkWindow *bin_window;
 	int width;
 	int height;
 
-	if (gtk_widget_is_drawable (widget)) {
-		bin_window = 
-			gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
-		
-		gdk_drawable_get_size (bin_window, &width, &height);
-		
-		gtk_paint_focus (gtk_widget_get_style (widget),
-				 bin_window,
-				 gtk_widget_get_state (widget),
-				 NULL,
-				 widget,
-				 "treeview-drop-indicator",
-				 0, 0, width, height);
-	}
-	
+        /* FIXMEchpe: is bin window right here??? */
+        bin_window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
+
+        width = gdk_window_get_width (bin_window);
+        height = gdk_window_get_height (bin_window);
+
+        gtk_paint_focus (gtk_widget_get_style (widget),
+                         cr,
+                         gtk_widget_get_state (widget),
+                         widget,
+                         "treeview-drop-indicator",
+                         0, 0, width, height);
+
 	return FALSE;
 }
 
@@ -211,8 +209,8 @@ set_widget_highlight (NautilusTreeViewDragDest *dest, gboolean highlight)
 	if (highlight && !dest->details->highlight_id) {
 		dest->details->highlight_id = 
 			g_signal_connect_object (dest->details->tree_view,
-						 "expose_event",
-						 G_CALLBACK (highlight_expose),
+						 "draw",
+						 G_CALLBACK (highlight_draw),
 						 dest, 0);
 		gtk_widget_queue_draw (GTK_WIDGET (dest->details->tree_view));
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]