atk 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,44 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbatkobjectfactory.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2003/12/07 18:12:33 $
8
+
9
+ Copyright (C) 2003 Masao Mutoh
10
+ ************************************************/
11
+ #include "rbatk.h"
12
+
13
+ #define _SELF(s) (ATK_OBJECT_FACTORY(RVAL2GOBJ(s)))
14
+
15
+ static VALUE
16
+ rbatkfact_create_accessible(self, obj)
17
+ VALUE self, obj;
18
+ {
19
+ return GOBJ2RVAL(atk_object_factory_create_accessible(_SELF(self), RVAL2GOBJ(obj)));
20
+ }
21
+
22
+ static VALUE
23
+ rbatkfact_get_accessible_type(self)
24
+ VALUE self;
25
+ {
26
+ return GTYPE2CLASS(atk_object_factory_get_accessible_type(_SELF(self)));
27
+ }
28
+
29
+ static VALUE
30
+ rbatkfact_invalidate(self)
31
+ VALUE self;
32
+ {
33
+ atk_object_factory_invalidate(_SELF(self));
34
+ return self;
35
+ }
36
+
37
+ void
38
+ Init_atk_objectfactory()
39
+ {
40
+ VALUE fact = G_DEF_CLASS(ATK_TYPE_OBJECT_FACTORY, "ObjectFactory", mAtk);
41
+ rb_define_method(fact, "create_accessible", rbatkfact_create_accessible, 0);
42
+ rb_define_method(fact, "accessible_type", rbatkfact_get_accessible_type, 0);
43
+ rb_define_method(fact, "invalidate", rbatkfact_invalidate, 0);
44
+ }
@@ -0,0 +1,55 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbatkregistry.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2003/12/07 18:12:33 $
8
+
9
+ Copyright (C) 2003 Masao Mutoh
10
+ ************************************************/
11
+ #include "rbatk.h"
12
+
13
+ #define _SELF(s) (ATK_REGISTRY(RVAL2GOBJ(s)))
14
+
15
+ static VALUE
16
+ rbatkregistry_set_factory_type(self, type, factory_type)
17
+ VALUE self, type, factory_type;
18
+ {
19
+ atk_registry_set_factory_type(_SELF(self),
20
+ CLASS2GTYPE(type),
21
+ CLASS2GTYPE(factory_type));
22
+ return self;
23
+ }
24
+
25
+ static VALUE
26
+ rbatkregistry_get_factory_type(self, type)
27
+ VALUE self, type;
28
+ {
29
+ return GTYPE2CLASS(atk_registry_get_factory_type(_SELF(self), CLASS2GTYPE(type)));
30
+ }
31
+
32
+ static VALUE
33
+ rbatkregistry_get_factory(self, type)
34
+ VALUE self, type;
35
+ {
36
+ return GOBJ2RVAL(atk_registry_get_factory(_SELF(self),
37
+ CLASS2GTYPE(type)));
38
+ }
39
+
40
+ static VALUE
41
+ rbatkregistry_s_get_default_registry(self)
42
+ VALUE self;
43
+ {
44
+ return GOBJ2RVAL(atk_get_default_registry());
45
+ }
46
+
47
+ void
48
+ Init_atk_registry()
49
+ {
50
+ VALUE registry = G_DEF_CLASS(ATK_TYPE_REGISTRY, "Registry", mAtk);
51
+ rb_define_method(registry, "set_factory_type", rbatkregistry_set_factory_type, 2);
52
+ rb_define_method(registry, "get_factory_type", rbatkregistry_get_factory_type, 1);
53
+ rb_define_method(registry, "get_factory", rbatkregistry_get_factory, 1);
54
+ rb_define_singleton_method(registry, "default_registry", rbatkregistry_s_get_default_registry, 0);
55
+ }
@@ -0,0 +1,104 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbatkrelation.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2005/09/15 17:30:46 $
8
+
9
+ Copyright (C) 2003 Masao Mutoh
10
+ ************************************************/
11
+ #include "rbatk.h"
12
+
13
+ #define _SELF(s) (ATK_RELATION(RVAL2GOBJ(s)))
14
+
15
+ static VALUE
16
+ rbatkrel_s_type_register(self, name)
17
+ VALUE self, name;
18
+ {
19
+ return GENUM2RVAL(atk_relation_type_register(RVAL2CSTR(name)), ATK_TYPE_RELATION_TYPE);
20
+ }
21
+
22
+ /* We don't need them
23
+ G_CONST_RETURN gchar* atk_relation_type_get_name
24
+ (AtkRelationType type);
25
+ */
26
+
27
+ static VALUE
28
+ rbatkrelation_s_for_name(self, name)
29
+ VALUE self, name;
30
+ {
31
+ return GENUM2RVAL(atk_relation_type_for_name(RVAL2CSTR(name)), ATK_TYPE_RELATION_TYPE);
32
+ }
33
+
34
+
35
+ static VALUE
36
+ rbatkrel_initialize(self, targets, relationship)
37
+ VALUE self, targets, relationship;
38
+ {
39
+ gint i;
40
+ gint len = RARRAY_LEN(targets);
41
+ AtkObject* objects = g_new(AtkObject, len);
42
+
43
+ for (i = 0; i < len; i++) {
44
+ objects = (AtkObject*)RARRAY_PTR(targets)[i];
45
+ objects++;
46
+ }
47
+
48
+ G_INITIALIZE(self, atk_relation_new(&objects, len,
49
+ RVAL2GENUM(relationship, ATK_TYPE_RELATION_TYPE)));
50
+ g_free(objects);
51
+
52
+ return Qnil;
53
+ }
54
+
55
+ static VALUE
56
+ rbatkrel_get_relation_type(self)
57
+ VALUE self;
58
+ {
59
+ return GENUM2RVAL(atk_relation_get_relation_type(_SELF(self)), ATK_TYPE_RELATION_TYPE);
60
+ }
61
+
62
+ static VALUE
63
+ rbatkrel_get_target(self)
64
+ VALUE self;
65
+ {
66
+ gint i;
67
+ GPtrArray* garray = atk_relation_get_target(_SELF(self));
68
+ VALUE ary = rb_ary_new();
69
+
70
+ for (i = 0; i < garray->len; i++){
71
+ rb_ary_push(ary, GOBJ2RVAL((AtkObject*)g_ptr_array_index(garray, i)));
72
+ }
73
+ g_ptr_array_free(garray, TRUE);
74
+ return ary;
75
+ }
76
+
77
+ #if ATK_CHECK_VERSION(1,9,0)
78
+ static VALUE
79
+ rbatkrel_add_target(self, obj)
80
+ VALUE self, obj;
81
+ {
82
+ atk_relation_add_target(_SELF(self), ATK_OBJECT(RVAL2GOBJ(obj)));
83
+ return self;
84
+ }
85
+ #endif
86
+
87
+ void
88
+ Init_atk_relation()
89
+ {
90
+ VALUE rel = G_DEF_CLASS(ATK_TYPE_RELATION, "Relation", mAtk);
91
+ VALUE type;
92
+ rb_define_singleton_method(rel, "type_register", rbatkrel_s_type_register, 1);
93
+ rb_define_method(rel, "initialize", rbatkrel_initialize, 2);
94
+ rb_define_method(rel, "relation_type", rbatkrel_get_relation_type, 0);
95
+ rb_define_method(rel, "target", rbatkrel_get_target, 0);
96
+ #if ATK_CHECK_VERSION(1,9,0)
97
+ rb_define_method(rel, "add_target", rbatkrel_add_target, 1);
98
+ #endif
99
+
100
+ /* AtkRelationType */
101
+ type = G_DEF_CLASS(ATK_TYPE_RELATION_TYPE, "Type", rel);
102
+ rb_define_singleton_method(type, "for_name", rbatkrelation_s_for_name, 1);
103
+ G_DEF_CONSTANTS(rel, ATK_TYPE_RELATION_TYPE, "ATK_");
104
+ }
@@ -0,0 +1,94 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbatkrelationset.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2005/09/15 17:30:46 $
8
+
9
+ Copyright (C) 2003 Masao Mutoh
10
+ ************************************************/
11
+ #include "rbatk.h"
12
+
13
+ #define _SELF(s) (ATK_RELATION_SET(RVAL2GOBJ(s)))
14
+
15
+ static VALUE
16
+ rbatkrelset_initialize(self)
17
+ VALUE self;
18
+ {
19
+ G_INITIALIZE(self, atk_relation_set_new());
20
+ return Qnil;
21
+ }
22
+
23
+ static VALUE
24
+ rbatkrelset_contains(self, relationship)
25
+ VALUE self, relationship;
26
+ {
27
+ return CBOOL2RVAL(atk_relation_set_contains(
28
+ _SELF(self),
29
+ RVAL2GENUM(relationship, ATK_TYPE_RELATION_TYPE)));
30
+ }
31
+
32
+ static VALUE
33
+ rbatkrelset_remove(self, relation)
34
+ VALUE self, relation;
35
+ {
36
+ atk_relation_set_remove(_SELF(self), ATK_RELATION(RVAL2GOBJ(relation)));
37
+ return self;
38
+ }
39
+
40
+ static VALUE
41
+ rbatkrelset_add(self, relation)
42
+ VALUE self, relation;
43
+ {
44
+ atk_relation_set_add(_SELF(self), ATK_RELATION(RVAL2GOBJ(relation)));
45
+ return self;
46
+ }
47
+
48
+ static VALUE
49
+ rbatkrelset_get_n_relations(self)
50
+ VALUE self;
51
+ {
52
+ return INT2NUM(atk_relation_set_get_n_relations(_SELF(self)));
53
+ }
54
+
55
+ static VALUE
56
+ rbatkrelset_get_relation(self, i)
57
+ VALUE self, i;
58
+ {
59
+ if (rb_obj_is_kind_of(i, GTYPE2CLASS(ATK_TYPE_RELATION_TYPE))){
60
+ return GOBJ2RVAL(atk_relation_set_get_relation_by_type(
61
+ _SELF(self),
62
+ RVAL2GENUM(i, ATK_TYPE_RELATION_TYPE)));
63
+ } else {
64
+ return GOBJ2RVAL(atk_relation_set_get_relation(_SELF(self), NUM2INT(i)));
65
+ }
66
+ }
67
+
68
+ #if ATK_CHECK_VERSION(1,9,0)
69
+ static VALUE
70
+ rbatkrelset_add_relation(self, relationship, obj)
71
+ VALUE self, relationship, obj;
72
+ {
73
+ atk_relation_set_add_relation_by_type(_SELF(self),
74
+ RVAL2GENUM(relationship, ATK_TYPE_RELATION_TYPE),
75
+ ATK_OBJECT(RVAL2GOBJ(obj)));
76
+ return self;
77
+ }
78
+ #endif
79
+
80
+ void
81
+ Init_atk_relation_set()
82
+ {
83
+ VALUE rel = G_DEF_CLASS(ATK_TYPE_RELATION_SET, "RelationSet", mAtk);
84
+
85
+ rb_define_method(rel, "initialize", rbatkrelset_initialize, 0);
86
+ rb_define_method(rel, "contains?", rbatkrelset_contains, 1);
87
+ rb_define_method(rel, "remove", rbatkrelset_remove, 1);
88
+ rb_define_method(rel, "add", rbatkrelset_add, 1);
89
+ rb_define_method(rel, "n_relations", rbatkrelset_get_n_relations, 0);
90
+ rb_define_method(rel, "get_relation", rbatkrelset_get_relation, 1);
91
+ #if ATK_CHECK_VERSION(1,9,0)
92
+ rb_define_method(rel, "add_relation", rbatkrelset_add_relation, 2);
93
+ #endif
94
+ }
@@ -0,0 +1,82 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbatkselection.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2004/03/05 15:33:48 $
8
+
9
+ Copyright (C) 2004 Masao Mutoh
10
+ ************************************************/
11
+ #include "rbatk.h"
12
+
13
+ #define _SELF(s) (ATK_SELECTION(RVAL2GOBJ(s)))
14
+
15
+ static VALUE
16
+ rbatksel_add_selection(self, i)
17
+ VALUE self, i;
18
+ {
19
+ gboolean ret = atk_selection_add_selection(_SELF(self), NUM2INT(i));
20
+ if (! ret) rb_raise(rb_eRuntimeError, "Can't add selection");
21
+ return self;
22
+ }
23
+
24
+ static VALUE
25
+ rbatksel_clear_selection(self)
26
+ VALUE self;
27
+ {
28
+ gboolean ret = atk_selection_clear_selection(_SELF(self));
29
+ if (! ret) rb_raise(rb_eRuntimeError, "Can't clear selection");
30
+ return self;
31
+ }
32
+
33
+ static VALUE
34
+ rbatksel_ref_selection(self, i)
35
+ VALUE self, i;
36
+ {
37
+ return GOBJ2RVAL(atk_selection_ref_selection(_SELF(self), NUM2INT(i)));
38
+ }
39
+
40
+ static VALUE
41
+ rbatksel_get_selection_count(self)
42
+ VALUE self;
43
+ {
44
+ return INT2NUM(atk_selection_get_selection_count(_SELF(self)));
45
+ }
46
+
47
+ static VALUE
48
+ rbatksel_is_child_selected(self, i)
49
+ VALUE self, i;
50
+ {
51
+ return CBOOL2RVAL(atk_selection_is_child_selected(_SELF(self), NUM2INT(i)));
52
+ }
53
+
54
+ static VALUE
55
+ rbatksel_remove_selection(self, i)
56
+ VALUE self, i;
57
+ {
58
+ gboolean ret = atk_selection_remove_selection(_SELF(self), NUM2INT(i));
59
+ if (! ret) rb_raise(rb_eRuntimeError, "Can't remove selection");
60
+ return self;
61
+ }
62
+
63
+ static VALUE
64
+ rbatksel_select_all_selection(self)
65
+ VALUE self;
66
+ {
67
+ return CBOOL2RVAL(atk_selection_select_all_selection(_SELF(self)));
68
+ }
69
+
70
+ void
71
+ Init_atk_selection()
72
+ {
73
+ VALUE sel = G_DEF_INTERFACE(ATK_TYPE_SELECTION, "Selection", mAtk);
74
+
75
+ rb_define_method(sel, "add_selection", rbatksel_add_selection, 1);
76
+ rb_define_method(sel, "clear_selection", rbatksel_clear_selection, 0);
77
+ rb_define_method(sel, "ref_selection", rbatksel_ref_selection, 1);
78
+ rb_define_method(sel, "selection_count", rbatksel_get_selection_count, 0);
79
+ rb_define_method(sel, "child_selected?", rbatksel_is_child_selected, 1);
80
+ rb_define_method(sel, "remove_selection", rbatksel_remove_selection, 1);
81
+ rb_define_method(sel, "select_all_selection", rbatksel_select_all_selection, 0);
82
+ }
@@ -0,0 +1,41 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbatkstate.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2004/10/17 23:06:07 $
8
+
9
+ Copyright (C) 2003,2004 Masao Mutoh
10
+ ************************************************/
11
+ #include "rbatk.h"
12
+
13
+ #define _SELF(s) (ATK_STATE(RVAL2GOBJ(s)))
14
+
15
+ static VALUE
16
+ rbatkstate_s_type_register(self, name)
17
+ VALUE self, name;
18
+ {
19
+ return GENUM2RVAL(atk_state_type_register(RVAL2CSTR(name)), ATK_TYPE_STATE_TYPE);
20
+ }
21
+
22
+ /* We don't need this.
23
+ G_CONST_RETURN gchar* atk_state_type_get_name
24
+ (AtkStateType type);
25
+ */
26
+
27
+ static VALUE
28
+ rbatkstate_s_for_name(self, name)
29
+ VALUE self, name;
30
+ {
31
+ return GENUM2RVAL(atk_state_type_for_name(RVAL2CSTR(name)), ATK_TYPE_STATE_TYPE);
32
+ }
33
+
34
+ void
35
+ Init_atk_state()
36
+ {
37
+ VALUE state = G_DEF_CLASS(ATK_TYPE_STATE_TYPE, "State", mAtk);
38
+ rb_define_singleton_method(state, "type_register", rbatkstate_s_type_register, 1);
39
+ rb_define_singleton_method(state, "for_name", rbatkstate_s_for_name, 1);
40
+ G_DEF_CONSTANTS(mAtk, ATK_TYPE_STATE_TYPE, "ATK_");
41
+ }
@@ -0,0 +1,143 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbatkstateset.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2003/12/23 15:59:28 $
8
+
9
+ Copyright (C) 2003 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbatk.h"
13
+
14
+ #define _SELF(s) (ATK_STATE_SET(RVAL2GOBJ(s)))
15
+
16
+ static VALUE
17
+ rbatkstateset_initialize(self)
18
+ VALUE self;
19
+ {
20
+ G_INITIALIZE(self, atk_state_set_new());
21
+ return Qnil;
22
+ }
23
+
24
+ static VALUE
25
+ rbatkstateset_is_empty(self)
26
+ VALUE self;
27
+ {
28
+ return CBOOL2RVAL(atk_state_set_is_empty(_SELF(self)));
29
+ }
30
+
31
+ static VALUE
32
+ rbatkstateset_add_state(self, type)
33
+ VALUE self, type;
34
+ {
35
+ return CBOOL2RVAL(atk_state_set_add_state(_SELF(self),
36
+ RVAL2GENUM(type, ATK_TYPE_STATE_TYPE)));
37
+ }
38
+
39
+ static VALUE
40
+ rbatkstateset_add_states(self, types)
41
+ VALUE self, types;
42
+ {
43
+ gint i;
44
+ gint n_types = RARRAY_LEN(types);
45
+ AtkStateType* atypes = g_new(AtkStateType, n_types);
46
+
47
+ Check_Type(types, T_ARRAY);
48
+
49
+ for (i = 0; i < n_types; i++) {
50
+ atypes[i] = RVAL2GENUM(RARRAY_PTR(types)[i], ATK_TYPE_STATE_TYPE);
51
+ }
52
+
53
+ atk_state_set_add_states(_SELF(self), atypes, n_types);
54
+ g_free(atypes);
55
+ return self;
56
+ }
57
+
58
+ static VALUE
59
+ rbatkstateset_clear_states(self)
60
+ VALUE self;
61
+ {
62
+ atk_state_set_clear_states(_SELF(self));
63
+ return self;
64
+ }
65
+
66
+ static VALUE
67
+ rbatkstateset_contains_state(self, type)
68
+ VALUE self;
69
+ {
70
+ return CBOOL2RVAL(atk_state_set_contains_state(_SELF(self),
71
+ RVAL2GENUM(type, ATK_TYPE_STATE_TYPE)));
72
+ }
73
+
74
+ static VALUE
75
+ rbatkstateset_contains_states(self, types)
76
+ VALUE self, types;
77
+ {
78
+ gint i;
79
+ gboolean ret;
80
+ gint n_types = RARRAY_LEN(types);
81
+ AtkStateType* atypes = g_new(AtkStateType, n_types);
82
+
83
+ Check_Type(types, T_ARRAY);
84
+
85
+ for (i = 0; i < n_types; i++) {
86
+ atypes[i] = RVAL2GENUM(RARRAY_PTR(types)[i], ATK_TYPE_STATE_TYPE);
87
+ }
88
+
89
+ ret = CBOOL2RVAL(atk_state_set_contains_states(_SELF(self), atypes, n_types));
90
+
91
+ g_free(atypes);
92
+ return ret;
93
+ }
94
+
95
+ static VALUE
96
+ rbatkstateset_remove_state(self, type)
97
+ VALUE self, type;
98
+ {
99
+ return CBOOL2RVAL(atk_state_set_remove_state(_SELF(self),
100
+ RVAL2GENUM(type, ATK_TYPE_STATE_TYPE)));
101
+ }
102
+
103
+ static VALUE
104
+ rbatkstateset_and_sets(self, compare_set)
105
+ VALUE self, compare_set;
106
+ {
107
+ return GOBJ2RVAL(atk_state_set_and_sets(_SELF(self), _SELF(compare_set)));
108
+ }
109
+
110
+ static VALUE
111
+ rbatkstateset_or_sets(self, compare_set)
112
+ VALUE self, compare_set;
113
+ {
114
+ return GOBJ2RVAL(atk_state_set_or_sets(_SELF(self), _SELF(compare_set)));
115
+ }
116
+
117
+ static VALUE
118
+ rbatkstateset_xor_sets(self, compare_set)
119
+ VALUE self, compare_set;
120
+ {
121
+ return GOBJ2RVAL(atk_state_set_xor_sets(_SELF(self), _SELF(compare_set)));
122
+ }
123
+
124
+ void
125
+ Init_atk_state_set()
126
+ {
127
+ VALUE stateset = G_DEF_CLASS(ATK_TYPE_STATE_SET, "StateSet", mAtk);
128
+
129
+ rb_define_method(stateset, "initialize", rbatkstateset_initialize, 0);
130
+ rb_define_method(stateset, "empty?", rbatkstateset_is_empty, 0);
131
+ rb_define_method(stateset, "add_state", rbatkstateset_add_state, 1);
132
+ rb_define_method(stateset, "add_states", rbatkstateset_add_states, 1);
133
+ rb_define_method(stateset, "clear_states", rbatkstateset_clear_states, 0);
134
+ rb_define_method(stateset, "contains_state", rbatkstateset_contains_state, 1);
135
+ rb_define_method(stateset, "contains_states", rbatkstateset_contains_states, 1);
136
+ rb_define_method(stateset, "remove_state", rbatkstateset_remove_state, 1);
137
+ rb_define_method(stateset, "and", rbatkstateset_and_sets, 1);
138
+ rb_define_alias(stateset, "&", "and");
139
+ rb_define_method(stateset, "or", rbatkstateset_or_sets, 1);
140
+ rb_define_alias(stateset, "|", "or");
141
+ rb_define_method(stateset, "xor", rbatkstateset_xor_sets, 1);
142
+ rb_define_alias(stateset, "^", "xor");
143
+ }