diff pidgin/gtkdnd-hints.c @ 32672:3828a61c44da

A boring and large patch so I can merge heads.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 23 Dec 2011 08:21:58 +0000
parents a3bd979c9ce4
children
line wrap: on
line diff
--- a/pidgin/gtkdnd-hints.c	Mon Aug 22 22:46:08 2011 +0000
+++ b/pidgin/gtkdnd-hints.c	Fri Dec 23 08:21:58 2011 +0000
@@ -57,34 +57,29 @@
 static GtkWidget *
 dnd_hints_init_window(const gchar *fname)
 {
-  /* TODO: this is likely very broken right now, I think this needs to be
-     Cairo-ified */
 	GdkPixbuf *pixbuf;
-	/*GdkPixmap *pixmap;*/
-	/*GdkBitmap *bitmap;*/
+	GdkPixmap *pixmap;
+	GdkBitmap *bitmap;
 	GtkWidget *pix;
 	GtkWidget *win;
+	GdkColormap *colormap;
 
 	pixbuf = gdk_pixbuf_new_from_file(fname, NULL);
 	g_return_val_if_fail(pixbuf, NULL);
 
-  /*
-	gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, &bitmap, 128);
+	win = gtk_window_new(GTK_WINDOW_POPUP);
+	colormap = gtk_widget_get_colormap(win);
+	gdk_pixbuf_render_pixmap_and_mask_for_colormap(pixbuf, colormap,
+	                                               &pixmap, &bitmap, 128);
 	g_object_unref(G_OBJECT(pixbuf));
-  */
-  
-	/*gtk_widget_push_colormap(gdk_rgb_get_colormap());*/
-	win = gtk_window_new(GTK_WINDOW_POPUP);
-	pix = gtk_image_new_from_pixbuf(pixbuf);
+
+	pix = gtk_image_new_from_pixmap(pixmap, bitmap);
 	gtk_container_add(GTK_CONTAINER(win), pix);
-	/*gtk_widget_shape_combine_mask(win, bitmap, 0, 0);
-	gtk_widget_pop_colormap();*/
+	gtk_widget_shape_combine_mask(win, bitmap, 0, 0);
 
-  /*
 	g_object_unref(G_OBJECT(pixmap));
 	g_object_unref(G_OBJECT(bitmap));
-  */
-  
+
 	gtk_widget_show_all(pix);
 
 	return win;
@@ -94,22 +89,17 @@
 get_widget_coords(GtkWidget *w, gint *x1, gint *y1, gint *x2, gint *y2)
 {
 	gint ox, oy, width, height;
-  GtkWidget *parent = gtk_widget_get_parent(w);
-    
-	if (parent && gtk_widget_get_window(parent) == gtk_widget_get_window(w))
+
+	if (w->parent && w->parent->window == w->window)
 	{
-    GtkAllocation allocation;
-
-    gtk_widget_get_allocation(w, &allocation);
-		get_widget_coords(parent, &ox, &oy, NULL, NULL);
-		height = allocation.height;
-		width = allocation.width;
+		get_widget_coords(w->parent, &ox, &oy, NULL, NULL);
+		height = w->allocation.height;
+		width = w->allocation.width;
 	}
 	else
 	{
-		gdk_window_get_origin(gtk_widget_get_window(w), &ox, &oy);
-    width = gdk_window_get_width(gtk_widget_get_window(w));
-    height = gdk_window_get_height(gtk_widget_get_window(w));
+		gdk_window_get_origin(w->window, &ox, &oy);
+		gdk_drawable_get_size(w->window, &width, &height);
 	}
 
 	if (x1) *x1 = ox;
@@ -182,13 +172,10 @@
 {
 	gint x1, x2, y1, y2;
 	gint x = 0, y = 0;
-  GtkAllocation allocation;
-
-  gtk_widget_get_allocation(widget, &allocation);
 
 	get_widget_coords(widget, &x1, &y1, &x2, &y2);
-	x1 += allocation.x;	x2 += allocation.x;
-	y1 += allocation.y;	y2 += allocation.y;
+	x1 += widget->allocation.x;	x2 += widget->allocation.x;
+	y1 += widget->allocation.y;	y2 += widget->allocation.y;
 
 	switch (horiz)
 	{