aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-03-09 16:21:40 +0800
committerEmanuele Aina <emanuele.aina@collabora.com>2012-03-12 19:52:07 +0800
commit532a1f7c653866c50589d37fb20b13e1f71738cf (patch)
treecd08a38a3128f845dd3acdf6d27641aae9019ec9 /src
parent48370f1bead25fff25e3694f4e87d0b33068fdb3 (diff)
downloadgsoc2013-empathy-532a1f7c653866c50589d37fb20b13e1f71738cf.tar
gsoc2013-empathy-532a1f7c653866c50589d37fb20b13e1f71738cf.tar.gz
gsoc2013-empathy-532a1f7c653866c50589d37fb20b13e1f71738cf.tar.bz2
gsoc2013-empathy-532a1f7c653866c50589d37fb20b13e1f71738cf.tar.lz
gsoc2013-empathy-532a1f7c653866c50589d37fb20b13e1f71738cf.tar.xz
gsoc2013-empathy-532a1f7c653866c50589d37fb20b13e1f71738cf.tar.zst
gsoc2013-empathy-532a1f7c653866c50589d37fb20b13e1f71738cf.zip
rounded-rectangle: use the 'draw' signal
Looks like that's the right way to do it since Clutter 1.8 https://bugzilla.gnome.org/show_bug.cgi?id=669673
Diffstat (limited to 'src')
-rw-r--r--src/empathy-rounded-rectangle.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/empathy-rounded-rectangle.c b/src/empathy-rounded-rectangle.c
index 8e6dab3da..60246151b 100644
--- a/src/empathy-rounded-rectangle.c
+++ b/src/empathy-rounded-rectangle.c
@@ -37,12 +37,13 @@ struct _EmpathyRoundedRectanglePriv
guint border_width;
};
-static void
-empathy_rounded_rectangle_paint (EmpathyRoundedRectangle *self)
+static gboolean
+draw_cb (ClutterCairoTexture *canvas,
+ cairo_t *cr)
{
+ EmpathyRoundedRectangle *self = EMPATHY_ROUNDED_RECTANGLE (canvas);
guint width, height;
guint tmp_alpha;
- cairo_t *cr;
#define RADIUS (height / 8.)
@@ -55,8 +56,6 @@ empathy_rounded_rectangle_paint (EmpathyRoundedRectangle *self)
* self->priv->border_color.alpha
/ 255;
- cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (self));
-
cairo_set_source_rgba (cr,
self->priv->border_color.red,
self->priv->border_color.green,
@@ -84,9 +83,9 @@ empathy_rounded_rectangle_paint (EmpathyRoundedRectangle *self)
cairo_close_path (cr);
cairo_stroke (cr);
- cairo_destroy (cr);
#undef RADIUS
+ return TRUE;
}
static void
@@ -99,8 +98,18 @@ empathy_rounded_rectangle_init (EmpathyRoundedRectangle *self)
}
static void
+empathy_rounded_rectangle_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (empathy_rounded_rectangle_parent_class)->finalize (object);
+}
+
+static void
empathy_rounded_rectangle_class_init (EmpathyRoundedRectangleClass *klass)
{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = empathy_rounded_rectangle_finalize;
+
g_type_class_add_private (klass, sizeof (EmpathyRoundedRectanglePriv));
}
@@ -123,8 +132,10 @@ empathy_rounded_rectangle_new (guint width,
self->priv->width = width;
self->priv->height = height;
+ g_signal_connect (self, "draw", G_CALLBACK (draw_cb), NULL);
+
empathy_rounded_rectangle_update_surface_size (self);
- empathy_rounded_rectangle_paint (self);
+ clutter_cairo_texture_invalidate (CLUTTER_CAIRO_TEXTURE (self));
return CLUTTER_ACTOR (self);
}
@@ -136,7 +147,7 @@ empathy_rounded_rectangle_set_border_width (EmpathyRoundedRectangle *self,
self->priv->border_width = border_width;
empathy_rounded_rectangle_update_surface_size (self);
- empathy_rounded_rectangle_paint (self);
+ clutter_cairo_texture_invalidate (CLUTTER_CAIRO_TEXTURE (self));
}
void
@@ -145,5 +156,5 @@ empathy_rounded_rectangle_set_border_color (EmpathyRoundedRectangle *self,
{
self->priv->border_color = *color;
- empathy_rounded_rectangle_paint (self);
+ clutter_cairo_texture_invalidate (CLUTTER_CAIRO_TEXTURE (self));
}