Released 0.1
[atk.git] / atk / atkeditabletext.c
blob2d65cc61d5a1026782536f445b13e2c351cb790a
1 /* ATK - The Accessibility Toolkit for GTK+
2 * Copyright 2001 Sun Microsystems Inc.
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.
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.
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.
20 #include "atkeditabletext.h"
22 enum {
23 TEXT_CHANGED,
24 CARET_MOVED,
25 LAST_SIGNAL
28 struct _AtkEditableTextIfaceClass
30 GObjectClass parent;
33 typedef struct _AtkEditableTextIfaceClass AtkEditableTextIfaceClass;
35 #if 0
36 static void atk_editable_text_interface_init (AtkEditableTextIfaceClass *klass);
38 static gpointer parent_class = NULL;
39 #endif
42 GType
43 atk_editable_text_get_type ()
45 static GType type = 0;
47 if (!type) {
48 static const GTypeInfo tinfo =
50 sizeof (AtkEditableTextIface),
51 NULL,
52 NULL,
56 type = g_type_register_static (G_TYPE_INTERFACE, "AtkEditableText", &tinfo, 0);
59 return type;
63 * Additional GObject properties exported by AtkText:
64 * "accessible_text" (accessible text has changed)
65 * "accessible_caret" (accessible text cursor position changed:
66 * editable text only)
69 #if 0
70 static void
71 atk_editable_text_interface_init (AtkEditableTextIfaceClass *klass)
73 parent_class = g_type_class_ref (ATK_TYPE_EDITABLE_TEXT);
75 /* Note that text_changed signal supports details "insert", "delete", possibly "replace". */
77 atk_signals[TEXT_CHANGED] =
78 g_signal_newc ("text_changed",
79 G_TYPE_FROM_CLASS (klass),
80 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
81 G_STRUCT_OFFSET (AtkEditableTextClass, text_changed), /* still need to declare and define this func */
82 NULL,
83 g_cclosure_marshal_VOID__UINT_POINTER,
84 G_TYPE_NONE,
85 2, G_TYPE_UINT, ATK_TYPE_OBJECT);
87 atk_signals[CARET_MOVED] =
88 g_signal_newc ("text_caret_moved",
89 G_TYPE_FROM_CLASS (klass),
90 G_SIGNAL_RUN_LAST,
91 G_STRUCT_OFFSET (AtkTextClass, caret_changed), /* still need to declare and define this func */
92 NULL,
93 g_cclosure_marshal_VOID__UINT_POINTER,
94 G_TYPE_NONE,
95 2, G_TYPE_UINT, ATK_TYPE_OBJECT);
97 #endif
99 void
100 atk_editable_text_select_text (AtkEditableText *text,
101 gint start_pos,
102 gint end_pos)
104 AtkEditableTextIface *iface;
106 g_return_if_fail (text != NULL);
107 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
109 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
111 if (iface->select_text)
112 (*(iface->select_text)) (text, start_pos, end_pos);
115 void
116 atk_editable_text_set_attributes (AtkEditableText *text,
117 gint start_pos,
118 gint end_pos,
119 PangoAttrList *attributes)
121 AtkEditableTextIface *iface;
123 g_return_if_fail (text != NULL);
124 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
126 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
128 if (iface->set_attributes)
129 (*(iface->set_attributes)) (text, start_pos, end_pos, attributes);
132 void
133 atk_editable_text_set_text_contents (AtkEditableText *text,
134 const gchar *string)
136 AtkEditableTextIface *iface;
138 g_return_if_fail (text != NULL);
139 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
141 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
143 if (iface->set_text_contents)
144 (*(iface->set_text_contents)) (text, string);
147 void
148 atk_editable_text_insert_text (AtkEditableText *text,
149 const gchar *string,
150 gint length,
151 gint *position)
153 AtkEditableTextIface *iface;
155 g_return_if_fail (text != NULL);
156 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
158 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
160 if (iface->insert_text)
161 (*(iface->insert_text)) (text, string, length, position);
164 void
165 atk_editable_text_copy_text (AtkEditableText *text,
166 gint start_pos,
167 gint end_pos)
169 AtkEditableTextIface *iface;
171 g_return_if_fail (text != NULL);
172 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
174 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
176 if (iface->copy_text)
177 (*(iface->copy_text)) (text, start_pos, end_pos);
180 void
181 atk_editable_text_cut_text (AtkEditableText *text,
182 gint start_pos,
183 gint end_pos)
185 AtkEditableTextIface *iface;
187 g_return_if_fail (text != NULL);
188 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
190 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
192 if (iface->cut_text)
193 (*(iface->cut_text)) (text, start_pos, end_pos);
196 void
197 atk_editable_text_delete_text (AtkEditableText *text,
198 gint start_pos,
199 gint end_pos)
201 AtkEditableTextIface *iface;
203 g_return_if_fail (text != NULL);
204 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
206 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
208 if (iface->delete_text)
209 (*(iface->delete_text)) (text, start_pos, end_pos);
212 void
213 atk_editable_text_paste_text (AtkEditableText *text,
214 gint position)
216 AtkEditableTextIface *iface;
218 g_return_if_fail (text != NULL);
219 g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
221 iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
223 if (iface->paste_text)
224 (*(iface->paste_text)) (text, position);