Moved caret_moved and text_changed signals from AtkEditableText to AtkText.
[platform/upstream/atk.git] / atk / atkeditabletext.c
1 /* ATK - The Accessibility Toolkit for GTK+
2  * Copyright 2001 Sun Microsystems Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include "atkeditabletext.h"
21
22
23 struct _AtkEditableTextIfaceClass
24 {
25   GObjectClass parent;
26 };
27
28 typedef struct _AtkEditableTextIfaceClass AtkEditableTextIfaceClass;
29
30 GType
31 atk_editable_text_get_type ()
32 {
33   static GType type = 0;
34
35   if (!type) {
36     static const GTypeInfo tinfo =
37     {
38       sizeof (AtkEditableTextIface),
39       NULL,
40       NULL,
41
42     };
43
44     type = g_type_register_static (G_TYPE_INTERFACE, "AtkEditableText", &tinfo, 0);
45   }
46
47   return type;
48 }
49
50
51 void 
52 atk_editable_text_select_text (AtkEditableText  *text,
53                                gint             start_pos,
54                                gint             end_pos)
55 {
56   AtkEditableTextIface *iface;
57
58   g_return_if_fail (text != NULL);
59   g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
60
61   iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
62
63   if (iface->select_text)
64     (*(iface->select_text)) (text, start_pos, end_pos);
65 }
66
67 void 
68 atk_editable_text_set_attributes (AtkEditableText  *text,
69                                   gint             start_pos,
70                                   gint             end_pos,
71                                   PangoAttrList    *attributes)
72 {
73   AtkEditableTextIface *iface;
74
75   g_return_if_fail (text != NULL);
76   g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
77
78   iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
79
80   if (iface->set_attributes)
81     (*(iface->set_attributes)) (text, start_pos, end_pos, attributes);
82 }
83
84 void 
85 atk_editable_text_set_text_contents (AtkEditableText  *text,
86                                      const gchar      *string)
87 {
88   AtkEditableTextIface *iface;
89
90   g_return_if_fail (text != NULL);
91   g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
92
93   iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
94
95   if (iface->set_text_contents)
96     (*(iface->set_text_contents)) (text, string);
97 }
98
99 void 
100 atk_editable_text_insert_text (AtkEditableText  *text,
101                                const gchar      *string,
102                                gint             length,
103                                gint             *position)
104 {
105   AtkEditableTextIface *iface;
106
107   g_return_if_fail (text != NULL);
108   g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
109
110   iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
111
112   if (iface->insert_text)
113     (*(iface->insert_text)) (text, string, length, position);
114 }
115
116 void 
117 atk_editable_text_copy_text (AtkEditableText  *text,
118                              gint             start_pos,
119                              gint             end_pos)
120 {
121   AtkEditableTextIface *iface;
122
123   g_return_if_fail (text != NULL);
124   g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
125
126   iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
127
128   if (iface->copy_text)
129     (*(iface->copy_text)) (text, start_pos, end_pos);
130 }
131
132 void 
133 atk_editable_text_cut_text  (AtkEditableText  *text,
134                              gint             start_pos,
135                              gint             end_pos)
136 {
137   AtkEditableTextIface *iface;
138
139   g_return_if_fail (text != NULL);
140   g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
141
142   iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
143
144   if (iface->cut_text)
145     (*(iface->cut_text)) (text, start_pos, end_pos);
146 }
147
148 void 
149 atk_editable_text_delete_text (AtkEditableText  *text,
150                                gint             start_pos,
151                                gint             end_pos)
152 {
153   AtkEditableTextIface *iface;
154
155   g_return_if_fail (text != NULL);
156   g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
157
158   iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
159
160   if (iface->delete_text)
161     (*(iface->delete_text)) (text, start_pos, end_pos);
162 }
163
164 void 
165 atk_editable_text_paste_text (AtkEditableText  *text,
166                               gint             position)
167 {
168   AtkEditableTextIface *iface;
169
170   g_return_if_fail (text != NULL);
171   g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
172
173   iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
174
175   if (iface->paste_text)
176     (*(iface->paste_text)) (text, position);
177 }