atk 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,38 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2003 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 "rbatkprivate.h"
23
+
24
+ #define RG_TARGET_NAMESPACE cType
25
+
26
+ static VALUE
27
+ rg_s_for_name(G_GNUC_UNUSED VALUE self, VALUE name)
28
+ {
29
+ return ATKRELATIONTYPE2RVAL(atk_relation_type_for_name(RVAL2CSTR(name)));
30
+ }
31
+
32
+ void
33
+ Init_atk_relation_type(VALUE cRelation)
34
+ {
35
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_RELATION_TYPE, "Type", cRelation);
36
+ RG_DEF_SMETHOD(for_name, 1);
37
+ G_DEF_CONSTANTS(cRelation, ATK_TYPE_RELATION_TYPE, "ATK_");
38
+ }
@@ -1,19 +1,31 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 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
+ */
3
21
 
4
- rbatkselection.c -
22
+ #include "rbatkprivate.h"
5
23
 
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)))
24
+ #define RG_TARGET_NAMESPACE mSelection
25
+ #define _SELF(s) (RVAL2ATKSELECTION(s))
14
26
 
15
27
  static VALUE
16
- rbatksel_add_selection(VALUE self, VALUE i)
28
+ rg_add_selection(VALUE self, VALUE i)
17
29
  {
18
30
  gboolean ret = atk_selection_add_selection(_SELF(self), NUM2INT(i));
19
31
  if (! ret) rb_raise(rb_eRuntimeError, "Can't add selection");
@@ -21,7 +33,7 @@ rbatksel_add_selection(VALUE self, VALUE i)
21
33
  }
22
34
 
23
35
  static VALUE
24
- rbatksel_clear_selection(VALUE self)
36
+ rg_clear_selection(VALUE self)
25
37
  {
26
38
  gboolean ret = atk_selection_clear_selection(_SELF(self));
27
39
  if (! ret) rb_raise(rb_eRuntimeError, "Can't clear selection");
@@ -29,25 +41,25 @@ rbatksel_clear_selection(VALUE self)
29
41
  }
30
42
 
31
43
  static VALUE
32
- rbatksel_ref_selection(VALUE self, VALUE i)
44
+ rg_ref_selection(VALUE self, VALUE i)
33
45
  {
34
46
  return GOBJ2RVAL(atk_selection_ref_selection(_SELF(self), NUM2INT(i)));
35
47
  }
36
48
 
37
49
  static VALUE
38
- rbatksel_get_selection_count(VALUE self)
50
+ rg_selection_count(VALUE self)
39
51
  {
40
52
  return INT2NUM(atk_selection_get_selection_count(_SELF(self)));
41
53
  }
42
54
 
43
55
  static VALUE
44
- rbatksel_is_child_selected(VALUE self, VALUE i)
56
+ rg_child_selected_p(VALUE self, VALUE i)
45
57
  {
46
58
  return CBOOL2RVAL(atk_selection_is_child_selected(_SELF(self), NUM2INT(i)));
47
59
  }
48
60
 
49
61
  static VALUE
50
- rbatksel_remove_selection(VALUE self, VALUE i)
62
+ rg_remove_selection(VALUE self, VALUE i)
51
63
  {
52
64
  gboolean ret = atk_selection_remove_selection(_SELF(self), NUM2INT(i));
53
65
  if (! ret) rb_raise(rb_eRuntimeError, "Can't remove selection");
@@ -55,21 +67,21 @@ rbatksel_remove_selection(VALUE self, VALUE i)
55
67
  }
56
68
 
57
69
  static VALUE
58
- rbatksel_select_all_selection(VALUE self)
70
+ rg_select_all_selection(VALUE self)
59
71
  {
60
72
  return CBOOL2RVAL(atk_selection_select_all_selection(_SELF(self)));
61
73
  }
62
74
 
63
75
  void
