gdk3 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +18 -4
  3. data/lib/gdk3/atom.rb +26 -0
  4. data/lib/gdk3/cairo.rb +60 -0
  5. data/lib/gdk3/color.rb +27 -0
  6. data/lib/gdk3/deprecated.rb +14 -16
  7. data/lib/gdk3/event.rb +38 -0
  8. data/lib/gdk3/loader.rb +266 -0
  9. data/lib/gdk3/rectangle.rb +38 -0
  10. data/lib/gdk3/rgba.rb +32 -0
  11. data/lib/gdk3/window-attr.rb +28 -0
  12. data/lib/gdk3/window.rb +21 -0
  13. data/lib/gdk3.rb +61 -2
  14. data/test/run-test.rb +15 -6
  15. data/test/test-gdk-cairo.rb +41 -0
  16. data/test/test-gdk-event-type.rb +25 -0
  17. data/test/test-gdk-event.rb +47 -49
  18. data/test/test-gdk-keyval.rb +21 -0
  19. data/test/test-gdk-pixbuf.rb +49 -0
  20. data/test/test-gdk-rectangle.rb +35 -4
  21. data/test/test-gdk-rgba.rb +6 -1
  22. data/test/test-gdk-window-attr.rb +1 -1
  23. metadata +23 -51
  24. data/ext/gdk3/depend +0 -11
  25. data/ext/gdk3/extconf.rb +0 -130
  26. data/ext/gdk3/gdk3.def +0 -12
  27. data/ext/gdk3/init.c +0 -35
  28. data/ext/gdk3/rbgdk.c +0 -491
  29. data/ext/gdk3/rbgdk3.h +0 -73
  30. data/ext/gdk3/rbgdk3conversions.h +0 -121
  31. data/ext/gdk3/rbgdk3private.h +0 -85
  32. data/ext/gdk3/rbgdkatom.c +0 -122
  33. data/ext/gdk3/rbgdkcairo.c +0 -91
  34. data/ext/gdk3/rbgdkcolor.c +0 -137
  35. data/ext/gdk3/rbgdkconst.c +0 -33
  36. data/ext/gdk3/rbgdkcursor.c +0 -92
  37. data/ext/gdk3/rbgdkdevice.c +0 -253
  38. data/ext/gdk3/rbgdkdevicemanager.c +0 -39
  39. data/ext/gdk3/rbgdkdisplay.c +0 -434
  40. data/ext/gdk3/rbgdkdisplaymanager.c +0 -55
  41. data/ext/gdk3/rbgdkdragcontext.c +0 -191
  42. data/ext/gdk3/rbgdkevent.c +0 -1173
  43. data/ext/gdk3/rbgdkgeometry.c +0 -253
  44. data/ext/gdk3/rbgdkkeymap.c +0 -151
  45. data/ext/gdk3/rbgdkkeyval.c +0 -108
  46. data/ext/gdk3/rbgdkpango.c +0 -197
  47. data/ext/gdk3/rbgdkpangorenderer.c +0 -144
  48. data/ext/gdk3/rbgdkpixbuf.c +0 -176
  49. data/ext/gdk3/rbgdkproperty.c +0 -305
  50. data/ext/gdk3/rbgdkrectangle.c +0 -140
  51. data/ext/gdk3/rbgdkrgb.c +0 -199
  52. data/ext/gdk3/rbgdkrgba.c +0 -142
  53. data/ext/gdk3/rbgdkscreen.c +0 -443
  54. data/ext/gdk3/rbgdkselection.c +0 -146
  55. data/ext/gdk3/rbgdkthreads.c +0 -77
  56. data/ext/gdk3/rbgdktimecoord.c +0 -133
  57. data/ext/gdk3/rbgdkvisual.c +0 -251
  58. data/ext/gdk3/rbgdkwindow.c +0 -1069
  59. data/ext/gdk3/rbgdkwindowattr.c +0 -191
  60. data/ext/gdk3/rbgdkx11.c +0 -102
  61. data/ext/gdk3/rbgdkx11x11window.c +0 -66
  62. data/extconf.rb +0 -49
  63. data/lib/gdk3/base.rb +0 -59
