? a
? alexl@master.gnome.org
? attachment.cgi?id=30349
? attachment.cgi?id=32229
? attachment.cgi?id=34225
? attachment.cgi?id=34451
? attachment.cgi?id=35409
? attachment.cgi?id=36545
? attachment.cgi?id=38723
? attachment.cgi?id=38926
? attachment.cgi?id=39309
? attachment.cgi?id=39685
? attachment.cgi?id=46666
? attachment.cgi?id=47200
? compile
? configure-fail.patch
? core.22311
? depcomp
? filename-collation.patch
? fix.patch
? icons.patch
? nautilus-2.10.0.tar.gz
? nautilus-2.11.1.tar.gz
? nautilus-2.11.2.tar.gz
? nautilus-2.9.1.tar.gz
? nautilus-2.9.2.tar.gz
? nautilus-2.9.90.tar.gz
? nautilus-2.9.91.tar.gz
? nautilus-2.9.92.tar.gz
? nautilus-folder-handler.desktop
? nautilus-memuse.patch
? nautilus-parent-menu.patch
? nautilus.log
? reverted.patch
? stamp-h1
? tree-patch-review.txt
? unique-volume.patch
? src/a
Index: libnautilus-private/nautilus-icon-canvas-item.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-canvas-item.c,v
retrieving revision 1.190
diff -u -p -r1.190 nautilus-icon-canvas-item.c
--- libnautilus-private/nautilus-icon-canvas-item.c	3 Jun 2005 07:48:01 -0000	1.190
+++ libnautilus-private/nautilus-icon-canvas-item.c	15 Jun 2005 17:46:48 -0000
@@ -454,12 +454,57 @@ nautilus_icon_canvas_item_get_property (
 		break;
 	}
 }
