changeset 32627:ba21d11c06d0

propagate from branch 'im.pidgin.cpw.qulogic.cairo' (head 2efef3c76346222c20254255e83de8bb572d0ed8) to branch 'im.pidgin.cpw.qulogic.gtk3' (head 3002b1e2f6dcbe5b12ce1d35e8eedc486db63e96)
author Marcus Lundblad <ml@update.uu.se>
date Mon, 22 Nov 2010 10:18:15 +0000
parents 1c660ba17ba1 (diff) 89cc6d935af9 (current diff)
children a3bd979c9ce4
files
diffstat 3 files changed, 63 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkimhtml.c	Sat Nov 20 22:34:25 2010 +0000
+++ b/pidgin/gtkimhtml.c	Mon Nov 22 10:18:15 2010 +0000
@@ -756,7 +756,7 @@
 	GtkTextIter start, end, cur;
 	int buf_x, buf_y;
 	GdkRectangle visible_rect;
-	GdkGC *gc = gdk_gc_new(GDK_DRAWABLE(event->window));
+	cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(event->window));
 	GdkColor gcolor;
 
 	gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &visible_rect);
@@ -774,16 +774,16 @@
 
 		if (GTK_IMHTML(widget)->edit.background) {
 			gdk_color_parse(GTK_IMHTML(widget)->edit.background, &gcolor);
-			gdk_gc_set_rgb_fg_color(gc, &gcolor);
+			gdk_cairo_set_source_color(cr, &gcolor);
 		} else {
-			gdk_gc_set_rgb_fg_color(gc, &(widget->style->base[GTK_WIDGET_STATE(widget)]));
+			gdk_cairo_set_source_color(cr, &(widget->style->base[GTK_WIDGET_STATE(widget)]));
 		}
 
-		gdk_draw_rectangle(event->window,
-				   gc,
-				   TRUE,
-				   visible_rect.x, visible_rect.y, visible_rect.width, visible_rect.height);
-		g_object_unref(G_OBJECT(gc));
+		cairo_rectangle(cr,
+		                visible_rect.x, visible_rect.y,
+		                visible_rect.width, visible_rect.height);
+		cairo_fill(cr);
+		cairo_destroy(cr);
 
 		if (GTK_WIDGET_CLASS (parent_class)->expose_event)
 			return (* GTK_WIDGET_CLASS (parent_class)->expose_event)
@@ -854,12 +854,12 @@
 				if (!gdk_color_parse(tmp, &gcolor))
 					gdk_color_parse("white", &gcolor);
 			}
-			gdk_gc_set_rgb_fg_color(gc, &gcolor);
-
-			gdk_draw_rectangle(event->window,
-			                   gc,
-			                   TRUE,
-			                   rect.x, rect.y, rect.width, rect.height);
+			gdk_cairo_set_source_color(cr, &gcolor);
+
+			cairo_rectangle(cr,
+			                rect.x, rect.y,
+			                rect.width, rect.height);
+			cairo_fill(cr);
 			gtk_text_iter_backward_char(&cur); /* go back one, in case the end is the begining is the end
 			                                    * note that above, we always moved cur ahead by at least
 			                                    * one character */
@@ -874,7 +874,7 @@
 		       !gtk_text_iter_begins_tag(&cur, NULL));
 	}
 
-	g_object_unref(G_OBJECT(gc));
+	cairo_destroy(cr);
 
 	if (GTK_WIDGET_CLASS (parent_class)->expose_event)
 		return (* GTK_WIDGET_CLASS (parent_class)->expose_event)
--- a/pidgin/gtkwhiteboard.c	Sat Nov 20 22:34:25 2010 +0000
+++ b/pidgin/gtkwhiteboard.c	Mon Nov 22 10:18:15 2010 +0000
@@ -282,6 +282,9 @@
 	/* Clear graphical memory */
 	if(gtkwb->pixmap)
 	{
+		cairo_t *cr = g_object_get_data(G_OBJECT(gtkwb->pixmap), "cairo-context");
+		if (cr)
+			cairo_destroy(cr);
 		g_object_unref(gtkwb->pixmap);
 		gtkwb->pixmap = NULL;
 	}
@@ -353,25 +356,29 @@
 static gboolean pidgin_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
 {
 	PidginWhiteboard *gtkwb = (PidginWhiteboard*)data;
-
 	GdkPixmap *pixmap = gtkwb->pixmap;
+	cairo_t *cr;
 
-	if(pixmap)
+	if (pixmap) {
+		cr = g_object_get_data(G_OBJECT(pixmap), "cairo-context");
+		if (cr)
+			cairo_destroy(cr);
 		g_object_unref(pixmap);
+	}
 
 	pixmap = gdk_pixmap_new(widget->window,
 							widget->allocation.width,
 							widget->allocation.height,
 							-1);
-
 	gtkwb->pixmap = pixmap;
 
-	gdk_draw_rectangle(pixmap,
-					   widget->style->white_gc,
-					   TRUE,
-					   0, 0,
-					   widget->allocation.width,
-					   widget->allocation.height);
+	cr = gdk_cairo_create(GDK_DRAWABLE(pixmap));
+	g_object_set_data(G_OBJECT(pixmap), "cairo-context", cr);
+	gdk_cairo_set_source_color(cr, &widget->style->white);
+	cairo_rectangle(cr,
+	                0, 0,
+	                widget->allocation.width, widget->allocation.height);
+	cairo_fill(cr);
 
 	return TRUE;
 }
