/*
- * $Id: rb_edje.c 66 2004-08-12 19:37:52Z tilman $
+ * $Id: rb_edje.c 96 2004-08-23 15:21:41Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
/*
* call-seq:
- * edje.on_signal(signal, source) { |signal, source| block } => nil
+ * edje.on_signal(signal [, source]) { |signal, source| block } => nil
*
* Registers a callback that will get called when <i>signal</i>
* is emitted by <i>source</i>.
+ * If source is nil, "*" will be used instead.
* The block is passed two strings, signal and source, which identify
* the emission.
*/
-static VALUE c_on_signal (VALUE self, VALUE signal, VALUE src)
+static VALUE c_on_signal (int argc, VALUE *argv, VALUE self)
{
- VALUE cb;
+ VALUE signal, src, cb;
+ char *ssrc = "*";
GET_OBJ (self, RbEdje, e);
+ rb_scan_args (argc, argv, "11", &signal, &src);
+
Check_Type (signal, T_STRING);
- Check_Type (src, T_STRING);
+
+ if (!NIL_P (src)) {
+ Check_Type (src, T_STRING);
+ ssrc = StringValuePtr (src);
+ }
if (!rb_block_given_p ())
return Qnil;
edje_object_signal_callback_add (e->real.real,
StringValuePtr (signal),
- StringValuePtr (src), on_signal,
- (void *) cb);
+ ssrc, on_signal, (void *) cb);
return Qnil;
}
rb_define_method (cEdje, "part", c_part_get, 1);
rb_define_method (cEdje, "on_text_changed", c_on_text_changed, 0);
rb_define_method (cEdje, "emit_signal", c_emit_signal, 2);
- rb_define_method (cEdje, "on_signal", c_on_signal, 2);
+ rb_define_method (cEdje, "on_signal", c_on_signal, -1);
rb_define_method (cEdje, "play?", c_play_get, 0);
rb_define_method (cEdje, "play=", c_play_set, 1);
rb_define_method (cEdje, "animation?", c_animation_get, 0);