X-Git-Url: http://git.code-monkey.de/?p=ruby-edje.git;a=blobdiff_plain;f=src%2Frb_edje.c;h=4b76cce71a771229b01f52254012c3852ecf2224;hp=50ba39b4369a613393ada20ff00e67098f65019e;hb=ba313b5cb6ebd3d8eae9c551fac8504651251bb9;hpb=2bcc79d1ea2295fdb7ab271e4b39a7a7de39ef9f
diff --git a/src/rb_edje.c b/src/rb_edje.c
index 50ba39b..4b76cce 100644
--- a/src/rb_edje.c
+++ b/src/rb_edje.c
@@ -1,5 +1,5 @@
/*
- * $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)
*
@@ -285,21 +285,29 @@ static void on_signal (void *data, Evas_Object *o,
/*
* 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 signal
* is emitted by source.
+ * 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;
@@ -309,8 +317,7 @@ static VALUE c_on_signal (VALUE self, VALUE signal, VALUE src)
edje_object_signal_callback_add (e->real.real,
StringValuePtr (signal),
- StringValuePtr (src), on_signal,
- (void *) cb);
+ ssrc, on_signal, (void *) cb);
return Qnil;
}
@@ -389,7 +396,7 @@ void Init_Edje (void)
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);