Added ecore_x bindings.
authorTilman Sauerbeck <tilman@code-monkey.de>
Sun, 25 Jul 2004 13:13:57 +0000 (13:13 +0000)
committerTilman Sauerbeck <tilman@code-monkey.de>
Sun, 25 Jul 2004 13:13:57 +0000 (13:13 +0000)
configure.ac
src/Makefile.am
src/ecore_x/Makefile.am [new file with mode: 0644]
src/ecore_x/rb_ecore_x.c [new file with mode: 0644]
src/ecore_x/rb_ecore_x.h [new file with mode: 0644]
src/ecore_x/rb_window.c [new file with mode: 0644]
src/ecore_x/rb_window.h [new file with mode: 0644]

index 36bc5e061f28704ac0a31ca146e60ceb7a3715bd..0fc8a4b962b8c108e4375314fa80a8e074d4e8f9 100644 (file)
@@ -1,4 +1,4 @@
-dnl $Id: configure.ac 9 2004-06-19 19:53:47Z tilman $
+dnl $Id: configure.ac 39 2004-07-25 13:13:57Z tilman $
 
 AC_INIT(ruby-ecore, 0.0.1)
 AC_CONFIG_SRCDIR([src/ecore/rb_ecore.c])
@@ -29,8 +29,9 @@ Makefile
 m4/Makefile
 src/Makefile
 src/ecore/Makefile
-src/ecore_job/Makefile
 src/ecore_evas/Makefile
+src/ecore_job/Makefile
+src/ecore_x/Makefile
 ])
 
 AC_OUTPUT
index a978f0df287cc82fb6eb2d90af7bf6ebb36e85b0..e35ffad4f7210cc7a8b862e4817c2522c99ae905 100644 (file)
@@ -1,3 +1,3 @@
-## $Id: Makefile.am 9 2004-06-19 19:53:47Z tilman $
+## $Id: Makefile.am 39 2004-07-25 13:13:57Z tilman $
 
-SUBDIRS = ecore ecore_job ecore_evas
+SUBDIRS = ecore ecore_evas ecore_job ecore_x
diff --git a/src/ecore_x/Makefile.am b/src/ecore_x/Makefile.am
new file mode 100644 (file)
index 0000000..0969ccc
--- /dev/null
@@ -0,0 +1,13 @@
+## $Id: Makefile.am 39 2004-07-25 13:13:57Z tilman $
+
+AM_CFLAGS = $(ECORE_CFLAGS)
+INCLUDES = -I$(RUBYDIR) -I$(RUBYSITEDIR)
+
+ext_LTLIBRARIES = ecore_x.la
+extdir = $(RUBYSITEDIR)
+
+ecore_x_la_SOURCES = rb_ecore_x.c rb_ecore_x.h \
+                     rb_window.c rb_window.h
+
+ecore_x_la_LIBADD = -lruby $(ECORE_LIBS)
+ecore_x_la_LDFLAGS = -module -avoid-version
diff --git a/src/ecore_x/rb_ecore_x.c b/src/ecore_x/rb_ecore_x.c
new file mode 100644 (file)
index 0000000..c23492c
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * $Id: rb_ecore_x.c 39 2004-07-25 13:13:57Z tilman $
+ *
+ * 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 <Ecore_X.h>
+
+#include "../ecore/rb_ecore.h"
+#include "rb_ecore_x.h"
+#include "rb_window.h"
+
+#ifdef DEBUG
+static VALUE m_init (VALUE self)
+{
+       return INT2FIX (ecore_x_init ());
+}
+
+static VALUE m_shutdown (VALUE self)
+{
+       return INT2FIX (ecore_x_shutdown ());
+}
+#endif
+
+void Init_ecore_x (void)
+{
+       rb_require ("ecore");
+
+       mX = rb_define_module_under (mEcore, "X");
+
+#ifdef DEBUG
+       rb_define_module_function (mx, "init", m_init, 0);
+       rb_define_module_function (mx, "shutdown", m_shutdown, 0);
+#endif
+
+       Init_Window ();
+}
+
diff --git a/src/ecore_x/rb_ecore_x.h b/src/ecore_x/rb_ecore_x.h
new file mode 100644 (file)
index 0000000..7c02194
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * $Id: rb_ecore_x.h 39 2004-07-25 13:13:57Z tilman $
+ *
+ * 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
+ */
+
+#ifndef __RB_ECORE_X_H
+#define __RB_ECORE_X_H
+
+VALUE mX;
+
+#endif
diff --git a/src/ecore_x/rb_window.c b/src/ecore_x/rb_window.c
new file mode 100644 (file)
index 0000000..2d7e3c0
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * $Id: rb_window.c 39 2004-07-25 13:13:57Z tilman $
+ *
+ * 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 <Ecore.h>
+#include <Ecore_X.h>
+
+#include "rb_ecore_x.h"
+
+static VALUE cWindow, parents;
+
+static void c_mark (Ecore_X_Window *w)
+{
+       VALUE parent;
+
+       parent = rb_hash_aref (parents, INT2NUM ((long) (w)));
+       if (parent != Qnil)
+               rb_gc_mark (parent);
+}
+
+static void c_free (Ecore_X_Window *w)
+{
+       rb_hash_aset (parents, INT2NUM ((long) w), Qnil);
+
+       free (w);
+}
+
+VALUE TO_ECORE_X_WINDOW (VALUE parent, Ecore_X_Window w)
+{
+       VALUE self;
+       Ecore_X_Window *my_w = NULL;
+
+       if (NIL_P (parent) || !w)
+               return Qnil;
+
+       self = Data_Make_Struct (cWindow, Ecore_X_Window,
+                                c_mark, c_free, my_w);
+       *my_w = w;
+
+       rb_hash_aset (parents, INT2NUM ((long) my_w), parent);
+
+       rb_obj_call_init (self, 0, NULL);
+
+       return self;
+}
+
+void Init_Window (void)
+{
+       cWindow = rb_define_class_under (mX, "Window", rb_cObject);
+
+       /* not publically instantiable yet */
+       rb_define_private_method (rb_singleton_class (cWindow),
+                                 "new", NULL, 0);
+
+       parents = rb_hash_new ();
+       rb_global_variable (&parents);
+}
diff --git a/src/ecore_x/rb_window.h b/src/ecore_x/rb_window.h
new file mode 100644 (file)
index 0000000..198244f
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * $Id: rb_window.h 39 2004-07-25 13:13:57Z tilman $
+ *
+ * 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
+ */
+
+#ifndef __RB_WINDOW_H
+#define __RB_WINDOW_H
+
+void Init_Window (void);
+VALUE TO_ECORE_X_WINDOW (VALUE parent, Ecore_X_Window w);
+
+#endif