X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;ds=sidebyside;f=src%2Frb_edje.c;h=4b76cce71a771229b01f52254012c3852ecf2224;hb=a405c57ad4ce8be9ab99b97464cbfe69a00853a3;hp=6e32824418a6764ba6bd9d970d692c6f78dd87b3;hpb=30fb3b8341f1f9ee89d0fc2a699401c98b4c9201;p=ruby-edje.git
diff --git a/src/rb_edje.c b/src/rb_edje.c
index 6e32824..4b76cce 100644
--- a/src/rb_edje.c
+++ b/src/rb_edje.c
@@ -1,5 +1,5 @@
/*
- * $Id: rb_edje.c 59 2004-08-10 14:10:31Z tilman $
+ * $Id: rb_edje.c 96 2004-08-23 15:21:41Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
@@ -169,7 +169,8 @@ static VALUE c_get_size_max (VALUE self)
* call-seq:
* edje.part_exists?(part) => true or false
*
- * Returns true if edje has a part called part, else false.
+ * Returns true if edje has a part called part,
+ * else returns false.
*/
static VALUE c_part_exists_get (VALUE self, VALUE name)
{
@@ -284,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;
@@ -308,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;
}
@@ -318,7 +326,7 @@ static VALUE c_on_signal (VALUE self, VALUE signal, VALUE src)
* call-seq:
* edje.play? => true or false
*
- * Returns true if edje is in play mode, else false.
+ * Returns true if edje is in play mode, else returns false.
*/
static VALUE c_play_get (VALUE self)
{
@@ -388,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);