From: Tilman Sauerbeck Date: Sat, 19 Jun 2004 19:48:46 +0000 (+0000) Subject: Initial commit. X-Git-Url: http://git.code-monkey.de/?p=ruby-ecore.git;a=commitdiff_plain;h=627a83d5b49b1abd92bd73a10a56042a6d202dfa Initial commit. --- 627a83d5b49b1abd92bd73a10a56042a6d202dfa diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e69de29 diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..e69de29 diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..42fa5f4 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,3 @@ +## $Id$ + +SUBDIRS = src diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..265eff7 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,62 @@ +#! /bin/sh +# Run this to generate all the initial makefiles, etc. + +# Stolen from the GNU Midnight Commander. Customized for giFTcurs. Stolen from +# giFTcurs. Customized for giFT. Stolen from giFT. +# Customized for $this_project. + +# Make it possible to specify path in the environment +: ${AUTOCONF=autoconf} +: ${AUTOHEADER=autoheader} +: ${AUTOMAKE=automake} +: ${ACLOCAL=aclocal} +: ${LIBTOOLIZE=libtoolize} + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +( +cd $srcdir + +# The autoconf cache (version after 2.52) is not reliable yet. +rm -rf autom4te.cache + +rm -f aclocal.m4 +ACLOCAL_INCLUDES="-I m4" + +# Some old version of GNU build tools fail to set error codes. +# Check that they generate some of the files they should. + +echo "Running $ACLOCAL..." +$ACLOCAL $ACLOCAL_INCLUDES $ACLOCAL_FLAGS || exit 1 +test -f aclocal.m4 || \ + { echo "aclocal failed to generate aclocal.m4" 2>&1; exit 1; } + +echo "Running $AUTOHEADER..." +$AUTOHEADER || exit 1 +test -f config.h.in || \ + { echo "autoheader failed to generate config.h.in" 2>&1; exit 1; } + +echo "Running $AUTOCONF..." +$AUTOCONF || exit 1 +test -f configure || \ + { echo "autoconf failed to generate configure" 2>&1; exit 1; } + +# hack hack hack...i hate autotools. +echo "Running $LIBTOOLIZE --automake..." +$LIBTOOLIZE --automake || exit 1 +test -f ltmain.sh || \ + { echo "libtoolize failed to generate ltmain.sh" 2>&1; exit 1; } + +# Workaround for Automake 1.5 to ensure that depcomp is distributed. +echo "Running $AUTOMAKE..." +$AUTOMAKE -c -a src/Makefile || exit 1 +$AUTOMAKE -c -a || exit 1 +test -f Makefile.in || \ + { echo "automake failed to generate Makefile.in" 2>&1; exit 1; } + +) || exit 1 + +echo +echo "Type './configure' to configure ruby-ecore." +echo diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..b50b72e --- /dev/null +++ b/configure.ac @@ -0,0 +1,37 @@ +dnl $Id$ + +AC_INIT(ruby-ecore, 0.0.1) +AC_CONFIG_SRCDIR([src/ecore/rb_ecore.c]) + +AM_INIT_AUTOMAKE([dist-bzip2]) +AM_CONFIG_HEADER(config.h) + +AC_PROG_CC +AC_PROG_CC_STDC +AC_PROG_INSTALL +AC_CHECK_PROG(RUBY, ruby) + +AM_DISABLE_STATIC +AC_PROG_LIBTOOL + +AC_HEADER_STDC +AC_HEADER_STDBOOL + +AC_RUBY_EXT + +AC_PATH_GENERIC(ecore, , , + AC_MSG_ERROR(Cannot find ecore: Is ecore-config in path?)) + +AC_PATH_GENERIC(evas, , , + AC_MSG_ERROR(Cannot find evas: Is evas-config in path?)) + +AC_CONFIG_FILES([ +Makefile +src/Makefile +src/ecore/Makefile +src/ecore_job/Makefile +src/ecore_evas/Makefile +]) + +AC_OUTPUT + diff --git a/m4/Makefile.am b/m4/Makefile.am new file mode 100644 index 0000000..47135b7 --- /dev/null +++ b/m4/Makefile.am @@ -0,0 +1,3 @@ +## $Id$ + +EXTRA_DIST = ac_path_generic.m4 ac_ruby.m4 diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..e18a6db --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,3 @@ +## $Id$ + +SUBDIRS = ecore ecore_job ecore_evas diff --git a/src/ecore/Makefile.am b/src/ecore/Makefile.am new file mode 100644 index 0000000..ef84b56 --- /dev/null +++ b/src/ecore/Makefile.am @@ -0,0 +1,14 @@ +## $Id$ + +AM_CFLAGS = $(ECORE_CFLAGS) +INCLUDES = -I$(RUBYDIR) + +ext_LTLIBRARIES = ecore.la +extdir = $(RUBYSITEDIR) + +ecore_la_SOURCES = rb_ecore.c rb_ecore.h \ + rb_idler.c rb_idler.h \ + rb_timer.c rb_timer.h + +ecore_la_LIBADD = -lruby $(ECORE_LIBS) +ecore_la_LDFLAGS = -module -avoid-version diff --git a/src/ecore/rb_ecore.c b/src/ecore/rb_ecore.c new file mode 100644 index 0000000..00a5d1e --- /dev/null +++ b/src/ecore/rb_ecore.c @@ -0,0 +1,80 @@ +/* + * $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 + +#include + +#include "rb_ecore.h" +#include "rb_timer.h" +#include "rb_idler.h" + +static VALUE m_init (VALUE self) +{ + return INT2FIX (ecore_init ()); +} + +static VALUE m_main_loop_begin (VALUE self) +{ + ecore_main_loop_begin (); + + return Qnil; +} + +static VALUE m_main_loop_iterate (VALUE self) +{ + ecore_main_loop_iterate (); + + return Qnil; +} + +static VALUE m_main_loop_quit (VALUE self) +{ + ecore_main_loop_quit (); + + return Qnil; +} + +static VALUE m_shutdown (VALUE self) +{ + rb_gc_start (); + + return INT2FIX (ecore_shutdown ()); +} + +void Init_ecore (void) +{ + mEcore = rb_define_module ("Ecore"); + + rb_define_module_function (mEcore, "init", + m_init, 0); + rb_define_module_function (mEcore, "main_loop_begin", + m_main_loop_begin, 0); + rb_define_module_function (mEcore, "main_loop_iterate", + m_main_loop_iterate, 0); + rb_define_module_function (mEcore, "main_loop_quit", + m_main_loop_quit, 0); + rb_define_module_function (mEcore, "shutdown", + m_shutdown, 0); + + Init_Timer (); + Init_Idler (); +} + diff --git a/src/ecore/rb_ecore.h b/src/ecore/rb_ecore.h new file mode 100644 index 0000000..899dea8 --- /dev/null +++ b/src/ecore/rb_ecore.h @@ -0,0 +1,26 @@ +/* + * $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 + */ + +#ifndef __RB_ECORE_H +#define __RB_ECORE_H + +VALUE mEcore; + +#endif diff --git a/src/ecore/rb_idler.c b/src/ecore/rb_idler.c new file mode 100644 index 0000000..5552fe2 --- /dev/null +++ b/src/ecore/rb_idler.c @@ -0,0 +1,108 @@ +/* + * $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 + +#include +#include + +#include "rb_ecore.h" + +typedef struct { + Ecore_Idler *idler; + void *cb; + bool deleted; +} RbEcoreIdler; + +VALUE cIdler; + +static int on_idler (void *data) +{ + VALUE r; + RbEcoreIdler *idler = data; + + r = rb_funcall ((VALUE) idler->cb, rb_intern ("call"), 0); + + /* if the callback returns false, we return 0 and Ecore + * will remove the idler + */ + if (r == Qfalse) + idler->deleted = true; + + return (r != Qfalse); +} + +static VALUE c_init (VALUE self) +{ + RbEcoreIdler *idler = NULL; + + Data_Get_Struct (self, RbEcoreIdler, idler); + + idler->cb = (void *) rb_block_proc (); + idler->idler = ecore_idler_add (on_idler, idler); + + return self; +} + +static void c_free (RbEcoreIdler *idler) +{ + if (idler->idler && !idler->deleted) + ecore_idler_del (idler->idler); + + free (idler); +} + +static VALUE c_new (VALUE klass) +{ + VALUE self; + RbEcoreIdler *idler; + + self = Data_Make_Struct (klass, RbEcoreIdler, NULL, c_free, idler); + + rb_obj_call_init (self, 0, NULL); + + return self; +} + +static VALUE c_delete (VALUE self) +{ + RbEcoreIdler *idler = NULL; + + Data_Get_Struct (self, RbEcoreIdler, idler); + + if (idler->idler && !idler->deleted) { + ecore_idler_del (idler->idler); + idler->idler = NULL; + idler->deleted = true; + } else + rb_raise (rb_eException, "Idler already deleted!"); + + return Qnil; +} + +void Init_Idler (void) +{ + cIdler = rb_define_class_under (mEcore, "Idler", rb_cObject); + + rb_define_singleton_method (cIdler, "new", c_new, 1); + rb_define_method (cIdler, "initialize", c_init, 1); + rb_define_method (cIdler, "delete", c_delete, 0); +} + diff --git a/src/ecore/rb_idler.h b/src/ecore/rb_idler.h new file mode 100644 index 0000000..9e4c023 --- /dev/null +++ b/src/ecore/rb_idler.h @@ -0,0 +1,26 @@ +/* + * $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 + */ + +#ifndef __RB_IDLER_H +#define __RB_IDLER_H + +void Init_Idler (void); + +#endif diff --git a/src/ecore/rb_timer.c b/src/ecore/rb_timer.c new file mode 100644 index 0000000..28bb405 --- /dev/null +++ b/src/ecore/rb_timer.c @@ -0,0 +1,110 @@ +/* + * $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 + +#include +#include + +#include "rb_ecore.h" + +typedef struct { + Ecore_Timer *timer; + void *cb; + bool deleted; +} RbEcoreTimer; + +VALUE cTimer; + +static int on_timer (void *data) +{ + VALUE r; + RbEcoreTimer *timer = data; + + r = rb_funcall ((VALUE) timer->cb, rb_intern ("call"), 0); + + /* if the callback returns false, we return 0 and Ecore + * will remove the timer + */ + if (r == Qfalse) + timer->deleted = true; + + return (r != Qfalse); +} + +static VALUE c_init (VALUE self, VALUE interval) +{ + RbEcoreTimer *timer = NULL; + + Data_Get_Struct (self, RbEcoreTimer, timer); + + timer->cb = (void *) rb_block_proc (); + timer->timer = ecore_timer_add (NUM2DBL (interval), + on_timer, timer); + + return self; +} + +static void c_free (RbEcoreTimer *timer) +{ + if (timer->timer && !timer->deleted) + ecore_timer_del (timer->timer); + + free (timer); +} + +static VALUE c_new (VALUE klass, VALUE interval) +{ + VALUE self, argv[1]; + RbEcoreTimer *timer; + + self = Data_Make_Struct (klass, RbEcoreTimer, NULL, c_free, timer); + + argv[0] = interval; + rb_obj_call_init (self, 1, argv); + + return self; +} + +static VALUE c_delete (VALUE self) +{ + RbEcoreTimer *timer = NULL; + + Data_Get_Struct (self, RbEcoreTimer, timer); + + if (timer->timer && !timer->deleted) { + ecore_timer_del (timer->timer); + timer->timer = NULL; + timer->deleted = true; + } else + rb_raise (rb_eException, "Timer already deleted!"); + + return Qnil; +} + +void Init_Timer (void) +{ + cTimer = rb_define_class_under (mEcore, "Timer", rb_cObject); + + rb_define_singleton_method (cTimer, "new", c_new, 1); + rb_define_method (cTimer, "initialize", c_init, 1); + rb_define_method (cTimer, "delete", c_delete, 0); +} + diff --git a/src/ecore/rb_timer.h b/src/ecore/rb_timer.h new file mode 100644 index 0000000..7c85b6b --- /dev/null +++ b/src/ecore/rb_timer.h @@ -0,0 +1,26 @@ +/* + * $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 + */ + +#ifndef __RB_TIMER_H +#define __RB_TIMER_H + +void Init_Timer (void); + +#endif diff --git a/src/ecore_evas/Makefile.am b/src/ecore_evas/Makefile.am new file mode 100644 index 0000000..2bdb32b --- /dev/null +++ b/src/ecore_evas/Makefile.am @@ -0,0 +1,15 @@ +## $Id$ + +AM_CFLAGS = $(ECORE_CFLAGS) +INCLUDES = -I$(RUBYDIR) -I$(RUBYSITEDIR) + +ext_LTLIBRARIES = ecore_evas.la +extdir = $(RUBYSITEDIR) + +ecore_evas_la_SOURCES = rb_ecore_evas_main.c rb_ecore_evas_main.h \ + rb_ecore_evas.c rb_ecore_evas.h \ + rb_software_x11.c rb_software_x11.h \ + rb_gl_x11.c rb_gl_x11.h + +ecore_evas_la_LIBADD = -lruby $(ECORE_LIBS) +ecore_evas_la_LDFLAGS = -module -avoid-version diff --git a/src/ecore_evas/rb_ecore_evas.c b/src/ecore_evas/rb_ecore_evas.c new file mode 100644 index 0000000..cf887c9 --- /dev/null +++ b/src/ecore_evas/rb_ecore_evas.c @@ -0,0 +1,182 @@ +/* + * $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 + +#include +#include + +#include "rb_ecore_evas_main.h" +#include "rb_ecore_evas.h" + +#define GET_OBJ(obj, ee) \ + Ecore_Evas **(ee) = NULL; \ +\ + Data_Get_Struct ((obj), Ecore_Evas *, (ee)); \ +\ + if (!*(ee)) { \ + rb_raise (rb_eException, "EcoreEvas destroyed already"); \ + return Qnil; \ + } + +/* called by the child classes */ +void c_ecore_evas_free (Ecore_Evas **ee) +{ + if (*ee) + ecore_evas_free (*ee); + + free (ee); +} + +#if 0 +static VALUE c_init (int argc, VALUE argv, VALUE self) +{ + rb_iv_set (self, "@title", rb_str_new2 ("")); + rb_iv_set (self, "@name", rb_str_new2 ("")); + rb_iv_set (self, "@class", rb_str_new2 ("")); + rb_iv_set (self, "@name", rb_str_new2 ("")); + + return self; +} +#endif + +static VALUE c_show (VALUE self) +{ + GET_OBJ (self, ee); + + ecore_evas_show (*ee); + + return Qnil; +} + +static VALUE c_hide (VALUE self) +{ + GET_OBJ (self, ee); + + ecore_evas_hide (*ee); + + return Qnil; +} + +static VALUE c_is_visible (VALUE self) +{ + GET_OBJ (self, ee); + + return ecore_evas_visibility_get (*ee) ? Qtrue : Qfalse; +} + +static VALUE c_evas (VALUE self) +{ + GET_OBJ (self, ee); + + return TO_EVAS (self, ecore_evas_get (*ee)); +} + +static VALUE c_resize (VALUE self, VALUE w, VALUE h) +{ + GET_OBJ (self, ee); + + Check_Type (w, T_FIXNUM); + Check_Type (h, T_FIXNUM); + + ecore_evas_resize (*ee, FIX2INT (w), FIX2INT (h)); + + return Qnil; +} + +static VALUE c_title_get (VALUE self) +{ + const char *tmp; + + GET_OBJ (self, ee); + + if (!(tmp = ecore_evas_title_get (*ee))) + return Qnil; + else + return rb_str_new2 (tmp); +} + +static VALUE c_title_set (VALUE self, VALUE val) +{ + GET_OBJ (self, ee); + + Check_Type (val, T_STRING); + + ecore_evas_title_set (*ee, STR2CSTR (val)); + + return Qnil; +} + +static VALUE c_borderless_get (VALUE self) +{ + GET_OBJ (self, ee); + + return ecore_evas_borderless_get (*ee) ? Qtrue : Qfalse; +} + +static VALUE c_borderless_set (VALUE self, VALUE val) +{ + GET_OBJ (self, ee); + + /* make sure we're passed a boolean */ + 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; + } + + ecore_evas_borderless_set (*ee, val == Qtrue ? 1 : 0); + + return Qnil; +} + +static VALUE c_delete (VALUE self) +{ + GET_OBJ (self, ee); + + /* reap our children */ + rb_gc_start (); + + ecore_evas_free (*ee); + *ee = NULL; + + return Qnil; +} + +void Init_EcoreEvas (void) +{ + cEcoreEvas = rb_define_class_under (mEvas, "EcoreEvas", rb_cObject); + + rb_define_private_method (rb_singleton_class (cEcoreEvas), + "new", NULL, 0); + /*rb_define_method (cEcoreEvas, "initialize", c_init, -1);*/ + rb_define_method (cEcoreEvas, "delete", c_delete, 0); + rb_define_method (cEcoreEvas, "show", c_show, 0); + rb_define_method (cEcoreEvas, "hide", c_hide, 0); + rb_define_method (cEcoreEvas, "visible?", c_is_visible, 0); + rb_define_method (cEcoreEvas, "evas", c_evas, 0); + rb_define_method (cEcoreEvas, "resize", c_resize, 2); + rb_define_method (cEcoreEvas, "title", c_title_get, 0); + rb_define_method (cEcoreEvas, "title=", c_title_set, 1); + rb_define_method (cEcoreEvas, "borderless", c_borderless_get, 0); + rb_define_method (cEcoreEvas, "borderless=", c_borderless_set, 1); +} + diff --git a/src/ecore_evas/rb_ecore_evas.h b/src/ecore_evas/rb_ecore_evas.h new file mode 100644 index 0000000..88c788f --- /dev/null +++ b/src/ecore_evas/rb_ecore_evas.h @@ -0,0 +1,30 @@ +/* + * $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 + */ + +#ifndef __RB_ECORE_EVAS_H +#define __RB_ECORE_EVAS_H + +VALUE cEcoreEvas; + +void Init_EcoreEvas (void); + +void c_ecore_evas_free (Ecore_Evas **ee); + +#endif diff --git a/src/ecore_evas/rb_ecore_evas_main.c b/src/ecore_evas/rb_ecore_evas_main.c new file mode 100644 index 0000000..ccd40bc --- /dev/null +++ b/src/ecore_evas/rb_ecore_evas_main.c @@ -0,0 +1,55 @@ +/* + * $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 + +#include + +#include "../ecore/rb_ecore.h" +#include "rb_ecore_evas_main.h" +#include "rb_ecore_evas.h" +#include "rb_software_x11.h" + +static VALUE m_init (VALUE self) +{ + return INT2FIX (ecore_evas_init ()); +} + +static VALUE m_shutdown (VALUE self) +{ + return INT2FIX (ecore_evas_shutdown ()); +} + +void Init_ecore_evas (void) +{ + rb_require ("ecore"); + rb_require ("evas"); + + mEvas = rb_define_module_under (mEcore, "Evas"); + + rb_define_module_function (mEvas, "init", m_init, 0); + rb_define_module_function (mEvas, "shutdown", m_shutdown, 0); + + Init_EcoreEvas (); + Init_SoftwareX11 (); + Init_GlX11 (); + /*Init_FrameBuffer ();*/ +} + diff --git a/src/ecore_evas/rb_ecore_evas_main.h b/src/ecore_evas/rb_ecore_evas_main.h new file mode 100644 index 0000000..4c9a994 --- /dev/null +++ b/src/ecore_evas/rb_ecore_evas_main.h @@ -0,0 +1,27 @@ +/* + * $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 + */ + +#ifndef __RB_ECORE_EVAS_MAIN_H +#define __RB_ECORE_EVAS_MAIN_H + +VALUE mEvas; + +#endif + diff --git a/src/ecore_evas/rb_gl_x11.c b/src/ecore_evas/rb_gl_x11.c new file mode 100644 index 0000000..523f1af --- /dev/null +++ b/src/ecore_evas/rb_gl_x11.c @@ -0,0 +1,82 @@ +/* + * $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 + +#include + +#include "rb_ecore_evas_main.h" +#include "rb_ecore_evas.h" + +VALUE cSoftwareX11; + +static VALUE c_init (int argc, VALUE *argv, VALUE self) +{ + VALUE disp, parent, geom[4]; + Ecore_Evas **ee = NULL; + char *cdisp = NULL; + int i, igeom[4] = {0}; + + Data_Get_Struct (self, Ecore_Evas *, ee); + + rb_scan_args (argc, argv, "06", &disp, &parent, + &geom[0], &geom[1], &geom[2], &geom[3]); + + if (!NIL_P (disp)) { + Check_Type (disp, T_STRING); + cdisp = STR2CSTR (disp); + } + + for (i = 0; i < 4; i++) + if (!NIL_P (geom[i])) { + Check_Type (geom[i], T_FIXNUM); + igeom[i] = NUM2INT (geom[i]); + } + + *ee = ecore_evas_software_x11_new (cdisp, 0, + igeom[0], igeom[1], + igeom[2], igeom[3]); + + return self; +} + +static VALUE c_new (int argc, VALUE *argv, VALUE klass) +{ + VALUE self; + Ecore_Evas **ee; + + self = Data_Make_Struct (klass, Ecore_Evas *, + NULL, c_ecore_evas_free, ee); + + rb_obj_call_init (self, argc, argv); + + return self; +} + +void Init_SoftwareX11 (void) +{ + cSoftwareX11 = rb_define_class_under (mEvas, + "SoftwareX11", + cEcoreEvas); + + rb_define_singleton_method (cSoftwareX11, "new", c_new, -1); + rb_define_method (cSoftwareX11, "initialize", c_init, -1); +} + diff --git a/src/ecore_evas/rb_gl_x11.h b/src/ecore_evas/rb_gl_x11.h new file mode 100644 index 0000000..a9785ee --- /dev/null +++ b/src/ecore_evas/rb_gl_x11.h @@ -0,0 +1,26 @@ +/* + * $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 + */ + +#ifndef __RB_SOFTWARE_X11_H +#define __RB_SOFTWARE_X11_H + +void Init_SoftwareX11 (void); + +#endif diff --git a/src/ecore_evas/rb_software_x11.c b/src/ecore_evas/rb_software_x11.c new file mode 100644 index 0000000..817c287 --- /dev/null +++ b/src/ecore_evas/rb_software_x11.c @@ -0,0 +1,80 @@ +/* + * $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 + +#include + +#include "rb_ecore_evas_main.h" +#include "rb_ecore_evas.h" + +VALUE cGlX11; + +static VALUE c_init (int argc, VALUE *argv, VALUE self) +{ + VALUE disp, parent, geom[4]; + Ecore_Evas **ee = NULL; + char *cdisp = NULL; + int i, igeom[4] = {0}; + + Data_Get_Struct (self, Ecore_Evas *, ee); + + rb_scan_args (argc, argv, "06", &disp, &parent, + &geom[0], &geom[1], &geom[2], &geom[3]); + + if (!NIL_P (disp)) { + Check_Type (disp, T_STRING); + cdisp = STR2CSTR (disp); + } + + for (i = 0; i < 4; i++) + if (!NIL_P (geom[i])) { + Check_Type (geom[i], T_FIXNUM); + igeom[i] = NUM2INT (geom[i]); + } + + *ee = ecore_evas_gl_x11_new (cdisp, 0, + igeom[0], igeom[1], + igeom[2], igeom[3]); + + return self; +} + +static VALUE c_new (int argc, VALUE *argv, VALUE klass) +{ + VALUE self; + Ecore_Evas **ee; + + self = Data_Make_Struct (klass, Ecore_Evas *, + NULL, c_ecore_evas_free, ee); + + rb_obj_call_init (self, argc, argv); + + return self; +} + +void Init_GlX11 (void) +{ + cGlX11 = rb_define_class_under (mEvas, "GlX11", cEcoreEvas); + + rb_define_singleton_method (cGlX11, "new", c_new, -1); + rb_define_method (cGlX11, "initialize", c_init, -1); +} + diff --git a/src/ecore_evas/rb_software_x11.h b/src/ecore_evas/rb_software_x11.h new file mode 100644 index 0000000..6d2f42b --- /dev/null +++ b/src/ecore_evas/rb_software_x11.h @@ -0,0 +1,26 @@ +/* + * $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 + */ + +#ifndef __RB_GL_X11_H +#define __RB_GL_X11_H + +void Init_GlX11 (void); + +#endif diff --git a/src/ecore_job/Makefile.am b/src/ecore_job/Makefile.am new file mode 100644 index 0000000..092ebd6 --- /dev/null +++ b/src/ecore_job/Makefile.am @@ -0,0 +1,13 @@ +## $Id$ + +AM_CFLAGS = $(ECORE_CFLAGS) +INCLUDES = -I$(RUBYDIR) + +ext_LTLIBRARIES = ecore_job.la +extdir = $(RUBYSITEDIR) + +ecore_job_la_SOURCES = rb_ecore_job.c rb_ecore_job.h \ + rb_job.c rb_job.h + +ecore_job_la_LIBADD = -lruby $(ECORE_LIBS) +ecore_job_la_LDFLAGS = -module -avoid-version diff --git a/src/ecore_job/rb_ecore_job.c b/src/ecore_job/rb_ecore_job.c new file mode 100644 index 0000000..edaf670 --- /dev/null +++ b/src/ecore_job/rb_ecore_job.c @@ -0,0 +1,35 @@ +/* + * $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 + +#include "../ecore/rb_ecore.h" +#include "rb_ecore_job.h" +#include "rb_job.h" + +void Init_ecore_job (void) +{ + rb_require ("ecore"); + + mJob = rb_define_module_under (mEcore, "Job"); + + Init_Job (); +} + diff --git a/src/ecore_job/rb_ecore_job.h b/src/ecore_job/rb_ecore_job.h new file mode 100644 index 0000000..1dc3082 --- /dev/null +++ b/src/ecore_job/rb_ecore_job.h @@ -0,0 +1,27 @@ +/* + * $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 + */ + +#ifndef __RB_ECORE_JOB_H +#define __RB_ECORE_JOB_H + +VALUE mJob; + +#endif + diff --git a/src/ecore_job/rb_job.c b/src/ecore_job/rb_job.c new file mode 100644 index 0000000..7db2f68 --- /dev/null +++ b/src/ecore_job/rb_job.c @@ -0,0 +1,101 @@ +/* + * $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 + +#include +#include + +#include "rb_ecore_job.h" + +typedef struct { + Ecore_Job *job; + void *cb; + bool deleted; +} RbEcoreJob; + +VALUE cEcoreJob; + +static void on_job (void *data) +{ + RbEcoreJob *job = data; + + rb_funcall ((VALUE) job->cb, rb_intern ("call"), 0); + job->deleted = true; +} + +static VALUE c_init (VALUE self) +{ + RbEcoreJob *job = NULL; + + Data_Get_Struct (self, RbEcoreJob, job); + + job->cb = (void *) rb_block_proc (); + job->job = ecore_job_add (on_job, job); + + return self; +} + +static void c_free (RbEcoreJob *job) +{ + if (job->job && !job->deleted) + ecore_job_del (job->job); + + free (job); +} + +static VALUE c_new (VALUE klass) +{ + VALUE self; + RbEcoreJob *job; + + self = Data_Make_Struct (klass, RbEcoreJob, NULL, c_free, job); + + rb_obj_call_init (self, 0, NULL); + + return self; +} + +static VALUE c_delete (VALUE self) +{ + VALUE ret = Qfalse; + RbEcoreJob *job = NULL; + + Data_Get_Struct (self, RbEcoreJob, job); + + if (job->job && !job->deleted) { + ecore_job_del (job->job); + job->deleted = true; + job->job = NULL; + ret = Qtrue; + } + + return ret; +} + +void Init_Job (void) +{ + cEcoreJob = rb_define_class_under (mJob, "Job", rb_cObject); + + rb_define_singleton_method (cEcoreJob, "new", c_new, 0); + rb_define_method (cEcoreJob, "initialize", c_init, 0); + rb_define_method (cEcoreJob, "delete", c_delete, 0); +} + diff --git a/src/ecore_job/rb_job.h b/src/ecore_job/rb_job.h new file mode 100644 index 0000000..60797fa --- /dev/null +++ b/src/ecore_job/rb_job.h @@ -0,0 +1,26 @@ +/* + * $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 + */ + +#ifndef __RB_JOB_H +#define __RB_JOB_H + +void Init_Job (void); + +#endif