From: Tilman Sauerbeck Date: Tue, 22 Jun 2004 19:37:54 +0000 (+0000) Subject: Added wrappers for some functions. X-Git-Url: http://git.code-monkey.de/?a=commitdiff_plain;ds=inline;h=e677d2b2bc8c9bbe883278a0f5b63e16a14820cf;hp=3ccc7a4601c765acb891b7ea449892a078186d7a;p=ruby-edje.git Added wrappers for some functions. --- diff --git a/src/rb_edje.c b/src/rb_edje.c index e79d67b..5b4ef80 100644 --- a/src/rb_edje.c +++ b/src/rb_edje.c @@ -1,5 +1,5 @@ /* - * $Id: rb_edje.c 13 2004-06-20 10:32:56Z tilman $ + * $Id: rb_edje.c 17 2004-06-22 19:37:54Z tilman $ * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * @@ -57,7 +57,7 @@ static VALUE c_new (VALUE klass, VALUE evas) static VALUE c_load (VALUE self, VALUE eet, VALUE group) { - GET_OBJ (self, Evas_Object, e, "EvasObject"); + GET_OBJ (self, Evas_Object, e, "Edje"); Check_Type (eet, T_STRING); Check_Type (group, T_STRING); @@ -69,11 +69,110 @@ static VALUE c_load (VALUE self, VALUE eet, VALUE group) return Qnil; } +static VALUE c_get_size_min (VALUE self) +{ + int w = 0, h = 0; + + GET_OBJ (self, Evas_Object, e, "Edje"); + + edje_object_size_min_get (*e, &w, &h); + + return rb_ary_new3 (2, INT2FIX (w), INT2FIX (h)); +} + +static VALUE c_get_size_max (VALUE self) +{ + int w = 0, h = 0; + + GET_OBJ (self, Evas_Object, e, "Edje"); + + edje_object_size_max_get (*e, &w, &h); + + return rb_ary_new3 (2, INT2FIX (w), INT2FIX (h)); +} + +static VALUE c_part_exists_get (VALUE self, VALUE part) +{ + int r; + + GET_OBJ (self, Evas_Object, e, "Edje"); + + Check_Type (part, T_STRING); + + r = edje_object_part_exists (*e, StringValuePtr (part)); + + return r ? Qtrue : Qfalse; +} + +static VALUE c_part_swallow (VALUE self, VALUE part, VALUE target) +{ + GET_OBJ (self, Evas_Object, e, "Edje"); + + Check_Type (part, T_STRING); + + if (!rb_obj_is_kind_of (target, cEvasObject)) { + rb_raise (rb_eTypeError, + "wrong argument type %s (expected EvasObject)", + rb_obj_classname (target)); + return Qnil; + } + + GET_OBJ (target, Evas_Object, target2, "EvasObject"); + + edje_object_part_swallow (*e, StringValuePtr (part), *target2); + + return Qnil; +} + +static VALUE c_part_unswallow (VALUE self, VALUE target) +{ + GET_OBJ (self, Evas_Object, e, "Edje"); + + if (!rb_obj_is_kind_of (target, cEvasObject)) { + rb_raise (rb_eTypeError, + "wrong argument type %s (expected EvasObject)", + rb_obj_classname (target)); + return Qnil; + } + + GET_OBJ (target, Evas_Object, target2, "EvasObject"); + + edje_object_part_unswallow (*e, *target2); + + return Qnil; +} + +static VALUE c_get_part_swallow (VALUE self, VALUE part) +{ + Evas_Object *o; + void *obj; + + GET_OBJ (self, Evas_Object, e, "Edje"); + + Check_Type (part, T_STRING); + + if (!(o = edje_object_part_swallow_get (*e, StringValuePtr (part)))) + return Qnil; + + if (!(obj = evas_object_data_get (o, RUBY_EVAS_OBJECT_KEY))) { + rb_raise (rb_eException, "EvasObject Ruby object key missing"); + return Qnil; + } + + return (VALUE) obj; +} + void Init_Edje (void) { cEdje = rb_define_class_under (mEdje, "Edje", cEvasObject); rb_define_singleton_method (cEdje, "new", c_new, 1); rb_define_method (cEdje, "load", c_load, 2); + rb_define_method (cEdje, "get_size_min", c_get_size_min, 0); + rb_define_method (cEdje, "get_size_max", c_get_size_max, 0); + rb_define_method (cEdje, "part_exists?", c_part_exists_get, 1); + rb_define_method (cEdje, "part_swallow", c_part_swallow, 2); + rb_define_method (cEdje, "part_unswallow", c_part_unswallow, 1); + rb_define_method (cEdje, "get_part_swallow", c_get_part_swallow, 1); } diff --git a/src/rb_edje_main.c b/src/rb_edje_main.c index 7444762..f9c37bc 100644 --- a/src/rb_edje_main.c +++ b/src/rb_edje_main.c @@ -1,5 +1,5 @@ /* - * $Id: rb_edje_main.c 7 2004-06-19 19:32:33Z tilman $ + * $Id: rb_edje_main.c 17 2004-06-22 19:37:54Z tilman $ * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * @@ -37,6 +37,34 @@ static VALUE m_shutdown (VALUE self) return INT2FIX (edje_shutdown ()); } +static VALUE m_freeze (VALUE self) +{ + edje_freeze (); + + return Qnil; +} + +static VALUE m_thaw (VALUE self) +{ + edje_thaw (); + + return Qnil; +} + +static VALUE m_frametime_get (VALUE self) +{ + return rb_float_new (edje_frametime_get ()); +} + +static VALUE m_frametime_set (VALUE self, VALUE val) +{ + Check_Type (val, T_FLOAT); + + edje_frametime_set (NUM2DBL (val)); + + return Qnil; +} + void Init_edje (void) { rb_require ("evas"); @@ -45,6 +73,10 @@ void Init_edje (void) rb_define_module_function (mEdje, "init", m_init, 0); rb_define_module_function (mEdje, "shutdown", m_shutdown, 0); + rb_define_module_function (mEdje, "freeze", m_freeze, 0); + rb_define_module_function (mEdje, "thaw", m_thaw, 0); + rb_define_module_function (mEdje, "frametime", m_frametime_get, 0); + rb_define_module_function (mEdje, "frametime=", m_frametime_set, 1); Init_Edje (); }