@@ -1,253 +0,0 @@
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 geometry;
57
- memset(&geometry, 0, sizeof(GdkGeometry));
58
- G_INITIALIZE(self, g_boxed_copy(GDK_TYPE_GEOMETRY, &geometry));
59
- return Qnil;
60
- }
61
-
62
- static VALUE
63
- 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)
64
- {
65
- GdkGeometry *geo = _SELF(self);
66
- geo->min_width = NUM2INT(min_width);
67
- geo->min_height = NUM2INT(min_height);
68
- geo->max_width = NUM2INT(max_width);
69
- geo->max_height = NUM2INT(max_height);
70
- geo->base_width = NUM2INT(base_width);
71
- geo->base_height = NUM2INT(base_height);
72
- geo->width_inc = NUM2INT(width_inc);
73
- geo->height_inc = NUM2INT(height_inc);
74
- geo->min_aspect = NUM2DBL(min_aspect);
75
- geo->max_aspect = NUM2DBL(max_aspect);
76
- geo->win_gravity = RVAL2GDKGRAVITY(gravity);
77
-
78
- return self;
79
- }
80
-
81
- static VALUE
82
- rg_min_width(VALUE self)
83
- {
84
- return INT2NUM(_SELF(self)->min_width);
85
- }
86
-
87
- static VALUE
88
- rg_min_height(VALUE self)
89
- {
90
- return INT2NUM(_SELF(self)->min_height);
91
- }
92
-
93
- static VALUE
94
- rg_max_width(VALUE self)
95
- {
96
- return INT2NUM(_SELF(self)->max_width);
97
- }
98
-
99
- static VALUE
100
- rg_max_height(VALUE self)
101
- {
102
- return INT2NUM(_SELF(self)->max_height);
103
- }
104
-
105
- static VALUE
106
- rg_base_width(VALUE self)
107
- {
108
- return INT2NUM(_SELF(self)->base_width);
109
- }
110
-
111
- static VALUE
112
- rg_base_height(VALUE self)
113
- {
114
- return INT2NUM(_SELF(self)->base_height);
115
- }
116
-
117
- static VALUE
118
- rg_width_inc(VALUE self)
119
- {
120
- return INT2NUM(_SELF(self)->width_inc);
121
- }
122
-
123
- static VALUE
124
- rg_height_inc(VALUE self)
125
- {
126
- return INT2NUM(_SELF(self)->height_inc);
127
- }
128
-
129
- static VALUE
130
- rg_min_aspect(VALUE self)
131
- {
132
- return rb_float_new(_SELF(self)->min_aspect);
133
- }
134
-
135
- static VALUE
136
- rg_max_aspect(VALUE self)
137
- {
138
- return rb_float_new(_SELF(self)->max_aspect);
139
- }
140
-
141
- static VALUE
142
- rg_win_gravity(VALUE self)
143
- {
144
- return GDKGRAVITY2RVAL(_SELF(self)->win_gravity);
145
- }
146
-
147
- static VALUE
148
- rg_set_min_width(VALUE self, VALUE min_width)
149
- {
150
- _SELF(self)->min_width = NUM2INT(min_width);
151
- return self;
152
- }
153
-
154
- static VALUE
155
- rg_set_min_height(VALUE self, VALUE min_height)
156
- {
157
- _SELF(self)->min_height = NUM2INT(min_height);
158
- return self;
159
- }
160
-
161
- static VALUE
162
- rg_set_max_width(VALUE self, VALUE max_width)
163
- {
164
- _SELF(self)->max_width = NUM2INT(max_width);
165
- return self;
166
- }
167
-
168
- static VALUE
169
- rg_set_max_height(VALUE self, VALUE max_height)
170
- {
171
- _SELF(self)->max_height = NUM2INT(max_height);
172
- return self;
173
- }
174
-
175
- static VALUE
176
- rg_set_base_width(VALUE self, VALUE base_width)
177
- {
178
- _SELF(self)->base_width = NUM2INT(base_width);
179
- return self;
180
- }
181
-
182
- static VALUE
183
- rg_set_base_height(VALUE self, VALUE base_height)
184
- {
185
- _SELF(self)->base_height = NUM2INT(base_height);
186
- return self;
187
- }
188
-
189
- static VALUE
190
- rg_set_width_inc(VALUE self, VALUE width_inc)
191
- {
192
- _SELF(self)->width_inc = NUM2INT(width_inc);
193
- return self;
194
- }
195
-
196
- static VALUE
197
- rg_set_height_inc(VALUE self, VALUE height_inc)
198
- {
199
- _SELF(self)->height_inc = NUM2INT(height_inc);
200
- return self;
201
- }
202
-
203
- static VALUE
204
- rg_set_min_aspect(VALUE self, VALUE min_aspect)
205
- {
206
- _SELF(self)->min_aspect = NUM2DBL(min_aspect);
207
- return self;
208
- }
209
-
210
- static VALUE
211
- rg_set_max_aspect(VALUE self, VALUE max_aspect)
212
- {
213
- _SELF(self)->max_aspect = NUM2DBL(max_aspect);
214
- return self;
215
- }
216
-
217
- static VALUE
218
- rg_set_win_gravity(VALUE self, VALUE gravity)
219
- {
220
- _SELF(self)->win_gravity = RVAL2GDKGRAVITY(gravity);
221
- return self;
222
- }
223
-
224
- void
225
- Init_gdk_geometry(VALUE mGdk)
226
- {
227
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_GEOMETRY, "Geometry", mGdk);
228
-
229
- RG_DEF_METHOD(initialize, 0);
230
- RG_DEF_METHOD(min_width, 0);
231
- RG_DEF_METHOD(min_height, 0);
232
- RG_DEF_METHOD(max_width, 0);
233
- RG_DEF_METHOD(max_height, 0);
234
- RG_DEF_METHOD(base_width, 0);
235
- RG_DEF_METHOD(base_height, 0);
236
- RG_DEF_METHOD(width_inc, 0);
237
- RG_DEF_METHOD(height_inc, 0);
238
- RG_DEF_METHOD(min_aspect, 0);
239
- RG_DEF_METHOD(max_aspect, 0);
240
- RG_DEF_METHOD(win_gravity, 0);
241
- RG_DEF_METHOD(set, 11);
242
- RG_DEF_METHOD(set_min_width, 1);
243
- RG_DEF_METHOD(set_min_height, 1);
244
- RG_DEF_METHOD(set_max_width, 1);
245
- RG_DEF_METHOD(set_max_height, 1);
246
- RG_DEF_METHOD(set_base_width, 1);
247
- RG_DEF_METHOD(set_base_height, 1);
248
- RG_DEF_METHOD(set_width_inc, 1);
249
- RG_DEF_METHOD(set_height_inc, 1);
250
- RG_DEF_METHOD(set_min_aspect, 1);
251
- RG_DEF_METHOD(set_max_aspect, 1);
252
- RG_DEF_METHOD(set_win_gravity, 1);
253
- }
@@ -1,151 +0,0 @@
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
- }
@@ -1,108 +0,0 @@
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
- }
@@ -1,197 +0,0 @@
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
- #include "rbpango.h"
24
-
25
- #define RG_TARGET_NAMESPACE mPango
26
-
27
- static VALUE
28
- rg_s_context(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
29
- {
30
- VALUE screen, ret;
31
- rb_scan_args(argc, argv, "01", &screen);
32
- if (NIL_P(screen)){
33
- ret = GOBJ2RVAL(gdk_pango_context_get());
34
- } else {
35
- ret = GOBJ2RVAL(gdk_pango_context_get_for_screen(RVAL2GDKSCREEN(screen)));
36
- }
37
- return ret;
38
- }
39
-
40
- /* deprecated
41
- static VALUE
42
- gdkpango_context_set_colormap(VALUE self, VALUE colormap)
43
- {
44
- gdk_pango_context_set_colormap(RVAL2PANGOCONTEXT(self),
45
- RVAL2GDKCOLORMAP(colormap));
46
- return self;
47
- }
48
-
49
- static VALUE
50
- gdkpango_attr_embossed_initialize(VALUE self, VALUE embossed)
51
- {
52
- DATA_PTR(self) = gdk_pango_attr_embossed_new(RVAL2CBOOL(embossed));
53
- return Qnil;
54
- }
55
-
56
- static VALUE
57
- gdkpango_attr_embossed_value(VALUE self)
58
- {
59
- return CBOOL2RVAL(((GdkPangoAttrEmbossed*)RVAL2ATTR(self))->embossed);
60
- }
61
- */
62
-
63
- /* deprecated
64
- static VALUE
65
- gdkpango_attr_stipple_initialize(VALUE self, VALUE stipple)
66
- {
67
- DATA_PTR(self) = gdk_pango_attr_stipple_new(RVAL2GDKBITMAP(stipple));
68
- return Qnil;
69
- }
70
-
71
- static VALUE
72
- gdkpango_attr_stipple_value(VALUE self)
73
- {
74
- return GOBJ2RVAL(((GdkPangoAttrStipple*)RVAL2ATTR(self))->stipple);
75
- }
76
- */
77
-
78
- static VALUE
79
- gdkpango_layout_get_clip_region(VALUE self, VALUE rbx_origin, VALUE rby_origin, VALUE rbindex_ranges)
80
- {
81
- PangoLayout *layout = RVAL2PANGOLAYOUT(self);
82
- gint x_origin = NUM2INT(rbx_origin);
83
- gint y_origin = NUM2INT(rby_origin);
84
- long n;
85
- gint *index_ranges = RVAL2GINTS(rbindex_ranges, n);
86
- cairo_region_t *result;
87
-
88
- if (n % 2 != 0) {
89
- g_free(index_ranges);
90
-
91
- rb_raise(rb_eArgError,
92
- "an even number of byte indexes must be given");
93
- }
94
-
95
- result = gdk_pango_layout_get_clip_region(layout, x_origin, y_origin, index_ranges, n / 2);
96
-
97
- g_free(index_ranges);
98
-
99
- return CRREGION2RVAL(result);
100
- }
101
-
102
- static VALUE
103
- gdkpango_layout_line_get_clip_region(VALUE self, VALUE rbx_origin, VALUE rby_origin, VALUE rbindex_ranges)
104
- {
105
- PangoLayoutLine *line = RVAL2PANGOLAYOUTLINE(self);
106
- gint x_origin = NUM2INT(rbx_origin);
107
- gint y_origin = NUM2INT(rby_origin);
108
- long n;
109
- gint *index_ranges = RVAL2GINTS(rbindex_ranges, n);
110
- cairo_region_t *result;
111
-
112
- if (n % 2 != 0) {
113
- g_free(index_ranges);
114
-
115
- rb_raise(rb_eArgError,
116
- "an even number of byte indexes must be given");
117
- }
118
-
119
- result = gdk_pango_layout_line_get_clip_region(line, x_origin, y_origin, index_ranges, n / 2);
120
-
121
- g_free(index_ranges);
122
-
123
- return CRREGION2RVAL(result);
124
- }
125
-
126
- /* deprecated
127
- static VALUE
128
- gdkpango_attr_emboss_color_initialize(VALUE self, VALUE color)
129
- {
130
- DATA_PTR(self) = gdk_pango_attr_emboss_color_new(RVAL2GDKCOLOR(color));
131
- return Qnil;
132
- }
133
-
134
- static VALUE
135
- gdkpango_attr_emboss_color_value(VALUE self)
136
- {
137
- return PANGOCOLOR2RVAL(&(((GdkPangoAttrEmbossColor *)RVAL2ATTR(self))->color));
138
- }
139
- */
140
-
141
- void
142
- Init_gdk_pango(VALUE mGdk)
143
- {
144
- /* deprecated
145
- VALUE klass;
146
- PangoAttribute* tmpattr;
147
- GdkColor color;
148
- */
149
-
150
- VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "Pango");
151
- /* deprecated
152
- VALUE context = GTYPE2CLASS(PANGO_TYPE_CONTEXT);
153
- */
154
- VALUE layout = GTYPE2CLASS(PANGO_TYPE_LAYOUT);
155
- VALUE layoutline = GTYPE2CLASS(PANGO_TYPE_LAYOUT_LINE);
156
- /* deprecated
157
- VALUE pattr = ATTRTYPE2CLASS(CSTR2RVAL("Attribute"));
158
- VALUE pattrbool = ATTRTYPE2CLASS(CSTR2RVAL("AttrBool"));
159
- VALUE pattr_color = ATTRTYPE2CLASS(CSTR2RVAL("AttrColor"));
160
- */
161
-
162
- RG_DEF_SMETHOD(context, -1);
163
-
164
- /* deprecated
165
- rbg_define_method(context, "set_colormap", gdkpango_context_set_colormap, 1);
166
- */
167
- rbg_define_method(layout, "get_clip_region", gdkpango_layout_get_clip_region, 3);
168
- rbg_define_method(layoutline, "get_clip_region", gdkpango_layout_line_get_clip_region, 3);
169
-
170
- /* deprecated
171
- klass = rb_define_class_under(mGdk, "PangoAttrEmbossed", pattrbool);
172
- rbg_define_method(klass, "initialize", gdkpango_attr_embossed_initialize, 1);
173
- tmpattr = gdk_pango_attr_embossed_new(TRUE);
174
- rbg_define_method(klass, "value", gdkpango_attr_embossed_value, 0);
175
- RBPANGO_ADD_ATTRIBUTE(tmpattr->klass->type, klass);
176
- pango_attribute_destroy(tmpattr);
177
- */
178
-
179
- /* deprecated
180
- klass = rb_define_class_under(mGdk, "PangoAttrStipple", pattr);
181
- rbg_define_method(klass, "initialize", gdkpango_attr_stipple_initialize, 1);
182
- rbg_define_method(klass, "value", gdkpango_attr_stipple_value, 0);
183
- tmpattr = gdk_pango_attr_stipple_new(NULL);
184
- RBPANGO_ADD_ATTRIBUTE(tmpattr->klass->type, klass);
185
- pango_attribute_destroy(tmpattr);
186
- */
187
-
188
- /* deprecated
189
- klass = rb_define_class_under(mGdk, "PangoAttrEmbossColor", pattr_color);
190
- rbg_define_method(klass, "initialize",
191
- gdkpango_attr_emboss_color_initialize, 1);
192
- rbg_define_method(klass, "value", gdkpango_attr_emboss_color_value, 0);
193
- tmpattr = gdk_pango_attr_emboss_color_new(&color);
194
- RBPANGO_ADD_ATTRIBUTE(tmpattr->klass->type, klass);
195
- pango_attribute_destroy(tmpattr);
196
- */
197
- }