X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fecore%2Frb_ecore.c;h=239da0f89518826932c508c86cec865585c47143;hb=b19653233d0564dde78f97ef518d4d11f3eb11c4;hp=52b7e7a4915156673fe7da6d6e00ae7ef2392088;hpb=6aefc9e933176f5287f7cedf3b44224dc629e5d0;p=ruby-ecore.git diff --git a/src/ecore/rb_ecore.c b/src/ecore/rb_ecore.c index 52b7e7a..239da0f 100644 --- a/src/ecore/rb_ecore.c +++ b/src/ecore/rb_ecore.c @@ -1,5 +1,5 @@ /* - * $Id: rb_ecore.c 83 2004-08-21 19:55:35Z tilman $ + * $Id: rb_ecore.c 360 2006-02-12 15:53:44Z tilman $ * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * @@ -25,8 +25,11 @@ #define __RB_ECORE_C #include "rb_ecore.h" #include "rb_timer.h" +#include "rb_animator.h" #include "rb_idler.h" +#include "rb_idle_enterer.h" #include "rb_event_handler.h" +#include "rb_fd_handler.h" VALUE mEcore; @@ -69,6 +72,36 @@ static VALUE m_main_loop_quit (VALUE self) return Qnil; } +static VALUE m_time_get (VALUE self) +{ + return rb_float_new (ecore_time_get ()); +} + +static VALUE m_new_event_type (VALUE self, VALUE klass) +{ + VALUE num; + + num = INT2FIX (ecore_event_type_new()); + rb_hash_aset (event_classes, num, klass); + + return num; +} + +static void free_ruby_event (void *data, void *event) +{ + /* do nothing */ +} + +static VALUE m_add_event (VALUE self, VALUE type, VALUE event) +{ + Check_Type (type, T_FIXNUM); + + ecore_event_add (FIX2INT (type), (void *) event, free_ruby_event, NULL); + + return Qnil; +} + +#if 0 static VALUE c_ev_exe_exit_init (VALUE self, VALUE event) { VALUE c = CLASS_OF (self); @@ -88,6 +121,7 @@ static VALUE c_ev_exe_exit_init (VALUE self, VALUE event) return self; } +#endif static VALUE c_ev_sig_user_init (VALUE self, VALUE event) { @@ -127,10 +161,19 @@ static VALUE c_ev_sig_rt_init (VALUE self, VALUE event) return self; } +static void at_exit () +{ + ecore_shutdown (); +} + void Init_ecore (void) { VALUE c; + ecore_init (); + + atexit (at_exit); + mEcore = rb_define_module ("Ecore"); rb_define_module_function (mEcore, "main_loop_begin", @@ -139,10 +182,17 @@ void Init_ecore (void) m_main_loop_iterate, 0); rb_define_module_function (mEcore, "main_loop_quit", m_main_loop_quit, 0); + rb_define_module_function (mEcore, "time", m_time_get, 0); + rb_define_module_function (mEcore, "new_event_type", + m_new_event_type, 1); + rb_define_module_function (mEcore, "add_event", m_add_event, 2); Init_Timer (); + Init_Animator (); Init_Idler (); + Init_IdleEnterer (); Init_EventHandler (); + Init_FdHandler (); /* SIGNAL_HUP */ ADD_EVENT (mEcore, ECORE_EVENT_, SIGNAL_HUP, @@ -154,9 +204,11 @@ void Init_ecore (void) "SignalPower", c); rb_define_private_method (c, "initialize", c_ev_generic_init, 1); +#if 0 /* EXE_EXIT */ ADD_EVENT (mEcore, ECORE_EVENT_, EXE_EXIT, "ExeExit", c); rb_define_private_method (c, "initialize", c_ev_exe_exit_init, 1); +#endif /* SIGNAL_USER */ ADD_EVENT (mEcore, ECORE_EVENT_, SIGNAL_USER,