-      
-GdkPixmap *
-nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
-				     GdkBitmap **mask)
+
+/* dest and mask are the same size */
+static void
+get_alpha_from_mask (GdkPixbuf *dest, GdkBitmap *mask)
+{
+	guchar *dest_ptr;
+	guchar *mask_ptr;
+	guchar *d, *m;
+	int width, height, mask_stride, dest_stride;
+	int w;
+	GdkPixbuf *mask_pixbuf;
+
+	g_assert (gdk_pixbuf_get_has_alpha (dest));
+	
+	width = gdk_pixbuf_get_width (dest);
+	height = gdk_pixbuf_get_height (dest);
+	
+	mask_pixbuf = gdk_pixbuf_get_from_drawable (NULL, mask,
+						    NULL,
+						    0, 0,
+						    0, 0,
+						    width, height);
+	
+	mask_stride = gdk_pixbuf_get_rowstride (mask_pixbuf);
+	dest_stride = gdk_pixbuf_get_rowstride (dest);
+	
+	mask_ptr = gdk_pixbuf_get_pixels (mask_pixbuf);
+	dest_ptr = gdk_pixbuf_get_pixels (dest);
+
+	while (height--) {
+		w = width;
+		d = dest_ptr;
+		m = mask_ptr;
+		while (w--) {
+			d[3] = m[0];
+			d += 4;
+			m += 3;
+		}
+		mask_ptr += mask_stride;
+		dest_ptr += dest_stride;
+	}
+	
+	g_object_unref (mask_pixbuf);
+}
+
+
+GdkPixbuf *
+nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item)
 {
 	GdkPixmap *pixmap;
+	GdkBitmap *mask;
 	EelCanvas *canvas;
 	GdkScreen *screen;
 	GdkColormap *colormap;
@@ -498,7 +543,7 @@ nautilus_icon_canvas_item_get_image (Nau
 
 	pixbuf = item->details->pixbuf;
 	gc = gdk_gc_new (pixmap);
-	gdk_draw_rectangle (pixmap, GTK_WIDGET (canvas)->style->white_gc,
+	gdk_draw_rectangle (pixmap, GTK_WIDGET (canvas)->style->black_gc,
 			    TRUE,
 			    0, 0,
 			    width, height);
@@ -509,17 +554,17 @@ nautilus_icon_canvas_item_get_image (Nau
 			 0, 0);
 	g_object_unref (gc);
 
-	*mask = gdk_pixmap_new (gdk_screen_get_root_window (screen),
+	mask = gdk_pixmap_new (gdk_screen_get_root_window (screen),
 				width, height,
 				1);
-	gc = gdk_gc_new (*mask);
-	gdk_draw_rectangle (*mask, gc,
+	gc = gdk_gc_new (mask);
+	gdk_draw_rectangle (mask, gc,
 			    TRUE,
 			    0, 0,
 			    width, height);
 	g_object_unref (gc);
 	  
-	gdk_pixbuf_render_threshold_alpha (pixbuf, *mask,
+	gdk_pixbuf_render_threshold_alpha (pixbuf, mask,
 					   0, 0, item_offset_x, item_offset_y,
 					   gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
 					   128);
@@ -532,9 +577,26 @@ nautilus_icon_canvas_item_get_image (Nau
 	icon_rect.x1 = item_offset_x + gdk_pixbuf_get_width (pixbuf);
 	icon_rect.y1 = item_offset_y + gdk_pixbuf_get_height (pixbuf);
 	draw_label_text (item, GDK_DRAWABLE (pixmap), FALSE, icon_rect);
-	draw_label_text (item, GDK_DRAWABLE (*mask), TRUE, icon_rect);
+	draw_label_text (item, GDK_DRAWABLE (mask), TRUE, icon_rect);
 	
-	return pixmap;
+	/* We convert the pixmap + mask to a pixbuf, because then we can use
+	   gtk_drag_set_icon_pixbuf() which does flicker-free dnd icons
+	   with later versions of X and gtk+.
+	   Unfortunately we loose the alpha in this conversion...
+	 */
+	pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
+	gdk_pixbuf_get_from_drawable (pixbuf,
+				      pixmap,
+				      colormap,
+				      0, 0,
+				      0, 0,
+				      width, height);
+	if (0) get_alpha_from_mask (pixbuf, mask);
+
+	g_object_unref (pixmap);
+	g_object_unref (mask);
+
+	return pixbuf;
 }
 
 void
Index: libnautilus-private/nautilus-icon-canvas-item.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-canvas-item.h,v
retrieving revision 1.27
diff -u -p -r1.27 nautilus-icon-canvas-item.h
--- libnautilus-private/nautilus-icon-canvas-item.h	9 Jun 2003 11:38:26 -0000	1.27
+++ libnautilus-private/nautilus-icon-canvas-item.h	15 Jun 2005 17:46:48 -0000
@@ -63,8 +63,7 @@ GType       nautilus_icon_canvas_item_ge
 /* attributes */
 void        nautilus_icon_canvas_item_set_image                (NautilusIconCanvasItem       *item,
 								GdkPixbuf                    *image);
-GdkPixmap * nautilus_icon_canvas_item_get_image                (NautilusIconCanvasItem       *item,
-								GdkBitmap                   **mask);
+GdkPixbuf * nautilus_icon_canvas_item_get_image                (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,
Index: libnautilus-private/nautilus-icon-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-dnd.c,v
retrieving revision 1.143
diff -u -p -r1.143 nautilus-icon-dnd.c
--- libnautilus-private/nautilus-icon-dnd.c	2 Jun 2005 16:16:55 -0000	1.143
+++ libnautilus-private/nautilus-icon-dnd.c	15 Jun 2005 17:46:48 -0000
@@ -1250,8 +1250,7 @@ nautilus_icon_dnd_begin_drag (NautilusIc
 	NautilusIconDndInfo *dnd_info;
 	EelCanvas *canvas;
 	GdkDragContext *context;
-	GdkPixmap *pixmap;
-	GdkBitmap *mask;
+	GdkPixbuf *pixbuf;
 	int x_offset, y_offset;
 	double x1, y1, x2, y2, winx, winy;
 	
@@ -1268,8 +1267,8 @@ nautilus_icon_dnd_begin_drag (NautilusIc
 	dnd_info->drag_info.start_x = start_x - gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (canvas)));
 	dnd_info->drag_info.start_y = start_y - gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (canvas)));	
 
-        /* create a pixmap and mask to drag with */
-        pixmap = nautilus_icon_canvas_item_get_image (container->details->drag_icon->item, &mask);
+        /* create an image to drag with */
+        pixbuf = nautilus_icon_canvas_item_get_image (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
@@ -1291,11 +1290,12 @@ nautilus_icon_dnd_begin_drag (NautilusIc
 
 	if (context) {
 		/* set the icon for dragging */
-		gtk_drag_set_icon_pixmap (context,
-					  gtk_widget_get_colormap (GTK_WIDGET (container)),
-					  pixmap, mask,
+		gtk_drag_set_icon_pixbuf (context,
+					  pixbuf,
 					  x_offset, y_offset);
 	}
+	
+	g_object_unref (pixbuf);
 }
 
 static gboolean