64
- Init_atk_selection()
76
+ Init_atk_selection(VALUE mAtk)
65
77
  {
66
- VALUE sel = G_DEF_INTERFACE(ATK_TYPE_SELECTION, "Selection", mAtk);
78
+ VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(ATK_TYPE_SELECTION, "Selection", mAtk);
67
79
 
68
- rb_define_method(sel, "add_selection", rbatksel_add_selection, 1);
69
- rb_define_method(sel, "clear_selection", rbatksel_clear_selection, 0);
70
- rb_define_method(sel, "ref_selection", rbatksel_ref_selection, 1);
71
- rb_define_method(sel, "selection_count", rbatksel_get_selection_count, 0);
72
- rb_define_method(sel, "child_selected?", rbatksel_is_child_selected, 1);
73
- rb_define_method(sel, "remove_selection", rbatksel_remove_selection, 1);
74
- rb_define_method(sel, "select_all_selection", rbatksel_select_all_selection, 0);
80
+ RG_DEF_METHOD(add_selection, 1);
81
+ RG_DEF_METHOD(clear_selection, 0);
82
+ RG_DEF_METHOD(ref_selection, 1);
83
+ RG_DEF_METHOD(selection_count, 0);
84
+ RG_DEF_METHOD_P(child_selected, 1);
85
+ RG_DEF_METHOD(remove_selection, 1);
86
+ RG_DEF_METHOD(select_all_selection, 0);
75
87
  }
@@ -1,21 +1,33 @@
1
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)))
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 "rbatkprivate.h"
23
+
24
+ #define RG_TARGET_NAMESPACE cState
25
+ #define _SELF(s) (RVAL2ATKSTATE(s))
14
26
 
15
27
  static VALUE
16
- rbatkstate_s_type_register(VALUE self, VALUE name)
28
+ rg_s_type_register(G_GNUC_UNUSED VALUE self, VALUE name)
17
29
  {
18
- return GENUM2RVAL(atk_state_type_register(RVAL2CSTR(name)), ATK_TYPE_STATE_TYPE);
30
+ return ATKSTATETYPE2RVAL(atk_state_type_register(RVAL2CSTR(name)));
19
31
  }
20
32
 
21
33
  /* We don't need this.
@@ -24,16 +36,16 @@ G_CONST_RETURN gchar* atk_state_type_get_name
24
36
  */
25
37
 
26
38
  static VALUE
27
- rbatkstate_s_for_name(VALUE self, VALUE name)
39
+ rg_s_for_name(G_GNUC_UNUSED VALUE self, VALUE name)
28
40
  {
29
- return GENUM2RVAL(atk_state_type_for_name(RVAL2CSTR(name)), ATK_TYPE_STATE_TYPE);
41
+ return ATKSTATETYPE2RVAL(atk_state_type_for_name(RVAL2CSTR(name)));
30
42
  }
31
43
 
32
44
  void
33
- Init_atk_state()
45
+ Init_atk_state(VALUE mAtk)
34
46
  {
35
- VALUE state = G_DEF_CLASS(ATK_TYPE_STATE_TYPE, "State", mAtk);
36
- rb_define_singleton_method(state, "type_register", rbatkstate_s_type_register, 1);
37
- rb_define_singleton_method(state, "for_name", rbatkstate_s_for_name, 1);
47
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_STATE_TYPE, "State", mAtk);
48
+ RG_DEF_SMETHOD(type_register, 1);
49
+ RG_DEF_SMETHOD(for_name, 1);
38
50
  G_DEF_CONSTANTS(mAtk, ATK_TYPE_STATE_TYPE, "ATK_");
39
51
  }
@@ -1,132 +1,180 @@
1
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)))
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2003 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 "rbatkprivate.h"
23
+
24
+ #define RG_TARGET_NAMESPACE cStateSet
25
+ #define _SELF(s) (RVAL2ATKSTATESET(s))
15
26
 
16
27
  static VALUE
17
- rbatkstateset_initialize(VALUE self)
28
+ rg_initialize(VALUE self)
18
29
  {
19
30
  G_INITIALIZE(self, atk_state_set_new());
20
31
  return Qnil;
21
32
  }
22
33
 
23
34
  static VALUE
24
- rbatkstateset_is_empty(VALUE self)
35
+ rg_empty_p(VALUE self)
25
36
  {
26
37
  return CBOOL2RVAL(atk_state_set_is_empty(_SELF(self)));
27
38
  }
28
39
 
29
40
  static VALUE
