]> git.0d.be Git - empathy.git/commitdiff
rounded-rectangle: use the 'draw' signal
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 9 Mar 2012 08:21:40 +0000 (09:21 +0100)
committerEmanuele Aina <emanuele.aina@collabora.com>
Mon, 12 Mar 2012 11:52:07 +0000 (12:52 +0100)
Looks like that's the right way to do it since Clutter 1.8

https://bugzilla.gnome.org/show_bug.cgi?id=669673

configure.ac
src/empathy-rounded-rectangle.c

index 70ca49214b7f8038ed30e51087b4b0df6a46dbc0..6e5caeceb1f534c1a399b182155a4c3c6a8d7e86 100644 (file)
@@ -45,9 +45,9 @@ GTK_REQUIRED=3.0.2
 AC_DEFINE(GDK_VERSION_MIN_REQUIRED, GDK_VERSION_3_0, [Ignore post 3.0 deprecations])
 AC_DEFINE(GDK_VERSION_MAX_REQUIRED, GDK_VERSION_3_0, [Prevent post 3.0 APIs])
 
-CLUTTER_REQUIRED=1.7.14
-AC_DEFINE(CLUTTER_VERSION_MIN_REQUIRED, CLUTTER_VERSION_1_6, [Ignore post 1.6 deprecations])
-AC_DEFINE(CLUTTER_VERSION_MAX, CLUTTER_VERSION_1_6, [Prevent post 1.6 APIs])
+CLUTTER_REQUIRED=1.8.0
+AC_DEFINE(CLUTTER_VERSION_MIN_REQUIRED, CLUTTER_VERSION_1_8, [Ignore post 1.8 deprecations])
+AC_DEFINE(CLUTTER_VERSION_MAX, CLUTTER_VERSION_1_8, [Prevent post 1.8 APIs])
 
 CLUTTER_GTK_REQUIRED=0.90.3
 
index 8e6dab3da36ec03170b26c842f406606a76c985c..60246151b8b75632370d33eb9f4712df993ff895 100644 (file)
@@ -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
@@ -98,9 +97,19 @@ empathy_rounded_rectangle_init (EmpathyRoundedRectangle *self)
   self->priv->border_width = 1;
 }
 
+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));
 }