Commit e9bd3b6d9cc97fd7c3fa8fc5e40fc9ef4cf0dd22
1 parent
5a1d9130
Exists in
master
and in
5 other branches
Implementando avisos de estado
Showing
3 changed files
with
104 additions
and
7 deletions
Show diff stats
src/gtk/v3270/accessible.c
| @@ -73,7 +73,6 @@ G_DEFINE_TYPE_WITH_CODE (v3270Accessible, v3270_accessible, GTK_TYPE_ACCESSIBLE, | @@ -73,7 +73,6 @@ G_DEFINE_TYPE_WITH_CODE (v3270Accessible, v3270_accessible, GTK_TYPE_ACCESSIBLE, | ||
| 73 | 73 | ||
| 74 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 74 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 75 | 75 | ||
| 76 | -/* | ||
| 77 | static const gchar * v3270_accessible_get_description (AtkObject *accessible) | 76 | static const gchar * v3270_accessible_get_description (AtkObject *accessible) |
| 78 | { | 77 | { |
| 79 | GtkWidget *widget = gtk_accessible_get_widget(GTK_ACCESSIBLE (accessible)); | 78 | GtkWidget *widget = gtk_accessible_get_widget(GTK_ACCESSIBLE (accessible)); |
| @@ -83,16 +82,15 @@ static const gchar * v3270_accessible_get_description (AtkObject *accessible) | @@ -83,16 +82,15 @@ static const gchar * v3270_accessible_get_description (AtkObject *accessible) | ||
| 83 | 82 | ||
| 84 | return _( "3270 screen" ); | 83 | return _( "3270 screen" ); |
| 85 | } | 84 | } |
| 86 | -*/ | ||
| 87 | 85 | ||
| 88 | static void v3270_accessible_class_init(v3270AccessibleClass *klass) | 86 | static void v3270_accessible_class_init(v3270AccessibleClass *klass) |
| 89 | { | 87 | { |
| 90 | AtkObjectClass *class = ATK_OBJECT_CLASS (klass); | 88 | AtkObjectClass *class = ATK_OBJECT_CLASS (klass); |
| 91 | 89 | ||
| 92 | -// class->get_description = v3270_accessible_get_description; | 90 | + class->get_description = v3270_accessible_get_description; |
| 93 | 91 | ||
| 94 | /* | 92 | /* |
| 95 | - | 93 | + class->focus_event = gtk_widget_accessible_focus_event; |
| 96 | 94 | ||
| 97 | klass->notify_gtk = gtk_widget_accessible_notify_gtk; | 95 | klass->notify_gtk = gtk_widget_accessible_notify_gtk; |
| 98 | 96 | ||
| @@ -274,7 +272,7 @@ static void v3270_accessible_get_character_extents( AtkText *text, | @@ -274,7 +272,7 @@ static void v3270_accessible_get_character_extents( AtkText *text, | ||
| 274 | *width = widget->metrics.width; | 272 | *width = widget->metrics.width; |
| 275 | *height = widget->metrics.height+widget->metrics.descent; | 273 | *height = widget->metrics.height+widget->metrics.descent; |
| 276 | 274 | ||
| 277 | - if (coords == ATK_XY_WINDOW) | 275 | + if(coords == ATK_XY_WINDOW) |
| 278 | { | 276 | { |
| 279 | // Correct position based on toplevel | 277 | // Correct position based on toplevel |
| 280 | window = gdk_window_get_toplevel(window); | 278 | window = gdk_window_get_toplevel(window); |
| @@ -552,3 +550,87 @@ static void atk_component_interface_init(AtkComponentIface *iface) | @@ -552,3 +550,87 @@ static void atk_component_interface_init(AtkComponentIface *iface) | ||
| 552 | */ | 550 | */ |
| 553 | } | 551 | } |
| 554 | 552 | ||
| 553 | +void v3270_acessible_set_state(GtkAccessible *obj, LIB3270_MESSAGE id) | ||
| 554 | +{ | ||
| 555 | + #ifdef DEBUG | ||
| 556 | + #define STATE_MESSAGE(x,c) { #x, x, c } | ||
| 557 | + #else | ||
| 558 | + #define STATE_MESSAGE(x,c) { x, c } | ||
| 559 | + #endif | ||
| 560 | + | ||
| 561 | + static const struct _state | ||
| 562 | + { | ||
| 563 | + #ifdef DEBUG | ||
| 564 | + const gchar * dbg; | ||
| 565 | + #endif | ||
| 566 | + AtkStateType atkstate; | ||
| 567 | + V3270_STATE flag; | ||
| 568 | + } table[] = | ||
| 569 | + { | ||
| 570 | + STATE_MESSAGE(ATK_STATE_BUSY, V3270_STATE_BUSY ), | ||
| 571 | + STATE_MESSAGE(ATK_STATE_EDITABLE, V3270_STATE_EDITABLE ), | ||
| 572 | + STATE_MESSAGE(ATK_STATE_ENABLED, V3270_STATE_ENABLED ), | ||
| 573 | + STATE_MESSAGE(ATK_STATE_INVALID_ENTRY, V3270_STATE_INVALID_ENTRY ), | ||
| 574 | + }; | ||
| 575 | + | ||
| 576 | + V3270_STATE state = GTK_V3270_ACCESSIBLE(obj)->state; | ||
| 577 | + V3270_STATE bits; | ||
| 578 | + int f; | ||
| 579 | + | ||
| 580 | + switch(id) | ||
| 581 | + { | ||
| 582 | + case LIB3270_MESSAGE_NONE: | ||
| 583 | + state = V3270_STATE_EDITABLE|V3270_STATE_ENABLED; | ||
| 584 | + break; | ||
| 585 | + | ||
| 586 | + case LIB3270_MESSAGE_SYSWAIT: | ||
| 587 | + case LIB3270_MESSAGE_TWAIT: | ||
| 588 | + case LIB3270_MESSAGE_RESOLVING: | ||
| 589 | + case LIB3270_MESSAGE_CONNECTING: | ||
| 590 | + state = V3270_STATE_BUSY; | ||
| 591 | + break; | ||
| 592 | + | ||
| 593 | + case LIB3270_MESSAGE_CONNECTED: | ||
| 594 | + case LIB3270_MESSAGE_AWAITING_FIRST: | ||
| 595 | + state = V3270_STATE_ENABLED; | ||
| 596 | + break; | ||
| 597 | + | ||
| 598 | + case LIB3270_MESSAGE_DISCONNECTED: | ||
| 599 | + state = 0; | ||
| 600 | + break; | ||
| 601 | + | ||
| 602 | + case LIB3270_MESSAGE_MINUS: | ||
| 603 | + case LIB3270_MESSAGE_INHIBIT: | ||
| 604 | + case LIB3270_MESSAGE_X: | ||
| 605 | + break; | ||
| 606 | + | ||
| 607 | + case LIB3270_MESSAGE_PROTECTED: | ||
| 608 | + case LIB3270_MESSAGE_NUMERIC: | ||
| 609 | + case LIB3270_MESSAGE_OVERFLOW: | ||
| 610 | + case LIB3270_MESSAGE_KYBDLOCK: | ||
| 611 | + state = V3270_STATE_INVALID_ENTRY|V3270_STATE_EDITABLE|V3270_STATE_ENABLED; | ||
| 612 | + break; | ||
| 613 | + | ||
| 614 | + } | ||
| 615 | + | ||
| 616 | + if(state == GTK_V3270_ACCESSIBLE(obj)->state) | ||
| 617 | + return; | ||
| 618 | + | ||
| 619 | + bits = GTK_V3270_ACCESSIBLE(obj)->state ^ state; | ||
| 620 | + | ||
| 621 | + trace("State change from %04x to %04x (bits=%04x)", | ||
| 622 | + GTK_V3270_ACCESSIBLE(obj)->state, | ||
| 623 | + state, bits ); | ||
| 624 | + | ||
| 625 | + for(f=0;f<G_N_ELEMENTS(table);f++) | ||
| 626 | + { | ||
| 627 | + if(bits & table[f].flag) | ||
| 628 | + { | ||
| 629 | + trace("State %s is %s",table[f].dbg,(state & table[f].flag) ? "Yes" : "No"); | ||
| 630 | + atk_object_notify_state_change(ATK_OBJECT(obj),table[f].atkstate,(state & table[f].flag) ? TRUE : FALSE); | ||
| 631 | + } | ||
| 632 | + } | ||
| 633 | + | ||
| 634 | + GTK_V3270_ACCESSIBLE(obj)->state = state; | ||
| 635 | +} | ||
| 636 | + |
src/gtk/v3270/accessible.h
| @@ -41,11 +41,22 @@ G_BEGIN_DECLS | @@ -41,11 +41,22 @@ G_BEGIN_DECLS | ||
| 41 | typedef struct _v3270Accessible v3270Accessible; | 41 | typedef struct _v3270Accessible v3270Accessible; |
| 42 | typedef struct _v3270AccessibleClass v3270AccessibleClass; | 42 | typedef struct _v3270AccessibleClass v3270AccessibleClass; |
| 43 | 43 | ||
| 44 | +typedef enum _v3270_state | ||
| 45 | +{ | ||
| 46 | + V3270_STATE_NONE = 0x0000, | ||
| 47 | + V3270_STATE_EDITABLE = 0x0001, | ||
| 48 | + V3270_STATE_BUSY = 0x0002, | ||
| 49 | + V3270_STATE_ENABLED = 0x0004, | ||
| 50 | + V3270_STATE_INVALID_ENTRY = 0x0008, | ||
| 51 | + | ||
| 52 | +} V3270_STATE; | ||
| 53 | + | ||
| 44 | struct _v3270Accessible | 54 | struct _v3270Accessible |
| 45 | { | 55 | { |
| 46 | - GtkAccessible parent; | 56 | + GtkAccessible parent; |
| 57 | + V3270_STATE state; | ||
| 47 | 58 | ||
| 48 | - AtkLayer layer; | 59 | +// AtkLayer layer; |
| 49 | }; | 60 | }; |
| 50 | 61 | ||
| 51 | struct _v3270AccessibleClass | 62 | struct _v3270AccessibleClass |
| @@ -57,5 +68,6 @@ struct _v3270AccessibleClass | @@ -57,5 +68,6 @@ struct _v3270AccessibleClass | ||
| 57 | 68 | ||
| 58 | GType v3270_accessible_get_type(void); | 69 | GType v3270_accessible_get_type(void); |
| 59 | 70 | ||
| 71 | +void v3270_acessible_set_state(GtkAccessible *obj, LIB3270_MESSAGE id); | ||
| 60 | 72 | ||
| 61 | G_END_DECLS | 73 | G_END_DECLS |
src/gtk/v3270/oia.c
| @@ -652,6 +652,9 @@ void v3270_update_message(v3270 *widget, LIB3270_MESSAGE id) | @@ -652,6 +652,9 @@ void v3270_update_message(v3270 *widget, LIB3270_MESSAGE id) | ||
| 652 | cairo_destroy(cr); | 652 | cairo_destroy(cr); |
| 653 | 653 | ||
| 654 | gtk_widget_queue_draw_area(GTK_WIDGET(widget),rect->x,rect->y,rect->width,rect->height); | 654 | gtk_widget_queue_draw_area(GTK_WIDGET(widget),rect->x,rect->y,rect->width,rect->height); |
| 655 | + | ||
| 656 | + if(widget->accessible) | ||
| 657 | + v3270_acessible_set_state(widget->accessible,id); | ||
| 655 | } | 658 | } |
| 656 | 659 | ||
| 657 | static void draw_cursor_position(cairo_t *cr, GdkRectangle *rect, struct v3270_metrics *metrics, int row, int col) | 660 | static void draw_cursor_position(cairo_t *cr, GdkRectangle *rect, struct v3270_metrics *metrics, int row, int col) |