[giggle/gtk3: 6/8] giggle-avatar-image: Port to the new GtkWidget::draw signal
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [giggle/gtk3: 6/8] giggle-avatar-image: Port to the new GtkWidget::draw signal
- Date: Wed, 27 Oct 2010 02:27:09 +0000 (UTC)
commit 317670e226fc4daa16ae9e21f4f74a23f5ba291f
Author: Javier Jardón <jjardon gnome org>
Date: Wed Oct 27 02:53:31 2010 +0200
giggle-avatar-image: Port to the new GtkWidget::draw signal
src/giggle-avatar-image.c | 24 +++++++++---------------
1 files changed, 9 insertions(+), 15 deletions(-)
---
diff --git a/src/giggle-avatar-image.c b/src/giggle-avatar-image.c
index 310e3b5..d37493e 100644
--- a/src/giggle-avatar-image.c
+++ b/src/giggle-avatar-image.c
@@ -334,34 +334,30 @@ rounded_rectangle (cairo_t *cr,
}
static gboolean
-avatar_image_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
+avatar_image_draw (GtkWidget *widget,
+ cairo_t *cr)
{
GiggleAvatarImagePriv *priv = GET_PRIV (widget);
- GtkAllocation allocation;
GtkRequisition requisition;
GtkStyle *style;
float xalign, yalign;
double x, y;
+ gint width, height;
int w, h;
- cairo_t *cr;
gtk_widget_get_preferred_size (widget, &requisition, NULL);
- gtk_widget_get_allocation (widget, &allocation);
+ width = gtk_widget_get_allocated_width (widget);
+ height = gtk_widget_get_allocated_height (widget);
style = gtk_widget_get_style (widget);
- cr = gdk_cairo_create (event->window);
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
-
w = requisition.width;
h = requisition.height;
gtk_misc_get_alignment (GTK_MISC (widget), &xalign, &yalign);
- cairo_translate
- (cr, (int) ((allocation.width - w) * xalign),
- (int) ((allocation.height - h) * yalign));
+ cairo_translate (cr,
+ (int) ((width - w) * xalign),
+ (int) ((height - h) * yalign));
rounded_rectangle (cr, 0.5, 0.5, w - 1, h - 1, MIN (w, h) * 0.2);
gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_NORMAL]);
@@ -379,8 +375,6 @@ avatar_image_expose_event (GtkWidget *widget,
cairo_set_line_width (cr, 1);
cairo_stroke (cr);
- cairo_destroy (cr);
-
return TRUE;
}
@@ -408,7 +402,7 @@ giggle_avatar_image_class_init (GiggleAvatarImageClass *class)
object_class->get_property = avatar_image_get_property;
object_class->finalize = avatar_image_finalize;
- widget_class->expose_event = avatar_image_expose_event;
+ widget_class->draw = avatar_image_draw;
widget_class->size_request = avatar_image_size_request;
g_object_class_install_property
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]