Commit b0ece9a932a7239cf7fc14888c88ec7aae51cd58
1 parent
7f11a0a3
Exists in
master
and in
5 other branches
Implementando acessibilidade
Showing
1 changed file
with
112 additions
and
14 deletions
Show diff stats
src/gtk/v3270/accessible.c
@@ -52,7 +52,7 @@ | @@ -52,7 +52,7 @@ | ||
52 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ | 52 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ |
53 | 53 | ||
54 | static void atk_component_interface_init (AtkComponentIface *iface); | 54 | static void atk_component_interface_init (AtkComponentIface *iface); |
55 | - | 55 | +static void atk_action_interface_init (AtkActionIface *iface); |
56 | static void v3270_accessible_class_init (v3270AccessibleClass *klass); | 56 | static void v3270_accessible_class_init (v3270AccessibleClass *klass); |
57 | static void v3270_accessible_init (v3270Accessible *widget); | 57 | static void v3270_accessible_init (v3270Accessible *widget); |
58 | 58 | ||
@@ -62,7 +62,9 @@ static void atk_text_interface_init (AtkTextIface *iface); | @@ -62,7 +62,9 @@ static void atk_text_interface_init (AtkTextIface *iface); | ||
62 | 62 | ||
63 | G_DEFINE_TYPE_WITH_CODE (v3270Accessible, v3270_accessible, GTK_TYPE_ACCESSIBLE, | 63 | G_DEFINE_TYPE_WITH_CODE (v3270Accessible, v3270_accessible, GTK_TYPE_ACCESSIBLE, |
64 | G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init) | 64 | G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init) |
65 | - G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init) ) | 65 | + G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init) |
66 | + G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init) | ||
67 | + ) | ||
66 | 68 | ||
67 | // G_IMPLEMENT_INTERFACE (ATK_TYPE_EDITABLE_TEXT, atk_editable_text_interface_init) ) | 69 | // G_IMPLEMENT_INTERFACE (ATK_TYPE_EDITABLE_TEXT, atk_editable_text_interface_init) ) |
68 | // G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init) | 70 | // G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init) |
@@ -71,12 +73,25 @@ G_DEFINE_TYPE_WITH_CODE (v3270Accessible, v3270_accessible, GTK_TYPE_ACCESSIBLE, | @@ -71,12 +73,25 @@ G_DEFINE_TYPE_WITH_CODE (v3270Accessible, v3270_accessible, GTK_TYPE_ACCESSIBLE, | ||
71 | 73 | ||
72 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 74 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
73 | 75 | ||
76 | +/* | ||
77 | +static const gchar * v3270_accessible_get_description (AtkObject *accessible) | ||
78 | +{ | ||
79 | + GtkWidget *widget = gtk_accessible_get_widget(GTK_ACCESSIBLE (accessible)); | ||
80 | + | ||
81 | + if (widget == NULL) | ||
82 | + return NULL; | ||
83 | + | ||
84 | + return _( "3270 screen" ); | ||
85 | +} | ||
86 | +*/ | ||
87 | + | ||
74 | static void v3270_accessible_class_init(v3270AccessibleClass *klass) | 88 | static void v3270_accessible_class_init(v3270AccessibleClass *klass) |
75 | { | 89 | { |
76 | AtkObjectClass *class = ATK_OBJECT_CLASS (klass); | 90 | AtkObjectClass *class = ATK_OBJECT_CLASS (klass); |
77 | 91 | ||
92 | +// class->get_description = v3270_accessible_get_description; | ||
93 | + | ||
78 | /* | 94 | /* |
79 | - class->get_description = v3270_accessible_get_description; | ||
80 | 95 | ||
81 | 96 | ||
82 | klass->notify_gtk = gtk_widget_accessible_notify_gtk; | 97 | klass->notify_gtk = gtk_widget_accessible_notify_gtk; |
@@ -91,16 +106,45 @@ static void v3270_accessible_class_init(v3270AccessibleClass *klass) | @@ -91,16 +106,45 @@ static void v3270_accessible_class_init(v3270AccessibleClass *klass) | ||
91 | */ | 106 | */ |
92 | } | 107 | } |
93 | 108 | ||
94 | -static void atk_component_interface_init(AtkComponentIface *iface) | 109 | +static gint v3270_accessible_get_n_actions(AtkAction *action) |
110 | +{ | ||
111 | + return 1; | ||
112 | +} | ||
113 | + | ||
114 | +static const gchar* v3270_accessible_action_get_name (AtkAction *action, gint i) | ||
115 | +{ | ||
116 | + if (i != 0) | ||
117 | + return NULL; | ||
118 | + | ||
119 | + return "activate"; | ||
120 | +} | ||
121 | + | ||
122 | +static gboolean v3270_accessible_do_action(AtkAction *action, gint i) | ||
95 | { | 123 | { |
124 | + GtkWidget *widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action)); | ||
125 | + | ||
126 | + if(widget == NULL) | ||
127 | + return FALSE; | ||
128 | + | ||
129 | + if(!gtk_widget_get_sensitive (widget) || !gtk_widget_get_visible (widget)) | ||
130 | + return FALSE; | ||
131 | + | ||
132 | + if (i != 0) | ||
133 | + return FALSE; | ||
134 | + | ||
135 | + gtk_widget_activate(widget); | ||
136 | + | ||
137 | + return TRUE; | ||
138 | +} | ||
139 | + | ||
140 | +static void atk_action_interface_init(AtkActionIface *iface) | ||
141 | +{ | ||
142 | + iface->get_name = v3270_accessible_action_get_name; | ||
143 | + iface->get_n_actions = v3270_accessible_get_n_actions; | ||
144 | + iface->do_action = v3270_accessible_do_action; | ||
145 | + | ||
96 | /* | 146 | /* |
97 | - iface->get_extents = gtk_widget_accessible_get_extents; | ||
98 | - iface->get_size = gtk_widget_accessible_get_size; | ||
99 | - iface->get_layer = gtk_widget_accessible_get_layer; | ||
100 | - iface->grab_focus = gtk_widget_accessible_grab_focus; | ||
101 | - iface->set_extents = gtk_widget_accessible_set_extents; | ||
102 | - iface->set_position = gtk_widget_accessible_set_position; | ||
103 | - iface->set_size = gtk_widget_accessible_set_size; | 147 | + iface->get_keybinding = gtk_entry_accessible_get_keybinding; |
104 | */ | 148 | */ |
105 | } | 149 | } |
106 | 150 | ||
@@ -215,8 +259,6 @@ static void v3270_accessible_get_character_extents( AtkText *text, | @@ -215,8 +259,6 @@ static void v3270_accessible_get_character_extents( AtkText *text, | ||
215 | GdkWindow * window; | 259 | GdkWindow * window; |
216 | gint x_window, y_window; | 260 | gint x_window, y_window; |
217 | 261 | ||
218 | - trace("**************************** %s",__FUNCTION__); | ||
219 | - | ||
220 | if (widget == NULL) | 262 | if (widget == NULL) |
221 | return; | 263 | return; |
222 | 264 | ||
@@ -241,6 +283,8 @@ static void v3270_accessible_get_character_extents( AtkText *text, | @@ -241,6 +283,8 @@ static void v3270_accessible_get_character_extents( AtkText *text, | ||
241 | *y -= y_window; | 283 | *y -= y_window; |
242 | } | 284 | } |
243 | 285 | ||
286 | + trace("%s: offset=%d x=%d y=%d",__FUNCTION__,offset,x,y); | ||
287 | + | ||
244 | } | 288 | } |
245 | 289 | ||
246 | static gchar * v3270_accessible_get_text_at_offset(AtkText *atk_text, gint offset, AtkTextBoundary boundary_type, gint *start_offset, gint *end_offset) | 290 | static gchar * v3270_accessible_get_text_at_offset(AtkText *atk_text, gint offset, AtkTextBoundary boundary_type, gint *start_offset, gint *end_offset) |
@@ -412,10 +456,64 @@ static void atk_text_interface_init(AtkTextIface *iface) | @@ -412,10 +456,64 @@ static void atk_text_interface_init(AtkTextIface *iface) | ||
412 | static void v3270_accessible_init(v3270Accessible *widget) | 456 | static void v3270_accessible_init(v3270Accessible *widget) |
413 | { | 457 | { |
414 | AtkObject *obj = ATK_OBJECT(widget); | 458 | AtkObject *obj = ATK_OBJECT(widget); |
459 | + obj->role = ATK_ROLE_TEXT; | ||
460 | +} | ||
415 | 461 | ||
416 | 462 | ||
417 | - obj->role = ATK_ROLE_TEXT; | 463 | +void v3270_accessible_get_extents(AtkComponent *component, gint *x, gint *y,gint *width,gint *height, AtkCoordType coord_type) |
464 | +{ | ||
465 | + GtkWidget *widget = gtk_accessible_get_widget(GTK_ACCESSIBLE (component)); | ||
466 | + GdkWindow *window; | ||
467 | + gint x_window, y_window; | ||
468 | + GtkAllocation allocation; | ||
469 | + | ||
470 | + if (widget == NULL) | ||
471 | + return; | ||
472 | + | ||
473 | + gtk_widget_get_allocation (widget, &allocation); | ||
474 | + *width = allocation.width; | ||
475 | + *height = allocation.height; | ||
476 | + | ||
477 | + if(gtk_widget_get_parent(widget)) | ||
478 | + { | ||
479 | + *x = allocation.x; | ||
480 | + *y = allocation.y; | ||
481 | + window = gtk_widget_get_parent_window (widget); | ||
482 | + } | ||
483 | + else | ||
484 | + { | ||
485 | + *x = 0; | ||
486 | + *y = 0; | ||
487 | + window = gtk_widget_get_window (widget); | ||
488 | + } | ||
489 | + | ||
490 | + gdk_window_get_origin(window, &x_window, &y_window); | ||
491 | + *x += x_window; | ||
492 | + *y += y_window; | ||
493 | + | ||
494 | + if (coord_type == ATK_XY_WINDOW) | ||
495 | + { | ||
496 | + gint x_toplevel, y_toplevel; | ||
497 | + | ||
498 | + window = gdk_window_get_toplevel (gtk_widget_get_window (widget)); | ||
499 | + gdk_window_get_origin (window, &x_toplevel, &y_toplevel); | ||
500 | + | ||
501 | + *x -= x_toplevel; | ||
502 | + *y -= y_toplevel; | ||
503 | + } | ||
418 | } | 504 | } |
419 | 505 | ||
506 | +static void atk_component_interface_init(AtkComponentIface *iface) | ||
507 | +{ | ||
508 | + iface->get_extents = v3270_accessible_get_extents; | ||
420 | 509 | ||
510 | +/* | ||
511 | + iface->get_size = gtk_widget_accessible_get_size; | ||
512 | + iface->get_layer = gtk_widget_accessible_get_layer; | ||
513 | + iface->grab_focus = gtk_widget_accessible_grab_focus; | ||
514 | + iface->set_extents = gtk_widget_accessible_set_extents; | ||
515 | + iface->set_position = gtk_widget_accessible_set_position; | ||
516 | + iface->set_size = gtk_widget_accessible_set_size; | ||
517 | +*/ | ||
518 | +} | ||
421 | 519 |