2 * $Id: rb_ecore.c 77 2004-08-19 17:39:29Z 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
29 #include "rb_event_handler.h"
35 * Ecore.main_loop_begin
37 * Starts the Ecore main loop.
39 static VALUE m_main_loop_begin (VALUE self)
41 ecore_main_loop_begin ();
48 * Ecore.main_loop_iterate
50 * Run one iteration of the Ecore main loop.
52 static VALUE m_main_loop_iterate (VALUE self)
54 ecore_main_loop_iterate ();
61 * Ecore.main_loop_quit
63 * Stops the Ecore main loop.
65 static VALUE m_main_loop_quit (VALUE self)
67 ecore_main_loop_quit ();
72 static VALUE c_ev_exe_exit_init (VALUE self, VALUE event)
74 Ecore_Event_Exe_Exit *e = (void *) event;
76 rb_iv_set (self, "@pid", INT2FIX (e->pid));
77 rb_iv_set (self, "@exit_code", INT2FIX (e->exit_code));
78 rb_iv_set (self, "@exit_signal", INT2FIX (e->exit_signal));
79 rb_iv_set (self, "@exited", e->exited ? Qtrue : Qfalse);
80 rb_iv_set (self, "@signalled", e->signalled ? Qtrue : Qfalse);
85 static VALUE c_ev_sig_user_init (VALUE self, VALUE event)
87 Ecore_Event_Signal_User *e = (void *) event;
89 rb_iv_set (self, "@number", INT2FIX (e->number));
94 static VALUE c_ev_sig_exit_init (VALUE self, VALUE event)
96 Ecore_Event_Signal_Exit *e = (void *) event;
98 rb_iv_set (self, "@interrupt", e->interrupt ? Qtrue : Qfalse);
99 rb_iv_set (self, "@quit", e->quit ? Qtrue : Qfalse);
100 rb_iv_set (self, "@terminate", e->terminate ? Qtrue : Qfalse);
105 static VALUE c_ev_sig_rt_init (VALUE self, VALUE event)
107 Ecore_Event_Signal_Realtime *e = (void *) event;
109 rb_iv_set (self, "@number", INT2FIX (e->num));
114 void Init_ecore (void)
118 mEcore = rb_define_module ("Ecore");
120 rb_define_module_function (mEcore, "main_loop_begin",
121 m_main_loop_begin, 0);
122 rb_define_module_function (mEcore, "main_loop_iterate",
123 m_main_loop_iterate, 0);
124 rb_define_module_function (mEcore, "main_loop_quit",
125 m_main_loop_quit, 0);
129 Init_EventHandler ();
132 ADD_EVENT (mEcore, ECORE_EVENT_, SIGNAL_HUP,
134 rb_define_private_method (c, "initialize", c_ev_generic_init, 1);
137 ADD_EVENT (mEcore, ECORE_EVENT_, SIGNAL_POWER,
139 rb_define_private_method (c, "initialize", c_ev_generic_init, 1);
142 ADD_EVENT (mEcore, ECORE_EVENT_, EXE_EXIT, "ExeExit", c);
143 rb_define_private_method (c, "initialize", c_ev_exe_exit_init, 1);
145 rb_define_attr (c, "pid", 1, 0);
146 rb_define_attr (c, "exit_code", 1, 0);
147 rb_define_attr (c, "exit_signal", 1, 0);
148 rb_define_attr (c, "exited", 1, 0);
149 rb_define_attr (c, "signalled", 1, 0);
152 ADD_EVENT (mEcore, ECORE_EVENT_, SIGNAL_USER,
154 rb_define_private_method (c, "initialize", c_ev_sig_user_init, 1);
156 rb_define_attr (c, "number", 1, 0);
159 ADD_EVENT (mEcore, ECORE_EVENT_, SIGNAL_EXIT,
161 rb_define_private_method (c, "initialize", c_ev_sig_exit_init, 1);
163 rb_define_attr (c, "interrupt", 1, 0);
164 rb_define_attr (c, "quit", 1, 0);
165 rb_define_attr (c, "terminate", 1, 0);
167 /* SIGNAL_REALTIME */
168 ADD_EVENT (mEcore, ECORE_EVENT_, SIGNAL_REALTIME,
169 "SignalRealtime", c);
170 rb_define_private_method (c, "initialize", c_ev_sig_rt_init, 1);
172 rb_define_attr (c, "number", 1, 0);