We now use real structs to wrap objects.
[ruby-ecore.git] / src / ecore_x / rb_window.c
1 /*
2  * $Id: rb_window.c 50 2004-08-01 10:18:39Z tilman $
3  *
4  * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include <ruby.h>
22
23 #include <Ecore.h>
24 #include <Ecore_X.h>
25
26 #define __RB_WINDOW_C
27 #include "../ecore/rb_ecore.h"
28 #include "rb_ecore_x.h"
29 #include "rb_window.h"
30
31 VALUE cWindow;
32
33 static void c_mark (RbWindow *w)
34 {
35         if (!NIL_P (w->parent))
36                 rb_gc_mark (w->parent);
37 }
38
39 VALUE TO_ECORE_X_WINDOW (VALUE parent, Ecore_X_Window w)
40 {
41         VALUE self;
42         RbWindow *window = NULL;
43
44         if (!w)
45                 return Qnil;
46
47         self = Data_Make_Struct (cWindow, RbWindow, c_mark, free, window);
48
49         window->real = w;
50         window->parent = parent;
51
52         rb_obj_call_init (self, 0, NULL);
53
54         return self;
55 }
56
57 void Init_Window (void)
58 {
59         cWindow = rb_define_class_under (mX, "Window", rb_cObject);
60
61         /* not publically instantiable yet */
62         rb_define_private_method (rb_singleton_class (cWindow),
63                                   "new", NULL, 0);
64 }