gdk3 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/Rakefile +53 -0
  2. data/ext/gdk3/depend +11 -0
  3. data/ext/gdk3/extconf.rb +127 -0
  4. data/ext/gdk3/gdk3.def +12 -0
  5. data/ext/gdk3/init.c +35 -0
  6. data/ext/gdk3/rbgdk.c +540 -0
  7. data/ext/gdk3/rbgdk3.h +71 -0
  8. data/ext/gdk3/rbgdk3conversions.h +118 -0
  9. data/ext/gdk3/rbgdk3private.h +93 -0
  10. data/ext/gdk3/rbgdkatom.c +122 -0
  11. data/ext/gdk3/rbgdkcairo.c +95 -0
  12. data/ext/gdk3/rbgdkcolor.c +137 -0
  13. data/ext/gdk3/rbgdkconst.c +33 -0
  14. data/ext/gdk3/rbgdkcursor.c +99 -0
  15. data/ext/gdk3/rbgdkdevice.c +197 -0
  16. data/ext/gdk3/rbgdkdisplay.c +482 -0
  17. data/ext/gdk3/rbgdkdisplaymanager.c +55 -0
  18. data/ext/gdk3/rbgdkdragcontext.c +191 -0
  19. data/ext/gdk3/rbgdkdraw.c +520 -0
  20. data/ext/gdk3/rbgdkevent.c +926 -0
  21. data/ext/gdk3/rbgdkgeometry.c +252 -0
  22. data/ext/gdk3/rbgdkkeymap.c +151 -0
  23. data/ext/gdk3/rbgdkkeyval.c +108 -0
  24. data/ext/gdk3/rbgdkpango.c +197 -0
  25. data/ext/gdk3/rbgdkpangorenderer.c +144 -0
  26. data/ext/gdk3/rbgdkpixbuf.c +176 -0
  27. data/ext/gdk3/rbgdkproperty.c +305 -0
  28. data/ext/gdk3/rbgdkrectangle.c +140 -0
  29. data/ext/gdk3/rbgdkrgb.c +199 -0
  30. data/ext/gdk3/rbgdkrgba.c +142 -0
  31. data/ext/gdk3/rbgdkscreen.c +443 -0
  32. data/ext/gdk3/rbgdkselection.c +146 -0
  33. data/ext/gdk3/rbgdkthreads.c +77 -0
  34. data/ext/gdk3/rbgdktimecoord.c +133 -0
  35. data/ext/gdk3/rbgdkvisual.c +251 -0
  36. data/ext/gdk3/rbgdkwindow.c +1044 -0
  37. data/ext/gdk3/rbgdkwindowattr.c +191 -0
  38. data/ext/gdk3/rbgdkx11.c +102 -0
  39. data/ext/gdk3/rbgdkx11x11window.c +66 -0
  40. data/extconf.rb +49 -0
  41. data/lib/gdk3.rb +3 -0
  42. data/lib/gdk3/base.rb +50 -0
  43. data/lib/gdk3/deprecated.rb +152 -0
  44. metadata +156 -0
