193.1.1
by Eitan Isaacson
First pass at basic ATK support. The bubble has no useful public properties or getters, so there is no real information given. |
1 |
/*******************************************************************************
|
2 |
**3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
|
|
3 |
** 10 20 30 40 50 60 70 80
|
|
4 |
**
|
|
193.1.18
by Eitan Isaacson
Remove codename. |
5 |
** notify-osd
|
193.1.1
by Eitan Isaacson
First pass at basic ATK support. The bubble has no useful public properties or getters, so there is no real information given. |
6 |
**
|
193.1.16
by Eitan Isaacson
Some cleanup, indentation, headers, etc. |
7 |
** bubble-window-accessible.c - implements an accessible bubble window
|
193.1.1
by Eitan Isaacson
First pass at basic ATK support. The bubble has no useful public properties or getters, so there is no real information given. |
8 |
**
|
9 |
** Copyright 2009 Canonical Ltd.
|
|
10 |
**
|
|
11 |
** Authors:
|
|
12 |
** Eitan Isaacson <eitan@ascender.com>
|
|
13 |
**
|
|
14 |
** This program is free software: you can redistribute it and/or modify it
|
|
15 |
** under the terms of the GNU General Public License version 3, as published
|
|
16 |
** by the Free Software Foundation.
|
|
17 |
**
|
|
18 |
** This program is distributed in the hope that it will be useful, but
|
|
19 |
** WITHOUT ANY WARRANTY; without even the implied warranties of
|
|
20 |
** MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
|
21 |
** PURPOSE. See the GNU General Public License for more details.
|
|
22 |
**
|
|
23 |
** You should have received a copy of the GNU General Public License along
|
|
24 |
** with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
25 |
**
|
|
26 |
*******************************************************************************/
|
|
27 |
||
28 |
#include "bubble-window-accessible.h" |
|
29 |
#include "bubble.h" |
|
193.1.11
by Eitan Isaacson
Added value interface |
30 |
#include <string.h> |
193.1.1
by Eitan Isaacson
First pass at basic ATK support. The bubble has no useful public properties or getters, so there is no real information given. |
31 |
|
193.1.10
by Eitan Isaacson
Fold bubble accessible into bubble window. Fix tests/Makefile.am |
32 |
static void bubble_window_accessible_init (BubbleWindowAccessible* object); |
33 |
static void bubble_window_accessible_finalize (GObject* object); |
|
34 |
static void bubble_window_accessible_class_init (BubbleWindowAccessibleClass* klass); |
|
35 |
static const char* bubble_window_accessible_get_name (AtkObject* obj); |
|
36 |
static const char* bubble_window_accessible_get_description (AtkObject* obj); |
|
193.1.12
by Eitan Isaacson
Added value-changed events and object:property-change:accessible-value in turn. |
37 |
static void bubble_window_real_initialize (AtkObject* obj, |
38 |
gpointer data); |
|
193.1.11
by Eitan Isaacson
Added value interface |
39 |
static void atk_value_interface_init (AtkValueIface* iface); |
301.1.1
by Eitan Isaacson
implemented getText. |
40 |
static void atk_text_interface_init (AtkTextIface* iface); |
193.1.11
by Eitan Isaacson
Added value interface |
41 |
static void bubble_window_get_current_value (AtkValue* obj, |
42 |
GValue* value); |
|
43 |
static void bubble_window_get_maximum_value (AtkValue* obj, |
|
44 |
GValue* value); |
|
45 |
static void bubble_window_get_minimum_value (AtkValue* obj, |
|
46 |
GValue* value); |
|
193.1.12
by Eitan Isaacson
Added value-changed events and object:property-change:accessible-value in turn. |
47 |
static void bubble_value_changed_event (Bubble* bubble, |
48 |
gint value, |
|
49 |
AtkObject *obj); |
|
301.1.6
by Eitan Isaacson
added object:text-changed events to ATK interface. |
50 |
static void bubble_message_body_deleted_event (Bubble* bubble, |
51 |
const gchar* text, |
|
52 |
AtkObject* obj); |
|
53 |
static void bubble_message_body_inserted_event (Bubble* bubble, |
|
54 |
const gchar* text, |
|
55 |
AtkObject* obj); |
|
193.1.6
by Eitan Isaacson
Changed _get_type to use the parent class of the BubbleWindow's accessible object class |
56 |
|
301.1.3
by Eitan Isaacson
added selection methods |
57 |
static gchar* bubble_window_get_text (AtkText *obj, |
58 |
gint start_offset, |
|
59 |
gint end_offset); |
|
60 |
static gint bubble_window_get_character_count (AtkText *obj); |
|
301.1.4
by Eitan Isaacson
added getCharacterAtOffset. And made getText utf-8 friendly. |
61 |
static gunichar bubble_window_get_character_at_offset (AtkText *obj, |
62 |
gint offset); |
|
301.1.2
by Eitan Isaacson
implemented characterCount |
63 |
|
193.1.6
by Eitan Isaacson
Changed _get_type to use the parent class of the BubbleWindow's accessible object class |
64 |
static void* bubble_window_accessible_parent_class; |
65 |
||
444.1.1
by Luke Yelavich
Refactor accessibility code to work properly with GTK3.1+ accessibility code |
66 |
G_DEFINE_TYPE_WITH_CODE (BubbleWindowAccessible, bubble_window_accessible, GTK_TYPE_ACCESSIBLE, |
67 |
G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init) |
|
68 |
G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init)) |
|
193.1.6
by Eitan Isaacson
Changed _get_type to use the parent class of the BubbleWindow's accessible object class |
69 |
|
193.1.1
by Eitan Isaacson
First pass at basic ATK support. The bubble has no useful public properties or getters, so there is no real information given. |
70 |
static void |
193.1.11
by Eitan Isaacson
Added value interface |
71 |
atk_value_interface_init (AtkValueIface* iface) |
72 |
{
|
|
73 |
g_return_if_fail (iface != NULL); |
|
74 |
||
75 |
iface->get_current_value = bubble_window_get_current_value; |
|
76 |
iface->get_maximum_value = bubble_window_get_maximum_value; |
|
77 |
iface->get_minimum_value = bubble_window_get_minimum_value; |
|
78 |
}
|
|
79 |
||
80 |
static void |
|
301.1.1
by Eitan Isaacson
implemented getText. |
81 |
atk_text_interface_init (AtkTextIface* iface) |
82 |
{
|
|
83 |
g_return_if_fail (iface != NULL); |
|
84 |
||
85 |
iface->get_text = bubble_window_get_text; |
|
301.1.2
by Eitan Isaacson
implemented characterCount |
86 |
iface->get_character_count = bubble_window_get_character_count; |
301.1.4
by Eitan Isaacson
added getCharacterAtOffset. And made getText utf-8 friendly. |
87 |
iface->get_character_at_offset = bubble_window_get_character_at_offset; |
301.1.2
by Eitan Isaacson
implemented characterCount |
88 |
|
301.1.1
by Eitan Isaacson
implemented getText. |
89 |
}
|
90 |
||
91 |
static void |
|
193.1.1
by Eitan Isaacson
First pass at basic ATK support. The bubble has no useful public properties or getters, so there is no real information given. |
92 |
bubble_window_accessible_init (BubbleWindowAccessible *object) |
93 |
{
|
|
94 |
/* TODO: Add initialization code here */
|
|
95 |
}
|
|
96 |
||
97 |
static void |
|
98 |
bubble_window_accessible_finalize (GObject *object) |
|
99 |
{
|
|
100 |
/* TODO: Add deinitalization code here */
|
|
101 |
||
102 |
G_OBJECT_CLASS (bubble_window_accessible_parent_class)->finalize (object); |
|
103 |
}
|
|
104 |
||
105 |
static void |
|
106 |
bubble_window_accessible_class_init (BubbleWindowAccessibleClass *klass) |
|
107 |
{
|
|
193.1.16
by Eitan Isaacson
Some cleanup, indentation, headers, etc. |
108 |
GObjectClass* object_class = G_OBJECT_CLASS (klass); |
109 |
AtkObjectClass* class = ATK_OBJECT_CLASS (klass); |
|
193.1.6
by Eitan Isaacson
Changed _get_type to use the parent class of the BubbleWindow's accessible object class |
110 |
|
111 |
bubble_window_accessible_parent_class = g_type_class_peek_parent (klass); |
|
193.1.10
by Eitan Isaacson
Fold bubble accessible into bubble window. Fix tests/Makefile.am |
112 |
|
113 |
class->get_name = bubble_window_accessible_get_name; |
|
114 |
class->get_description = bubble_window_accessible_get_description; |
|
193.1.12
by Eitan Isaacson
Added value-changed events and object:property-change:accessible-value in turn. |
115 |
class->initialize = bubble_window_real_initialize; |
193.1.1
by Eitan Isaacson
First pass at basic ATK support. The bubble has no useful public properties or getters, so there is no real information given. |
116 |
|
117 |
object_class->finalize = bubble_window_accessible_finalize; |
|
118 |
}
|
|
119 |
||
193.1.12
by Eitan Isaacson
Added value-changed events and object:property-change:accessible-value in turn. |
120 |
static void |
121 |
bubble_window_real_initialize (AtkObject* obj, |
|
122 |
gpointer data) |
|
123 |
{
|
|
124 |
GtkWidget* widget = GTK_WIDGET (data); |
|
125 |
Bubble* bubble; |
|
126 |
||
127 |
ATK_OBJECT_CLASS (bubble_window_accessible_parent_class)->initialize (obj, data); |
|
128 |
||
129 |
bubble = g_object_get_data (G_OBJECT(widget), "bubble"); |
|
130 |
||
131 |
g_signal_connect (bubble, |
|
132 |
"value-changed", |
|
133 |
G_CALLBACK (bubble_value_changed_event), |
|
134 |
obj); |
|
135 |
||
301.1.6
by Eitan Isaacson
added object:text-changed events to ATK interface. |
136 |
g_signal_connect (bubble, |
137 |
"message-body-deleted", |
|
138 |
G_CALLBACK (bubble_message_body_deleted_event), |
|
139 |
obj); |
|
140 |
||
141 |
g_signal_connect (bubble, |
|
142 |
"message-body-inserted", |
|
143 |
G_CALLBACK (bubble_message_body_inserted_event), |
|
144 |
obj); |
|
145 |
||
444.1.1
by Luke Yelavich
Refactor accessibility code to work properly with GTK3.1+ accessibility code |
146 |
atk_object_set_role (obj, ATK_ROLE_NOTIFICATION); |
193.1.12
by Eitan Isaacson
Added value-changed events and object:property-change:accessible-value in turn. |
147 |
}
|
148 |
||
193.1.1
by Eitan Isaacson
First pass at basic ATK support. The bubble has no useful public properties or getters, so there is no real information given. |
149 |
AtkObject* |
150 |
bubble_window_accessible_new (GtkWidget *widget) |
|
151 |
{
|
|
193.1.16
by Eitan Isaacson
Some cleanup, indentation, headers, etc. |
152 |
GObject *object; |
153 |
AtkObject *aobj; |
|
193.1.1
by Eitan Isaacson
First pass at basic ATK support. The bubble has no useful public properties or getters, so there is no real information given. |
154 |
|
155 |
object = g_object_new (BUBBLE_WINDOW_TYPE_ACCESSIBLE, NULL); |
|
156 |
||
193.1.10
by Eitan Isaacson
Fold bubble accessible into bubble window. Fix tests/Makefile.am |
157 |
aobj = ATK_OBJECT (object); |
193.1.1
by Eitan Isaacson
First pass at basic ATK support. The bubble has no useful public properties or getters, so there is no real information given. |
158 |
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
159 |
gtk_accessible_set_widget (GTK_ACCESSIBLE (aobj), widget); |
193.1.1
by Eitan Isaacson
First pass at basic ATK support. The bubble has no useful public properties or getters, so there is no real information given. |
160 |
|
193.1.10
by Eitan Isaacson
Fold bubble accessible into bubble window. Fix tests/Makefile.am |
161 |
atk_object_initialize (aobj, widget); |
162 |
||
163 |
return aobj; |
|
164 |
}
|
|
165 |
||
166 |
static const char* |
|
167 |
bubble_window_accessible_get_name (AtkObject* obj) |
|
168 |
{
|
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
169 |
GtkWidget* widget; |
193.1.14
by Eitan Isaacson
Added "synchronous" string hack to get immediate results for empty titles. |
170 |
Bubble* bubble; |
171 |
const gchar* title; |
|
193.1.10
by Eitan Isaacson
Fold bubble accessible into bubble window. Fix tests/Makefile.am |
172 |
|
173 |
g_return_val_if_fail (BUBBLE_WINDOW_IS_ACCESSIBLE (obj), ""); |
|
174 |
||
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
175 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); |
193.1.10
by Eitan Isaacson
Fold bubble accessible into bubble window. Fix tests/Makefile.am |
176 |
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
177 |
if (widget == NULL) |
178 |
return ""; |
|
193.1.10
by Eitan Isaacson
Fold bubble accessible into bubble window. Fix tests/Makefile.am |
179 |
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
180 |
bubble = g_object_get_data (G_OBJECT (widget), "bubble"); |
193.1.10
by Eitan Isaacson
Fold bubble accessible into bubble window. Fix tests/Makefile.am |
181 |
|
182 |
g_return_val_if_fail (IS_BUBBLE (bubble), ""); |
|
183 |
||
193.1.14
by Eitan Isaacson
Added "synchronous" string hack to get immediate results for empty titles. |
184 |
|
185 |
title = bubble_get_title(bubble); |
|
186 |
if (g_strcmp0(title, " ") == 0) |
|
187 |
{
|
|
193.1.16
by Eitan Isaacson
Some cleanup, indentation, headers, etc. |
188 |
/* HACK: Titles should never be empty. This solution is extremely wrong.
|
189 |
https://bugs.launchpad.net/notify-osd/+bug/334292 */
|
|
193.1.14
by Eitan Isaacson
Added "synchronous" string hack to get immediate results for empty titles. |
190 |
const gchar* synch_str; |
191 |
synch_str = bubble_get_synchronous(bubble); |
|
192 |
if (synch_str != NULL) |
|
193 |
return synch_str; |
|
194 |
else
|
|
193.1.16
by Eitan Isaacson
Some cleanup, indentation, headers, etc. |
195 |
return ""; |
193.1.14
by Eitan Isaacson
Added "synchronous" string hack to get immediate results for empty titles. |
196 |
}
|
197 |
||
198 |
||
199 |
return title; |
|
193.1.10
by Eitan Isaacson
Fold bubble accessible into bubble window. Fix tests/Makefile.am |
200 |
}
|
201 |
||
202 |
static const char* |
|
203 |
bubble_window_accessible_get_description (AtkObject* obj) |
|
204 |
{
|
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
205 |
GtkWidget *widget; |
193.1.16
by Eitan Isaacson
Some cleanup, indentation, headers, etc. |
206 |
Bubble *bubble; |
193.1.10
by Eitan Isaacson
Fold bubble accessible into bubble window. Fix tests/Makefile.am |
207 |
|
208 |
g_return_val_if_fail (BUBBLE_WINDOW_IS_ACCESSIBLE (obj), ""); |
|
209 |
||
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
210 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); |
193.1.10
by Eitan Isaacson
Fold bubble accessible into bubble window. Fix tests/Makefile.am |
211 |
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
212 |
if (widget == NULL) |
213 |
return ""; |
|
193.1.10
by Eitan Isaacson
Fold bubble accessible into bubble window. Fix tests/Makefile.am |
214 |
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
215 |
bubble = g_object_get_data (G_OBJECT (widget), "bubble"); |
193.1.10
by Eitan Isaacson
Fold bubble accessible into bubble window. Fix tests/Makefile.am |
216 |
|
217 |
g_return_val_if_fail (IS_BUBBLE (bubble), ""); |
|
218 |
||
219 |
return bubble_get_message_body(bubble); |
|
193.1.1
by Eitan Isaacson
First pass at basic ATK support. The bubble has no useful public properties or getters, so there is no real information given. |
220 |
}
|
193.1.11
by Eitan Isaacson
Added value interface |
221 |
|
222 |
static void |
|
193.1.16
by Eitan Isaacson
Some cleanup, indentation, headers, etc. |
223 |
bubble_window_get_current_value (AtkValue* obj, |
224 |
GValue* value) |
|
193.1.11
by Eitan Isaacson
Added value interface |
225 |
{
|
193.1.16
by Eitan Isaacson
Some cleanup, indentation, headers, etc. |
226 |
gdouble current_value; |
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
227 |
GtkWidget* widget; |
193.1.16
by Eitan Isaacson
Some cleanup, indentation, headers, etc. |
228 |
Bubble* bubble; |
193.1.11
by Eitan Isaacson
Added value interface |
229 |
|
230 |
g_return_if_fail (BUBBLE_WINDOW_IS_ACCESSIBLE (obj)); |
|
231 |
||
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
232 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); |
193.1.11
by Eitan Isaacson
Added value interface |
233 |
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
234 |
if (widget == NULL) |
235 |
return; |
|
193.1.11
by Eitan Isaacson
Added value interface |
236 |
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
237 |
bubble = g_object_get_data (G_OBJECT (widget), "bubble"); |
238 |
||
193.1.11
by Eitan Isaacson
Added value interface |
239 |
current_value = (gdouble) bubble_get_value(bubble); |
240 |
||
241 |
memset (value, 0, sizeof (GValue)); |
|
242 |
g_value_init (value, G_TYPE_DOUBLE); |
|
243 |
g_value_set_double (value,current_value); |
|
244 |
}
|
|
245 |
||
246 |
static void |
|
193.1.16
by Eitan Isaacson
Some cleanup, indentation, headers, etc. |
247 |
bubble_window_get_maximum_value (AtkValue* obj, |
248 |
GValue* value) |
|
193.1.11
by Eitan Isaacson
Added value interface |
249 |
{
|
250 |
memset (value, 0, sizeof (GValue)); |
|
251 |
g_value_init (value, G_TYPE_DOUBLE); |
|
252 |
g_value_set_double (value, 100.0); |
|
253 |
}
|
|
254 |
||
255 |
static void |
|
193.1.16
by Eitan Isaacson
Some cleanup, indentation, headers, etc. |
256 |
bubble_window_get_minimum_value (AtkValue* obj, |
257 |
GValue* value) |
|
193.1.11
by Eitan Isaacson
Added value interface |
258 |
{
|
259 |
memset (value, 0, sizeof (GValue)); |
|
260 |
g_value_init (value, G_TYPE_DOUBLE); |
|
261 |
g_value_set_double (value, 0.0); |
|
262 |
}
|
|
263 |
||
193.1.12
by Eitan Isaacson
Added value-changed events and object:property-change:accessible-value in turn. |
264 |
static void |
265 |
bubble_value_changed_event (Bubble* bubble, |
|
266 |
gint value, |
|
267 |
AtkObject* obj) |
|
268 |
{
|
|
269 |
g_object_notify (G_OBJECT (obj), "accessible-value"); |
|
270 |
}
|
|
301.1.1
by Eitan Isaacson
implemented getText. |
271 |
|
301.1.6
by Eitan Isaacson
added object:text-changed events to ATK interface. |
272 |
static void |
273 |
bubble_message_body_deleted_event (Bubble* bubble, |
|
274 |
const gchar* text, |
|
275 |
AtkObject* obj) |
|
276 |
{
|
|
277 |
/* Not getting very fancy here, delete is always complete */
|
|
278 |
g_signal_emit_by_name ( |
|
279 |
obj, "text_changed::delete", 0, g_utf8_strlen (text, -1)); |
|
280 |
}
|
|
281 |
||
282 |
static void |
|
283 |
bubble_message_body_inserted_event (Bubble* bubble, |
|
284 |
const gchar* text, |
|
285 |
AtkObject* obj) |
|
286 |
{
|
|
287 |
const gchar* message_body; |
|
288 |
||
289 |
message_body = bubble_get_message_body (bubble); |
|
290 |
||
291 |
g_signal_emit_by_name ( |
|
292 |
obj, "text_changed::insert", |
|
293 |
g_utf8_strlen (message_body, -1) - g_utf8_strlen (text, -1), |
|
294 |
g_utf8_strlen (message_body, -1)); |
|
295 |
}
|
|
296 |
||
301.1.1
by Eitan Isaacson
implemented getText. |
297 |
static gchar* |
298 |
bubble_window_get_text (AtkText *obj, |
|
299 |
gint start_offset, |
|
300 |
gint end_offset) |
|
301 |
{
|
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
302 |
GtkWidget* widget; |
301.1.1
by Eitan Isaacson
implemented getText. |
303 |
Bubble* bubble; |
304 |
const gchar* body_text; |
|
301.1.4
by Eitan Isaacson
added getCharacterAtOffset. And made getText utf-8 friendly. |
305 |
gsize char_length; |
301.1.9
by Eitan Isaacson
put back the return_val_if_fail lines with g_strdup. |
306 |
glong body_strlen; |
307 |
||
308 |
g_return_val_if_fail (BUBBLE_WINDOW_IS_ACCESSIBLE (obj), g_strdup("")); |
|
309 |
||
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
310 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); |
301.1.9
by Eitan Isaacson
put back the return_val_if_fail lines with g_strdup. |
311 |
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
312 |
g_return_val_if_fail (GTK_IS_WINDOW (widget), g_strdup("")); |
301.1.1
by Eitan Isaacson
implemented getText. |
313 |
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
314 |
bubble = g_object_get_data (G_OBJECT(widget), "bubble"); |
301.1.1
by Eitan Isaacson
implemented getText. |
315 |
|
301.1.9
by Eitan Isaacson
put back the return_val_if_fail lines with g_strdup. |
316 |
if (end_offset <= start_offset) |
317 |
return g_strdup(""); |
|
318 |
||
301.1.1
by Eitan Isaacson
implemented getText. |
319 |
body_text = bubble_get_message_body (bubble); |
320 |
||
301.1.9
by Eitan Isaacson
put back the return_val_if_fail lines with g_strdup. |
321 |
body_strlen = g_utf8_strlen(body_text, -1); |
322 |
||
323 |
if (start_offset > body_strlen) |
|
324 |
start_offset = body_strlen; |
|
325 |
||
326 |
if (end_offset > body_strlen || end_offset == -1) |
|
327 |
end_offset = body_strlen; |
|
328 |
||
301.1.1
by Eitan Isaacson
implemented getText. |
329 |
|
301.1.4
by Eitan Isaacson
added getCharacterAtOffset. And made getText utf-8 friendly. |
330 |
char_length = g_utf8_offset_to_pointer (body_text, end_offset) - |
301.1.6
by Eitan Isaacson
added object:text-changed events to ATK interface. |
331 |
g_utf8_offset_to_pointer (body_text, start_offset); |
332 |
||
301.1.9
by Eitan Isaacson
put back the return_val_if_fail lines with g_strdup. |
333 |
return g_strndup (g_utf8_offset_to_pointer(body_text, start_offset), |
334 |
char_length); |
|
301.1.1
by Eitan Isaacson
implemented getText. |
335 |
}
|
301.1.2
by Eitan Isaacson
implemented characterCount |
336 |
|
337 |
static gint |
|
338 |
bubble_window_get_character_count (AtkText *obj) |
|
339 |
{
|
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
340 |
GtkWidget* widget; |
301.1.2
by Eitan Isaacson
implemented characterCount |
341 |
Bubble* bubble; |
342 |
||
343 |
g_return_val_if_fail (BUBBLE_WINDOW_IS_ACCESSIBLE (obj), 0); |
|
344 |
||
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
345 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); |
301.1.2
by Eitan Isaacson
implemented characterCount |
346 |
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
347 |
if (widget == NULL) |
348 |
return 0; |
|
301.1.2
by Eitan Isaacson
implemented characterCount |
349 |
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
350 |
bubble = g_object_get_data (G_OBJECT (widget), "bubble"); |
301.1.2
by Eitan Isaacson
implemented characterCount |
351 |
|
301.1.9
by Eitan Isaacson
put back the return_val_if_fail lines with g_strdup. |
352 |
return g_utf8_strlen(bubble_get_message_body (bubble), -1); |
301.1.2
by Eitan Isaacson
implemented characterCount |
353 |
}
|
301.1.3
by Eitan Isaacson
added selection methods |
354 |
|
301.1.4
by Eitan Isaacson
added getCharacterAtOffset. And made getText utf-8 friendly. |
355 |
static gunichar |
356 |
bubble_window_get_character_at_offset (AtkText *obj, |
|
357 |
gint offset) |
|
358 |
{
|
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
359 |
GtkWidget* widget; |
301.1.4
by Eitan Isaacson
added getCharacterAtOffset. And made getText utf-8 friendly. |
360 |
Bubble* bubble; |
361 |
const gchar* body_text; |
|
362 |
||
363 |
g_return_val_if_fail (BUBBLE_WINDOW_IS_ACCESSIBLE (obj), 0); |
|
364 |
||
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
365 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj)); |
301.1.4
by Eitan Isaacson
added getCharacterAtOffset. And made getText utf-8 friendly. |
366 |
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
367 |
if (widget == NULL) |
368 |
return 0; |
|
301.1.4
by Eitan Isaacson
added getCharacterAtOffset. And made getText utf-8 friendly. |
369 |
|
426.1.1
by Michael Terry
Don't use deprecated functions. Bump required GTK+ version to 2.22. This fixes LP: #655232 |
370 |
bubble = g_object_get_data (G_OBJECT (widget), "bubble"); |
301.1.4
by Eitan Isaacson
added getCharacterAtOffset. And made getText utf-8 friendly. |
371 |
|
372 |
body_text = bubble_get_message_body (bubble); |
|
373 |
||
374 |
return g_utf8_get_char (g_utf8_offset_to_pointer (body_text, offset)); |
|
375 |
}
|