2 * $Id: rb_ecore.c 366 2006-02-14 21:53:15Z tilman $
4 * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "rb_animator.h"
30 #include "rb_idle_enterer.h"
31 #include "rb_event_handler.h"
32 #include "rb_fd_handler.h"
38 * Ecore.main_loop_begin
40 * Starts the Ecore main loop.
42 static VALUE m_main_loop_begin (VALUE self)
44 ecore_main_loop_begin ();
51 * Ecore.main_loop_iterate
53 * Run one iteration of the Ecore main loop.
55 static VALUE m_main_loop_iterate (VALUE self)
57 ecore_main_loop_iterate ();
64 * Ecore.main_loop_quit
66 * Stops the Ecore main loop.
68 static VALUE m_main_loop_quit (VALUE self)
70 ecore_main_loop_quit ();
75 static VALUE m_time_get (VALUE self)
77 return rb_float_new (ecore_time_get ());
81 static VALUE c_ev_exe_exit_init (VALUE self, VALUE event)
83 VALUE c = CLASS_OF (self);
84 Ecore_Event_Exe_Exit *e = (void *) event;
86 rb_define_attr (c, "pid", 1, 0);
87 rb_define_attr (c, "exit_code", 1, 0);
88 rb_define_attr (c, "exit_signal", 1, 0);
89 rb_define_attr (c, "exited", 1, 0);
90 rb_define_attr (c, "signalled", 1, 0);
92 rb_iv_set (self, "@pid", INT2FIX (e->pid));
93 rb_iv_set (self, "@exit_code", INT2FIX (e->exit_code));
94 rb_iv_set (self, "@exit_signal", INT2FIX (e->exit_signal));
95 rb_iv_set (self, "@exited", e->exited ? Qtrue : Qfalse);
96 rb_iv_set (self, "@signalled", e->signalled ? Qtrue : Qfalse);
102 static VALUE c_ev_sig_user_init (VALUE self, VALUE event)
104 Ecore_Event_Signal_User *e = (void *) event;
106 rb_define_attr (CLASS_OF (self), "number", 1, 0);
108 rb_iv_set (self, "@number", INT2FIX (e->number));
113 static VALUE c_ev_sig_exit_init (VALUE self, VALUE event)
115 VALUE c = CLASS_OF (self);
116 Ecore_Event_Signal_Exit *e = (void *) event;
118 rb_define_attr (c, "interrupt", 1, 0);
119 rb_define_attr (c, "quit", 1, 0);
120 rb_define_attr (c, "terminate", 1, 0);
122 rb_iv_set (self, "@interrupt", e->interrupt ? Qtrue : Qfalse);
123 rb_iv_set (self, "@quit", e->quit ? Qtrue : Qfalse);
124 rb_iv_set (self, "@terminate", e->terminate ? Qtrue : Qfalse);
129 static VALUE c_ev_sig_rt_init (VALUE self, VALUE event)
131 Ecore_Event_Signal_Realtime *e = (void *) event;
133 rb_define_attr (CLASS_OF (self), "number", 1, 0);
135 rb_iv_set (self, "@number", INT2FIX (e->num));
140 static void at_exit ()
145 void Init_ecore (void)
153 mEcore = rb_define_module ("Ecore");
155 rb_define_module_function (mEcore, "main_loop_begin",
156 m_main_loop_begin, 0);
157 rb_define_module_function (mEcore, "main_loop_iterate",
158 m_main_loop_iterate, 0);
159 rb_define_module_function (mEcore, "main_loop_quit",
160 m_main_loop_quit, 0);
161 rb_define_module_function (mEcore, "time", m_time_get, 0);
167 Init_EventHandler ();
171 ADD_EVENT (mEcore, ECORE_EVENT_SIGNAL_HUP,
172 "SignalHupEvent", c);
175 ADD_EVENT (mEcore, ECORE_EVENT_SIGNAL_POWER,
176 "SignalPowerEvent", c);
180 ADD_EVENT (mEcore, ECORE_EVENT_EXE_EXIT, "ExeExitEvent", c);
181 rb_define_private_method (c, "initialize", c_ev_exe_exit_init, 1);
185 ADD_EVENT (mEcore, ECORE_EVENT_SIGNAL_USER,
186 "SignalUserEvent", c);
187 rb_define_private_method (c, "initialize", c_ev_sig_user_init, 1);
190 ADD_EVENT (mEcore, ECORE_EVENT_SIGNAL_EXIT,
191 "SignalExitEvent", c);
192 rb_define_private_method (c, "initialize", c_ev_sig_exit_init, 1);
194 /* SIGNAL_REALTIME */
195 ADD_EVENT (mEcore, ECORE_EVENT_SIGNAL_REALTIME,
196 "SignalRealtimeEvent", c);
197 rb_define_private_method (c, "initialize", c_ev_sig_rt_init, 1);