diff src/shape_text.c @ 73:9ab15ebc9061

Observer for mouse events
author Thinker K.F. Li <thinker@branda.to>
date Mon, 18 Aug 2008 01:59:26 +0800
parents 1ca417f741f1
children dd813dcc232c
line wrap: on
line diff
--- a/src/shape_text.c	Wed Aug 13 09:25:57 2008 +0800
+++ b/src/shape_text.c	Mon Aug 18 01:59:26 2008 +0800
@@ -23,6 +23,14 @@
 
 #define TXF_SCALE_DIRTY 0x1
 
+static void sh_text_free(shape_t *shape) {
+    sh_text_t *text = (sh_text_t *)shape;
+
+    if(text->scaled_font)
+	cairo_scaled_font_destroy(text->scaled_font);
+    cairo_font_face_destroy(text->face);
+}
+
 shape_t *sh_text_new(const char *txt, co_aix x, co_aix y,
 		     co_aix font_size, cairo_font_face_t *face) {
     sh_text_t *text;
@@ -45,15 +53,9 @@
     text->face = face;
     text->flags |= TXF_SCALE_DIRTY;
 
-    return (shape_t *)text;
-}
+    text->shape.free = sh_text_free;
 
-void sh_text_free(shape_t *shape) {
-    sh_text_t *text = (sh_text_t *)shape;
-
-    if(text->scaled_font)
-	cairo_scaled_font_destroy(text->scaled_font);
-    cairo_font_face_destroy(text->face);
+    return (shape_t *)text;
 }
 
 static int get_extents(sh_text_t *text, cairo_text_extents_t *extents) {