30
- rbatkstateset_add_state(VALUE self, VALUE type)
41
+ rg_add_state(VALUE self, VALUE type)
31
42
  {
32
43
  return CBOOL2RVAL(atk_state_set_add_state(_SELF(self),
33
- RVAL2GENUM(type, ATK_TYPE_STATE_TYPE)));
44
+ RVAL2ATKSTATETYPE(type)));
45
+ }
46
+
47
+ struct rval2atkstatetype_args {
48
+ VALUE ary;
49
+ long n;
50
+ AtkStateType *result;
51
+ };
52
+
53
+ static VALUE
54
+ rval2atkstatetype_body(VALUE value)
55
+ {
56
+ long i;
57
+ struct rval2atkstatetype_args *args = (struct rval2atkstatetype_args *)value;
58
+
59
+ for (i = 0; i < args->n; i++)
60
+ args->result[i] = RVAL2ATKSTATETYPE(RARRAY_PTR(args->ary)[i]);
61
+
62
+ return Qnil;
34
63
  }
35
64
 
65
+ static G_GNUC_NORETURN VALUE
66
+ rval2atkstatetype_rescue(VALUE value)
67
+ {
68
+ g_free(((struct rval2atkstatetype_args *)value)->result);
69
+
70
+ rb_exc_raise(rb_errinfo());
71
+ }
72
+
73
+ static AtkStateType *
74
+ rval2atkstatetype(VALUE value, long *n)
75
+ {
76
+ struct rval2atkstatetype_args args;
77
+
78
+ args.ary = rb_ary_to_ary(value);
79
+ args.n = RARRAY_LEN(args.ary);
80
+ args.result = g_new(AtkStateType, args.n + 1);
81
+
82
+ rb_rescue(rval2atkstatetype_body, (VALUE)&args,
83
+ rval2atkstatetype_rescue, (VALUE)&args);
84
+
85
+ if (n != NULL)
86
+ *n = args.n;
87
+
88
+ return args.result;
89
+ }
90
+
91
+ #define RVAL2ATKSTATETYPES(value, n) rval2atkstatetype(value, n)
92
+
36
93
  static VALUE
37
- rbatkstateset_add_states(VALUE self, VALUE types)
94
+ rg_add_states(VALUE self, VALUE rbtypes)
38
95
  {
39
- gint i;
40
- gint n_types = RARRAY_LEN(types);
41
- AtkStateType* atypes = g_new(AtkStateType, n_types);
96
+ AtkStateSet *set = _SELF(self);
97
+ long n;
98
+ AtkStateType *types = RVAL2ATKSTATETYPES(rbtypes, &n);
42
99
 
43
- Check_Type(types, T_ARRAY);
100
+ atk_state_set_add_states(set, types, n);
44
101
 
45
- for (i = 0; i < n_types; i++) {
46
- atypes[i] = RVAL2GENUM(RARRAY_PTR(types)[i], ATK_TYPE_STATE_TYPE);
47
- }
102
+ g_free(types);
48
103
 
49
- atk_state_set_add_states(_SELF(self), atypes, n_types);
50
- g_free(atypes);
51
104
  return self;
52
105
  }
53
106
 
54
107
  static VALUE
55
- rbatkstateset_clear_states(VALUE self)
108
+ rg_clear_states(VALUE self)
56
109
  {
57
110
  atk_state_set_clear_states(_SELF(self));
58
111
  return self;
59
112
  }
60
113
 
61
114
  static VALUE
62
- rbatkstateset_contains_state(VALUE self, VALUE type)
115
+ rg_contains_state(VALUE self, VALUE type)
63
116
  {
64
117
  return CBOOL2RVAL(atk_state_set_contains_state(_SELF(self),
65
- RVAL2GENUM(type, ATK_TYPE_STATE_TYPE)));
118
+ RVAL2ATKSTATETYPE(type)));
66
119
  }
67
120
 
68
121
  static VALUE
69
- rbatkstateset_contains_states(VALUE self, VALUE types)
122
+ rg_contains_states(VALUE self, VALUE rbtypes)
70
123
  {
71
- gint i;
72
- gboolean ret;
73
- gint n_types = RARRAY_LEN(types);
74
- AtkStateType* atypes = g_new(AtkStateType, n_types);
124
+ AtkStateSet *set = _SELF(self);
125
+ long n;
126
+ AtkStateType *types = RVAL2ATKSTATETYPES(rbtypes, &n);
127
+ gboolean result;
75
128
 
76
- Check_Type(types, T_ARRAY);
129
+ result = atk_state_set_contains_states(set, types, n);
77
130
 
78
- for (i = 0; i < n_types; i++) {
79
- atypes[i] = RVAL2GENUM(RARRAY_PTR(types)[i], ATK_TYPE_STATE_TYPE);
80
- }
81
-
82
- ret = CBOOL2RVAL(atk_state_set_contains_states(_SELF(self), atypes, n_types));
131
+ g_free(types);
83
132
 
84
- g_free(atypes);
85
- return ret;
133
+ return CBOOL2RVAL(result);
86
134
  }
