Implemented more functions/properties.
authorTilman Sauerbeck <tilman@code-monkey.de>
Tue, 22 Jun 2004 20:40:05 +0000 (20:40 +0000)
committerTilman Sauerbeck <tilman@code-monkey.de>
Tue, 22 Jun 2004 20:40:05 +0000 (20:40 +0000)
src/rb_edje.c

index 5b4ef806c10132a5ff282d1386f125ccd7097f5f..d6f60f29e5fa73198f50eed7eca88ceb7e47e5f9 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * $Id: rb_edje.c 17 2004-06-22 19:37:54Z tilman $
+ * $Id: rb_edje.c 19 2004-06-22 20:40:05Z tilman $
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
  *
  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
  *
                return Qnil; \
        }
 
                return Qnil; \
        }
 
+#define CHECK_BOOL(val) \
+       if (TYPE ((val)) != T_TRUE && TYPE ((val)) != T_FALSE) { \
+               rb_raise (rb_eTypeError, \
+                         "wrong argument type %s (expected true or false)", \
+                         rb_obj_classname ((val))); \
+               return Qnil; \
+       }
+
 VALUE cEdje;
 
 static VALUE c_new (VALUE klass, VALUE evas)
 VALUE cEdje;
 
 static VALUE c_new (VALUE klass, VALUE evas)
@@ -162,6 +170,102 @@ static VALUE c_get_part_swallow (VALUE self, VALUE part)
        return (VALUE) obj;
 }
 
        return (VALUE) obj;
 }
 
+static VALUE c_get_part_text (VALUE self, VALUE part)
+{
+       const char *s;
+
+       GET_OBJ (self, Evas_Object, e, "Edje");
+
+       Check_Type (part, T_STRING);
+
+       if (!(s = edje_object_part_text_get (*e, StringValuePtr (part))))
+               return Qnil;
+       else
+               return rb_str_new2 (s);
+}
+
+static VALUE c_set_part_text (VALUE self, VALUE part, VALUE text)
+{
+       GET_OBJ (self, Evas_Object, e, "Edje");
+
+       Check_Type (part, T_STRING);
+       Check_Type (text, T_STRING);
+
+       edje_object_part_text_set (*e, StringValuePtr (part),
+                                  StringValuePtr (text));
+
+       return Qnil;
+}
+
+static void on_text_changed (void *data, Evas_Object *e,
+                             const char *part)
+{
+       rb_funcall ((VALUE) data, rb_intern ("call"), 1,
+                   rb_str_new2 (part));
+}
+
+static VALUE c_on_text_changed (VALUE self)
+{
+       GET_OBJ (self, Evas_Object, e, "Edje");
+
+       if (!rb_block_given_p ())
+               return Qnil;
+
+       edje_object_text_change_cb_set (*e, on_text_changed,
+                                       (void *) rb_block_proc ());
+
+       return Qnil;
+}
+
+static VALUE c_signal_emit (VALUE self, VALUE emission, VALUE source)
+{
+       GET_OBJ (self, Evas_Object, e, "Edje");
+
+       Check_Type (emission, T_STRING);
+       Check_Type (source, T_STRING);
+
+       edje_object_signal_emit (*e, StringValuePtr (emission),
+                                StringValuePtr (source));
+
+       return Qnil;
+}
+
+static VALUE c_play_get (VALUE self)
+{
+       GET_OBJ (self, Evas_Object, e, "Edje");
+
+       return edje_object_play_get (*e) ? Qtrue : Qfalse;
+}
+
+static VALUE c_play_set (VALUE self, VALUE val)
+{
+       GET_OBJ (self, Evas_Object, e, "Edje");
+
+       CHECK_BOOL(val);
+
+       edje_object_play_set (*e, val == Qtrue ? 1 : 0);
+
+       return Qnil;
+}
+
+static VALUE c_animation_get (VALUE self)
+{
+       GET_OBJ (self, Evas_Object, e, "Edje");
+
+       return edje_object_animation_get (*e) ? Qtrue : Qfalse;
+}
+
+static VALUE c_animation_set (VALUE self, VALUE val)
+{
+       GET_OBJ (self, Evas_Object, e, "Edje");
+
+       CHECK_BOOL(val);
+
+       edje_object_animation_set (*e, val == Qtrue ? 1 : 0);
+
+       return Qnil;
+}
+
 void Init_Edje (void)
 {
        cEdje = rb_define_class_under (mEdje, "Edje", cEvasObject);
 void Init_Edje (void)
 {
        cEdje = rb_define_class_under (mEdje, "Edje", cEvasObject);
@@ -174,5 +278,13 @@ void Init_Edje (void)
        rb_define_method (cEdje, "part_swallow", c_part_swallow, 2);
        rb_define_method (cEdje, "part_unswallow", c_part_unswallow, 1);
        rb_define_method (cEdje, "get_part_swallow", c_get_part_swallow, 1);
        rb_define_method (cEdje, "part_swallow", c_part_swallow, 2);
        rb_define_method (cEdje, "part_unswallow", c_part_unswallow, 1);
        rb_define_method (cEdje, "get_part_swallow", c_get_part_swallow, 1);
+       rb_define_method (cEdje, "get_part_text", c_get_part_text, 1);
+       rb_define_method (cEdje, "set_part_text", c_set_part_text, 2);
+       rb_define_method (cEdje, "on_text_changed", c_on_text_changed, 0);
+       rb_define_method (cEdje, "signal_emit", c_signal_emit, 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);
+       rb_define_method (cEdje, "animation=", c_animation_set, 1);
 }
 
 }