cpw.qulogic.gtk3-required: e44e9fd1: Fix DND hints on GTK+3.

qulogic at pidgin.im qulogic at pidgin.im
Tue Feb 28 03:08:42 EST 2012


----------------------------------------------------------------------
Revision: e44e9fd16139fe788e9e7ae054804212a36a2ad5
Parent:   a0baeabb884751241a81faae6a0d6ffce771d20f
Author:   qulogic at pidgin.im
Date:     02/28/12 02:42:05
Branch:   im.pidgin.cpw.qulogic.gtk3-required
URL: http://d.pidgin.im/viewmtn/revision/info/e44e9fd16139fe788e9e7ae054804212a36a2ad5

Changelog: 

Fix DND hints on GTK+3.

Changes against parent a0baeabb884751241a81faae6a0d6ffce771d20f

  patched  pidgin/gtkdnd-hints.c

-------------- next part --------------
============================================================
--- pidgin/gtkdnd-hints.c	41583142d7829ada029a8232f357411c9912a439
+++ pidgin/gtkdnd-hints.c	12e8644d8c808fbb19e20631602d93a6f9eddd19
@@ -54,39 +54,51 @@ static HintWindowInfo hint_windows[] = {
 	{ NULL, NULL, 0, 0 }
 };
 
+static void
+dnd_hints_realized_cb(GtkWidget *window, GtkWidget *pix)
+{
+	GdkPixbuf *pixbuf;
+	cairo_surface_t *surface;
+	cairo_region_t *region;
+	cairo_t *cr;
+
+	pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(pix));
+
+	surface = cairo_image_surface_create(CAIRO_FORMAT_A1,
+	                                     gdk_pixbuf_get_width(pixbuf),
+	                                     gdk_pixbuf_get_height(pixbuf));
+      
+	cr = cairo_create(surface);
+	gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
+	cairo_paint(cr);
+	cairo_destroy(cr);
+
+	region = gdk_cairo_region_create_from_surface(surface);
+	gtk_widget_shape_combine_region(window, region);
+	cairo_region_destroy(region);
+
+	cairo_surface_destroy(surface);
+}
+
 static GtkWidget *
 dnd_hints_init_window(const gchar *fname)
 {
-	/* TODO: this is likely very broken right now, I think this needs to be 
-	 * Caito-ified. */
 	GdkPixbuf *pixbuf;
-	/*GdkPixmap *pixmap;*/
-	/*GdkBitmap *bitmap;*/
-	/*GtkWidget *pix;*/
+	GtkWidget *pix;
 	GtkWidget *win;
-	/*GdkColormap *colormap;*/
 
 	pixbuf = gdk_pixbuf_new_from_file(fname, NULL);
 	g_return_val_if_fail(pixbuf, NULL);
 
 	win = gtk_window_new(GTK_WINDOW_POPUP);
-#if 0
-	colormap = gtk_widget_get_colormap(win);
-	gdk_pixbuf_render_pixmap_and_mask_for_colormap(pixbuf, colormap,
-	                                               &pixmap, &bitmap, 128);
-#endif
-	g_object_unref(G_OBJECT(pixbuf));
-
-#if 0
-	pix = gtk_image_new_from_pixmap(pixmap, bitmap);
+	pix = gtk_image_new_from_pixbuf(pixbuf);
 	gtk_container_add(GTK_CONTAINER(win), pix);
-	gtk_widget_shape_combine_mask(win, bitmap, 0, 0);
+	gtk_widget_show_all(pix);
 
-	g_object_unref(G_OBJECT(pixmap));
-	g_object_unref(G_OBJECT(bitmap));
+	g_object_unref(G_OBJECT(pixbuf));
 
-	gtk_widget_show_all(pix);
-#endif
+	g_signal_connect(G_OBJECT(win), "realize",
+	                 G_CALLBACK(dnd_hints_realized_cb), pix);
 
 	return win;
 }


More information about the Commits mailing list