87
135
 
88
136
  static VALUE
89
- rbatkstateset_remove_state(VALUE self, VALUE type)
137
+ rg_remove_state(VALUE self, VALUE type)
90
138
  {
91
139
  return CBOOL2RVAL(atk_state_set_remove_state(_SELF(self),
92
- RVAL2GENUM(type, ATK_TYPE_STATE_TYPE)));
140
+ RVAL2ATKSTATETYPE(type)));
93
141
  }
94
142
 
95
143
  static VALUE
96
- rbatkstateset_and_sets(VALUE self, VALUE compare_set)
144
+ rg_and(VALUE self, VALUE compare_set)
97
145
  {
98
146
  return GOBJ2RVAL(atk_state_set_and_sets(_SELF(self), _SELF(compare_set)));
99
147
  }
100
148
 
101
149
  static VALUE
102
- rbatkstateset_or_sets(VALUE self, VALUE compare_set)
150
+ rg_or(VALUE self, VALUE compare_set)
103
151
  {
104
152
  return GOBJ2RVAL(atk_state_set_or_sets(_SELF(self), _SELF(compare_set)));
105
153
  }
106
154
 
107
155
  static VALUE
108
- rbatkstateset_xor_sets(VALUE self, VALUE compare_set)
156
+ rg_xor(VALUE self, VALUE compare_set)
109
157
  {
110
158
  return GOBJ2RVAL(atk_state_set_xor_sets(_SELF(self), _SELF(compare_set)));
111
159
  }
112
160
 
113
161
  void
114
- Init_atk_state_set()
162
+ Init_atk_state_set(VALUE mAtk)
115
163
  {
116
- VALUE stateset = G_DEF_CLASS(ATK_TYPE_STATE_SET, "StateSet", mAtk);
117
-
118
- rb_define_method(stateset, "initialize", rbatkstateset_initialize, 0);
119
- rb_define_method(stateset, "empty?", rbatkstateset_is_empty, 0);
120
- rb_define_method(stateset, "add_state", rbatkstateset_add_state, 1);
121
- rb_define_method(stateset, "add_states", rbatkstateset_add_states, 1);
122
- rb_define_method(stateset, "clear_states", rbatkstateset_clear_states, 0);
123
- rb_define_method(stateset, "contains_state", rbatkstateset_contains_state, 1);
124
- rb_define_method(stateset, "contains_states", rbatkstateset_contains_states, 1);
125
- rb_define_method(stateset, "remove_state", rbatkstateset_remove_state, 1);
126
- rb_define_method(stateset, "and", rbatkstateset_and_sets, 1);
127
- rb_define_alias(stateset, "&", "and");
128
- rb_define_method(stateset, "or", rbatkstateset_or_sets, 1);
129
- rb_define_alias(stateset, "|", "or");
130
- rb_define_method(stateset, "xor", rbatkstateset_xor_sets, 1);
131
- rb_define_alias(stateset, "^", "xor");
164
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(ATK_TYPE_STATE_SET, "StateSet", mAtk);
165
+
166
+ RG_DEF_METHOD(initialize, 0);
167
+ RG_DEF_METHOD_P(empty, 0);
168
+ RG_DEF_METHOD(add_state, 1);
169
+ RG_DEF_METHOD(add_states, 1);
170
+ RG_DEF_METHOD(clear_states, 0);
171
+ RG_DEF_METHOD(contains_state, 1);
172
+ RG_DEF_METHOD(contains_states, 1);
173
+ RG_DEF_METHOD(remove_state, 1);
174
+ RG_DEF_METHOD(and, 1);
175
+ RG_DEF_ALIAS("&", "and");
176
+ RG_DEF_METHOD(or, 1);
177
+ RG_DEF_ALIAS("|", "or");
178
+ RG_DEF_METHOD(xor, 1);
179
+ RG_DEF_ALIAS("^", "xor");
132
180
  }