We now use real structs to wrap objects.
[ruby-evas.git] / src / rb_text.c
index 4224e9883180b4ea2a59a0d03322692a2b94f342..7788465613d31a6d1356da461e74d80dfa93fa7d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_text.c 38 2004-07-25 11:27:25Z tilman $
+ * $Id: rb_text.c 49 2004-08-01 10:17:39Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #include "rb_evas.h"
 #include "rb_evas_object.h"
 
+static void c_free (RbEvasObject *e)
+{
+       c_evas_object_free (e, true);
+}
+
 static VALUE c_new (VALUE klass, VALUE evas)
 {
        VALUE self, argv[1];
-       Evas_Object **rect;
+       RbEvasObject *text;
 
        CHECK_CLASS (evas, cEvas);
-       GET_OBJ (evas, Evas *, e);
+       GET_OBJ (evas, RbEvas, e);
 
-       self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
-                                c_evas_object_free, rect);
-       *rect = evas_object_text_add (*e);
+       self = Data_Make_Struct (klass, RbEvasObject, c_evas_object_mark,
+                                c_free, text);
+       text->real = evas_object_text_add (e->real);
 
        argv[0] = evas;
        rb_obj_call_init (self, 1, argv);
@@ -48,9 +53,9 @@ static VALUE c_font_source_get (VALUE self)
 {
        const char *tmp;
 
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
-       if (!(tmp = evas_object_text_font_source_get (*e)))
+       if (!(tmp = evas_object_text_font_source_get (e->real)))
                return Qnil;
        else
                return rb_str_new2 (tmp);
@@ -58,11 +63,11 @@ static VALUE c_font_source_get (VALUE self)
 
 static VALUE c_font_source_set (VALUE self, VALUE val)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
        Check_Type (val, T_STRING);
 
-       evas_object_text_font_source_set (*e, StringValuePtr (val));
+       evas_object_text_font_source_set (e->real, StringValuePtr (val));
 
        return Qnil;
 }
@@ -72,9 +77,9 @@ static VALUE c_get_font (VALUE self)
        char *font = NULL;
        Evas_Font_Size size = 0;
 
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
-       evas_object_text_font_get (*e, &font, &size);
+       evas_object_text_font_get (e->real, &font, &size);
 
        return rb_ary_new3 (2, font ? rb_str_new2 (font) : Qnil,
                            INT2FIX (size));
@@ -82,12 +87,12 @@ static VALUE c_get_font (VALUE self)
 
 static VALUE c_set_font (VALUE self, VALUE font, VALUE size)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
        Check_Type (font, T_STRING);
        Check_Type (font, T_FIXNUM);
 
-       evas_object_text_font_set (*e, StringValuePtr (font),
+       evas_object_text_font_set (e->real, StringValuePtr (font),
                                   FIX2INT (size));
 
        return Qnil;
@@ -97,9 +102,9 @@ static VALUE c_text_get (VALUE self)
 {
        const char *tmp;
 
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
-       if (!(tmp = evas_object_text_text_get (*e)))
+       if (!(tmp = evas_object_text_text_get (e->real)))
                return Qnil;
        else
                return rb_str_new2 (tmp);
@@ -107,11 +112,11 @@ static VALUE c_text_get (VALUE self)
 
 static VALUE c_text_set (VALUE self, VALUE val)
 {
-       GET_OBJ (self, Evas_Object *, e);
+       GET_OBJ (self, RbEvasObject, e);
 
        Check_Type (val, T_STRING);
 
-       evas_object_text_text_set (*e, StringValuePtr (val));
+       evas_object_text_text_set (e->real, StringValuePtr (val));
 
        return Qnil;
 }