/*
- * $Id: rb_ecore_evas.c 110 2004-09-02 17:06:54Z tilman $
+ * $Id: rb_ecore_evas.c 346 2005-06-05 19:43:40Z tilman $
*
* Copyright (C) 2004 ruby-ecore team (see AUTHORS)
*
\
if (!rb_block_given_p ()) \
return Qnil; \
+\
+ if (NIL_P (ee->callbacks)) \
+ ee->callbacks = rb_hash_new (); \
\
rb_hash_aset (ee->callbacks, rb_str_new2 (#name), \
rb_block_proc ()); \
if (!NIL_P (ee->evas))
rb_gc_mark (ee->evas);
- rb_gc_mark (ee->callbacks);
+ if (!NIL_P (ee->callbacks))
+ rb_gc_mark (ee->callbacks);
}
void c_ecore_evas_free (RbEcoreEvas *ee, bool free_mem)
GET_OBJ (self, RbEcoreEvas, ee);
ee->evas = Qnil;
- ee->callbacks = rb_hash_new ();
+ ee->callbacks = Qnil;
ecore_evas_data_set (ee->real, RUBY_ECORE_EVAS_KEY, (void *) self);
return Qnil;
}
+static VALUE c_name_class_get (VALUE self)
+{
+ const char *name = NULL, *klass = NULL;
+
+ GET_OBJ (self, RbEcoreEvas, ee);
+
+ ecore_evas_name_class_get (ee->real, &name, &klass);
+
+ return rb_ary_new3 (2, name ? rb_str_new2 (name) : Qnil,
+ klass ? rb_str_new2 (klass) : Qnil);
+}
+
+static VALUE c_name_class_set (VALUE self, VALUE ary)
+{
+ VALUE s1, s2;
+
+ GET_OBJ (self, RbEcoreEvas, ee);
+
+ Check_Type (ary, T_ARRAY);
+
+ s1 = rb_ary_shift (ary);
+ s2 = rb_ary_shift (ary);
+
+ StringValue (s1);
+ StringValue (s2);
+
+ ecore_evas_name_class_set (ee->real, StringValuePtr (s1),
+ StringValuePtr (s2));
+
+ return Qnil;
+}
+
/* FIXME: this is unsafe!
* :nodoc:
*/
rb_define_method (cEcoreEvas, "sticky=", c_sticky_set, 1);
rb_define_method (cEcoreEvas, "rotation", c_rotation_get, 0);
rb_define_method (cEcoreEvas, "rotation=", c_rotation_set, 1);
+ rb_define_method (cEcoreEvas, "name_class", c_name_class_get, 0);
+ rb_define_method (cEcoreEvas, "name_class=", c_name_class_set, 1);
rb_define_method (cEcoreEvas, "on_resize", c_on_resize, 0);
rb_define_method (cEcoreEvas, "on_move", c_on_move, 0);