2 ===================================================================
3 RCS file: /cvs/gnome/vte/ChangeLog,v
4 retrieving revision 1.524
5 diff -u -p -r1.524 ChangeLog
6 --- vte/ChangeLog 2 May 2004 06:43:01 -0000 1.524
7 +++ vte/ChangeLog 6 May 2004 08:11:36 -0000
9 +2004-05-06 Padraig O'Briain <padraig.obriain@sun.com>
10 + * src/vte.c, src/vteint.h:
11 + Add new functions to support accessible text selection:
12 + _vte_terminal_get_selection, _vte_terminal_get_start_selection,
13 + _vte_terminal_get_end_selection, _vte_terminal_select_text,
14 + _vte_terminal_remove_selection
16 + (xy_from_offset): Fix for offset being entire text.
17 + (vte_terminal_accessibility_selection_changed): VteTerminal's
18 + selection-changed signal handler which emits text-selection-changed
20 + (vte_terminal_accessible_initialize): Connect to VteTerminal's
21 + selection-changed signal.
22 + (vte_terminal_accessible_get_n_selections) Add implementation.
23 + (vte_terminal_accessible_get_selection) Add implementation.
24 + (vte_terminal_accessible_add_selection) Add implementation.
25 + (vte_terminal_accessible_remove_selection) Add implementation.
26 + (vte_terminal_accessible_set_selection) Add implementation.
29 * src/reaper.c(vte_reaper_add_child): pass the global reaper in as
30 data when adding the child source, not the terminal which called us.
32 ===================================================================
33 RCS file: /cvs/gnome/vte/src/vte.c,v
34 retrieving revision 1.404
35 diff -u -p -r1.404 vte.c
36 --- vte/src/vte.c 2 May 2004 06:43:01 -0000 1.404
37 +++ vte/src/vte.c 6 May 2004 08:11:37 -0000
38 @@ -15758,3 +15758,76 @@ _vte_terminal_accessible_ref(VteTerminal
39 g_return_if_fail(VTE_IS_TERMINAL(terminal));
40 terminal->pvt->accessible_emit = TRUE;
44 +_vte_terminal_get_selection(VteTerminal *terminal)
46 + g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
48 + return g_strdup (terminal->pvt->selection);
52 +_vte_terminal_get_start_selection(VteTerminal *terminal, long *x, long *y)
54 + struct selection_cell_coords ss;
56 + g_return_if_fail(VTE_IS_TERMINAL(terminal));
58 + ss = terminal->pvt->selection_start;
70 +_vte_terminal_get_end_selection(VteTerminal *terminal, long *x, long *y)
72 + struct selection_cell_coords se;
74 + g_return_if_fail(VTE_IS_TERMINAL(terminal));
76 + se = terminal->pvt->selection_end;
88 +_vte_terminal_select_text(VteTerminal *terminal, long start_x, long start_y, long end_x, long end_y, int start_offset, int end_offset)
90 + g_return_if_fail(VTE_IS_TERMINAL(terminal));
92 + terminal->pvt->selection_type = selection_type_char;
93 + terminal->pvt->has_selection = TRUE;
94 + terminal->pvt->selecting_had_delta = TRUE;
95 + terminal->pvt->selection_start.x = start_x;
96 + terminal->pvt->selection_start.y = start_y;
97 + terminal->pvt->selection_end.x = end_x;
98 + terminal->pvt->selection_end.y = end_y;
99 + vte_terminal_copy(terminal,
100 + GDK_SELECTION_PRIMARY);
101 + vte_invalidate_cells (terminal,
103 + terminal->column_count,
104 + MIN (start_y, end_y),
105 + ABS (start_y - end_y) + 1);
107 + vte_terminal_emit_selection_changed(terminal);
111 +_vte_terminal_remove_selection(VteTerminal *terminal)
113 + vte_terminal_deselect_all (terminal);
115 Index: vte/src/vteaccess.c
116 ===================================================================
117 RCS file: /cvs/gnome/vte/src/vteaccess.c,v
118 retrieving revision 1.44
119 diff -u -p -r1.44 vteaccess.c
120 --- vte/src/vteaccess.c 1 May 2004 07:12:51 -0000 1.44
121 +++ vte/src/vteaccess.c 6 May 2004 08:11:37 -0000
122 @@ -150,7 +150,7 @@ xy_from_offset (VteTerminalAccessiblePri
125 if (i == priv->snapshot_linebreaks->len) {
126 - if (offset < priv->snapshot_characters->len) {
127 + if (offset <= priv->snapshot_characters->len) {
128 cur_x = offset - cur_offset;
131 @@ -735,6 +735,16 @@ vte_terminal_accessible_visibility_notif
135 +vte_terminal_accessible_selection_changed (VteTerminal *terminal,
138 + g_return_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(data));
139 + g_return_if_fail(VTE_IS_TERMINAL(terminal));
141 + g_signal_emit_by_name (data, "text_selection_changed");
145 vte_terminal_initialize (AtkObject *obj, gpointer data)
147 VteTerminal *terminal;
148 @@ -777,6 +787,9 @@ vte_terminal_initialize (AtkObject *obj,
149 g_signal_connect(G_OBJECT(terminal), "visibility-notify-event",
150 GTK_SIGNAL_FUNC(vte_terminal_accessible_visibility_notify),
152 + g_signal_connect(G_OBJECT(terminal), "selection-changed",
153 + GTK_SIGNAL_FUNC(vte_terminal_accessible_selection_changed),
156 if (GTK_IS_WIDGET((GTK_WIDGET(terminal))->parent)) {
157 parent = gtk_widget_get_accessible((GTK_WIDGET(terminal))->parent);
158 @@ -1382,55 +1395,136 @@ vte_terminal_accessible_get_offset_at_po
160 vte_terminal_accessible_get_n_selections(AtkText *text)
162 - g_return_val_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(text), 0);
164 + VteTerminal *terminal;
166 + g_return_val_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(text), -1);
167 vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(text),
172 + widget = GTK_ACCESSIBLE(text)->widget;
173 + if (widget == NULL) {
174 + /* State is defunct */
177 + g_return_val_if_fail (VTE_IS_TERMINAL (widget), -1);
178 + terminal = VTE_TERMINAL (widget);
179 + return (vte_terminal_get_has_selection (terminal)) ? 1 : 0;
183 vte_terminal_accessible_get_selection(AtkText *text, gint selection_number,
184 gint *start_offset, gint *end_offset)
187 + VteTerminal *terminal;
188 + VteTerminalAccessiblePrivate *priv;
189 + long start_x, start_y, end_x, end_y;
191 g_return_val_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(text), NULL);
192 vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(text),
196 + widget = GTK_ACCESSIBLE(text)->widget;
197 + if (widget == NULL) {
198 + /* State is defunct */
201 + g_return_val_if_fail (VTE_IS_TERMINAL (widget), NULL);
202 + terminal = VTE_TERMINAL (widget);
203 + if (!vte_terminal_get_has_selection (terminal)) {
206 + if (selection_number != 0) {
210 + priv = g_object_get_data(G_OBJECT(text),
211 + VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA);
212 + _vte_terminal_get_start_selection (terminal, &start_x, &start_y);
213 + *start_offset = offset_from_xy (priv, start_x, start_y);
214 + _vte_terminal_get_end_selection (terminal, &end_x, &end_y);
215 + *end_offset = offset_from_xy (priv, end_x, end_y);
216 + return _vte_terminal_get_selection (terminal);
220 vte_terminal_accessible_add_selection(AtkText *text,
221 gint start_offset, gint end_offset)
224 + VteTerminal *terminal;
225 + VteTerminalAccessiblePrivate *priv;
226 + gint start_x, start_y, end_x, end_y;
228 g_return_val_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(text), FALSE);
229 vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(text),
233 + widget = GTK_ACCESSIBLE(text)->widget;
234 + if (widget == NULL) {
235 + /* State is defunct */
238 + g_return_val_if_fail (VTE_IS_TERMINAL (widget), FALSE);
239 + terminal = VTE_TERMINAL (widget);
240 + g_return_val_if_fail (!vte_terminal_get_has_selection (terminal), FALSE);
241 + priv = g_object_get_data(G_OBJECT(text),
242 + VTE_TERMINAL_ACCESSIBLE_PRIVATE_DATA);
243 + xy_from_offset (priv, start_offset, &start_x, &start_y);
244 + xy_from_offset (priv, end_offset, &end_x, &end_y);
245 + _vte_terminal_select_text (terminal, start_x, start_y, end_x, end_y, start_offset, end_offset);
250 vte_terminal_accessible_remove_selection(AtkText *text,
251 gint selection_number)
254 + VteTerminal *terminal;
256 g_return_val_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(text), FALSE);
257 vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(text),
261 + widget = GTK_ACCESSIBLE(text)->widget;
262 + if (widget == NULL) {
263 + /* State is defunct */
266 + g_return_val_if_fail (VTE_IS_TERMINAL (widget), FALSE);
267 + terminal = VTE_TERMINAL (widget);
268 + if (selection_number == 0 && vte_terminal_get_has_selection (terminal)) {
269 + _vte_terminal_remove_selection (terminal);
277 vte_terminal_accessible_set_selection(AtkText *text, gint selection_number,
278 gint start_offset, gint end_offset)
281 + VteTerminal *terminal;
283 g_return_val_if_fail(VTE_IS_TERMINAL_ACCESSIBLE(text), FALSE);
284 vte_terminal_accessible_update_private_data_if_needed(ATK_OBJECT(text),
288 + widget = GTK_ACCESSIBLE(text)->widget;
289 + if (widget == NULL) {
290 + /* State is defunct */
293 + g_return_val_if_fail (VTE_IS_TERMINAL (widget), FALSE);
294 + terminal = VTE_TERMINAL (widget);
295 + if (selection_number != 0) {
298 + if (vte_terminal_get_has_selection (terminal)) {
299 + _vte_terminal_remove_selection (terminal);
302 + return vte_terminal_accessible_add_selection (text, start_offset, end_offset);
306 @@ -1519,6 +1613,9 @@ vte_terminal_accessible_get_position(Atk
309 widget = (GTK_ACCESSIBLE(component))->widget;
310 + if (widget == NULL) {
313 if (!GTK_WIDGET_REALIZED(widget)) {
316 @@ -1543,6 +1640,9 @@ vte_terminal_accessible_get_size(AtkComp
319 widget = (GTK_ACCESSIBLE(component))->widget;
320 + if (widget == NULL) {
323 if (!GTK_WIDGET_REALIZED(widget)) {
326 @@ -1575,7 +1675,12 @@ vte_terminal_accessible_set_size(AtkComp
328 VteTerminal *terminal;
329 gint columns, rows, xpad, ypad;
330 - terminal = VTE_TERMINAL((GTK_ACCESSIBLE(component))->widget);
332 + widget = GTK_ACCESSIBLE(component)->widget;
333 + if (widget == NULL) {
336 + terminal = VTE_TERMINAL(widget);
337 vte_terminal_get_padding(terminal, &xpad, &ypad);
338 /* If the size is an exact multiple of the cell size, use that,
339 * otherwise round down. */
340 @@ -1599,6 +1704,9 @@ vte_terminal_accessible_grab_focus(AtkCo
343 widget = (GTK_ACCESSIBLE(component))->widget;
344 + if (widget == NULL) {
347 if (GTK_WIDGET_HAS_FOCUS(widget)) {
350 Index: vte/src/vteint.h
351 ===================================================================
352 RCS file: /cvs/gnome/vte/src/vteint.h,v
353 retrieving revision 1.1
354 diff -u -p -r1.1 vteint.h
355 --- vte/src/vteint.h 16 Jun 2003 21:16:33 -0000 1.1
356 +++ vte/src/vteint.h 6 May 2004 08:11:37 -0000
360 void _vte_terminal_accessible_ref(VteTerminal *terminal);
361 +char* _vte_terminal_get_selection(VteTerminal *terminal);
362 +void _vte_terminal_get_start_selection(VteTerminal *terminal, long *x, long *y);
363 +void _vte_terminal_get_end_selection(VteTerminal *terminal, long *x, long *y);
364 +void _vte_terminal_select_text(VteTerminal *terminal, long start_x, long start_y, long end_x, long end_y, int start_offset, int end_offset);
365 +void _vte_terminal_remove_selection(VteTerminal *terminal);