@@ -0,0 +1,137 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team
5
+ * Copyright (C) 1998-2000 Yukihiro Matsumoto,
6
+ * Daisuke Kanda,
7
+ * Hiroshi Igarashi
8
+ *
9
+ * This library is free software; you can redistribute it and/or
10
+ * modify it under the terms of the GNU Lesser General Public
11
+ * License as published by the Free Software Foundation; either
12
+ * version 2.1 of the License, or (at your option) any later version.
13
+ *
14
+ * This library is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ * Lesser General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU Lesser General Public
20
+ * License along with this library; if not, write to the Free Software
21
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22
+ * MA 02110-1301 USA
23
+ */
24
+
25
+ #include "rbgdk3private.h"
26
+
27
+ #define RG_TARGET_NAMESPACE cColor
28
+ #define _SELF(c) (RVAL2GDKCOLOR(c))
29
+
30
+ static VALUE
31
+ rg_initialize(VALUE self, VALUE red, VALUE green, VALUE blue)
32
+ {
33
+ GdkColor c;
34
+ c.pixel = 0;
35
+ c.red = NUM2INT(red);
36
+ c.green = NUM2INT(green);
37
+ c.blue = NUM2INT(blue);
38
+
39
+ G_INITIALIZE(self, &c);
40
+
41
+ return Qnil;
42
+ }
43
+
44
+ static VALUE
45
+ rg_s_parse(G_GNUC_UNUSED VALUE self, VALUE name)
46
+ {
47
+ GdkColor c;
48
+ if (! gdk_color_parse(RVAL2CSTR(name), &c)) {
49
+ rb_raise(rb_eArgError, "can't parse color name `%s'", RVAL2CSTR(name));
50
+ }
51
+ return GDKCOLOR2RVAL(&c);
52
+ }
53
+
54
+ static VALUE
55
+ rg_pixel(VALUE self)
56
+ {
57
+ return INT2NUM(_SELF(self)->pixel);
58
+ }
59
+
60
+ static VALUE
61
+ rg_red(VALUE self)
62
+ {
63
+
64
+ return INT2FIX(_SELF(self)->red);
65
+ }
66
+
67
+ static VALUE
68
+ rg_set_red(VALUE self, VALUE red)
69
+ {
70
+ _SELF(self)->red = NUM2INT(red);
71
+ return self;
72
+ }
73
+
74
+ static VALUE
75
+ rg_green(VALUE self)
76
+ {
77
+ return INT2FIX(_SELF(self)->green);
78
+ }
79
+
80
+ static VALUE
81
+ rg_set_green(VALUE self, VALUE green)
82
+ {
83
+ _SELF(self)->green = NUM2INT(green);
84
+ return self;
85
+ }
86
+
87
+ static VALUE
88
+ rg_blue(VALUE self)
89
+ {
90
+ return INT2FIX(_SELF(self)->blue);
91
+ }
92
+
93
+ static VALUE
94
+ rg_set_blue(VALUE self, VALUE blue)
95
+ {
96
+ _SELF(self)->blue = NUM2INT(blue);
97
+ return self;
98
+ }
99
+
100
+ static VALUE
101
+ rg_to_a(VALUE self)
102
+ {
103
+ GdkColor *c = _SELF(self);
104
+ return rb_ary_new3(3, INT2FIX(c->red),
105
+ INT2FIX(c->green), INT2FIX(c->blue));
106
+ }
107
+
108
+ static VALUE
109
+ rg_operator_gdkcolor_equal(VALUE self, VALUE other)
110
+ {
111
+ return CBOOL2RVAL(gdk_color_equal(_SELF(self), _SELF(other)));
112
+ }
113
+
114
+ static VALUE
115
+ rg_to_s(VALUE self)
116
+ {
117
+ return CSTR2RVAL_FREE(gdk_color_to_string(_SELF(self)));
118
+ }
119
+
120
+ void
121
+ Init_gdk_color(VALUE mGdk)
122
+ {
123
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_COLOR, "Color", mGdk);
124
+
125
+ RG_DEF_SMETHOD(parse, 1);
126
+ RG_DEF_METHOD(initialize, 3);
127
+ RG_DEF_METHOD(pixel, 0);
128
+ RG_DEF_METHOD(red, 0);
129
+ RG_DEF_METHOD(set_red, 1);
130
+ RG_DEF_METHOD(green, 0);
131
+ RG_DEF_METHOD(set_green, 1);
132
+ RG_DEF_METHOD(blue, 0);
133
+ RG_DEF_METHOD(set_blue, 1);
134
+ RG_DEF_METHOD(to_a, 0);
135
+ RG_DEF_METHOD_OPERATOR("==", gdkcolor_equal, 1);
136
+ RG_DEF_METHOD(to_s, 0);
137
+ }
@@ -0,0 +1,33 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team
5
+ * Copyright (C) 1998-2000 Yukihiro Matsumoto,
6
+ * Daisuke Kanda,
7
+ * Hiroshi Igarashi
8
+ *
9
+ * This library is free software; you can redistribute it and/or
10
+ * modify it under the terms of the GNU Lesser General Public
11
+ * License as published by the Free Software Foundation; either
12
+ * version 2.1 of the License, or (at your option) any later version.
13
+ *
14
+ * This library is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ * Lesser General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU Lesser General Public
20
+ * License along with this library; if not, write to the Free Software
21
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22
+ * MA 02110-1301 USA
23
+ */
24
+
25
+ #include "rbgdk3private.h"
26
+
27
+ void
28
+ Init_gdk_const(VALUE mGdk)
29
+ {
30
+ G_DEF_CLASS(GDK_TYPE_STATUS, "Status", mGdk);
31
+ }
32
+
33
+
@@ -0,0 +1,99 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2001-2004 Masao Mutoh
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., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
21
+
22
+ #include "rbgdk3private.h"
23
+
24
+ #define RG_TARGET_NAMESPACE cCursor
25
+
26
+ static VALUE
27
+ rg_initialize(int argc, VALUE *argv, VALUE self)
28
+ {
29
+ GdkCursor* cursor = NULL;
30
+
31
+ if (argc == 1){
32
+ VALUE type;
33
+ rb_scan_args(argc, argv, "10", &type);
34
+ cursor = gdk_cursor_new(RVAL2GDKCURSORTYPE(type));
35
+ } else if (argc == 2) {
36
+ VALUE display, type_or_name;
37
+ rb_scan_args(argc, argv, "20", &display, &type_or_name);
38
+ if (TYPE(type_or_name) == T_STRING)
39
+ cursor = gdk_cursor_new_from_name(RVAL2GDKDISPLAYOBJECT(display),
40
+ RVAL2CSTR(type_or_name));
41
+ else
42
+ cursor = gdk_cursor_new_for_display(RVAL2GDKDISPLAYOBJECT(display),
43
+ RVAL2GDKCURSORTYPE(type_or_name));
44
+ } else if (argc == 4) {
45
+ VALUE display, pixbuf, x, y;
46
+ rb_scan_args(argc, argv, "40", &display, &pixbuf, &x, &y);
47
+ cursor = gdk_cursor_new_from_pixbuf(RVAL2GDKDISPLAYOBJECT(display),
48
+ RVAL2GDKPIXBUF(pixbuf),
49
+ NUM2INT(x), NUM2INT(y));
50
+ /* deprecated
51
+ } else if (argc == 6) {
52
+ VALUE pixmap, mask, fg, bg, x, y;
53
+ rb_scan_args(argc, argv, "60", &pixmap, &mask, &fg, &bg, &x, &y);
54
+ cursor = gdk_cursor_new_from_pixmap(RVAL2GDKPIXMAP(pixmap),
55
+ NIL_P(mask)?NULL:RVAL2GDKPIXMAP(mask),
56
+ RVAL2GDKCOLOR(fg),
57
+ RVAL2GDKCOLOR(bg),
58
+ NUM2INT(x), NUM2INT(y));
59
+ */
60
+ }
61
+ G_INITIALIZE(self, cursor);
62
+
63
+ return Qnil;
64
+ }
65
+
66
+ static VALUE
67
+ rg_display(VALUE self)
68
+ {
69
+ return GOBJ2RVAL(gdk_cursor_get_display(RVAL2GDKCURSOR(self)));
70
+ }
71
+
72
+ /* TODO
73
+ static VALUE
74
+ rg_cursor_type(VALUE self)
75
+ {
76
+ return GDKCURSORTYPE2RVAL((RVAL2GDKCURSOR(self))->type);
77
+ }
78
+ */
79
+
80
+ static VALUE
81
+ rg_image(VALUE self)
82
+ {
83
+ return GOBJ2RVAL(gdk_cursor_get_image(RVAL2GDKCURSOR(self)));
84
+ }
85
+
86
+ void
87
+ Init_gdk_cursor(VALUE mGdk)
88
+ {
89
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_CURSOR, "Cursor", mGdk);
90
+
91
+ RG_DEF_METHOD(initialize, -1);
92
+ RG_DEF_METHOD(display, 0);
93
+ /* TODO
94
+ RG_DEF_METHOD(cursor_type, 0);
95
+ */
96
+ RG_DEF_METHOD(image, 0);
97
+
98
+ G_DEF_CLASS(GDK_TYPE_CURSOR_TYPE, "Type", RG_TARGET_NAMESPACE);
99
+ }
@@ -0,0 +1,197 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2003-2006 Masao Mutoh
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., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
21
+
22
+ #include "rbgdk3private.h"
23
+
24
+ #define RG_TARGET_NAMESPACE cDevice
25
+ #define _SELF(self) (RVAL2GDKDEVICE(self))
26
+
27
+ /* deprecated
28
+ static VALUE
29
+ rg_s_list(G_GNUC_UNUSED VALUE self)
30
+ {
31
+ return GOBJGLIST2RVAL(gdk_devices_list());
32
+ }
33
+
34
+ static VALUE
35
+ rg_s_set_extension_events(G_GNUC_UNUSED VALUE self, VALUE window, VALUE mask, VALUE mode)
36
+ {
37
+ gdk_input_set_extension_events(RVAL2GDKWINDOW(window),
38
+ NUM2INT(mask), FIX2INT(mode));
39
+ return Qnil;
40
+ }
41
+
42
+ static VALUE
43
+ rg_s_core_pointer(G_GNUC_UNUSED VALUE self)
44
+ {
45
+ return GOBJ2RVAL(gdk_device_get_core_pointer());
46
+ }
47
+
48
+ static VALUE
49
+ rg_set_source(VALUE self, VALUE source)
50
+ {
51
+ gdk_device_set_source(_SELF(self), RVAL2GDKINPUTSOURCE(source));
52
+ return self;
53
+ }
54
+ */
55
+
56
+ static VALUE
57
+ rg_set_mode(VALUE self, VALUE mode)
58
+ {
59
+ return CBOOL2RVAL(gdk_device_set_mode(_SELF(self), RVAL2GDKINPUTMODE(mode)));
60
+ }
61
+
62
+ static VALUE
63
+ rg_set_key(VALUE self, VALUE index, VALUE keyval, VALUE modifiers)
64
+ {
65
+ gdk_device_set_key(_SELF(self), NUM2UINT(index), NUM2UINT(keyval),
66
+ RVAL2GDKMODIFIERTYPE(modifiers));
67
+ return self;
68
+ }
69
+
70
+ static VALUE
71
+ rg_set_axis_use(VALUE self, VALUE index, VALUE use)
72
+ {
73
+ gdk_device_set_axis_use(_SELF(self), NUM2UINT(index),
74
+ RVAL2GDKAXISUSE(use));
75
+ return self;
76
+ }
77
+
78
+ static VALUE
79
+ rg_get_state(VALUE self, VALUE window)
80
+ {
81
+ gdouble axes[2];
82
+ GdkModifierType mask;
83
+
84
+ gdk_device_get_state(_SELF(self), RVAL2GDKWINDOW(window),
85
+ axes, &mask);
86
+ return rb_ary_new3(3, rb_float_new(axes[0]), rb_float_new(axes[1]),
87
+ GDKMODIFIERTYPE2RVAL(mask));
88
+ }
89
+
90
+ static VALUE
91
+ rg_get_history(VALUE self, VALUE window, VALUE start, VALUE stop)
92
+ {
93
+ gboolean ret;
94
+ GdkTimeCoord** events;
95
+ gint i, n_events;
96
+ VALUE ary = Qnil;
97
+ ret = gdk_device_get_history(_SELF(self),
98
+ RVAL2GDKWINDOW(window),
99
+ NUM2UINT(start), NUM2UINT(stop),
100
+ &events, &n_events);
101
+ if (ret){
102
+ ary = rb_ary_new();
103
+ for (i = 0; i < n_events; i++){
104
+ rb_ary_push(ary, GDKTIMECOORD2RVAL(events));
105
+ }
106
+ gdk_device_free_history(events, n_events);
107
+ }
108
+ return ary;
109
+ }
110
+
111
+ static VALUE
112
+ rg_get_axis(VALUE self, VALUE rbaxes, VALUE rbuse)
113
+ {
114
+ GdkDevice *device = _SELF(self);
115
+ GdkAxisUse use = RVAL2GDKAXISUSE(rbuse);
116
+ long n;
117
+ gdouble *axes = RVAL2GDOUBLES(rbaxes, n);
118
+ gint device_n_axes = gdk_device_get_n_axes(device);
119
+ gdouble value;
120
+ gboolean found;
121
+
122
+ if (n != device_n_axes)
123
+ rb_raise(rb_eArgError,
124
+ "unexpected number of axes: %ld != %d",
125
+ n, device_n_axes);
126
+
127
+ found = gdk_device_get_axis(device, axes, use, &value);
128
+
129
+ g_free(axes);
130
+
131
+ return found ? DBL2NUM(value) : Qnil;
132
+ }
133
+
134
+ static VALUE
135
+ rg_mode(VALUE self)
136
+ {
137
+ return GDKINPUTMODE2RVAL(gdk_device_get_mode(_SELF(self)));
138
+ }
139
+
140
+ /* deprecated
141
+ static VALUE
142
+ rg_axes(VALUE self)
143
+ {
144
+ gint i;
145
+ VALUE ary = rb_ary_new();
146
+ GdkDeviceAxis* axes = _SELF(self)->axes;
147
+
148
+ for (i = 0; i < _SELF(self)->num_axes; i++){
149
+ rb_ary_push(ary, rb_ary_new3(3, GDKAXISUSE2RVAL(axes[i].use),
150
+ rb_float_new(axes[i].min), rb_float_new(axes[i].max)));
151
+ }
152
+ return ary;
153
+ }
154
+
155
+ static VALUE
156
+ rg_keys(VALUE self)
157
+ {
158
+ gint i;
159
+ VALUE ary = rb_ary_new();
160
+ GdkDeviceKey* keys = _SELF(self)->keys;
161
+
162
+ for (i = 0; i < _SELF(self)->num_keys; i++){
163
+ rb_ary_push(ary, rb_ary_new3(2, UINT2NUM(keys[i].keyval),
164
+ GDKMODIFIERTYPE2RVAL(keys[i].modifiers)));
165
+ }
166
+ return ary;
167
+ }
168
+ */
169
+
170
+ void
171
+ Init_gdk_device(VALUE mGdk)
172
+ {
173
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_DEVICE, "Device", mGdk);
174
+
175
+ /* deprecated
176
+ RG_DEF_SMETHOD(list, 0);
177
+ RG_DEF_SMETHOD(set_extension_events, 3);
178
+ RG_DEF_SMETHOD(core_pointer, 0);
179
+
180
+ RG_DEF_METHOD(set_source, 1);
181
+ */
182
+ RG_DEF_METHOD(set_mode, 1);
183
+ RG_DEF_METHOD(set_key, 3);
184
+ RG_DEF_METHOD(set_axis_use, 2);
185
+ RG_DEF_METHOD(get_state, 1);
186
+ RG_DEF_METHOD(get_history, 3);
187
+ RG_DEF_METHOD(get_axis, 2);
188
+ RG_DEF_METHOD(mode, 0);
189
+ /* deprecated
190
+ RG_DEF_METHOD(axes, 0);
191
+ RG_DEF_METHOD(keys, 0);
192
+ */
193
+
194
+ G_DEF_CLASS(GDK_TYPE_INPUT_SOURCE, "InputSource", RG_TARGET_NAMESPACE);
195
+ G_DEF_CLASS(GDK_TYPE_INPUT_MODE, "InputMode", RG_TARGET_NAMESPACE);
196
+ G_DEF_CLASS(GDK_TYPE_AXIS_USE, "AxisUse", RG_TARGET_NAMESPACE);
197
+ }