@@ -380,13 +387,15 @@
 {
 	PidginWhiteboard *gtkwb = (PidginWhiteboard*)(data);
 	GdkPixmap *pixmap = gtkwb->pixmap;
+	cairo_t *cr;
 
-	gdk_draw_drawable(widget->window,
-					  widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
-					  pixmap,
-					  event->area.x, event->area.y,
-					  event->area.x, event->area.y,
-					  event->area.width, event->area.height);
+	cr = gdk_cairo_create(GDK_DRAWABLE(widget->window));
+	gdk_cairo_set_source_pixmap(cr, pixmap, 0, 0);
+	cairo_rectangle(cr,
+	                event->area.x, event->area.y,
+	                event->area.width, event->area.height);
+	cairo_fill(cr);
+	cairo_destroy(cr);
 
 	return FALSE;
 }
@@ -586,50 +595,24 @@
 	GtkWidget *widget = gtkwb->drawing_area;
 	GdkPixmap *pixmap = gtkwb->pixmap;
 
-	GdkRectangle update_rect;
-
-	GdkGC *gfx_con = gdk_gc_new(pixmap);
+	cairo_t *gfx_con = g_object_get_data(G_OBJECT(pixmap), "cairo-context");
 	GdkColor col;
 
-	update_rect.x      = x - size / 2;
-	update_rect.y      = y - size / 2;
-	update_rect.width  = size;
-	update_rect.height = size;
-
 	/* Interpret and convert color */
 	pidgin_whiteboard_rgb24_to_rgb48(color, &col);
 
-	gdk_gc_set_rgb_fg_color(gfx_con, &col);
-	/* gdk_gc_set_rgb_bg_color(gfx_con, &col); */
+	gdk_cairo_set_source_color(gfx_con, &col);
 
-	/* NOTE 5 is a size constant for now... this is because of how poorly the
-	 * gdk_draw_arc draws small circles
-	 */
-	if(size < 5)
-	{
-		/* Draw a rectangle/square */
-		gdk_draw_rectangle(pixmap,
-						   gfx_con,
-						   TRUE,
-						   update_rect.x, update_rect.y,
-						   update_rect.width, update_rect.height);
-	}
-	else
-	{
-		/* Draw a circle */
-		gdk_draw_arc(pixmap,
-					 gfx_con,
-					 TRUE,
-					 update_rect.x, update_rect.y,
-					 update_rect.width, update_rect.height,
-					 0, FULL_CIRCLE_DEGREES);
-	}
+	/* Draw a circle */
+	cairo_arc(gfx_con,
+	          x, y,
+	          size / 2.0,
+	          0.0, 2.0 * M_PI);
+	cairo_fill(gfx_con);
 
 	gtk_widget_queue_draw_area(widget,
-							   update_rect.x, update_rect.y,
-							   update_rect.width, update_rect.height);
-
-	g_object_unref(G_OBJECT(gfx_con));
+							   x - size / 2, y - size / 2,
+							   size, size);
 }
 
 /* Uses Bresenham's algorithm (as provided by Wikipedia) */
@@ -720,13 +703,14 @@
 	PidginWhiteboard *gtkwb = wb->ui_data;
 	GdkPixmap *pixmap = gtkwb->pixmap;
 	GtkWidget *drawing_area = gtkwb->drawing_area;
+	cairo_t *cr = g_object_get_data(G_OBJECT(pixmap), "cairo-context");
 
-	gdk_draw_rectangle(pixmap,
-					   drawing_area->style->white_gc,
-					   TRUE,
-					   0, 0,
-					   drawing_area->allocation.width,
-					   drawing_area->allocation.height);
+	gdk_cairo_set_source_color(cr, &drawing_area->style->white);
+	cairo_rectangle(cr,
+	                0, 0,
+	                drawing_area->allocation.width,
+	                drawing_area->allocation.height);
+	cairo_fill(cr);
 
 	gtk_widget_queue_draw_area(drawing_area,
 							   0, 0,
--- a/pidgin/plugins/markerline.c	Sat Nov 20 22:34:25 2010 +0000
+++ b/pidgin/plugins/markerline.c	Mon Nov 22 10:18:15 2010 +0000
@@ -79,12 +79,14 @@
 	if (y >= event->area.y)
 	{
 		GdkColor red = {0, 0xffff, 0, 0};
-		GdkGC *gc = gdk_gc_new(GDK_DRAWABLE(event->window));
+		cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(event->window));
 
-		gdk_gc_set_rgb_fg_color(gc, &red);
-		gdk_draw_line(event->window, gc,
-					0, y, visible_rect.width, y);
-		g_object_unref(G_OBJECT(gc));
+		gdk_cairo_set_source_color(cr, &red);
+		cairo_move_to(cr, 0.0, y + 0.5);
+		cairo_rel_line_to(cr, visible_rect.width, 0.0);
+		cairo_set_line_width(cr, 1.0);
+		cairo_stroke(cr);
+		cairo_destroy(cr);
 	}
 	return FALSE;
 }