X-Git-Url: http://git.code-monkey.de/?p=ruby-edje.git;a=blobdiff_plain;f=src%2Frb_part.c;h=563be555b6430020945c92e24248e5d9ad7b6959;hp=381d04962b2b07d07954c4b85c98295ed071bfe3;hb=3a9c35673bdd0dc885f7474865be23d6d0061789;hpb=fc473416558a8d1cbccdabfe9ab5fae2a1e987fa diff --git a/src/rb_part.c b/src/rb_part.c index 381d049..563be55 100644 --- a/src/rb_part.c +++ b/src/rb_part.c @@ -1,5 +1,5 @@ /* - * $Id: rb_part.c 48 2004-07-31 13:46:07Z tilman $ + * $Id: rb_part.c 51 2004-08-01 10:19:02Z tilman $ * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * @@ -21,8 +21,6 @@ #include #include -#include -#include #include "rb_edje_main.h" #include "rb_edje.h" @@ -52,32 +50,14 @@ static inline VALUE GET_EDJE (VALUE o) return rb_ivar_get (o, id); } -static void c_mark (VALUE *self) -{ - rb_gc_mark (GET_EDJE (*self)); -} - -static void c_free (VALUE *self) -{ - edje_shutdown (); - - free (self); -} - VALUE TO_PART (VALUE edje, VALUE name) { - VALUE self, *self2; + VALUE self; CHECK_CLASS (edje, cEdje); Check_Type (name, T_STRING); - edje_init (); - - /* we only use Data_Make_Struct to be able to specify - * mark and sweep hooks - */ - self = Data_Make_Struct (cPart, VALUE, c_mark, c_free, self2); - self2 = &self; + self = rb_obj_alloc (cPart); rb_iv_set (self, "@edje", edje); rb_iv_set (self, "@name", rb_str_dup (name)); @@ -91,9 +71,9 @@ static VALUE c_get_geometry (VALUE self) { int x = 0, y = 0, w = 0, h = 0; - GET_OBJ (GET_EDJE (self), Evas_Object *, e); + GET_OBJ (GET_EDJE (self), RbEdje, e); - edje_object_part_geometry_get (*e, GET_NAME (self), + edje_object_part_geometry_get (e->real.real, GET_NAME (self), (Evas_Coord *) &x, (Evas_Coord *) &y, (Evas_Coord *) &w, @@ -105,12 +85,12 @@ static VALUE c_get_geometry (VALUE self) static VALUE c_swallow (VALUE self, VALUE target) { - GET_OBJ (GET_EDJE (self), Evas_Object *, e); + GET_OBJ (GET_EDJE (self), RbEdje, e); CHECK_CLASS (target, cEvasObject); - GET_OBJ (target, Evas_Object *, target2); + GET_OBJ (target, RbEvasObject, t); - edje_object_part_swallow (*e, GET_NAME (self), *target2); + edje_object_part_swallow (e->real.real, GET_NAME (self), t->real); return Qnil; } @@ -119,14 +99,15 @@ static VALUE c_unswallow (VALUE self) { Evas_Object *o; - GET_OBJ (GET_EDJE (self), Evas_Object *, e); + GET_OBJ (GET_EDJE (self), RbEdje, e); - if (!(o = edje_object_part_swallow_get (*e, GET_NAME (self)))) { + o = edje_object_part_swallow_get (e->real.real, GET_NAME (self)); + if (!o) { rb_raise (rb_eException, "Part didn't swallow an EvasObject"); return Qnil; } - edje_object_part_unswallow (*e, o); + edje_object_part_unswallow (e->real.real, o); return Qnil; } @@ -136,9 +117,10 @@ static VALUE c_swallowed_object_get (VALUE self) Evas_Object *o; void *obj; - GET_OBJ (GET_EDJE (self), Evas_Object *, e); + GET_OBJ (GET_EDJE (self), RbEdje, e); - if (!(o = edje_object_part_swallow_get (*e, GET_NAME (self)))) + o = edje_object_part_swallow_get (e->real.real, GET_NAME (self)); + if (!o) return Qnil; if (!(obj = evas_object_data_get (o, RUBY_EVAS_OBJECT_KEY))) { @@ -153,21 +135,20 @@ static VALUE c_text_get (VALUE self) { const char *s; - GET_OBJ (GET_EDJE (self), Evas_Object *, e); + GET_OBJ (GET_EDJE (self), RbEdje, e); - if (!(s = edje_object_part_text_get (*e, GET_NAME (self)))) - return Qnil; - else - return rb_str_new2 (s); + s = edje_object_part_text_get (e->real.real, GET_NAME (self)); + + return s ? rb_str_new2 (s) : Qnil; } static VALUE c_text_set (VALUE self, VALUE text) { - GET_OBJ (GET_EDJE (self), Evas_Object *, e); + GET_OBJ (GET_EDJE (self), RbEdje, e); Check_Type (text, T_STRING); - edje_object_part_text_set (*e, GET_NAME (self), + edje_object_part_text_set (e->real.real, GET_NAME (self), StringValuePtr (text)); return Qnil; @@ -177,16 +158,16 @@ static VALUE c_get_drag_value (VALUE self) { double dx = 0, dy = 0; - GET_OBJ (GET_EDJE (self), Evas_Object *, e); + GET_OBJ (GET_EDJE (self), RbEdje, e); - edje_object_part_drag_value_get (*e, GET_NAME (self), &dx, &dy); + edje_object_part_drag_value_get (e->real.real, GET_NAME (self), &dx, &dy); return rb_ary_new3 (2, rb_float_new (dx), rb_float_new (dy)); } static VALUE c_set_drag_value (VALUE self, VALUE dx, VALUE dy) { - GET_OBJ (GET_EDJE (self), Evas_Object *, e); + GET_OBJ (GET_EDJE (self), RbEdje, e); if (!FIXNUM_P (dx)) Check_Type (dx, T_FLOAT); @@ -194,7 +175,7 @@ static VALUE c_set_drag_value (VALUE self, VALUE dx, VALUE dy) if (!FIXNUM_P (dy)) Check_Type (dy, T_FLOAT); - edje_object_part_drag_value_set (*e, GET_NAME (self), + edje_object_part_drag_value_set (e->real.real, GET_NAME (self), NUM2DBL (dx), NUM2DBL (dy)); return Qnil;