Added Edje.new_from_pointer.
[ruby-edje.git] / src / rb_edje.c
index 8e0f0b6cc0ea219ae659bf1d817a43b46b9d1e93..c46b3157731f0478b8db335fb485c94ce5d0bd95 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_edje.c 332 2005-04-28 18:37:16Z tilman $
+ * $Id: rb_edje.c 335 2005-05-02 17:28:37Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
@@ -84,6 +84,26 @@ static VALUE c_new (VALUE klass, VALUE evas)
        return self;
 }
 
+static VALUE c_new_from_pointer (VALUE klass, VALUE evas, VALUE ptr)
+{
+       VALUE self, argv[1];
+       RbEdje *edje = NULL;
+
+       edje_init ();
+
+       self = Data_Make_Struct (klass, RbEdje, c_mark, c_free, edje);
+
+       edje->real.real = (Evas_Object *) ptr;
+       edje->parts = Qnil;
+       edje->callbacks = Qnil;
+       edje->on_text_changed_cb = Qnil;
+
+       argv[0] = evas;
+       rb_obj_call_init (self, 1, argv);
+
+       return self;
+}
+
 /*
  * call-seq:
  *  edje.freeze => nil
@@ -515,11 +535,12 @@ static VALUE c_send_message (VALUE self, VALUE msg)
 
        CHECK_CLASS (msg, cMsg);
 
-       id = NUM2INT (rb_iv_get (msg, "@id"));
+       id = FIX2INT (rb_iv_get (msg, "@id"));
        v = rb_iv_get (msg, "@value");
 
        type = get_msg_type (v);
-       ary = rb_check_array_type (v);
+       if (!NIL_P (ary = rb_check_array_type (v)))
+               len = RARRAY (ary)->len;
 
        switch (type) {
                case EDJE_MESSAGE_NONE:
@@ -649,7 +670,7 @@ static VALUE c_msg_init (int argc, VALUE *argv, VALUE self)
 
        Check_Type (id, T_FIXNUM);
 
-       rb_iv_set (self, "@id", UINT2NUM (id));
+       rb_iv_set (self, "@id", id);
        rb_iv_set (self, "@value", val);
 
        return self;
@@ -660,6 +681,8 @@ void Init_Edje (void)
        cEdje = rb_define_class_under (mEdje, "Edje", cEvasObject);
 
        rb_define_singleton_method (cEdje, "new", c_new, 1);
+       rb_define_singleton_method (cEdje, "new_from_pointer",
+                                   c_new_from_pointer, 2);
        rb_define_method (cEdje, "freeze", c_freeze, 0);
        rb_define_method (cEdje, "thaw", c_thaw, 0);
        rb_define_method (cEdje, "load", c_load, 2);