gdk3 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,252 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002,2003 Masao Mutoh
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
+ /*****************************************/
28
+ static GdkGeometry*
29
+ geo_copy(const GdkGeometry* geo)
30
+ {
31
+ GdkGeometry* new_geo;
32
+ g_return_val_if_fail (geo != NULL, NULL);
33
+ new_geo = g_new(GdkGeometry, 1);
34
+ *new_geo = *geo;
35
+ return new_geo;
36
+ }
37
+
38
+ GType
39
+ gdk_geometry_get_type(void)
40
+ {
41
+ static GType our_type = 0;
42
+ if (our_type == 0)
43
+ our_type = g_boxed_type_register_static ("GdkGeometry",
44
+ (GBoxedCopyFunc)geo_copy,
45
+ (GBoxedFreeFunc)g_free);
46
+ return our_type;
47
+ }
48
+ /*****************************************/
49
+
50
+ #define RG_TARGET_NAMESPACE cGeometry
51
+ #define _SELF(g) (RVAL2GDKGEOMETRY(g))
52
+
53
+ static VALUE
54
+ rg_initialize(VALUE self)
55
+ {
56
+ GdkGeometry g;
57
+ G_INITIALIZE(self, &g);
58
+ return Qnil;
59
+ }
60
+
61
+ static VALUE
62
+ rg_set(VALUE self, VALUE min_width, VALUE min_height, VALUE max_width, VALUE max_height, VALUE base_width, VALUE base_height, VALUE width_inc, VALUE height_inc, VALUE min_aspect, VALUE max_aspect, VALUE gravity)
63
+ {
64
+ GdkGeometry *geo = _SELF(self);
65
+ geo->min_width = NUM2INT(min_width);
66
+ geo->min_height = NUM2INT(min_height);
67
+ geo->max_width = NUM2INT(max_width);
68
+ geo->max_height = NUM2INT(max_height);
69
+ geo->base_width = NUM2INT(base_width);
70
+ geo->base_height = NUM2INT(base_height);
71
+ geo->width_inc = NUM2INT(width_inc);
72
+ geo->height_inc = NUM2INT(height_inc);
73
+ geo->min_aspect = NUM2DBL(min_aspect);
74
+ geo->max_aspect = NUM2DBL(max_aspect);
75
+ geo->win_gravity = RVAL2GDKGRAVITY(gravity);
76
+
77
+ return self;
78
+ }
79
+
80
+ static VALUE
81
+ rg_min_width(VALUE self)
82
+ {
83
+ return INT2NUM(_SELF(self)->min_width);
84
+ }
85
+
86
+ static VALUE
87
+ rg_min_height(VALUE self)
88
+ {
89
+ return INT2NUM(_SELF(self)->min_height);
90
+ }
91
+
92
+ static VALUE
93
+ rg_max_width(VALUE self)
94
+ {
95
+ return INT2NUM(_SELF(self)->max_width);
96
+ }
97
+
98
+ static VALUE
99
+ rg_max_height(VALUE self)
100
+ {
101
+ return INT2NUM(_SELF(self)->max_height);
102
+ }
103
+
104
+ static VALUE
105
+ rg_base_width(VALUE self)
106
+ {
107
+ return INT2NUM(_SELF(self)->base_width);
108
+ }
109
+
110
+ static VALUE
111
+ rg_base_height(VALUE self)
112
+ {
113
+ return INT2NUM(_SELF(self)->base_height);
114
+ }
115
+
116
+ static VALUE
117
+ rg_width_inc(VALUE self)
118
+ {
119
+ return INT2NUM(_SELF(self)->width_inc);
120
+ }
121
+
122
+ static VALUE
123
+ rg_height_inc(VALUE self)
124
+ {
125
+ return INT2NUM(_SELF(self)->height_inc);
126
+ }
127
+
128
+ static VALUE
129
+ rg_min_aspect(VALUE self)
130
+ {
131
+ return rb_float_new(_SELF(self)->min_aspect);
132
+ }
133
+
134
+ static VALUE
135
+ rg_max_aspect(VALUE self)
136
+ {
137
+ return rb_float_new(_SELF(self)->max_aspect);
138
+ }
139
+
140
+ static VALUE
141
+ rg_win_gravity(VALUE self)
142
+ {
143
+ return GDKGRAVITY2RVAL(_SELF(self)->win_gravity);
144
+ }
145
+
146
+ static VALUE
147
+ rg_set_min_width(VALUE self, VALUE min_width)
148
+ {
149
+ _SELF(self)->min_width = NUM2INT(min_width);
150
+ return self;
151
+ }
152
+
153
+ static VALUE
154
+ rg_set_min_height(VALUE self, VALUE min_height)
155
+ {
156
+ _SELF(self)->min_height = NUM2INT(min_height);
157
+ return self;
158
+ }
159
+
160
+ static VALUE
161
+ rg_set_max_width(VALUE self, VALUE max_width)
162
+ {
163
+ _SELF(self)->max_width = NUM2INT(max_width);
164
+ return self;
165
+ }
166
+
167
+ static VALUE
168
+ rg_set_max_height(VALUE self, VALUE max_height)
169
+ {
170
+ _SELF(self)->max_height = NUM2INT(max_height);
171
+ return self;
172
+ }
173
+
174
+ static VALUE
175
+ rg_set_base_width(VALUE self, VALUE base_width)
176
+ {
177
+ _SELF(self)->base_width = NUM2INT(base_width);
178
+ return self;
179
+ }
180
+
181
+ static VALUE
182
+ rg_set_base_height(VALUE self, VALUE base_height)
183
+ {
184
+ _SELF(self)->base_height = NUM2INT(base_height);
185
+ return self;
186
+ }
187
+
188
+ static VALUE
189
+ rg_set_width_inc(VALUE self, VALUE width_inc)
190
+ {
191
+ _SELF(self)->width_inc = NUM2INT(width_inc);
192
+ return self;
193
+ }
194
+
195
+ static VALUE
196
+ rg_set_height_inc(VALUE self, VALUE height_inc)
197
+ {
198
+ _SELF(self)->height_inc = NUM2INT(height_inc);
199
+ return self;
200
+ }
201
+
202
+ static VALUE
203
+ rg_set_min_aspect(VALUE self, VALUE min_aspect)
204
+ {
205
+ _SELF(self)->min_aspect = NUM2DBL(min_aspect);
206
+ return self;
207
+ }
208
+
209
+ static VALUE
210
+ rg_set_max_aspect(VALUE self, VALUE max_aspect)
211
+ {
212
+ _SELF(self)->max_aspect = NUM2DBL(max_aspect);
213
+ return self;
214
+ }
215
+
216
+ static VALUE
217
+ rg_set_win_gravity(VALUE self, VALUE gravity)
218
+ {
219
+ _SELF(self)->win_gravity = RVAL2GDKGRAVITY(gravity);
220
+ return self;
221
+ }
222
+
223
+ void
224
+ Init_gdk_geometry(VALUE mGdk)
225
+ {
226
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_GEOMETRY, "Geometry", mGdk);
227
+
228
+ RG_DEF_METHOD(initialize, 0);
229
+ RG_DEF_METHOD(min_width, 0);
230
+ RG_DEF_METHOD(min_height, 0);
231
+ RG_DEF_METHOD(max_width, 0);
232
+ RG_DEF_METHOD(max_height, 0);
233
+ RG_DEF_METHOD(base_width, 0);
234
+ RG_DEF_METHOD(base_height, 0);
235
+ RG_DEF_METHOD(width_inc, 0);
236
+ RG_DEF_METHOD(height_inc, 0);
237
+ RG_DEF_METHOD(min_aspect, 0);
238
+ RG_DEF_METHOD(max_aspect, 0);
239
+ RG_DEF_METHOD(win_gravity, 0);
240
+ RG_DEF_METHOD(set, 11);
241
+ RG_DEF_METHOD(set_min_width, 1);
242
+ RG_DEF_METHOD(set_min_height, 1);
243
+ RG_DEF_METHOD(set_max_width, 1);
244
+ RG_DEF_METHOD(set_max_height, 1);
245
+ RG_DEF_METHOD(set_base_width, 1);
246
+ RG_DEF_METHOD(set_base_height, 1);
247
+ RG_DEF_METHOD(set_width_inc, 1);
248
+ RG_DEF_METHOD(set_height_inc, 1);
249
+ RG_DEF_METHOD(set_min_aspect, 1);
250
+ RG_DEF_METHOD(set_max_aspect, 1);
251
+ RG_DEF_METHOD(set_win_gravity, 1);
252
+ }
@@ -0,0 +1,151 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2003,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 cKeymap
25
+ #define _SELF(s) RVAL2GDKKEYMAP(s)
26
+
27
+ static VALUE
28
+ rg_s_default(G_GNUC_UNUSED VALUE self)
29
+ {
30
+ return GOBJ2RVAL(gdk_keymap_get_default());
31
+ }
32
+
33
+ static VALUE
34
+ rg_s_for_display(G_GNUC_UNUSED VALUE self, VALUE display)
35
+ {
36
+ return GOBJ2RVAL(gdk_keymap_get_for_display(RVAL2GDKDISPLAYOBJECT(display)));
37
+ }
38
+
39
+ static VALUE
40
+ rg_lookup_key(VALUE self, VALUE keycode, VALUE group, VALUE level)
41
+ {
42
+ GdkKeymapKey key;
43
+
44
+ key.keycode = NUM2UINT(keycode);
45
+ key.group = NUM2INT(group);
46
+ key.level = NUM2INT(level);
47
+
48
+ return INT2NUM(gdk_keymap_lookup_key(_SELF(self), &key));
49
+ }
50
+
51
+ static VALUE
52
+ rg_translate_keyboard_state(VALUE self, VALUE hardware_keycode, VALUE state, VALUE group)
53
+ {
54
+ guint keyval;
55
+ gint effective_group, level;
56
+ GdkModifierType consumed_modifiers;
57
+ gboolean ret;
58
+
59
+ ret = gdk_keymap_translate_keyboard_state(_SELF(self),
60
+ NUM2UINT(hardware_keycode),
61
+ RVAL2GDKMODIFIERTYPE(state),
62
+ NUM2INT(group),
63
+ &keyval, &effective_group,
64
+ &level, &consumed_modifiers);
65
+ return ret ? rb_ary_new3(4, UINT2NUM(keyval), INT2NUM(effective_group),
66
+ INT2NUM(level),
67
+ GDKMODIFIERTYPE2RVAL(consumed_modifiers)) : Qnil;
68
+ }
69
+
70
+ static VALUE
71
+ rg_get_entries_for_keyval(VALUE self, VALUE keyval)
72
+ {
73
+ GdkKeymapKey* keys;
74
+ gint n_keys;
75
+ gboolean ret;
76
+ ret = gdk_keymap_get_entries_for_keyval(_SELF(self),
77
+ NUM2UINT(keyval), &keys, &n_keys);
78
+
79
+ if (ret){
80
+ VALUE key;
81
+ VALUE ary = rb_ary_new();
82
+ gint i;
83
+ for (i = 0; i < n_keys; i++){
84
+ key = rb_ary_new3(3, UINT2NUM(keys[i].keycode), INT2NUM(keys[i].group),
85
+ INT2NUM(keys[i].level));
86
+ rb_ary_push(ary, key);
87
+ }
88
+ g_free(keys);
89
+ return ary;
90
+ } else {
91
+ return Qnil;
92
+ }
93
+ }
94
+
95
+ static VALUE
96
+ rg_get_entries_for_keycode(VALUE self, VALUE hardware_keycode)
97
+ {
98
+ GdkKeymapKey* keys;
99
+ guint* keyvals;
100
+ gint n_entries;
101
+ gboolean ret = gdk_keymap_get_entries_for_keycode(_SELF(self),
102
+ NUM2UINT(hardware_keycode),
103
+ &keys, &keyvals, &n_entries);
104
+ if (ret){
105
+ VALUE key;
106
+ VALUE ary = rb_ary_new();
107
+ gint i;
108
+ for (i = 0; i < n_entries; i++){
109
+ key = rb_ary_new3(4, UINT2NUM(keys[i].keycode), INT2NUM(keys[i].group),
110
+ INT2NUM(keys[i].level), UINT2NUM(keyvals[i]));
111
+ rb_ary_push(ary, key);
112
+ }
113
+ g_free(keys);
114
+ g_free(keyvals);
115
+ return ary;
116
+ } else {
117
+ return Qnil;
118
+ }
119
+ }
120
+
121
+ static VALUE
122
+ rg_direction(VALUE self)
123
+ {
124
+ return PANGODIRECTION2RVAL(gdk_keymap_get_direction(_SELF(self)));
125
+ }
126
+
127
+ static VALUE
128
+ rg_have_bidi_layouts_p(VALUE self)
129
+ {
130
+ return CBOOL2RVAL(gdk_keymap_have_bidi_layouts(_SELF(self)));
131
+ }
132
+
133
+ void
134
+ Init_gdk_keymap(VALUE mGdk)
135
+ {
136
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_KEYMAP, "Keymap", mGdk);
137
+
138
+ RG_DEF_SMETHOD(default, 0);
139
+ RG_DEF_SMETHOD(for_display, 0);
140
+ RG_DEF_METHOD(lookup_key, 3);
141
+ RG_DEF_METHOD(translate_keyboard_state, 3);
142
+ RG_DEF_METHOD(get_entries_for_keyval, 1);
143
+ RG_DEF_METHOD(get_entries_for_keycode, 1);
144
+ RG_DEF_METHOD(direction, 0);
145
+ RG_DEF_METHOD_P(have_bidi_layouts, 0);
146
+
147
+ #ifdef GDK_WINDOWING_X11
148
+ G_DEF_CLASS3("GdkKeymapX11", "KeymapX11", mGdk);
149
+ #endif
150
+
151
+ }
@@ -0,0 +1,108 @@
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
+ #include <gdk/gdkkeysyms.h>
27
+
28
+ #define RG_TARGET_NAMESPACE mGdkKeyval
29
+
30
+ static VALUE
31
+ rg_s_to_name(G_GNUC_UNUSED VALUE self, VALUE keyval)
32
+ {
33
+ gchar* name = gdk_keyval_name(NUM2UINT(keyval));
34
+ return name ? CSTR2RVAL(name) : Qnil;
35
+ }
36
+
37
+ static VALUE
38
+ rg_s_from_name(G_GNUC_UNUSED VALUE self, VALUE keyval_name)
39
+ {
40
+ return UINT2NUM(gdk_keyval_from_name(RVAL2CSTR(keyval_name)));
41
+ }
42
+
43
+ static VALUE
44
+ rg_s_upper_p(G_GNUC_UNUSED VALUE self, VALUE keyval)
45
+ {
46
+ return CBOOL2RVAL(gdk_keyval_is_upper(NUM2UINT(keyval)));
47
+ }
48
+
49
+ static VALUE
50
+ rg_s_lower_p(G_GNUC_UNUSED VALUE self, VALUE keyval)
51
+ {
52
+ return CBOOL2RVAL(gdk_keyval_is_lower(NUM2UINT(keyval)));
53
+ }
54
+
55
+ static VALUE
56
+ rg_s_convert_case(G_GNUC_UNUSED VALUE self, VALUE symbol)
57
+ {
58
+ guint upper, lower;
59
+ gdk_keyval_convert_case(NUM2UINT(symbol), &lower, &upper);
60
+ return rb_ary_new3(2, UINT2NUM(lower), UINT2NUM(upper));
61
+ }
62
+
63
+ static VALUE
64
+ rg_s_to_upper(G_GNUC_UNUSED VALUE self, VALUE keyval)
65
+ {
66
+ return INT2NUM(gdk_keyval_to_upper(NUM2UINT(keyval)));
67
+ }
68
+
69
+ static VALUE
70
+ rg_s_to_lower(G_GNUC_UNUSED VALUE self, VALUE keyval)
71
+ {
72
+ return INT2NUM(gdk_keyval_to_lower(NUM2UINT(keyval)));
73
+ }
74
+
75
+ static VALUE
76
+ rg_s_to_unicode(G_GNUC_UNUSED VALUE self, VALUE keyval)
77
+ {
78
+ return UINT2NUM(gdk_keyval_to_unicode(NUM2UINT(keyval)));
79
+ }
80
+
81
+ static VALUE
82
+ rg_s_from_unicode(G_GNUC_UNUSED VALUE self, VALUE wc)
83
+ {
84
+ VALUE unicode;
85
+ if (TYPE(wc) == T_STRING) {
86
+ unicode = NUM2UINT(rb_funcall(wc, rb_intern("[]"), 1, INT2FIX(0)));
87
+ } else {
88
+ unicode = NUM2UINT(wc);
89
+ }
90
+ return UINT2NUM(gdk_unicode_to_keyval(unicode));
91
+ }
92
+
93
+ void
94
+ Init_gdk_keyval(VALUE mGdk)
95
+ {
96
+ VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "Keyval");
97
+ RG_DEF_SMETHOD(to_name, 1);
98
+ RG_DEF_SMETHOD(from_name, 1);
99
+ RG_DEF_SMETHOD_P(upper, 1);
100
+ RG_DEF_SMETHOD_P(lower, 1);
101
+ RG_DEF_SMETHOD(convert_case, 1);
102
+ RG_DEF_SMETHOD(to_upper, 1);
103
+ RG_DEF_SMETHOD(to_lower, 1);
104
+ RG_DEF_SMETHOD(to_unicode, 1);
105
+ RG_DEF_SMETHOD(from_unicode, 1);
106
+
107
+ #include "rbgdkkeysyms.h"
108
+ }