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,36 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+ rbatk.h -
4
+
5
+ $Author: mutoh $
6
+ $Date: 2005/09/15 17:30:46 $
7
+
8
+ Copyright (C) 2003,2004 Masao Mutoh
9
+ ************************************************/
10
+ #include "ruby.h"
11
+ #include <atk/atk.h>
12
+ #include <atk/atk-enum-types.h>
13
+ #include <atk/atknoopobject.h>
14
+ #include <atk/atknoopobjectfactory.h>
15
+ #include "rbgobject.h"
16
+ #include "rbatkversion.h"
17
+
18
+
19
+ #if defined(G_PLATFORM_WIN32) && !defined(RUBY_ATK_STATIC_COMPILATION)
20
+ # ifdef RUBY_ATK_COMPILATION
21
+ # define RUBY_ATK_VAR __declspec(dllexport)
22
+ # else
23
+ # define RUBY_ATK_VAR extern __declspec(dllimport)
24
+ # endif
25
+ #else
26
+ # define RUBY_ATK_VAR extern
27
+ #endif
28
+
29
+ extern void Init_atk_inits();
30
+ extern GType atk_text_rectangle_get_type(void);
31
+ extern GType atk_text_range_get_type(void);
32
+
33
+ RUBY_ATK_VAR VALUE mAtk;
34
+
35
+ #define ATK_TYPE_TEXT_RECTANGLE (atk_text_rectangle_get_type())
36
+ #define ATK_TYPE_TEXT_RANGE (atk_text_range_get_type())
@@ -0,0 +1,81 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbatkaction.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2004/03/05 15:33:47 $
8
+
9
+ Copyright (C) 2004 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbatk.h"
13
+
14
+ #define _SELF(s) (ATK_ACTION(RVAL2GOBJ(s)))
15
+
16
+ static VALUE
17
+ rbatk_action_do_action(self, i)
18
+ VALUE self, i;
19
+ {
20
+ return CBOOL2RVAL(atk_action_do_action(_SELF(self), NUM2INT(i)));
21
+ }
22
+
23
+ static VALUE
24
+ rbatk_action_get_n_actions(self)
25
+ VALUE self;
26
+ {
27
+ return INT2NUM(atk_action_get_n_actions(_SELF(self)));
28
+ }
29
+
30
+ static VALUE
31
+ rbatk_action_get_description(self, i)
32
+ VALUE self, i;
33
+ {
34
+ return CSTR2RVAL(atk_action_get_description(_SELF(self), NUM2INT(i)));
35
+ }
36
+
37
+ static VALUE
38
+ rbatk_action_get_name(self, i)
39
+ VALUE self, i;
40
+ {
41
+ return CSTR2RVAL(atk_action_get_name(_SELF(self), NUM2INT(i)));
42
+ }
43
+
44
+ #ifdef HAVE_ATK_ACTION_GET_LOCALIZED_NAME
45
+ static VALUE
46
+ rbatk_action_get_localized_name(self, i)
47
+ VALUE self, i;
48
+ {
49
+ return CSTR2RVAL(atk_action_get_localized_name(_SELF(self), NUM2INT(i)));
50
+ }
51
+ #endif
52
+
53
+ static VALUE
54
+ rbatk_action_get_keybinding(self, i)
55
+ VALUE self, i;
56
+ {
57
+ return CSTR2RVAL(atk_action_get_keybinding(_SELF(self), NUM2INT(i)));
58
+ }
59
+
60
+ static VALUE
61
+ rbatk_action_set_description(self, i, desc)
62
+ VALUE self, i, desc;
63
+ {
64
+ return CBOOL2RVAL(atk_action_set_description(_SELF(self), NUM2INT(i), RVAL2CSTR(desc)));
65
+ }
66
+
67
+ void
68
+ Init_atk_action()
69
+ {
70
+ VALUE mAction = G_DEF_INTERFACE(ATK_TYPE_ACTION, "Action", mAtk);
71
+
72
+ rb_define_method(mAction, "do_action", rbatk_action_do_action, 1);
73
+ rb_define_method(mAction, "n_actions", rbatk_action_get_n_actions, 0);
74
+ rb_define_method(mAction, "get_description", rbatk_action_get_description, 1);
75
+ rb_define_method(mAction, "get_name", rbatk_action_get_name, 1);
76
+ #ifdef HAVE_ATK_ACTION_GET_LOCALIZED_NAME
77
+ rb_define_method(mAction, "get_localized_name", rbatk_action_get_localized_name, 1);
78
+ #endif
79
+ rb_define_method(mAction, "get_keybinding", rbatk_action_get_keybinding, 1);
80
+ rb_define_method(mAction, "set_description", rbatk_action_set_description, 2);
81
+ }
@@ -0,0 +1,184 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbatkcomponent.c -
5
+
6
+ $Author: sakai $
7
+ $Date: 2007/07/08 02:51:52 $
8
+
9
+ Copyright (C) 2004 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbatk.h"
13
+
14
+ #define _SELF(s) (ATK_COMPONENT(RVAL2GOBJ(s)))
15
+
16
+ /*
17
+ static void
18
+ focus_handler(aobj, bool)
19
+ AtkObject* aobj;
20
+ gboolean bool;
21
+ {
22
+ VALUE ret = rb_funcall((VALUE)func, id_call, 2,
23
+ GOBJ2RVAL(aobj), CBOOL2RVAL(bool));
24
+ }
25
+ static VALUE
26
+ comp_add_focus_handler(self)
27
+ VALUE self;
28
+ {
29
+ VALUE func = rb_block_proc();
30
+ G_RELATIVE(self, func);
31
+ return UINT2NUM(atk_component_add_focus_handler(_SELF(self), focus_handler));
32
+ }
33
+ */
34
+
35
+ static VALUE
36
+ comp_contains(self, x, y, coord_type)
37
+ VALUE self, x, y, coord_type;
38
+ {
39
+ return CBOOL2RVAL(atk_component_contains(_SELF(self),
40
+ NUM2INT(x), NUM2INT(y),
41
+ RVAL2GENUM(coord_type, ATK_TYPE_COORD_TYPE)));
42
+ }
43
+
44
+ static VALUE
45
+ comp_get_extents(self, coord_type)
46
+ VALUE self, coord_type;
47
+ {
48
+ gint x, y, width, height;
49
+ atk_component_get_extents(_SELF(self), &x, &y, &width, &height,
50
+ RVAL2GENUM(coord_type, ATK_TYPE_COORD_TYPE));
51
+ return rb_ary_new3(4, INT2NUM(x), INT2NUM(y), INT2NUM(width), INT2NUM(height));
52
+ }
53
+
54
+ #ifdef HAVE_ATK_COMPONENT_GET_LAYER
55
+ static VALUE
56
+ comp_get_layer(self)
57
+ VALUE self;
58
+ {
59
+ return GENUM2RVAL(atk_component_get_layer(_SELF(self)), ATK_TYPE_LAYER);
60
+ }
61
+ #endif
62
+
63
+ #ifdef HAVE_ATK_COMPONENT_GET_MDI_ZORDER
64
+ static VALUE
65
+ comp_get_mdi_zorder(self)
66
+ VALUE self;
67
+ {
68
+ return INT2NUM(atk_component_get_mdi_zorder(_SELF(self)));
69
+ }
70
+
71
+ #endif
72
+ static VALUE
73
+ comp_get_position(self, coord_type)
74
+ VALUE self, coord_type;
75
+ {
76
+ gint x, y;
77
+ atk_component_get_position(_SELF(self), &x, &y,
78
+ RVAL2GENUM(coord_type, ATK_TYPE_COORD_TYPE));
79
+ return rb_assoc_new(INT2NUM(x), INT2NUM(y));
80
+ }
81
+
82
+ static VALUE
83
+ comp_get_size(self)
84
+ VALUE self;
85
+ {
86
+ gint width, height;
87
+ atk_component_get_size(_SELF(self), &width, &height);
88
+ return rb_assoc_new(INT2NUM(width), INT2NUM(height));
89
+ }
90
+
91
+ static VALUE
92
+ comp_grab_focus(self)
93
+ VALUE self;
94
+ {
95
+ return CBOOL2RVAL(atk_component_grab_focus(_SELF(self)));
96
+ }
97
+
98
+ static VALUE
99
+ comp_ref_accessible_at_point(self, x, y, coord_type)
100
+ VALUE self, x, y, coord_type;
101
+ {
102
+ return GOBJ2RVAL(atk_component_ref_accessible_at_point(
103
+ _SELF(self),
104
+ NUM2INT(x), NUM2INT(y),
105
+ RVAL2GENUM(coord_type, ATK_TYPE_COORD_TYPE)));
106
+ }
107
+
108
+ static VALUE
109
+ comp_remove_focus_handler(self, handler_id)
110
+ VALUE self, handler_id;
111
+ {
112
+ atk_component_remove_focus_handler(_SELF(self), NUM2UINT(handler_id));
113
+ return self;
114
+ }
115
+
116
+ static VALUE
117
+ comp_set_extents(self, x, y, width, height, coord_type)
118
+ VALUE self, x, y, width, height, coord_type;
119
+ {
120
+ gboolean ret = atk_component_set_extents(_SELF(self),
121
+ NUM2INT(x), NUM2INT(y),
122
+ NUM2INT(width), NUM2INT(height),
123
+ RVAL2GENUM(coord_type, ATK_TYPE_COORD_TYPE));
124
+ if (! ret) rb_raise(rb_eRuntimeError, "Can't set extents");
125
+ return self;
126
+ }
127
+
128
+ static VALUE
129
+ comp_set_position(self, x, y, coord_type)
130
+ VALUE self, x, y, coord_type;
131
+ {
132
+ gboolean ret = atk_component_set_position(_SELF(self),
133
+ NUM2INT(x), NUM2INT(y),
134
+ RVAL2GENUM(coord_type, ATK_TYPE_COORD_TYPE));
135
+ if (! ret) rb_raise(rb_eRuntimeError, "Can't set the position");
136
+ return self;
137
+ }
138
+
139
+ static VALUE
140
+ comp_set_size(self, width, height)
141
+ VALUE self, width, height;
142
+ {
143
+ gboolean ret = atk_component_set_size(_SELF(self),
144
+ NUM2INT(width), NUM2INT(height));
145
+ if (! ret) rb_raise(rb_eRuntimeError, "Can't set the size");
146
+ return self;
147
+ }
148
+
149
+ #if ATK_CHECK_VERSION(1,12,0)
150
+ static VALUE
151
+ comp_get_alpha(self)
152
+ VALUE self;
153
+ {
154
+ return rb_float_new(atk_component_get_alpha(_SELF(self)));
155
+ }
156
+ #endif
157
+
158
+ void
159
+ Init_atk_component()
160
+ {
161
+ VALUE comp = G_DEF_INTERFACE(ATK_TYPE_COMPONENT, "Component", mAtk);
162
+ /*
163
+ rb_define_method(comp, "add_focus_handler", comp_add_focus_handler, 0);
164
+ */
165
+ rb_define_method(comp, "contains?", comp_contains, 3);
166
+ rb_define_method(comp, "get_extents", comp_get_extents, 1);
167
+ #ifdef HAVE_ATK_COMPONENT_GET_LAYER
168
+ rb_define_method(comp, "layer", comp_get_layer, 0);
169
+ #endif
170
+ #ifdef HAVE_ATK_COMPONENT_GET_MDI_ZORDER
171
+ rb_define_method(comp, "mdi_zorder", comp_get_mdi_zorder, 0);
172
+ #endif
173
+ rb_define_method(comp, "position", comp_get_position, 1);
174
+ rb_define_method(comp, "size", comp_get_size, 0);
175
+ rb_define_method(comp, "grab_focus", comp_grab_focus, 0);
176
+ rb_define_method(comp, "ref_accessible_at_point", comp_ref_accessible_at_point, 3);
177
+ rb_define_method(comp, "remove_focus_handler", comp_remove_focus_handler, 1);
178
+ rb_define_method(comp, "set_extents", comp_set_extents, 5);
179
+ rb_define_method(comp, "set_position", comp_set_position, 2);
180
+ rb_define_method(comp, "set_size", comp_set_size, 2);
181
+ #if ATK_CHECK_VERSION(1,12,0)
182
+ rb_define_method(comp, "alpha", comp_get_alpha, 0);
183
+ #endif
184
+ }
@@ -0,0 +1,95 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbatkdocument.c -
5
+
6
+ $Author: sakai $
7
+ $Date: 2007/06/16 09:18:55 $
8
+
9
+ Copyright (C) 2003 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbatk.h"
13
+
14
+ #define _SELF(s) (ATK_DOCUMENT(RVAL2GOBJ(s)))
15
+
16
+ static VALUE
17
+ rbatk_document_get_document_type(self)
18
+ VALUE self;
19
+ {
20
+ return CSTR2RVAL(atk_document_get_document_type(_SELF(self)));
21
+ }
22
+
23
+ /*
24
+ How can I implement this?
25
+ static VALUE
26
+ rbatk_document_get_document(self)
27
+ VALUE self;
28
+ {
29
+ return GOBJ2RVAL(atk_document_get_document(_SELF(self)));
30
+ }
31
+ */
32
+
33
+ #if ATK_CHECK_VERSION(1,12,0)
34
+ static VALUE
35
+ rbatk_document_get_attribute_value(self, name)
36
+ VALUE self, name;
37
+ {
38
+ return CSTR2RVAL(atk_document_get_attribute_value(_SELF(self),
39
+ (const gchar*)RVAL2CSTR(name)));
40
+ }
41
+
42
+ static VALUE
43
+ rbatk_document_set_attribute_value(self, name, value)
44
+ VALUE self, name, value;
45
+ {
46
+ gboolean ret = atk_document_set_attribute_value(_SELF(self),
47
+ (const gchar*)RVAL2CSTR(name),
48
+ (const gchar*)RVAL2CSTR(value));
49
+
50
+ if (! ret) rb_raise(rb_eRuntimeError, "Can't set attribute value: %s, %s",
51
+ RVAL2CSTR(name), RVAL2CSTR(value));
52
+
53
+ return self;
54
+ }
55
+
56
+ static VALUE
57
+ rbatk_document_get_attributes(self)
58
+ VALUE self;
59
+ {
60
+ AtkAttributeSet* list = atk_document_get_attributes(_SELF(self));
61
+ VALUE ary = rb_ary_new();
62
+ while (list) {
63
+ AtkAttribute* attr = list->data;
64
+ rb_ary_push(ary, rb_assoc_new(CSTR2RVAL(attr->name), CSTR2RVAL(attr->value)));
65
+ list = list->next;
66
+ }
67
+ return ary;
68
+ }
69
+
70
+ static VALUE
71
+ rbatk_document_get_locale(self)
72
+ VALUE self;
73
+ {
74
+ return CSTR2RVAL(atk_document_get_locale(_SELF(self)));
75
+ }
76
+ #endif
77
+
78
+ void
79
+ Init_atk_document()
80
+ {
81
+ VALUE mDoc = G_DEF_INTERFACE(ATK_TYPE_DOCUMENT, "Document", mAtk);
82
+
83
+ rb_define_method(mDoc, "document_type", rbatk_document_get_document_type, 0);
84
+ /*
85
+ rb_define_method(mDoc, "document", rbatk_document_get_document, 0);
86
+ */
87
+ #if ATK_CHECK_VERSION(1,12,0)
88
+ rb_define_method(mDoc, "get_attribute_value", rbatk_document_get_attribute_value, 1);
89
+ rb_define_alias(mDoc, "[]", "get_attribute_value");
90
+ rb_define_method(mDoc, "set_attribute_value", rbatk_document_set_attribute_value, 2);
91
+ rb_define_alias(mDoc, "[]=", "set_attribute_value");
92
+ rb_define_method(mDoc, "attributes", rbatk_document_get_attributes, 0);
93
+ rb_define_method(mDoc, "locale", rbatk_document_get_locale, 0);
94
+ #endif
95
+ }
@@ -0,0 +1,102 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbatkeditabletext.c -
5
+
6
+ $Author: sakai $
7
+ $Date: 2007/06/16 09:24:04 $
8
+
9
+ Copyright (C) 2003 Masao Mutoh
10
+ ************************************************/
11
+ #include "rbatk.h"
12
+
13
+ #define _SELF(s) (ATK_EDITABLE_TEXT(RVAL2GOBJ(s)))
14
+
15
+ static VALUE
16
+ rbatk_edit_set_run_attributes(self, attributes, start_offset, end_offset)
17
+ VALUE self, attributes, start_offset, end_offset;
18
+ {
19
+ long i;
20
+ gboolean ret;
21
+ AtkAttributeSet* list = NULL;
22
+
23
+ if (NIL_P(attributes)) return Qfalse;
24
+
25
+ Check_Type(attributes, T_ARRAY);
26
+ for (i=0; i<RARRAY_LEN(attributes); i++) {
27
+ list = g_slist_append(list, RVAL2GOBJ(RARRAY_PTR(attributes)[i]));
28
+ }
29
+
30
+ ret = CBOOL2RVAL(atk_editable_text_set_run_attributes(
31
+ _SELF(self), list,
32
+ NUM2INT(start_offset), NUM2INT(end_offset)));
33
+ g_slist_free(list);
34
+ return ret;
35
+ }
36
+
37
+ static VALUE
38
+ rbatk_edit_set_text_contents(self, str)
39
+ VALUE self, str;
40
+ {
41
+ atk_editable_text_set_text_contents(_SELF(self), RVAL2CSTR(str));
42
+ return self;
43
+ }
44
+
45
+ static VALUE
46
+ rbatk_edit_insert_text(self, str, position)
47
+ VALUE self, str, position;
48
+ {
49
+ gint pos = NUM2INT(position);
50
+
51
+ StringValue(str);
52
+ atk_editable_text_insert_text(_SELF(self), RVAL2CSTR(str), RSTRING_LEN(str), &pos);
53
+ return INT2NUM(pos);
54
+ }
55
+
56
+ static VALUE
57
+ rbatk_edit_copy_text(self, start_pos, end_pos)
58
+ VALUE self, start_pos, end_pos;
59
+ {
60
+ atk_editable_text_copy_text(_SELF(self), NUM2INT(start_pos), NUM2INT(end_pos));
61
+ return self;
62
+ }
63
+
64
+ static VALUE
65
+ rbatk_edit_cut_text(self, start_pos, end_pos)
66
+ VALUE self, start_pos, end_pos;
67
+ {
68
+ atk_editable_text_cut_text(_SELF(self), NUM2INT(start_pos), NUM2INT(end_pos));
69
+ return self;
70
+ }
71
+
72
+ static VALUE
73
+ rbatk_edit_delete_text(self, start_pos, end_pos)
74
+ VALUE self, start_pos, end_pos;
75
+ {
76
+ atk_editable_text_delete_text(_SELF(self), NUM2INT(start_pos), NUM2INT(end_pos));
77
+ return self;
78
+ }
79
+
80
+ static VALUE
81
+ rbatk_edit_paste_text(self, position)
82
+ VALUE self, position;
83
+ {
84
+ atk_editable_text_paste_text(_SELF(self), NUM2INT(position));
85
+ return self;
86
+ }
87
+
88
+ void
89
+ Init_atk_editabletext()
90
+ {
91
+ VALUE editable = G_DEF_INTERFACE(ATK_TYPE_EDITABLE_TEXT, "EditableText", mAtk);
92
+
93
+ rb_define_method(editable, "set_run_attributes", rbatk_edit_set_run_attributes, 3);
94
+ rb_define_method(editable, "set_text_contents", rbatk_edit_set_text_contents, 1);
95
+ rb_define_method(editable, "insert_text", rbatk_edit_insert_text, 2);
96
+ rb_define_method(editable, "copy_text", rbatk_edit_copy_text, 2);
97
+ rb_define_method(editable, "cut_text", rbatk_edit_cut_text, 2);
98
+ rb_define_method(editable, "delete_text", rbatk_edit_delete_text, 2);
99
+ rb_define_method(editable, "paste_text", rbatk_edit_paste_text, 1);
100
+
101
+ G_DEF_SETTERS(editable);
102
+ }