+/*
+ * $Id$
+ *
+ * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <ruby.h>
+
+#include <Edje.h>
+#include <rb_evas.h>
+#include <rb_evas_object.h>
+
+#include "rb_edje_main.h"
+
+#define GET_OBJ(obj, type, o, desc) \
+ type **(o) = NULL; \
+\
+ Data_Get_Struct ((obj), type *, (o)); \
+\
+ if (!*(o)) { \
+ rb_raise (rb_eException, desc " destroyed already"); \
+ return Qnil; \
+ }
+
+VALUE cEdje;
+
+static VALUE c_new (VALUE klass, VALUE evas)
+{
+ VALUE self, argv[1];
+ Evas_Object **edje;
+
+ GET_OBJ (evas, Evas, e, "Evas");
+
+ self = Data_Make_Struct (klass, Evas_Object *, c_evas_object_mark,
+ c_evas_object_free, edje);
+ *edje = edje_object_add (*e);
+
+ argv[0] = evas;
+ rb_obj_call_init (self, 1, argv);
+
+ return self;
+}
+
+static VALUE c_load (VALUE self, VALUE eet, VALUE group)
+{
+ GET_OBJ (self, Evas_Object, e, "EvasObject");
+
+ Check_Type (eet, T_STRING);
+ Check_Type (group, T_STRING);
+
+ if (!edje_object_file_set (*e, STR2CSTR (eet), STR2CSTR (group)))
+ rb_raise (rb_eException, "Cannot load eet");
+
+ return Qnil;
+}
+
+void Init_Edje (void)
+{
+ cEdje = rb_define_class_under (mEdje, "Edje", cEvasObject);
+
+ rb_define_singleton_method (cEdje, "new", c_new, 1);
+ rb_define_method (cEdje, "load", c_load, 2);
+}
+