| 1 |
/* GTK+ - accessibility implementations |
| 2 |
* Copyright (C) 2002, 2004 Anders Carlsson <[email protected]> |
| 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, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
#include "config.h" |
| 19 |
|
| 20 |
#include "gtkiconviewaccessibleprivate.h" |
| 21 |
|
| 22 |
#include <string.h> |
| 23 |
|
| 24 |
#include "gtk/gtkadjustment.h" |
| 25 |
#include "gtk/gtkiconviewprivate.h" |
| 26 |
#include "gtk/gtkcellrendererpixbuf.h" |
| 27 |
#include "gtk/gtkcellrenderertext.h" |
| 28 |
#include "gtk/gtkpango.h" |
| 29 |
#include "gtk/gtkwidgetprivate.h" |
| 30 |
|
| 31 |
#define GTK_TYPE_ICON_VIEW_ITEM_ACCESSIBLE (_gtk_icon_view_item_accessible_get_type ()) |
| 32 |
#define GTK_ICON_VIEW_ITEM_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ICON_VIEW_ITEM_ACCESSIBLE, GtkIconViewItemAccessible)) |
| 33 |
#define GTK_IS_ICON_VIEW_ITEM_ACCESSIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ICON_VIEW_ITEM_ACCESSIBLE)) |
| 34 |
|
| 35 |
struct _GtkIconViewAccessiblePrivate |
| 36 |
{ |
| 37 |
GList *items; |
| 38 |
GtkTreeModel *model; |
| 39 |
}; |
| 40 |
|
| 41 |
typedef struct |
| 42 |
{ |
| 43 |
AtkObject parent; |
| 44 |
|
| 45 |
GtkIconViewItem *item; |
| 46 |
GtkWidget *widget; |
| 47 |
AtkStateSet *state_set; |
| 48 |
gchar *text; |
| 49 |
gchar *action_description; |
| 50 |
gchar *image_description; |
| 51 |
guint action_idle_handler; |
| 52 |
} GtkIconViewItemAccessible; |
| 53 |
|
| 54 |
typedef struct |
| 55 |
{ |
| 56 |
AtkObjectClass parent_class; |
| 57 |
|
| 58 |
} GtkIconViewItemAccessibleClass; |
| 59 |
|
| 60 |
GType _gtk_icon_view_item_accessible_get_type (void); |
| 61 |
|
| 62 |
static gboolean gtk_icon_view_item_accessible_is_showing (GtkIconViewItemAccessible *item); |
| 63 |
|
| 64 |
static void atk_component_item_interface_init (AtkComponentIface *iface); |
| 65 |
static void atk_action_item_interface_init (AtkActionIface *iface); |
| 66 |
static void atk_text_item_interface_init (AtkTextIface *iface); |
| 67 |
static void atk_image_item_interface_init (AtkImageIface *iface); |
| 68 |
|
| 69 |
G_DEFINE_TYPE_WITH_CODE (GtkIconViewItemAccessible, _gtk_icon_view_item_accessible, ATK_TYPE_OBJECT, |
| 70 |
G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_item_interface_init) |
| 71 |
G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_item_interface_init) |
| 72 |
G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_item_interface_init) |
| 73 |
G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_item_interface_init)) |
| 74 |
|
| 75 |
|
| 76 |
static gboolean |
| 77 |
idle_do_action (gpointer data) |
| 78 |
{ |
| 79 |
GtkIconViewItemAccessible *item; |
| 80 |
GtkIconView *icon_view; |
| 81 |
GtkTreePath *path; |
| 82 |
|
| 83 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (data); |
| 84 |
item->action_idle_handler = 0; |
| 85 |
|
| 86 |
if (item->widget != NULL) |
| 87 |
{ |
| 88 |
icon_view = GTK_ICON_VIEW (item->widget); |
| 89 |
path = gtk_tree_path_new_from_indices (item->item->index, -1); |
| 90 |
gtk_icon_view_item_activated (icon_view, path); |
| 91 |
gtk_tree_path_free (path); |
| 92 |
} |
| 93 |
|
| 94 |
return FALSE; |
| 95 |
} |
| 96 |
|
| 97 |
static gboolean |
| 98 |
gtk_icon_view_item_accessible_do_action (AtkAction *action, |
| 99 |
gint i) |
| 100 |
{ |
| 101 |
GtkIconViewItemAccessible *item; |
| 102 |
|
| 103 |
if (i != 0) |
| 104 |
return FALSE; |
| 105 |
|
| 106 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (action); |
| 107 |
|
| 108 |
if (!GTK_IS_ICON_VIEW (item->widget)) |
| 109 |
return FALSE; |
| 110 |
|
| 111 |
if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT)) |
| 112 |
return FALSE; |
| 113 |
|
| 114 |
if (!item->action_idle_handler) |
| 115 |
{ |
| 116 |
item->action_idle_handler = gdk_threads_add_idle (idle_do_action, item); |
| 117 |
g_source_set_name_by_id (item->action_idle_handler, "[gtk+] idle_do_action"); |
| 118 |
} |
| 119 |
|
| 120 |
return TRUE; |
| 121 |
} |
| 122 |
|
| 123 |
static gint |
| 124 |
gtk_icon_view_item_accessible_get_n_actions (AtkAction *action) |
| 125 |
{ |
| 126 |
return 1; |
| 127 |
} |
| 128 |
|
| 129 |
static const gchar * |
| 130 |
gtk_icon_view_item_accessible_get_description (AtkAction *action, |
| 131 |
gint i) |
| 132 |
{ |
| 133 |
GtkIconViewItemAccessible *item; |
| 134 |
|
| 135 |
if (i != 0) |
| 136 |
return NULL; |
| 137 |
|
| 138 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (action); |
| 139 |
|
| 140 |
if (item->action_description) |
| 141 |
return item->action_description; |
| 142 |
else |
| 143 |
return "Activate item"; |
| 144 |
} |
| 145 |
|
| 146 |
static const gchar * |
| 147 |
gtk_icon_view_item_accessible_get_name (AtkAction *action, |
| 148 |
gint i) |
| 149 |
{ |
| 150 |
if (i != 0) |
| 151 |
return NULL; |
| 152 |
|
| 153 |
return "activate"; |
| 154 |
} |
| 155 |
|
| 156 |
static gboolean |
| 157 |
gtk_icon_view_item_accessible_set_description (AtkAction *action, |
| 158 |
gint i, |
| 159 |
const gchar *description) |
| 160 |
{ |
| 161 |
GtkIconViewItemAccessible *item; |
| 162 |
|
| 163 |
if (i != 0) |
| 164 |
return FALSE; |
| 165 |
|
| 166 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (action); |
| 167 |
|
| 168 |
g_free (item->action_description); |
| 169 |
item->action_description = g_strdup (description); |
| 170 |
|
| 171 |
return TRUE; |
| 172 |
} |
| 173 |
|
| 174 |
static void |
| 175 |
atk_action_item_interface_init (AtkActionIface *iface) |
| 176 |
{ |
| 177 |
iface->do_action = gtk_icon_view_item_accessible_do_action; |
| 178 |
iface->set_description = gtk_icon_view_item_accessible_set_description; |
| 179 |
iface->get_name = gtk_icon_view_item_accessible_get_name; |
| 180 |
iface->get_n_actions = gtk_icon_view_item_accessible_get_n_actions; |
| 181 |
iface->get_description = gtk_icon_view_item_accessible_get_description; |
| 182 |
} |
| 183 |
|
| 184 |
static const gchar * |
| 185 |
gtk_icon_view_item_accessible_get_image_description (AtkImage *image) |
| 186 |
{ |
| 187 |
GtkIconViewItemAccessible *item; |
| 188 |
|
| 189 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (image); |
| 190 |
|
| 191 |
return item->image_description; |
| 192 |
} |
| 193 |
|
| 194 |
static gboolean |
| 195 |
gtk_icon_view_item_accessible_set_image_description (AtkImage *image, |
| 196 |
const gchar *description) |
| 197 |
{ |
| 198 |
GtkIconViewItemAccessible *item; |
| 199 |
|
| 200 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (image); |
| 201 |
|
| 202 |
g_free (item->image_description); |
| 203 |
item->image_description = g_strdup (description); |
| 204 |
|
| 205 |
return TRUE; |
| 206 |
} |
| 207 |
|
| 208 |
typedef struct { |
| 209 |
GdkRectangle box; |
| 210 |
gboolean pixbuf_found; |
| 211 |
} GetPixbufBoxData; |
| 212 |
|
| 213 |
static gboolean |
| 214 |
get_pixbuf_foreach (GtkCellRenderer *renderer, |
| 215 |
const GdkRectangle *cell_area, |
| 216 |
const GdkRectangle *cell_background, |
| 217 |
GetPixbufBoxData *data) |
| 218 |
{ |
| 219 |
if (GTK_IS_CELL_RENDERER_PIXBUF (renderer)) |
| 220 |
{ |
| 221 |
data->box = *cell_area; |
| 222 |
data->pixbuf_found = TRUE; |
| 223 |
} |
| 224 |
return (data->pixbuf_found != FALSE); |
| 225 |
} |
| 226 |
|
| 227 |
static gboolean |
| 228 |
get_pixbuf_box (GtkIconView *icon_view, |
| 229 |
GtkIconViewItem *item, |
| 230 |
GdkRectangle *box) |
| 231 |
{ |
| 232 |
GetPixbufBoxData data = { { 0, }, FALSE }; |
| 233 |
GtkCellAreaContext *context; |
| 234 |
|
| 235 |
context = g_ptr_array_index (icon_view->priv->row_contexts, item->row); |
| 236 |
|
| 237 |
_gtk_icon_view_set_cell_data (icon_view, item); |
| 238 |
gtk_cell_area_foreach_alloc (icon_view->priv->cell_area, context, |
| 239 |
GTK_WIDGET (icon_view), |
| 240 |
&item->cell_area, &item->cell_area, |
| 241 |
(GtkCellAllocCallback)get_pixbuf_foreach, &data); |
| 242 |
|
| 243 |
*box = data.box; |
| 244 |
|
| 245 |
return data.pixbuf_found; |
| 246 |
} |
| 247 |
|
| 248 |
static gboolean |
| 249 |
get_text_foreach (GtkCellRenderer *renderer, |
| 250 |
gchar **text) |
| 251 |
{ |
| 252 |
if (GTK_IS_CELL_RENDERER_TEXT (renderer)) |
| 253 |
{ |
| 254 |
g_object_get (renderer, "text", text, NULL); |
| 255 |
return TRUE; |
| 256 |
} |
| 257 |
return FALSE; |
| 258 |
} |
| 259 |
|
| 260 |
static gchar * |
| 261 |
get_text (GtkIconView *icon_view, |
| 262 |
GtkIconViewItem *item) |
| 263 |
{ |
| 264 |
gchar *text = NULL; |
| 265 |
|
| 266 |
_gtk_icon_view_set_cell_data (icon_view, item); |
| 267 |
gtk_cell_area_foreach (icon_view->priv->cell_area, |
| 268 |
(GtkCellCallback)get_text_foreach, &text); |
| 269 |
|
| 270 |
return text; |
| 271 |
} |
| 272 |
|
| 273 |
static void |
| 274 |
gtk_icon_view_item_accessible_get_image_size (AtkImage *image, |
| 275 |
gint *width, |
| 276 |
gint *height) |
| 277 |
{ |
| 278 |
GtkIconViewItemAccessible *item; |
| 279 |
GdkRectangle box; |
| 280 |
|
| 281 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (image); |
| 282 |
|
| 283 |
if (!GTK_IS_ICON_VIEW (item->widget)) |
| 284 |
return; |
| 285 |
|
| 286 |
if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT)) |
| 287 |
return; |
| 288 |
|
| 289 |
*width = 0; |
| 290 |
*height = 0; |
| 291 |
|
| 292 |
if (get_pixbuf_box (GTK_ICON_VIEW (item->widget), item->item, &box)) |
| 293 |
{ |
| 294 |
*width = box.width; |
| 295 |
*height = box.height; |
| 296 |
} |
| 297 |
} |
| 298 |
|
| 299 |
static void |
| 300 |
gtk_icon_view_item_accessible_get_image_position (AtkImage *image, |
| 301 |
gint *x, |
| 302 |
gint *y, |
| 303 |
AtkCoordType coord_type) |
| 304 |
{ |
| 305 |
GtkIconViewItemAccessible *item; |
| 306 |
GdkRectangle box; |
| 307 |
|
| 308 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (image); |
| 309 |
|
| 310 |
if (!GTK_IS_ICON_VIEW (item->widget)) |
| 311 |
return; |
| 312 |
|
| 313 |
if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT)) |
| 314 |
return; |
| 315 |
|
| 316 |
atk_component_get_extents (ATK_COMPONENT (image), x, y, NULL, NULL, |
| 317 |
coord_type); |
| 318 |
|
| 319 |
if (get_pixbuf_box (GTK_ICON_VIEW (item->widget), item->item, &box)) |
| 320 |
{ |
| 321 |
*x+= box.x - item->item->cell_area.x; |
| 322 |
*y+= box.y - item->item->cell_area.y; |
| 323 |
} |
| 324 |
|
| 325 |
} |
| 326 |
|
| 327 |
static void |
| 328 |
atk_image_item_interface_init (AtkImageIface *iface) |
| 329 |
{ |
| 330 |
iface->get_image_description = gtk_icon_view_item_accessible_get_image_description; |
| 331 |
iface->set_image_description = gtk_icon_view_item_accessible_set_image_description; |
| 332 |
iface->get_image_size = gtk_icon_view_item_accessible_get_image_size; |
| 333 |
iface->get_image_position = gtk_icon_view_item_accessible_get_image_position; |
| 334 |
} |
| 335 |
|
| 336 |
static gchar * |
| 337 |
gtk_icon_view_item_accessible_get_text (AtkText *text, |
| 338 |
gint start_pos, |
| 339 |
gint end_pos) |
| 340 |
{ |
| 341 |
GtkIconViewItemAccessible *item; |
| 342 |
|
| 343 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (text); |
| 344 |
if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT)) |
| 345 |
return NULL; |
| 346 |
|
| 347 |
if (item->text) |
| 348 |
return g_utf8_substring (item->text, start_pos, end_pos > -1 ? end_pos : g_utf8_strlen (item->text, -1)); |
| 349 |
else |
| 350 |
return g_strdup (""); |
| 351 |
} |
| 352 |
|
| 353 |
static gunichar |
| 354 |
gtk_icon_view_item_accessible_get_character_at_offset (AtkText *text, |
| 355 |
gint offset) |
| 356 |
{ |
| 357 |
GtkIconViewItemAccessible *item; |
| 358 |
gchar *string; |
| 359 |
gchar *index; |
| 360 |
|
| 361 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (text); |
| 362 |
if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT)) |
| 363 |
return '\0'; |
| 364 |
|
| 365 |
string = item->text; |
| 366 |
|
| 367 |
if (!string) |
| 368 |
return '\0'; |
| 369 |
|
| 370 |
if (offset >= g_utf8_strlen (string, -1)) |
| 371 |
return '\0'; |
| 372 |
|
| 373 |
index = g_utf8_offset_to_pointer (string, offset); |
| 374 |
|
| 375 |
return g_utf8_get_char (index); |
| 376 |
} |
| 377 |
|
| 378 |
static PangoLayout * |
| 379 |
create_pango_layout (GtkIconViewItemAccessible *item) |
| 380 |
{ |
| 381 |
PangoLayout *layout; |
| 382 |
|
| 383 |
layout = gtk_widget_create_pango_layout (item->widget, item->text); |
| 384 |
|
| 385 |
return layout; |
| 386 |
} |
| 387 |
|
| 388 |
static gchar * |
| 389 |
gtk_icon_view_item_accessible_get_text_before_offset (AtkText *atk_text, |
| 390 |
gint offset, |
| 391 |
AtkTextBoundary boundary_type, |
| 392 |
gint *start_offset, |
| 393 |
gint *end_offset) |
| 394 |
{ |
| 395 |
GtkIconViewItemAccessible *item; |
| 396 |
PangoLayout *layout; |
| 397 |
gchar *text; |
| 398 |
|
| 399 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (atk_text); |
| 400 |
if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT)) |
| 401 |
return NULL; |
| 402 |
|
| 403 |
layout = create_pango_layout (item); |
| 404 |
text = _gtk_pango_get_text_before (layout, boundary_type, offset, start_offset, end_offset); |
| 405 |
g_object_unref (layout); |
| 406 |
|
| 407 |
return text; |
| 408 |
} |
| 409 |
|
| 410 |
static gchar * |
| 411 |
gtk_icon_view_item_accessible_get_text_at_offset (AtkText *atk_text, |
| 412 |
gint offset, |
| 413 |
AtkTextBoundary boundary_type, |
| 414 |
gint *start_offset, |
| 415 |
gint *end_offset) |
| 416 |
{ |
| 417 |
GtkIconViewItemAccessible *item; |
| 418 |
PangoLayout *layout; |
| 419 |
gchar *text; |
| 420 |
|
| 421 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (atk_text); |
| 422 |
if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT)) |
| 423 |
return NULL; |
| 424 |
|
| 425 |
layout = create_pango_layout (item); |
| 426 |
text = _gtk_pango_get_text_at (layout, boundary_type, offset, start_offset, end_offset); |
| 427 |
g_object_unref (layout); |
| 428 |
|
| 429 |
return text; |
| 430 |
} |
| 431 |
|
| 432 |
static gchar * |
| 433 |
gtk_icon_view_item_accessible_get_text_after_offset (AtkText *atk_text, |
| 434 |
gint offset, |
| 435 |
AtkTextBoundary boundary_type, |
| 436 |
gint *start_offset, |
| 437 |
gint *end_offset) |
| 438 |
{ |
| 439 |
GtkIconViewItemAccessible *item; |
| 440 |
PangoLayout *layout; |
| 441 |
gchar *text; |
| 442 |
|
| 443 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (atk_text); |
| 444 |
if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT)) |
| 445 |
return NULL; |
| 446 |
|
| 447 |
layout = create_pango_layout (item); |
| 448 |
text = _gtk_pango_get_text_after (layout, boundary_type, offset, start_offset, end_offset); |
| 449 |
g_object_unref (layout); |
| 450 |
|
| 451 |
return text; |
| 452 |
} |
| 453 |
|
| 454 |
static gint |
| 455 |
gtk_icon_view_item_accessible_get_character_count (AtkText *text) |
| 456 |
{ |
| 457 |
GtkIconViewItemAccessible *item; |
| 458 |
|
| 459 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (text); |
| 460 |
if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT)) |
| 461 |
return 0; |
| 462 |
|
| 463 |
if (item->text) |
| 464 |
return g_utf8_strlen (item->text, -1); |
| 465 |
else |
| 466 |
return 0; |
| 467 |
} |
| 468 |
|
| 469 |
static void |
| 470 |
gtk_icon_view_item_accessible_get_character_extents (AtkText *text, |
| 471 |
gint offset, |
| 472 |
gint *x, |
| 473 |
gint *y, |
| 474 |
gint *width, |
| 475 |
gint *height, |
| 476 |
AtkCoordType coord_type) |
| 477 |
{ |
| 478 |
GtkIconViewItemAccessible *item; |
| 479 |
#if 0 |
| 480 |
GtkIconView *icon_view; |
| 481 |
PangoRectangle char_rect; |
| 482 |
const gchar *item_text; |
| 483 |
gint index; |
| 484 |
#endif |
| 485 |
|
| 486 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (text); |
| 487 |
|
| 488 |
if (!GTK_IS_ICON_VIEW (item->widget)) |
| 489 |
return; |
| 490 |
|
| 491 |
if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT)) |
| 492 |
return; |
| 493 |
|
| 494 |
#if 0 |
| 495 |
icon_view = GTK_ICON_VIEW (item->widget); |
| 496 |
/* FIXME we probably have to use GailTextCell to salvage this */ |
| 497 |
gtk_icon_view_update_item_text (icon_view, item->item); |
| 498 |
item_text = pango_layout_get_text (icon_view->priv->layout); |
| 499 |
index = g_utf8_offset_to_pointer (item_text, offset) - item_text; |
| 500 |
pango_layout_index_to_pos (icon_view->priv->layout, index, &char_rect); |
| 501 |
|
| 502 |
atk_component_get_position (ATK_COMPONENT (text), x, y, coord_type); |
| 503 |
*x += item->item->layout_x - item->item->x + char_rect.x / PANGO_SCALE; |
| 504 |
/* Look at gtk_icon_view_paint_item() to see where the text is. */ |
| 505 |
*x -= ((item->item->width - item->item->layout_width) / 2) + (MAX (item->item->pixbuf_width, icon_view->priv->item_width) - item->item->width) / 2, |
| 506 |
*y += item->item->layout_y - item->item->y + char_rect.y / PANGO_SCALE; |
| 507 |
*width = char_rect.width / PANGO_SCALE; |
| 508 |
*height = char_rect.height / PANGO_SCALE; |
| 509 |
#endif |
| 510 |
} |
| 511 |
|
| 512 |
static gint |
| 513 |
gtk_icon_view_item_accessible_get_offset_at_point (AtkText *text, |
| 514 |
gint x, |
| 515 |
gint y, |
| 516 |
AtkCoordType coord_type) |
| 517 |
{ |
| 518 |
GtkIconViewItemAccessible *item; |
| 519 |
gint offset = 0; |
| 520 |
#if 0 |
| 521 |
GtkIconView *icon_view; |
| 522 |
const gchar *item_text; |
| 523 |
gint index; |
| 524 |
gint l_x, l_y; |
| 525 |
#endif |
| 526 |
|
| 527 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (text); |
| 528 |
|
| 529 |
if (!GTK_IS_ICON_VIEW (item->widget)) |
| 530 |
return -1; |
| 531 |
|
| 532 |
if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT)) |
| 533 |
return -1; |
| 534 |
|
| 535 |
#if 0 |
| 536 |
icon_view = GTK_ICON_VIEW (item->widget); |
| 537 |
/* FIXME we probably have to use GailTextCell to salvage this */ |
| 538 |
gtk_icon_view_update_item_text (icon_view, item->item); |
| 539 |
atk_component_get_position (ATK_COMPONENT (text), &l_x, &l_y, coord_type); |
| 540 |
x -= l_x + item->item->layout_x - item->item->x; |
| 541 |
x += ((item->item->width - item->item->layout_width) / 2) + (MAX (item->item->pixbuf_width, icon_view->priv->item_width) - item->item->width) / 2, |
| 542 |
y -= l_y + item->item->layout_y - item->item->y; |
| 543 |
item_text = pango_layout_get_text (icon_view->priv->layout); |
| 544 |
if (!pango_layout_xy_to_index (icon_view->priv->layout, |
| 545 |
x * PANGO_SCALE, |
| 546 |
y * PANGO_SCALE, |
| 547 |
&index, NULL)) |
| 548 |
{ |
| 549 |
if (x < 0 || y < 0) |
| 550 |
index = 0; |
| 551 |
else |
| 552 |
index = -1; |
| 553 |
} |
| 554 |
if (index == -1) |
| 555 |
offset = g_utf8_strlen (item_text, -1); |
| 556 |
else |
| 557 |
offset = g_utf8_pointer_to_offset (item_text, item_text + index); |
| 558 |
#endif |
| 559 |
return offset; |
| 560 |
} |
| 561 |
|
| 562 |
static void |
| 563 |
atk_text_item_interface_init (AtkTextIface *iface) |
| 564 |
{ |
| 565 |
iface->get_text = gtk_icon_view_item_accessible_get_text; |
| 566 |
iface->get_character_at_offset = gtk_icon_view_item_accessible_get_character_at_offset; |
| 567 |
iface->get_text_before_offset = gtk_icon_view_item_accessible_get_text_before_offset; |
| 568 |
iface->get_text_at_offset = gtk_icon_view_item_accessible_get_text_at_offset; |
| 569 |
iface->get_text_after_offset = gtk_icon_view_item_accessible_get_text_after_offset; |
| 570 |
iface->get_character_count = gtk_icon_view_item_accessible_get_character_count; |
| 571 |
iface->get_character_extents = gtk_icon_view_item_accessible_get_character_extents; |
| 572 |
iface->get_offset_at_point = gtk_icon_view_item_accessible_get_offset_at_point; |
| 573 |
} |
| 574 |
|
| 575 |
static void |
| 576 |
gtk_icon_view_item_accessible_get_extents (AtkComponent *component, |
| 577 |
gint *x, |
| 578 |
gint *y, |
| 579 |
gint *width, |
| 580 |
gint *height, |
| 581 |
AtkCoordType coord_type) |
| 582 |
{ |
| 583 |
GtkIconViewItemAccessible *item; |
| 584 |
AtkObject *parent_obj; |
| 585 |
gint l_x, l_y; |
| 586 |
|
| 587 |
g_return_if_fail (GTK_IS_ICON_VIEW_ITEM_ACCESSIBLE (component)); |
| 588 |
|
| 589 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (component); |
| 590 |
if (!GTK_IS_WIDGET (item->widget)) |
| 591 |
return; |
| 592 |
|
| 593 |
if (atk_state_set_contains_state (item->state_set, ATK_STATE_DEFUNCT)) |
| 594 |
return; |
| 595 |
|
| 596 |
*width = item->item->cell_area.width; |
| 597 |
*height = item->item->cell_area.height; |
| 598 |
if (gtk_icon_view_item_accessible_is_showing (item)) |
| 599 |
{ |
| 600 |
parent_obj = gtk_widget_get_accessible (item->widget); |
| 601 |
atk_component_get_extents (ATK_COMPONENT (parent_obj), &l_x, &l_y, |
| 602 |
NULL, NULL, coord_type); |
| 603 |
*x = l_x + item->item->cell_area.x; |
| 604 |
*y = l_y + item->item->cell_area.y; |
| 605 |
} |
| 606 |
else |
| 607 |
{ |
| 608 |
*x = G_MININT; |
| 609 |
*y = G_MININT; |
| 610 |
} |
| 611 |
} |
| 612 |
|
| 613 |
static gboolean |
| 614 |
gtk_icon_view_item_accessible_grab_focus (AtkComponent *component) |
| 615 |
{ |
| 616 |
GtkIconViewItemAccessible *item; |
| 617 |
GtkWidget *toplevel; |
| 618 |
|
| 619 |
g_return_val_if_fail (GTK_IS_ICON_VIEW_ITEM_ACCESSIBLE (component), FALSE); |
| 620 |
|
| 621 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (component); |
| 622 |
if (!GTK_IS_WIDGET (item->widget)) |
| 623 |
return FALSE; |
| 624 |
|
| 625 |
gtk_widget_grab_focus (item->widget); |
| 626 |
_gtk_icon_view_set_cursor_item (GTK_ICON_VIEW (item->widget), item->item, NULL); |
| 627 |
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (item->widget)); |
| 628 |
if (gtk_widget_is_toplevel (toplevel)) |
| 629 |
{ |
| 630 |
G_GNUC_BEGIN_IGNORE_DEPRECATIONS |
| 631 |
gtk_window_present (GTK_WINDOW (toplevel)); |
| 632 |
G_GNUC_END_IGNORE_DEPRECATIONS |
| 633 |
} |
| 634 |
|
| 635 |
return TRUE; |
| 636 |
} |
| 637 |
|
| 638 |
static void |
| 639 |
atk_component_item_interface_init (AtkComponentIface *iface) |
| 640 |
{ |
| 641 |
iface->get_extents = gtk_icon_view_item_accessible_get_extents; |
| 642 |
iface->grab_focus = gtk_icon_view_item_accessible_grab_focus; |
| 643 |
} |
| 644 |
|
| 645 |
static gboolean |
| 646 |
gtk_icon_view_item_accessible_add_state (GtkIconViewItemAccessible *item, |
| 647 |
AtkStateType state_type, |
| 648 |
gboolean emit_signal) |
| 649 |
{ |
| 650 |
gboolean rc; |
| 651 |
|
| 652 |
rc = atk_state_set_add_state (item->state_set, state_type); |
| 653 |
|
| 654 |
/* The signal should only be generated if the value changed, |
| 655 |
* not when the item is set up. So states that are set |
| 656 |
* initially should pass FALSE as the emit_signal argument. |
| 657 |
*/ |
| 658 |
if (emit_signal) |
| 659 |
{ |
| 660 |
atk_object_notify_state_change (ATK_OBJECT (item), state_type, TRUE); |
| 661 |
/* If state_type is ATK_STATE_VISIBLE, additional notification */ |
| 662 |
if (state_type == ATK_STATE_VISIBLE) |
| 663 |
g_signal_emit_by_name (item, "visible-data-changed"); |
| 664 |
} |
| 665 |
|
| 666 |
return rc; |
| 667 |
} |
| 668 |
|
| 669 |
static gboolean |
| 670 |
gtk_icon_view_item_accessible_remove_state (GtkIconViewItemAccessible *item, |
| 671 |
AtkStateType state_type, |
| 672 |
gboolean emit_signal) |
| 673 |
{ |
| 674 |
if (atk_state_set_contains_state (item->state_set, state_type)) |
| 675 |
{ |
| 676 |
gboolean rc; |
| 677 |
|
| 678 |
rc = atk_state_set_remove_state (item->state_set, state_type); |
| 679 |
|
| 680 |
/* The signal should only be generated if the value changed, |
| 681 |
* not when the item is set up. So states that are set |
| 682 |
* initially should pass FALSE as the emit_signal argument. |
| 683 |
*/ |
| 684 |
if (emit_signal) |
| 685 |
{ |
| 686 |
atk_object_notify_state_change (ATK_OBJECT (item), state_type, FALSE); |
| 687 |
/* If state_type is ATK_STATE_VISIBLE, additional notification */ |
| 688 |
if (state_type == ATK_STATE_VISIBLE) |
| 689 |
g_signal_emit_by_name (item, "visible-data-changed"); |
| 690 |
} |
| 691 |
|
| 692 |
return rc; |
| 693 |
} |
| 694 |
else |
| 695 |
return FALSE; |
| 696 |
} |
| 697 |
|
| 698 |
static gboolean |
| 699 |
gtk_icon_view_item_accessible_is_showing (GtkIconViewItemAccessible *item) |
| 700 |
{ |
| 701 |
GtkAllocation allocation; |
| 702 |
GtkIconView *icon_view; |
| 703 |
GdkRectangle visible_rect; |
| 704 |
gboolean is_showing; |
| 705 |
|
| 706 |
/* An item is considered "SHOWING" if any part of the item |
| 707 |
* is in the visible rectangle. |
| 708 |
*/ |
| 709 |
if (!GTK_IS_ICON_VIEW (item->widget)) |
| 710 |
return FALSE; |
| 711 |
|
| 712 |
if (item->item == NULL) |
| 713 |
return FALSE; |
| 714 |
|
| 715 |
gtk_widget_get_allocation (item->widget, &allocation); |
| 716 |
|
| 717 |
icon_view = GTK_ICON_VIEW (item->widget); |
| 718 |
visible_rect.x = 0; |
| 719 |
if (icon_view->priv->hadjustment) |
| 720 |
visible_rect.x += gtk_adjustment_get_value (icon_view->priv->hadjustment); |
| 721 |
visible_rect.y = 0; |
| 722 |
if (icon_view->priv->vadjustment) |
| 723 |
visible_rect.y += gtk_adjustment_get_value (icon_view->priv->vadjustment); |
| 724 |
visible_rect.width = allocation.width; |
| 725 |
visible_rect.height = allocation.height; |
| 726 |
|
| 727 |
if (((item->item->cell_area.x + item->item->cell_area.width) < visible_rect.x) || |
| 728 |
((item->item->cell_area.y + item->item->cell_area.height) < (visible_rect.y)) || |
| 729 |
(item->item->cell_area.x > (visible_rect.x + visible_rect.width)) || |
| 730 |
(item->item->cell_area.y > (visible_rect.y + visible_rect.height))) |
| 731 |
is_showing = FALSE; |
| 732 |
else |
| 733 |
is_showing = TRUE; |
| 734 |
|
| 735 |
return is_showing; |
| 736 |
} |
| 737 |
|
| 738 |
static gboolean |
| 739 |
gtk_icon_view_item_accessible_set_visibility (GtkIconViewItemAccessible *item, |
| 740 |
gboolean emit_signal) |
| 741 |
{ |
| 742 |
if (gtk_icon_view_item_accessible_is_showing (item)) |
| 743 |
return gtk_icon_view_item_accessible_add_state (item, ATK_STATE_SHOWING, |
| 744 |
emit_signal); |
| 745 |
else |
| 746 |
return gtk_icon_view_item_accessible_remove_state (item, ATK_STATE_SHOWING, |
| 747 |
emit_signal); |
| 748 |
} |
| 749 |
|
| 750 |
static void |
| 751 |
_gtk_icon_view_item_accessible_init (GtkIconViewItemAccessible *item) |
| 752 |
{ |
| 753 |
item->state_set = atk_state_set_new (); |
| 754 |
|
| 755 |
atk_state_set_add_state (item->state_set, ATK_STATE_ENABLED); |
| 756 |
atk_state_set_add_state (item->state_set, ATK_STATE_FOCUSABLE); |
| 757 |
atk_state_set_add_state (item->state_set, ATK_STATE_SENSITIVE); |
| 758 |
atk_state_set_add_state (item->state_set, ATK_STATE_SELECTABLE); |
| 759 |
atk_state_set_add_state (item->state_set, ATK_STATE_VISIBLE); |
| 760 |
|
| 761 |
item->action_description = NULL; |
| 762 |
item->image_description = NULL; |
| 763 |
|
| 764 |
item->action_idle_handler = 0; |
| 765 |
} |
| 766 |
|
| 767 |
static void |
| 768 |
_gtk_icon_view_item_accessible_finalize (GObject *object) |
| 769 |
{ |
| 770 |
GtkIconViewItemAccessible *item; |
| 771 |
|
| 772 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (object); |
| 773 |
|
| 774 |
if (item->widget) |
| 775 |
g_object_remove_weak_pointer (G_OBJECT (item->widget), (gpointer) &item->widget); |
| 776 |
|
| 777 |
if (item->state_set) |
| 778 |
g_object_unref (item->state_set); |
| 779 |
|
| 780 |
|
| 781 |
g_free (item->text); |
| 782 |
g_free (item->action_description); |
| 783 |
g_free (item->image_description); |
| 784 |
|
| 785 |
if (item->action_idle_handler) |
| 786 |
{ |
| 787 |
g_source_remove (item->action_idle_handler); |
| 788 |
item->action_idle_handler = 0; |
| 789 |
} |
| 790 |
|
| 791 |
G_OBJECT_CLASS (_gtk_icon_view_item_accessible_parent_class)->finalize (object); |
| 792 |
} |
| 793 |
|
| 794 |
static AtkObject* |
| 795 |
_gtk_icon_view_item_accessible_get_parent (AtkObject *obj) |
| 796 |
{ |
| 797 |
GtkIconViewItemAccessible *item; |
| 798 |
|
| 799 |
g_return_val_if_fail (GTK_IS_ICON_VIEW_ITEM_ACCESSIBLE (obj), NULL); |
| 800 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (obj); |
| 801 |
|
| 802 |
if (item->widget) |
| 803 |
return gtk_widget_get_accessible (item->widget); |
| 804 |
else |
| 805 |
return NULL; |
| 806 |
} |
| 807 |
|
| 808 |
static gint |
| 809 |
_gtk_icon_view_item_accessible_get_index_in_parent (AtkObject *obj) |
| 810 |
{ |
| 811 |
GtkIconViewItemAccessible *item; |
| 812 |
|
| 813 |
g_return_val_if_fail (GTK_IS_ICON_VIEW_ITEM_ACCESSIBLE (obj), 0); |
| 814 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (obj); |
| 815 |
|
| 816 |
return item->item->index; |
| 817 |
} |
| 818 |
|
| 819 |
static AtkStateSet * |
| 820 |
_gtk_icon_view_item_accessible_ref_state_set (AtkObject *obj) |
| 821 |
{ |
| 822 |
GtkIconViewItemAccessible *item; |
| 823 |
GtkIconView *icon_view; |
| 824 |
|
| 825 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (obj); |
| 826 |
g_return_val_if_fail (item->state_set, NULL); |
| 827 |
|
| 828 |
if (!item->widget) |
| 829 |
return NULL; |
| 830 |
|
| 831 |
icon_view = GTK_ICON_VIEW (item->widget); |
| 832 |
if (icon_view->priv->cursor_item == item->item) |
| 833 |
atk_state_set_add_state (item->state_set, ATK_STATE_FOCUSED); |
| 834 |
else |
| 835 |
atk_state_set_remove_state (item->state_set, ATK_STATE_FOCUSED); |
| 836 |
if (item->item->selected) |
| 837 |
atk_state_set_add_state (item->state_set, ATK_STATE_SELECTED); |
| 838 |
else |
| 839 |
atk_state_set_remove_state (item->state_set, ATK_STATE_SELECTED); |
| 840 |
|
| 841 |
return g_object_ref (item->state_set); |
| 842 |
} |
| 843 |
|
| 844 |
static void |
| 845 |
_gtk_icon_view_item_accessible_class_init (GtkIconViewItemAccessibleClass *klass) |
| 846 |
{ |
| 847 |
GObjectClass *gobject_class; |
| 848 |
AtkObjectClass *atk_class; |
| 849 |
|
| 850 |
gobject_class = (GObjectClass *)klass; |
| 851 |
atk_class = (AtkObjectClass *)klass; |
| 852 |
|
| 853 |
gobject_class->finalize = _gtk_icon_view_item_accessible_finalize; |
| 854 |
|
| 855 |
atk_class->get_index_in_parent = _gtk_icon_view_item_accessible_get_index_in_parent; |
| 856 |
atk_class->get_parent = _gtk_icon_view_item_accessible_get_parent; |
| 857 |
atk_class->ref_state_set = _gtk_icon_view_item_accessible_ref_state_set; |
| 858 |
} |
| 859 |
|
| 860 |
static void atk_component_interface_init (AtkComponentIface *iface); |
| 861 |
static void atk_selection_interface_init (AtkSelectionIface *iface); |
| 862 |
|
| 863 |
G_DEFINE_TYPE_WITH_CODE (GtkIconViewAccessible, gtk_icon_view_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE, |
| 864 |
G_ADD_PRIVATE (GtkIconViewAccessible) |
| 865 |
G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init) |
| 866 |
G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init)) |
| 867 |
|
| 868 |
typedef struct |
| 869 |
{ |
| 870 |
AtkObject *item; |
| 871 |
gint index; |
| 872 |
} GtkIconViewItemAccessibleInfo; |
| 873 |
|
| 874 |
|
| 875 |
static void |
| 876 |
gtk_icon_view_item_accessible_info_new (AtkObject *accessible, |
| 877 |
AtkObject *item, |
| 878 |
gint index) |
| 879 |
{ |
| 880 |
GtkIconViewAccessible *view = (GtkIconViewAccessible *)accessible; |
| 881 |
GtkIconViewItemAccessibleInfo *info; |
| 882 |
GtkIconViewItemAccessibleInfo *tmp_info; |
| 883 |
GList *items; |
| 884 |
|
| 885 |
info = g_new (GtkIconViewItemAccessibleInfo, 1); |
| 886 |
info->item = item; |
| 887 |
info->index = index; |
| 888 |
|
| 889 |
items = view->priv->items; |
| 890 |
while (items) |
| 891 |
{ |
| 892 |
tmp_info = items->data; |
| 893 |
if (tmp_info->index > index) |
| 894 |
break; |
| 895 |
items = items->next; |
| 896 |
} |
| 897 |
view->priv->items = g_list_insert_before (view->priv->items, items, info); |
| 898 |
} |
| 899 |
|
| 900 |
static gint |
| 901 |
gtk_icon_view_accessible_get_n_children (AtkObject *accessible) |
| 902 |
{ |
| 903 |
GtkIconView *icon_view; |
| 904 |
GtkWidget *widget; |
| 905 |
|
| 906 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); |
| 907 |
if (!widget) |
| 908 |
return 0; |
| 909 |
|
| 910 |
icon_view = GTK_ICON_VIEW (widget); |
| 911 |
|
| 912 |
return g_list_length (icon_view->priv->items); |
| 913 |
} |
| 914 |
|
| 915 |
static AtkObject * |
| 916 |
gtk_icon_view_accessible_find_child (AtkObject *accessible, |
| 917 |
gint index) |
| 918 |
{ |
| 919 |
GtkIconViewAccessible *view = (GtkIconViewAccessible*)accessible; |
| 920 |
GtkIconViewItemAccessibleInfo *info; |
| 921 |
GList *items; |
| 922 |
|
| 923 |
items = view->priv->items; |
| 924 |
|
| 925 |
while (items) |
| 926 |
{ |
| 927 |
info = items->data; |
| 928 |
if (info->index == index) |
| 929 |
return info->item; |
| 930 |
items = items->next; |
| 931 |
} |
| 932 |
|
| 933 |
return NULL; |
| 934 |
} |
| 935 |
|
| 936 |
static AtkObject * |
| 937 |
gtk_icon_view_accessible_ref_child (AtkObject *accessible, |
| 938 |
gint index) |
| 939 |
{ |
| 940 |
GtkIconView *icon_view; |
| 941 |
GtkWidget *widget; |
| 942 |
GList *icons; |
| 943 |
AtkObject *obj; |
| 944 |
GtkIconViewItemAccessible *a11y_item; |
| 945 |
|
| 946 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); |
| 947 |
if (!widget) |
| 948 |
return NULL; |
| 949 |
|
| 950 |
icon_view = GTK_ICON_VIEW (widget); |
| 951 |
icons = g_list_nth (icon_view->priv->items, index); |
| 952 |
obj = NULL; |
| 953 |
if (icons) |
| 954 |
{ |
| 955 |
GtkIconViewItem *item = icons->data; |
| 956 |
|
| 957 |
g_return_val_if_fail (item->index == index, NULL); |
| 958 |
obj = gtk_icon_view_accessible_find_child (accessible, index); |
| 959 |
if (!obj) |
| 960 |
{ |
| 961 |
obj = g_object_new (GTK_TYPE_ICON_VIEW_ITEM_ACCESSIBLE, NULL); |
| 962 |
gtk_icon_view_item_accessible_info_new (accessible, obj, index); |
| 963 |
obj->role = ATK_ROLE_ICON; |
| 964 |
a11y_item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (obj); |
| 965 |
a11y_item->item = item; |
| 966 |
a11y_item->widget = widget; |
| 967 |
|
| 968 |
g_free (a11y_item->text); |
| 969 |
a11y_item->text = get_text (icon_view, item); |
| 970 |
|
| 971 |
gtk_icon_view_item_accessible_set_visibility (a11y_item, FALSE); |
| 972 |
g_object_add_weak_pointer (G_OBJECT (widget), (gpointer) &(a11y_item->widget)); |
| 973 |
} |
| 974 |
g_object_ref (obj); |
| 975 |
} |
| 976 |
return obj; |
| 977 |
} |
| 978 |
|
| 979 |
static void |
| 980 |
gtk_icon_view_accessible_traverse_items (GtkIconViewAccessible *view, |
| 981 |
GList *list) |
| 982 |
{ |
| 983 |
GtkIconViewItemAccessibleInfo *info; |
| 984 |
GtkIconViewItemAccessible *item; |
| 985 |
GList *items; |
| 986 |
|
| 987 |
if (view->priv->items) |
| 988 |
{ |
| 989 |
GtkWidget *widget; |
| 990 |
gboolean act_on_item; |
| 991 |
|
| 992 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (view)); |
| 993 |
if (widget == NULL) |
| 994 |
return; |
| 995 |
|
| 996 |
items = view->priv->items; |
| 997 |
|
| 998 |
act_on_item = (list == NULL); |
| 999 |
|
| 1000 |
while (items) |
| 1001 |
{ |
| 1002 |
|
| 1003 |
info = (GtkIconViewItemAccessibleInfo *)items->data; |
| 1004 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item); |
| 1005 |
|
| 1006 |
if (act_on_item == FALSE && list == items) |
| 1007 |
act_on_item = TRUE; |
| 1008 |
|
| 1009 |
if (act_on_item) |
| 1010 |
gtk_icon_view_item_accessible_set_visibility (item, TRUE); |
| 1011 |
|
| 1012 |
items = items->next; |
| 1013 |
} |
| 1014 |
} |
| 1015 |
} |
| 1016 |
|
| 1017 |
void |
| 1018 |
_gtk_icon_view_accessible_adjustment_changed (GtkIconView *icon_view) |
| 1019 |
{ |
| 1020 |
GtkIconViewAccessible *view; |
| 1021 |
|
| 1022 |
view = GTK_ICON_VIEW_ACCESSIBLE (_gtk_widget_peek_accessible (GTK_WIDGET (icon_view))); |
| 1023 |
if (view == NULL) |
| 1024 |
return; |
| 1025 |
|
| 1026 |
gtk_icon_view_accessible_traverse_items (view, NULL); |
| 1027 |
} |
| 1028 |
|
| 1029 |
static void |
| 1030 |
gtk_icon_view_accessible_model_row_changed (GtkTreeModel *tree_model, |
| 1031 |
GtkTreePath *path, |
| 1032 |
GtkTreeIter *iter, |
| 1033 |
gpointer user_data) |
| 1034 |
{ |
| 1035 |
AtkObject *atk_obj; |
| 1036 |
gint index; |
| 1037 |
GtkWidget *widget; |
| 1038 |
GtkIconView *icon_view; |
| 1039 |
GtkIconViewItem *item; |
| 1040 |
GtkIconViewItemAccessible *a11y_item; |
| 1041 |
const gchar *name; |
| 1042 |
|
| 1043 |
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data)); |
| 1044 |
index = gtk_tree_path_get_indices(path)[0]; |
| 1045 |
a11y_item = GTK_ICON_VIEW_ITEM_ACCESSIBLE ( |
| 1046 |
gtk_icon_view_accessible_find_child (atk_obj, index)); |
| 1047 |
|
| 1048 |
if (a11y_item) |
| 1049 |
{ |
| 1050 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (atk_obj)); |
| 1051 |
icon_view = GTK_ICON_VIEW (widget); |
| 1052 |
item = a11y_item->item; |
| 1053 |
|
| 1054 |
name = atk_object_get_name (ATK_OBJECT (a11y_item)); |
| 1055 |
if (!name || strcmp (name, "") == 0) |
| 1056 |
{ |
| 1057 |
g_free (a11y_item->text); |
| 1058 |
a11y_item->text = get_text (icon_view, item); |
| 1059 |
} |
| 1060 |
} |
| 1061 |
|
| 1062 |
g_signal_emit_by_name (atk_obj, "visible-data-changed"); |
| 1063 |
|
| 1064 |
return; |
| 1065 |
} |
| 1066 |
|
| 1067 |
static void |
| 1068 |
gtk_icon_view_accessible_model_row_inserted (GtkTreeModel *tree_model, |
| 1069 |
GtkTreePath *path, |
| 1070 |
GtkTreeIter *iter, |
| 1071 |
gpointer user_data) |
| 1072 |
{ |
| 1073 |
GtkIconViewItemAccessibleInfo *info; |
| 1074 |
GtkIconViewAccessible *view; |
| 1075 |
GtkIconViewItemAccessible *item; |
| 1076 |
GList *items; |
| 1077 |
GList *tmp_list; |
| 1078 |
AtkObject *atk_obj; |
| 1079 |
gint index; |
| 1080 |
|
| 1081 |
index = gtk_tree_path_get_indices(path)[0]; |
| 1082 |
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data)); |
| 1083 |
view = GTK_ICON_VIEW_ACCESSIBLE (atk_obj); |
| 1084 |
|
| 1085 |
items = view->priv->items; |
| 1086 |
tmp_list = NULL; |
| 1087 |
while (items) |
| 1088 |
{ |
| 1089 |
info = items->data; |
| 1090 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item); |
| 1091 |
if (info->index != item->item->index) |
| 1092 |
{ |
| 1093 |
if (info->index < index) |
| 1094 |
g_warning ("Unexpected index value on insertion %d %d", index, info->index); |
| 1095 |
|
| 1096 |
if (tmp_list == NULL) |
| 1097 |
tmp_list = items; |
| 1098 |
|
| 1099 |
info->index = item->item->index; |
| 1100 |
} |
| 1101 |
|
| 1102 |
items = items->next; |
| 1103 |
} |
| 1104 |
gtk_icon_view_accessible_traverse_items (view, tmp_list); |
| 1105 |
g_signal_emit_by_name (atk_obj, "children-changed::add", |
| 1106 |
index, NULL, NULL); |
| 1107 |
return; |
| 1108 |
} |
| 1109 |
|
| 1110 |
static void |
| 1111 |
gtk_icon_view_accessible_model_row_deleted (GtkTreeModel *tree_model, |
| 1112 |
GtkTreePath *path, |
| 1113 |
gpointer user_data) |
| 1114 |
{ |
| 1115 |
GtkIconViewItemAccessibleInfo *info; |
| 1116 |
GtkIconViewAccessible *view; |
| 1117 |
GtkIconViewItemAccessible *item; |
| 1118 |
GList *items; |
| 1119 |
GList *tmp_list; |
| 1120 |
GList *deleted_item; |
| 1121 |
AtkObject *atk_obj; |
| 1122 |
gint index; |
| 1123 |
|
| 1124 |
index = gtk_tree_path_get_indices(path)[0]; |
| 1125 |
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data)); |
| 1126 |
view = GTK_ICON_VIEW_ACCESSIBLE (atk_obj); |
| 1127 |
|
| 1128 |
items = view->priv->items; |
| 1129 |
tmp_list = NULL; |
| 1130 |
deleted_item = NULL; |
| 1131 |
info = NULL; |
| 1132 |
while (items) |
| 1133 |
{ |
| 1134 |
info = items->data; |
| 1135 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item); |
| 1136 |
if (info->index == index) |
| 1137 |
{ |
| 1138 |
deleted_item = items; |
| 1139 |
} |
| 1140 |
else if (info->index != item->item->index) |
| 1141 |
{ |
| 1142 |
if (tmp_list == NULL) |
| 1143 |
tmp_list = items; |
| 1144 |
|
| 1145 |
info->index = item->item->index; |
| 1146 |
} |
| 1147 |
|
| 1148 |
items = items->next; |
| 1149 |
} |
| 1150 |
if (deleted_item) |
| 1151 |
{ |
| 1152 |
info = deleted_item->data; |
| 1153 |
gtk_icon_view_item_accessible_add_state (GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item), ATK_STATE_DEFUNCT, TRUE); |
| 1154 |
g_signal_emit_by_name (atk_obj, "children-changed::remove", |
| 1155 |
index, NULL, NULL); |
| 1156 |
view->priv->items = g_list_delete_link (view->priv->items, deleted_item); |
| 1157 |
g_object_unref (info->item); |
| 1158 |
g_free (info); |
| 1159 |
} |
| 1160 |
gtk_icon_view_accessible_traverse_items (view, tmp_list); |
| 1161 |
|
| 1162 |
return; |
| 1163 |
} |
| 1164 |
|
| 1165 |
static gint |
| 1166 |
gtk_icon_view_accessible_item_compare (GtkIconViewItemAccessibleInfo *i1, |
| 1167 |
GtkIconViewItemAccessibleInfo *i2) |
| 1168 |
{ |
| 1169 |
return i1->index - i2->index; |
| 1170 |
} |
| 1171 |
|
| 1172 |
static void |
| 1173 |
gtk_icon_view_accessible_model_rows_reordered (GtkTreeModel *tree_model, |
| 1174 |
GtkTreePath *path, |
| 1175 |
GtkTreeIter *iter, |
| 1176 |
gint *new_order, |
| 1177 |
gpointer user_data) |
| 1178 |
{ |
| 1179 |
GtkIconViewAccessible *view; |
| 1180 |
GtkIconViewItemAccessibleInfo *info; |
| 1181 |
GtkIconView *icon_view; |
| 1182 |
GtkIconViewItemAccessible *item; |
| 1183 |
GList *items; |
| 1184 |
AtkObject *atk_obj; |
| 1185 |
gint *order; |
| 1186 |
gint length, i; |
| 1187 |
|
| 1188 |
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data)); |
| 1189 |
icon_view = GTK_ICON_VIEW (user_data); |
| 1190 |
view = (GtkIconViewAccessible*)atk_obj; |
| 1191 |
|
| 1192 |
length = gtk_tree_model_iter_n_children (tree_model, NULL); |
| 1193 |
|
| 1194 |
order = g_new (gint, length); |
| 1195 |
for (i = 0; i < length; i++) |
| 1196 |
order [new_order[i]] = i; |
| 1197 |
|
| 1198 |
items = view->priv->items; |
| 1199 |
while (items) |
| 1200 |
{ |
| 1201 |
info = items->data; |
| 1202 |
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item); |
| 1203 |
info->index = order[info->index]; |
| 1204 |
item->item = g_list_nth_data (icon_view->priv->items, info->index); |
| 1205 |
items = items->next; |
| 1206 |
} |
| 1207 |
g_free (order); |
| 1208 |
view->priv->items = g_list_sort (view->priv->items, |
| 1209 |
(GCompareFunc)gtk_icon_view_accessible_item_compare); |
| 1210 |
|
| 1211 |
return; |
| 1212 |
} |
| 1213 |
|
| 1214 |
static void |
| 1215 |
gtk_icon_view_accessible_disconnect_model_signals (GtkTreeModel *model, |
| 1216 |
GtkWidget *widget) |
| 1217 |
{ |
| 1218 |
GObject *obj; |
| 1219 |
|
| 1220 |
obj = G_OBJECT (model); |
| 1221 |
g_signal_handlers_disconnect_by_func (obj, (gpointer) gtk_icon_view_accessible_model_row_changed, widget); |
| 1222 |
g_signal_handlers_disconnect_by_func (obj, (gpointer) gtk_icon_view_accessible_model_row_inserted, widget); |
| 1223 |
g_signal_handlers_disconnect_by_func (obj, (gpointer) gtk_icon_view_accessible_model_row_deleted, widget); |
| 1224 |
g_signal_handlers_disconnect_by_func (obj, (gpointer) gtk_icon_view_accessible_model_rows_reordered, widget); |
| 1225 |
} |
| 1226 |
|
| 1227 |
static void |
| 1228 |
gtk_icon_view_accessible_connect_model_signals (GtkIconView *icon_view) |
| 1229 |
{ |
| 1230 |
GObject *obj; |
| 1231 |
|
| 1232 |
obj = G_OBJECT (icon_view->priv->model); |
| 1233 |
g_signal_connect_object (obj, "row-changed", |
| 1234 |
G_CALLBACK (gtk_icon_view_accessible_model_row_changed), |
| 1235 |
icon_view, 0); |
| 1236 |
g_signal_connect_object (obj, "row-inserted", |
| 1237 |
G_CALLBACK (gtk_icon_view_accessible_model_row_inserted), |
| 1238 |
icon_view, G_CONNECT_AFTER); |
| 1239 |
g_signal_connect_object (obj, "row-deleted", |
| 1240 |
G_CALLBACK (gtk_icon_view_accessible_model_row_deleted), |
| 1241 |
icon_view, G_CONNECT_AFTER); |
| 1242 |
g_signal_connect_object (obj, "rows-reordered", |
| 1243 |
G_CALLBACK (gtk_icon_view_accessible_model_rows_reordered), |
| 1244 |
icon_view, G_CONNECT_AFTER); |
| 1245 |
} |
| 1246 |
|
| 1247 |
static void |
| 1248 |
gtk_icon_view_accessible_clear_cache (GtkIconViewAccessible *view) |
| 1249 |
{ |
| 1250 |
GtkIconViewItemAccessibleInfo *info; |
| 1251 |
GList *items; |
| 1252 |
|
| 1253 |
items = view->priv->items; |
| 1254 |
while (items) |
| 1255 |
{ |
| 1256 |
info = (GtkIconViewItemAccessibleInfo *) items->data; |
| 1257 |
gtk_icon_view_item_accessible_add_state (GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item), ATK_STATE_DEFUNCT, TRUE); |
| 1258 |
g_object_unref (info->item); |
| 1259 |
g_free (items->data); |
| 1260 |
items = items->next; |
| 1261 |
} |
| 1262 |
g_list_free (view->priv->items); |
| 1263 |
view->priv->items = NULL; |
| 1264 |
} |
| 1265 |
|
| 1266 |
static void |
| 1267 |
gtk_icon_view_accessible_notify_gtk (GObject *obj, |
| 1268 |
GParamSpec *pspec) |
| 1269 |
{ |
| 1270 |
GtkIconView *icon_view; |
| 1271 |
GtkWidget *widget; |
| 1272 |
AtkObject *atk_obj; |
| 1273 |
GtkIconViewAccessible *view; |
| 1274 |
|
| 1275 |
if (strcmp (pspec->name, "model") == 0) |
| 1276 |
{ |
| 1277 |
widget = GTK_WIDGET (obj); |
| 1278 |
atk_obj = gtk_widget_get_accessible (widget); |
| 1279 |
view = (GtkIconViewAccessible*)atk_obj; |
| 1280 |
if (view->priv->model) |
| 1281 |
{ |
| 1282 |
g_object_remove_weak_pointer (G_OBJECT (view->priv->model), |
| 1283 |
(gpointer *)&view->priv->model); |
| 1284 |
gtk_icon_view_accessible_disconnect_model_signals (view->priv->model, widget); |
| 1285 |
} |
| 1286 |
gtk_icon_view_accessible_clear_cache (view); |
| 1287 |
|
| 1288 |
icon_view = GTK_ICON_VIEW (obj); |
| 1289 |
view->priv->model = icon_view->priv->model; |
| 1290 |
/* If there is no model the GtkIconView is probably being destroyed */ |
| 1291 |
if (view->priv->model) |
| 1292 |
{ |
| 1293 |
g_object_add_weak_pointer (G_OBJECT (view->priv->model), (gpointer *)&view->priv->model); |
| 1294 |
gtk_icon_view_accessible_connect_model_signals (icon_view); |
| 1295 |
} |
| 1296 |
} |
| 1297 |
|
| 1298 |
return; |
| 1299 |
} |
| 1300 |
|
| 1301 |
static void |
| 1302 |
gtk_icon_view_accessible_initialize (AtkObject *accessible, |
| 1303 |
gpointer data) |
| 1304 |
{ |
| 1305 |
GtkIconViewAccessible *view; |
| 1306 |
GtkIconView *icon_view; |
| 1307 |
|
| 1308 |
if (ATK_OBJECT_CLASS (gtk_icon_view_accessible_parent_class)->initialize) |
| 1309 |
ATK_OBJECT_CLASS (gtk_icon_view_accessible_parent_class)->initialize (accessible, data); |
| 1310 |
|
| 1311 |
icon_view = (GtkIconView*)data; |
| 1312 |
view = (GtkIconViewAccessible*)accessible; |
| 1313 |
|
| 1314 |
g_signal_connect (data, "notify", |
| 1315 |
G_CALLBACK (gtk_icon_view_accessible_notify_gtk), NULL); |
| 1316 |
|
| 1317 |
view->priv->model = icon_view->priv->model; |
| 1318 |
if (view->priv->model) |
| 1319 |
{ |
| 1320 |
g_object_add_weak_pointer (G_OBJECT (view->priv->model), (gpointer *)&view->priv->model); |
| 1321 |
gtk_icon_view_accessible_connect_model_signals (icon_view); |
| 1322 |
} |
| 1323 |
|
| 1324 |
accessible->role = ATK_ROLE_LAYERED_PANE; |
| 1325 |
} |
| 1326 |
|
| 1327 |
static void |
| 1328 |
gtk_icon_view_accessible_finalize (GObject *object) |
| 1329 |
{ |
| 1330 |
GtkIconViewAccessible *view = (GtkIconViewAccessible*)object; |
| 1331 |
|
| 1332 |
gtk_icon_view_accessible_clear_cache (view); |
| 1333 |
|
| 1334 |
G_OBJECT_CLASS (gtk_icon_view_accessible_parent_class)->finalize (object); |
| 1335 |
} |
| 1336 |
|
| 1337 |
static void |
| 1338 |
gtk_icon_view_accessible_class_init (GtkIconViewAccessibleClass *klass) |
| 1339 |
{ |
| 1340 |
GObjectClass *gobject_class; |
| 1341 |
AtkObjectClass *atk_class; |
| 1342 |
|
| 1343 |
gobject_class = (GObjectClass *)klass; |
| 1344 |
atk_class = (AtkObjectClass *)klass; |
| 1345 |
|
| 1346 |
gobject_class->finalize = gtk_icon_view_accessible_finalize; |
| 1347 |
|
| 1348 |
atk_class->get_n_children = gtk_icon_view_accessible_get_n_children; |
| 1349 |
atk_class->ref_child = gtk_icon_view_accessible_ref_child; |
| 1350 |
atk_class->initialize = gtk_icon_view_accessible_initialize; |
| 1351 |
} |
| 1352 |
|
| 1353 |
static void |
| 1354 |
gtk_icon_view_accessible_init (GtkIconViewAccessible *accessible) |
| 1355 |
{ |
| 1356 |
accessible->priv = gtk_icon_view_accessible_get_instance_private (accessible); |
| 1357 |
} |
| 1358 |
|
| 1359 |
static AtkObject* |
| 1360 |
gtk_icon_view_accessible_ref_accessible_at_point (AtkComponent *component, |
| 1361 |
gint x, |
| 1362 |
gint y, |
| 1363 |
AtkCoordType coord_type) |
| 1364 |
{ |
| 1365 |
GtkWidget *widget; |
| 1366 |
GtkIconView *icon_view; |
| 1367 |
GtkIconViewItem *item; |
| 1368 |
gint x_pos, y_pos; |
| 1369 |
|
| 1370 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (component)); |
| 1371 |
if (widget == NULL) |
| 1372 |
return NULL; |
| 1373 |
|
| 1374 |
icon_view = GTK_ICON_VIEW (widget); |
| 1375 |
atk_component_get_extents (component, &x_pos, &y_pos, NULL, NULL, coord_type); |
| 1376 |
item = _gtk_icon_view_get_item_at_coords (icon_view, x - x_pos, y - y_pos, TRUE, NULL); |
| 1377 |
if (item) |
| 1378 |
return gtk_icon_view_accessible_ref_child (ATK_OBJECT (component), item->index); |
| 1379 |
|
| 1380 |
return NULL; |
| 1381 |
} |
| 1382 |
|
| 1383 |
static void |
| 1384 |
atk_component_interface_init (AtkComponentIface *iface) |
| 1385 |
{ |
| 1386 |
iface->ref_accessible_at_point = gtk_icon_view_accessible_ref_accessible_at_point; |
| 1387 |
} |
| 1388 |
|
| 1389 |
static gboolean |
| 1390 |
gtk_icon_view_accessible_add_selection (AtkSelection *selection, |
| 1391 |
gint i) |
| 1392 |
{ |
| 1393 |
GtkWidget *widget; |
| 1394 |
GtkIconView *icon_view; |
| 1395 |
GtkIconViewItem *item; |
| 1396 |
|
| 1397 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection)); |
| 1398 |
if (widget == NULL) |
| 1399 |
return FALSE; |
| 1400 |
|
| 1401 |
icon_view = GTK_ICON_VIEW (widget); |
| 1402 |
|
| 1403 |
item = g_list_nth_data (icon_view->priv->items, i); |
| 1404 |
if (!item) |
| 1405 |
return FALSE; |
| 1406 |
|
| 1407 |
_gtk_icon_view_select_item (icon_view, item); |
| 1408 |
|
| 1409 |
return TRUE; |
| 1410 |
} |
| 1411 |
|
| 1412 |
static gboolean |
| 1413 |
gtk_icon_view_accessible_clear_selection (AtkSelection *selection) |
| 1414 |
{ |
| 1415 |
GtkWidget *widget; |
| 1416 |
GtkIconView *icon_view; |
| 1417 |
|
| 1418 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection)); |
| 1419 |
if (widget == NULL) |
| 1420 |
return FALSE; |
| 1421 |
|
| 1422 |
icon_view = GTK_ICON_VIEW (widget); |
| 1423 |
gtk_icon_view_unselect_all (icon_view); |
| 1424 |
|
| 1425 |
return TRUE; |
| 1426 |
} |
| 1427 |
|
| 1428 |
static AtkObject* |
| 1429 |
gtk_icon_view_accessible_ref_selection (AtkSelection *selection, |
| 1430 |
gint i) |
| 1431 |
{ |
| 1432 |
GList *l; |
| 1433 |
GtkWidget *widget; |
| 1434 |
GtkIconView *icon_view; |
| 1435 |
GtkIconViewItem *item; |
| 1436 |
|
| 1437 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection)); |
| 1438 |
if (widget == NULL) |
| 1439 |
return NULL; |
| 1440 |
|
| 1441 |
icon_view = GTK_ICON_VIEW (widget); |
| 1442 |
|
| 1443 |
l = icon_view->priv->items; |
| 1444 |
while (l) |
| 1445 |
{ |
| 1446 |
item = l->data; |
| 1447 |
if (item->selected) |
| 1448 |
{ |
| 1449 |
if (i == 0) |
| 1450 |
return atk_object_ref_accessible_child (gtk_widget_get_accessible (widget), item->index); |
| 1451 |
else |
| 1452 |
i--; |
| 1453 |
} |
| 1454 |
l = l->next; |
| 1455 |
} |
| 1456 |
|
| 1457 |
return NULL; |
| 1458 |
} |
| 1459 |
|
| 1460 |
static gint |
| 1461 |
gtk_icon_view_accessible_get_selection_count (AtkSelection *selection) |
| 1462 |
{ |
| 1463 |
GtkWidget *widget; |
| 1464 |
GtkIconView *icon_view; |
| 1465 |
GtkIconViewItem *item; |
| 1466 |
GList *l; |
| 1467 |
gint count; |
| 1468 |
|
| 1469 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection)); |
| 1470 |
if (widget == NULL) |
| 1471 |
return 0; |
| 1472 |
|
| 1473 |
icon_view = GTK_ICON_VIEW (widget); |
| 1474 |
|
| 1475 |
l = icon_view->priv->items; |
| 1476 |
count = 0; |
| 1477 |
while (l) |
| 1478 |
{ |
| 1479 |
item = l->data; |
| 1480 |
|
| 1481 |
if (item->selected) |
| 1482 |
count++; |
| 1483 |
|
| 1484 |
l = l->next; |
| 1485 |
} |
| 1486 |
|
| 1487 |
return count; |
| 1488 |
} |
| 1489 |
|
| 1490 |
static gboolean |
| 1491 |
gtk_icon_view_accessible_is_child_selected (AtkSelection *selection, |
| 1492 |
gint i) |
| 1493 |
{ |
| 1494 |
GtkWidget *widget; |
| 1495 |
GtkIconView *icon_view; |
| 1496 |
GtkIconViewItem *item; |
| 1497 |
|
| 1498 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection)); |
| 1499 |
if (widget == NULL) |
| 1500 |
return FALSE; |
| 1501 |
|
| 1502 |
icon_view = GTK_ICON_VIEW (widget); |
| 1503 |
|
| 1504 |
item = g_list_nth_data (icon_view->priv->items, i); |
| 1505 |
if (!item) |
| 1506 |
return FALSE; |
| 1507 |
|
| 1508 |
return item->selected; |
| 1509 |
} |
| 1510 |
|
| 1511 |
static gboolean |
| 1512 |
gtk_icon_view_accessible_remove_selection (AtkSelection *selection, |
| 1513 |
gint i) |
| 1514 |
{ |
| 1515 |
GtkWidget *widget; |
| 1516 |
GtkIconView *icon_view; |
| 1517 |
GtkIconViewItem *item; |
| 1518 |
GList *l; |
| 1519 |
gint count; |
| 1520 |
|
| 1521 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection)); |
| 1522 |
if (widget == NULL) |
| 1523 |
return FALSE; |
| 1524 |
|
| 1525 |
icon_view = GTK_ICON_VIEW (widget); |
| 1526 |
l = icon_view->priv->items; |
| 1527 |
count = 0; |
| 1528 |
while (l) |
| 1529 |
{ |
| 1530 |
item = l->data; |
| 1531 |
if (item->selected) |
| 1532 |
{ |
| 1533 |
if (count == i) |
| 1534 |
{ |
| 1535 |
_gtk_icon_view_unselect_item (icon_view, item); |
| 1536 |
return TRUE; |
| 1537 |
} |
| 1538 |
count++; |
| 1539 |
} |
| 1540 |
l = l->next; |
| 1541 |
} |
| 1542 |
|
| 1543 |
return FALSE; |
| 1544 |
} |
| 1545 |
|
| 1546 |
static gboolean |
| 1547 |
gtk_icon_view_accessible_select_all_selection (AtkSelection *selection) |
| 1548 |
{ |
| 1549 |
GtkWidget *widget; |
| 1550 |
GtkIconView *icon_view; |
| 1551 |
|
| 1552 |
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (selection)); |
| 1553 |
if (widget == NULL) |
| 1554 |
return FALSE; |
| 1555 |
|
| 1556 |
icon_view = GTK_ICON_VIEW (widget); |
| 1557 |
gtk_icon_view_select_all (icon_view); |
| 1558 |
return TRUE; |
| 1559 |
} |
| 1560 |
|
| 1561 |
static void |
| 1562 |
atk_selection_interface_init (AtkSelectionIface *iface) |
| 1563 |
{ |
| 1564 |
iface->add_selection = gtk_icon_view_accessible_add_selection; |
| 1565 |
iface->clear_selection = gtk_icon_view_accessible_clear_selection; |
| 1566 |
iface->ref_selection = gtk_icon_view_accessible_ref_selection; |
| 1567 |
iface->get_selection_count = gtk_icon_view_accessible_get_selection_count; |
| 1568 |
iface->is_child_selected = gtk_icon_view_accessible_is_child_selected; |
| 1569 |
iface->remove_selection = gtk_icon_view_accessible_remove_selection; |
| 1570 |
iface->select_all_selection = gtk_icon_view_accessible_select_all_selection; |
| 1571 |
} |