atk 0.20.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.
@@ -0,0 +1,50 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbatkstreamablecontent.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2005/09/15 17:30:46 $
8
+
9
+ Copyright (C) 2003 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbatk.h"
13
+
14
+ #define _SELF(s) (ATK_STREAMABLE_CONTENT(RVAL2GOBJ(s)))
15
+
16
+ static VALUE
17
+ rbatkst_get_n_mime_types(self)
18
+ VALUE self;
19
+ {
20
+ return INT2NUM(atk_streamable_content_get_n_mime_types(_SELF(self)));
21
+ }
22
+
23
+ static VALUE
24
+ rbatkst_get_mime_type(self, i)
25
+ VALUE self, i;
26
+ {
27
+ return CSTR2RVAL(atk_streamable_content_get_mime_type(_SELF(self), NUM2INT(i)));
28
+ }
29
+
30
+ static VALUE
31
+ rbatkst_get_stream(self, mime_type)
32
+ VALUE self, mime_type;
33
+ {
34
+ GIOChannel* io = atk_streamable_content_get_stream(_SELF(self), RVAL2CSTR(mime_type));
35
+ if (!io)
36
+ rb_raise(rb_eRuntimeError, "Couldn't get the stream.");
37
+
38
+ return BOXED2RVAL(io, G_TYPE_IO_CHANNEL);
39
+ }
40
+
41
+
42
+ void
43
+ Init_atk_streamable_content()
44
+ {
45
+ VALUE mContent = G_DEF_INTERFACE(ATK_TYPE_STREAMABLE_CONTENT, "StreamableContent", mAtk);
46
+
47
+ rb_define_method(mContent, "n_mime_types", rbatkst_get_n_mime_types, 0);
48
+ rb_define_method(mContent, "mime_type", rbatkst_get_mime_type, 1);
49
+ rb_define_method(mContent, "get_stream", rbatkst_get_stream, 1);
50
+ }
@@ -0,0 +1,292 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbatktable.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2004/03/05 15:33:48 $
8
+
9
+ Copyright (C) 2003,2004 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbatk.h"
13
+
14
+ #define _SELF(s) (ATK_TABLE(RVAL2GOBJ(s)))
15
+
16
+ static VALUE
17
+ rbatk_table_ref_at(self, row, column)
18
+ VALUE self, row, column;
19
+ {
20
+ return GOBJ2RVAL(atk_table_ref_at(_SELF(self), NUM2INT(row), NUM2INT(column)));
21
+ }
22
+
23
+ static VALUE
24
+ rbatk_table_get_index_at(self, row, column)
25
+ VALUE self, row, column;
26
+ {
27
+ return INT2NUM(atk_table_get_index_at(_SELF(self), NUM2INT(row), NUM2INT(column)));
28
+ }
29
+
30
+ static VALUE
31
+ rbatk_table_get_column_at_index(self, index_)
32
+ VALUE self, index_;
33
+ {
34
+ return INT2NUM(atk_table_get_column_at_index(_SELF(self), NUM2INT(index_)));
35
+ }
36
+
37
+ static VALUE
38
+ rbatk_table_get_row_at_index(self, index_)
39
+ VALUE self, index_;
40
+ {
41
+ return INT2NUM(atk_table_get_row_at_index(_SELF(self), NUM2INT(index_)));
42
+ }
43
+
44
+ static VALUE
45
+ rbatk_table_get_n_columns(self)
46
+ VALUE self;
47
+ {
48
+ return INT2NUM(atk_table_get_n_columns(_SELF(self)));
49
+ }
50
+
51
+ static VALUE
52
+ rbatk_table_get_n_rows(self)
53
+ VALUE self;
54
+ {
55
+ return INT2NUM(atk_table_get_n_rows(_SELF(self)));
56
+ }
57
+
58
+ static VALUE
59
+ rbatk_table_get_column_extent_at(self, row, column)
60
+ VALUE self, row, column;
61
+ {
62
+ return INT2NUM(atk_table_get_column_extent_at(_SELF(self), NUM2INT(row), NUM2INT(column)));
63
+ }
64
+
65
+ static VALUE
66
+ rbatk_table_get_row_extent_at(self, row, column)
67
+ VALUE self, row, column;
68
+ {
69
+ return INT2NUM(atk_table_get_row_extent_at(_SELF(self), NUM2INT(row), NUM2INT(column)));
70
+ }
71
+
72
+ static VALUE
73
+ rbatk_table_get_caption(self)
74
+ VALUE self;
75
+ {
76
+ return GOBJ2RVAL(atk_table_get_caption(_SELF(self)));
77
+ }
78
+
79
+ static VALUE
80
+ rbatk_table_get_column_description(self, column)
81
+ VALUE self, column;
82
+ {
83
+ return CSTR2RVAL(atk_table_get_column_description(_SELF(self), NUM2INT(column)));
84
+ }
85
+
86
+ static VALUE
87
+ rbatk_table_get_row_description(self, row)
88
+ VALUE self, row;
89
+ {
90
+ return CSTR2RVAL(atk_table_get_row_description(_SELF(self), NUM2INT(row)));
91
+ }
92
+
93
+ static VALUE
94
+ rbatk_table_get_column_header(self, column)
95
+ VALUE self, column;
96
+ {
97
+ return GOBJ2RVAL(atk_table_get_column_header(_SELF(self), NUM2INT(column)));
98
+ }
99
+
100
+ static VALUE
101
+ rbatk_table_get_row_header(self, row)
102
+ VALUE self, row;
103
+ {
104
+ return GOBJ2RVAL(atk_table_get_row_header(_SELF(self), NUM2INT(row)));
105
+ }
106
+
107
+ static VALUE
108
+ rbatk_table_get_summary(self)
109
+ VALUE self;
110
+ {
111
+ return GOBJ2RVAL(atk_table_get_summary(_SELF(self)));
112
+ }
113
+
114
+ static VALUE
115
+ rbatk_table_set_caption(self, caption)
116
+ VALUE self, caption;
117
+ {
118
+ atk_table_set_caption(_SELF(self), ATK_OBJECT(RVAL2GOBJ(caption)));
119
+ return self;
120
+ }
121
+
122
+ static VALUE
123
+ rbatk_table_set_row_description(self, row, description)
124
+ VALUE self, row, description;
125
+ {
126
+ atk_table_set_row_description(_SELF(self), NUM2INT(row), RVAL2CSTR(description));
127
+ return self;
128
+ }
129
+
130
+ static VALUE
131
+ rbatk_table_set_column_description(self, column, description)
132
+ VALUE self, column, description;
133
+ {
134
+ atk_table_set_column_description(_SELF(self), NUM2INT(column), RVAL2CSTR(description));
135
+ return self;
136
+ }
137
+
138
+ static VALUE
139
+ rbatk_table_set_row_header(self, row, header)
140
+ VALUE self, row, header;
141
+ {
142
+ atk_table_set_row_header(_SELF(self), NUM2INT(row), ATK_OBJECT(RVAL2GOBJ(header)));
143
+ return self;
144
+ }
145
+
146
+ static VALUE
147
+ rbatk_table_set_column_header(self, column, header)
148
+ VALUE self, column, header;
149
+ {
150
+ atk_table_set_column_header(_SELF(self), NUM2INT(column), ATK_OBJECT(RVAL2GOBJ(header)));
151
+ return self;
152
+ }
153
+
154
+ static VALUE
155
+ rbatk_table_set_summary(self, accessible)
156
+ VALUE self, accessible;
157
+ {
158
+ atk_table_set_summary(_SELF(self), ATK_OBJECT(RVAL2GOBJ(accessible)));
159
+ return self;
160
+ }
161
+
162
+ static VALUE
163
+ rbatk_table_get_selected_columns(self)
164
+ VALUE self;
165
+ {
166
+ gint ret;
167
+ gint* selected;
168
+ VALUE result = Qnil;
169
+ ret = atk_table_get_selected_columns(_SELF(self), &selected);
170
+ if (ret > 0){
171
+ gint i;
172
+ result = rb_ary_new2(ret);
173
+ for (i = 0; i < ret; i++){
174
+ rb_ary_push(result, INT2NUM(selected[i]));
175
+ }
176
+ }
177
+ return result;
178
+ }
179
+
180
+ static VALUE
181
+ rbatk_table_get_selected_rows(self)
182
+ VALUE self;
183
+ {
184
+ gint ret;
185
+ gint* selected;
186
+ VALUE result = Qnil;
187
+ ret = atk_table_get_selected_rows(_SELF(self), &selected);
188
+ if (ret > 0){
189
+ gint i;
190
+ result = rb_ary_new2(ret);
191
+ for (i = 0; i < ret; i++){
192
+ rb_ary_push(result, INT2NUM(selected[i]));
193
+ }
194
+ }
195
+ return result;
196
+ }
197
+
198
+ static VALUE
199
+ rbatk_table_is_column_selected(self, column)
200
+ VALUE self, column;
201
+ {
202
+ return CBOOL2RVAL(atk_table_is_column_selected(_SELF(self), NUM2INT(column)));
203
+ }
204
+
205
+ static VALUE
206
+ rbatk_table_is_row_selected(self, row)
207
+ VALUE self, row;
208
+ {
209
+ return CBOOL2RVAL(atk_table_is_row_selected(_SELF(self), NUM2INT(row)));
210
+ }
211
+
212
+ static VALUE
213
+ rbatk_table_is_selected(self, row, column)
214
+ VALUE self, row, column;
215
+ {
216
+ return CBOOL2RVAL(atk_table_is_selected(_SELF(self), NUM2INT(row), NUM2INT(column)));
217
+ }
218
+
219
+ static VALUE
220
+ rbatk_table_add_column_selection(self, column)
221
+ VALUE self, column;
222
+ {
223
+ gboolean ret = atk_table_add_column_selection(_SELF(self), NUM2INT(column));
224
+ if (! ret) rb_raise(rb_eRuntimeError, "not implement this interface");
225
+ return self;
226
+ }
227
+
228
+ static VALUE
229
+ rbatk_table_add_row_selection(self, row)
230
+ VALUE self, row;
231
+ {
232
+ gboolean ret = atk_table_add_row_selection(_SELF(self), NUM2INT(row));
233
+ if (! ret) rb_raise(rb_eRuntimeError, "not implement this interface");
234
+ return self;
235
+ }
236
+
237
+ static VALUE
238
+ rbatk_table_remove_column_selection(self, column)
239
+ VALUE self, column;
240
+ {
241
+ gboolean ret = atk_table_remove_column_selection(_SELF(self), NUM2INT(column));
242
+ if (! ret) rb_raise(rb_eRuntimeError, "not implement this interface");
243
+ return self;
244
+ }
245
+
246
+ static VALUE
247
+ rbatk_table_remove_row_selection(self, row)
248
+ VALUE self, row;
249
+ {
250
+ gboolean ret = atk_table_remove_row_selection(_SELF(self), NUM2INT(row));
251
+ if (! ret) rb_raise(rb_eRuntimeError, "not implement this interface");
252
+ return self;
253
+ }
254
+
255
+ void
256
+ Init_atk_table()
257
+ {
258
+ VALUE mTable = G_DEF_INTERFACE(ATK_TYPE_TABLE, "Table", mAtk);
259
+
260
+ rb_define_method(mTable, "set_caption", rbatk_table_set_caption, 1);
261
+ rb_define_method(mTable, "ref_at", rbatk_table_ref_at, 2);
262
+ rb_define_method(mTable, "get_index_at", rbatk_table_get_index_at, 2);
263
+ rb_define_method(mTable, "get_column_at_index", rbatk_table_get_column_at_index, 1);
264
+ rb_define_method(mTable, "get_row_at_index", rbatk_table_get_row_at_index, 1);
265
+ rb_define_method(mTable, "n_columns", rbatk_table_get_n_columns, 0);
266
+ rb_define_method(mTable, "n_rows", rbatk_table_get_n_rows, 0);
267
+ rb_define_method(mTable, "get_column_extent_at", rbatk_table_get_column_extent_at, 2);
268
+ rb_define_method(mTable, "get_row_extent_at", rbatk_table_get_row_extent_at, 2);
269
+ rb_define_method(mTable, "caption", rbatk_table_get_caption, 0);
270
+ rb_define_method(mTable, "get_column_description", rbatk_table_get_column_description, 1);
271
+ rb_define_method(mTable, "get_row_description", rbatk_table_get_row_description, 1);
272
+ rb_define_method(mTable, "get_column_header", rbatk_table_get_column_header, 1);
273
+ rb_define_method(mTable, "get_row_header", rbatk_table_get_row_header, 1);
274
+ rb_define_method(mTable, "summary", rbatk_table_get_summary, 0);
275
+ rb_define_method(mTable, "set_caption", rbatk_table_set_caption, 1);
276
+ rb_define_method(mTable, "set_row_description", rbatk_table_set_row_description, 2);
277
+ rb_define_method(mTable, "set_column_description", rbatk_table_set_column_description, 2);
278
+ rb_define_method(mTable, "set_row_header", rbatk_table_set_row_header, 2);
279
+ rb_define_method(mTable, "set_column_header", rbatk_table_set_column_header, 2);
280
+ rb_define_method(mTable, "set_summary", rbatk_table_set_summary, 1);
281
+ rb_define_method(mTable, "selected_columns", rbatk_table_get_selected_columns, 0);
282
+ rb_define_method(mTable, "selected_rows", rbatk_table_get_selected_rows, 0);
283
+ rb_define_method(mTable, "column_selected?", rbatk_table_is_column_selected, 1);
284
+ rb_define_method(mTable, "row_selected?", rbatk_table_is_row_selected, 1);
285
+ rb_define_method(mTable, "selected?", rbatk_table_is_selected, 2);
286
+ rb_define_method(mTable, "add_column_selection", rbatk_table_add_column_selection, 1);
287
+ rb_define_method(mTable, "add_row_selection", rbatk_table_add_row_selection, 1);
288
+ rb_define_method(mTable, "remove_column_selection", rbatk_table_remove_column_selection, 1);
289
+ rb_define_method(mTable, "remove_row_selection", rbatk_table_remove_row_selection, 1);
290
+
291
+ G_DEF_SETTERS(mTable);
292
+ }
@@ -0,0 +1,364 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbatktext.c -
5
+
6
+ $Author: sakai $
7
+ $Date: 2006/05/26 14:12:06 $
8
+
9
+ Copyright (C) 2004 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbatk.h"
13
+
14
+ #define _SELF(s) (ATK_TEXT(RVAL2GOBJ(s)))
15
+
16
+ static VALUE
17
+ rbatk_text_get_text(self, start_offset, end_offset)
18
+ VALUE self, start_offset, end_offset;
19
+ {
20
+ VALUE ret;
21
+ gchar* text = atk_text_get_text(_SELF(self),
22
+ NUM2INT(start_offset),
23
+ NUM2INT(end_offset));
24
+ ret = CSTR2RVAL(text);
25
+ g_free(text);
26
+ return ret;
27
+ }
28
+
29
+ static VALUE
30
+ rbatk_text_get_character_at_offset(self, offset)
31
+ VALUE self, offset;
32
+ {
33
+ gchar buf[10];
34
+ gint len = g_unichar_to_utf8(atk_text_get_character_at_offset
35
+ (_SELF(self), NUM2INT(offset)), buf);
36
+ buf[len] = '\0';
37
+ return rb_str_new2(buf);
38
+ }
39
+
40
+ static VALUE
41
+ rbatk_text_get_text_after_offset(self, offset, boundary_type)
42
+ VALUE self, offset, boundary_type;
43
+ {
44
+ gchar* ret;
45
+ VALUE result;
46
+ gint start_offset, end_offset;
47
+
48
+ ret = atk_text_get_text_after_offset(_SELF(self), NUM2INT(offset),
49
+ RVAL2GENUM(boundary_type, ATK_TYPE_TEXT_BOUNDARY),
50
+ &start_offset, &end_offset);
51
+ result = rb_ary_new3(3, CSTR2RVAL(ret),
52
+ INT2NUM(start_offset), INT2NUM(end_offset));
53
+ g_free(ret);
54
+
55
+ return result;
56
+ }
57
+
58
+ static VALUE
59
+ rbatk_text_get_text_at_offset(self, offset, boundary_type)
60
+ VALUE self, offset, boundary_type;
61
+ {
62
+ gchar* ret;
63
+ VALUE result;
64
+ gint start_offset, end_offset;
65
+
66
+ ret = atk_text_get_text_at_offset(_SELF(self), NUM2INT(offset),
67
+ RVAL2GENUM(boundary_type, ATK_TYPE_TEXT_BOUNDARY),
68
+ &start_offset, &end_offset);
69
+ result = rb_ary_new3(3, CSTR2RVAL(ret),
70
+ INT2NUM(start_offset), INT2NUM(end_offset));
71
+ g_free(ret);
72
+
73
+ return result;
74
+ }
75
+
76
+ static VALUE
77
+ rbatk_text_get_text_before_offset(self, offset, boundary_type)
78
+ VALUE self, offset, boundary_type;
79
+ {
80
+ gchar* ret;
81
+ VALUE result;
82
+ gint start_offset, end_offset;
83
+
84
+ ret = atk_text_get_text_before_offset(_SELF(self), NUM2INT(offset),
85
+ RVAL2GENUM(boundary_type, ATK_TYPE_TEXT_BOUNDARY),
86
+ &start_offset, &end_offset);
87
+ result = rb_ary_new3(3, CSTR2RVAL(ret),
88
+ INT2NUM(start_offset), INT2NUM(end_offset));
89
+ g_free(ret);
90
+
91
+ return result;
92
+ }
93
+
94
+ static VALUE
95
+ rbatk_text_get_caret_offset(self)
96
+ VALUE self;
97
+ {
98
+ return INT2NUM(atk_text_get_caret_offset(_SELF(self)));
99
+ }
100
+
101
+ static VALUE
102
+ rbatk_text_get_character_extents(self, offset, coords)
103
+ VALUE self, offset, coords;
104
+ {
105
+ gint x, y, width, height;
106
+ atk_text_get_character_extents(_SELF(self), NUM2INT(offset),
107
+ &x, &y, &width, &height,
108
+ RVAL2GENUM(coords, ATK_TYPE_COORD_TYPE));
109
+ return rb_ary_new3(4, INT2NUM(x), INT2NUM(y), INT2NUM(width), INT2NUM(height));
110
+ }
111
+
112
+ static VALUE
113
+ rbatk_text_get_run_attributes(self, offset)
114
+ VALUE self, offset;
115
+ {
116
+ gint start_offset, end_offset;
117
+ AtkAttributeSet* list;
118
+ VALUE ary;
119
+
120
+ list = atk_text_get_run_attributes(_SELF(self), NUM2INT(offset),
121
+ &start_offset, &end_offset);
122
+
123
+ ary = rb_ary_new();
124
+
125
+ while (list) {
126
+ AtkAttribute* data = (AtkAttribute*)list->data;
127
+ rb_ary_push(ary, rb_assoc_new(CSTR2RVAL(data->name),
128
+ CSTR2RVAL(data->value)));
129
+ list = list->next;
130
+ }
131
+ atk_attribute_set_free(list);
132
+ return ary;
133
+ }
134
+
135
+ static VALUE
136
+ rbatk_text_get_default_attributes(self)
137
+ VALUE self;
138
+ {
139
+ AtkAttributeSet* list;
140
+ VALUE ary;
141
+
142
+ list = atk_text_get_default_attributes(_SELF(self));
143
+ ary = rb_ary_new();
144
+
145
+ while (list) {
146
+ AtkAttribute* data = (AtkAttribute*)list->data;
147
+ rb_ary_push(ary, rb_assoc_new(CSTR2RVAL(data->name),
148
+ CSTR2RVAL(data->value)));
149
+ list = list->next;
150
+ }
151
+ atk_attribute_set_free(list);
152
+ return ary;
153
+ }
154
+
155
+ static VALUE
156
+ rbatk_text_get_character_count(self)
157
+ VALUE self;
158
+ {
159
+ return INT2NUM(atk_text_get_character_count(_SELF(self)));
160
+ }
161
+
162
+ static VALUE
163
+ rbatk_text_get_offset_at_point(self, x, y, coords)
164
+ VALUE self, x, y, coords;
165
+ {
166
+ return INT2NUM(atk_text_get_offset_at_point(_SELF(self),
167
+ NUM2INT(x), NUM2INT(y),
168
+ RVAL2GENUM(coords, ATK_TYPE_COORD_TYPE)));
169
+ }
170
+
171
+ #ifdef HAVE_ATK_TEXT_GET_BOUNDED_RANGES
172
+ #ifdef HAVE_ATK_TEXT_CLIP_TYPE_GET_TYPE
173
+ static VALUE
174
+ rbatk_text_get_bounded_ranges(self, rect, coord_type, x_clip_type, y_clip_type)
175
+ VALUE self, rect, coord_type, x_clip_type, y_clip_type;
176
+ {
177
+ AtkTextRange** ranges;
178
+ int i = 0;
179
+ VALUE ary;
180
+ ranges = atk_text_get_bounded_ranges(_SELF(self),
181
+ RVAL2BOXED(rect, ATK_TYPE_TEXT_RECTANGLE),
182
+ RVAL2GENUM(coord_type, ATK_TYPE_COORD_TYPE),
183
+ RVAL2GENUM(x_clip_type, ATK_TYPE_TEXT_CLIP_TYPE),
184
+ RVAL2GENUM(y_clip_type, ATK_TYPE_TEXT_CLIP_TYPE));
185
+ ary = rb_ary_new();
186
+ while(ranges[i]){
187
+ rb_ary_push(ary, BOXED2RVAL(ranges[i], ATK_TYPE_TEXT_RANGE));
188
+ i++;
189
+ }
190
+ #ifdef HAVE_ATK_TEXT_FREE_RANGES
191
+ atk_text_free_ranges(ranges);
192
+ #endif
193
+ return ary;
194
+ }
195
+ #endif
196
+
197
+ static VALUE
198
+ rbatk_text_get_range_extents(self, start_offset, end_offset, coord_type)
199
+ VALUE self, start_offset, end_offset, coord_type;
200
+ {
201
+ AtkTextRectangle rect;
202
+ atk_text_get_range_extents(_SELF(self), NUM2INT(start_offset),
203
+ NUM2INT(end_offset),
204
+ RVAL2GENUM(coord_type, ATK_TYPE_COORD_TYPE),
205
+ &rect);
206
+ return BOXED2RVAL(&rect, ATK_TYPE_TEXT_RECTANGLE);
207
+ }
208
+
209
+ /* Don't need this
210
+ void atk_text_free_ranges (AtkTextRange **ranges);
211
+ */
212
+ #endif
213
+
214
+ static VALUE
215
+ rbatk_text_get_n_selections(self)
216
+ VALUE self;
217
+ {
218
+ return INT2NUM(atk_text_get_n_selections(_SELF(self)));
219
+ }
220
+
221
+ static VALUE
222
+ rbatk_text_get_selection(self, selection_num)
223
+ VALUE self, selection_num;
224
+ {
225
+ gint start_offset, end_offset;
226
+ VALUE ret;
227
+ gchar* text = atk_text_get_selection(_SELF(self), NUM2INT(selection_num),
228
+ &start_offset, &end_offset);
229
+ ret = CSTR2RVAL(text);
230
+ g_free(text);
231
+
232
+ return ret;
233
+ }
234
+
235
+ static VALUE
236
+ rbatk_text_add_selection(self, start_offset, end_offset)
237
+ VALUE self, start_offset, end_offset;
238
+ {
239
+ gboolean ret = atk_text_add_selection(_SELF(self), NUM2INT(start_offset),
240
+ NUM2INT(end_offset));
241
+ if (! ret) rb_raise(rb_eRuntimeError, "Can't add selection");
242
+ return self;
243
+ }
244
+
245
+ static VALUE
246
+ rbatk_text_remove_selection(self, selection_num)
247
+ VALUE self, selection_num;
248
+ {
249
+ gint num;
250
+ gboolean ret;
251
+
252
+ num = NUM2INT(selection_num);
253
+ ret = atk_text_remove_selection(_SELF(self), num);
254
+ if (! ret)
255
+ rb_raise(rb_eRuntimeError, "Can't remove selection. num = %d", num);
256
+ return self;
257
+ }
258
+
259
+ static VALUE
260
+ rbatk_text_set_selection(self, selection_num, start_offset, end_offset)
261
+ VALUE self, selection_num, start_offset, end_offset;
262
+ {
263
+ gboolean ret = atk_text_set_selection(_SELF(self), NUM2INT(selection_num),
264
+ NUM2INT(start_offset),
265
+ NUM2INT(end_offset));
266
+ if (! ret) rb_raise(rb_eRuntimeError, "Can't set selection");
267
+ return self;
268
+ }
269
+
270
+ static VALUE
271
+ rbatk_text_set_caret_offset(self, offset)
272
+ VALUE self, offset;
273
+ {
274
+ gboolean ret = atk_text_set_caret_offset(_SELF(self), NUM2INT(offset));
275
+ if (! ret) rb_raise(rb_eRuntimeError, "Can't set caret offset");
276
+ return self;
277
+ }
278
+
279
+
280
+ /* We don't need them.
281
+ void atk_attribute_set_free (AtkAttributeSet *attrib_set);
282
+ */
283
+
284
+ /*
285
+ * Atk::TextAttribute
286
+ */
287
+ static VALUE
288
+ rbatk_tattr_s_register(self, name)
289
+ VALUE self, name;
290
+ {
291
+ return GENUM2RVAL(atk_text_attribute_register(RVAL2CSTR(name)), ATK_TYPE_TEXT_ATTRIBUTE);
292
+ }
293
+
294
+ /* We don't need this.
295
+ G_CONST_RETURN gchar* atk_textattribute_type_get_name
296
+ (AtkTextattributeType type);
297
+ */
298
+
299
+ static VALUE
300
+ rbatk_tattr_s_for_name(self, name)
301
+ VALUE self, name;
302
+ {
303
+ return GENUM2RVAL(atk_text_attribute_for_name(RVAL2CSTR(name)), ATK_TYPE_TEXT_ATTRIBUTE);
304
+ }
305
+
306
+ static VALUE
307
+ rbatk_tattr_get_value(self, index)
308
+ VALUE self, index;
309
+ {
310
+ return CSTR2RVAL(atk_text_attribute_get_value(RVAL2GENUM(self, ATK_TYPE_TEXT_ATTRIBUTE),
311
+ NUM2INT(index)));
312
+ }
313
+ void
314
+ Init_atk_text()
315
+ {
316
+ VALUE tattr;
317
+ VALUE mText = G_DEF_INTERFACE(ATK_TYPE_TEXT, "Text", mAtk);
318
+
319
+ rb_define_method(mText, "get_text", rbatk_text_get_text, 2);
320
+ rb_define_method(mText, "get_character_at_offset", rbatk_text_get_character_at_offset, 1);
321
+ rb_define_method(mText, "get_text_after_offset", rbatk_text_get_text_after_offset, 2);
322
+ rb_define_method(mText, "get_text_at_offset", rbatk_text_get_text_at_offset, 2);
323
+ rb_define_method(mText, "get_text_before_offset", rbatk_text_get_text_before_offset, 2);
324
+ rb_define_method(mText, "caret_offset", rbatk_text_get_caret_offset, 0);
325
+ rb_define_method(mText, "get_character_extents", rbatk_text_get_character_extents, 2);
326
+ rb_define_method(mText, "get_run_attributes", rbatk_text_get_run_attributes, 1);
327
+ rb_define_method(mText, "default_attributes", rbatk_text_get_default_attributes, 0);
328
+ rb_define_method(mText, "character_count", rbatk_text_get_character_count, 0);
329
+ rb_define_method(mText, "get_offset_at_point", rbatk_text_get_offset_at_point, 3);
330
+ #ifdef HAVE_ATK_TEXT_GET_BOUNDED_RANGES
331
+ #ifdef HAVE_ATK_TEXT_CLIP_TYPE_GET_TYPE
332
+ rb_define_method(mText, "get_bounded_ranges", rbatk_text_get_bounded_ranges, 4);
333
+ rb_define_method(mText, "get_range_extents", rbatk_text_get_range_extents, 3);
334
+ #endif
335
+ #endif
336
+ rb_define_method(mText, "n_selections", rbatk_text_get_n_selections, 0);
337
+ rb_define_method(mText, "get_selection", rbatk_text_get_selection, 1);
338
+ rb_define_method(mText, "add_selection", rbatk_text_add_selection, 2);
339
+ rb_define_method(mText, "remove_selection", rbatk_text_remove_selection, 1);
340
+ rb_define_method(mText, "set_selection", rbatk_text_set_selection, 3);
341
+ rb_define_method(mText, "set_caret_offset", rbatk_text_set_caret_offset, 1);
342
+
343
+ G_DEF_SETTERS(mText);
344
+
345
+ /* AtkTextBoundary */
346
+ #ifdef ATK_TYPE_TEXT_BOUNDARY
347
+ G_DEF_CLASS(ATK_TYPE_TEXT_BOUNDARY, "Boundary", mText);
348
+ G_DEF_CONSTANTS(mText, ATK_TYPE_TEXT_BOUNDARY, "ATK_TEXT_");
349
+ #endif
350
+ /* AtkTextClipType */
351
+ #ifdef HAVE_ATK_TEXT_GET_BOUNDED_RANGES
352
+ #ifdef HAVE_ATK_TEXT_CLIP_TYPE_GET_TYPE
353
+ G_DEF_CLASS(ATK_TYPE_TEXT_CLIP_TYPE, "ClipType", mText);
354
+ G_DEF_CONSTANTS(mText, ATK_TYPE_TEXT_CLIP_TYPE, "ATK_TEXT_");
355
+ #endif
356
+ #endif
357
+
358
+ tattr = G_DEF_CLASS(ATK_TYPE_TEXT_ATTRIBUTE, "Attribute", mText);
359
+ G_DEF_CONSTANTS(mText, ATK_TYPE_TEXT_ATTRIBUTE, "ATK_TEXT_");
360
+
361
+ rb_define_singleton_method(tattr, "type_register", rbatk_tattr_s_register, 1);
362
+ rb_define_singleton_method(tattr, "for_name", rbatk_tattr_s_for_name, 1);
363
+ rb_define_method(tattr, "get_value", rbatk_tattr_get_value, 1);
364
+ }