Commit 73d7e595d40a12652b6872c0e2c2541fb05a2945
1 parent
4a81c5c9
Exists in
master
and in
1 other branch
Implementando aviso de script ativo
Showing
8 changed files
with
85 additions
and
18 deletions
Show diff stats
accessible.c
@@ -38,7 +38,7 @@ | @@ -38,7 +38,7 @@ | ||
38 | 38 | ||
39 | #include <pw3270.h> | 39 | #include <pw3270.h> |
40 | #include <lib3270/log.h> | 40 | #include <lib3270/log.h> |
41 | - #include <v3270.h> | 41 | + #include <pw3270/v3270.h> |
42 | #include "private.h" | 42 | #include "private.h" |
43 | #include "accessible.h" | 43 | #include "accessible.h" |
44 | 44 |
draw.c
@@ -32,7 +32,7 @@ | @@ -32,7 +32,7 @@ | ||
32 | #include <pw3270.h> | 32 | #include <pw3270.h> |
33 | #include <lib3270.h> | 33 | #include <lib3270.h> |
34 | #include <lib3270/session.h> | 34 | #include <lib3270/session.h> |
35 | - #include <v3270.h> | 35 | + #include <pw3270/v3270.h> |
36 | #include "private.h" | 36 | #include "private.h" |
37 | 37 | ||
38 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 38 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
keyboard.c
@@ -38,7 +38,7 @@ | @@ -38,7 +38,7 @@ | ||
38 | #include <string.h> | 38 | #include <string.h> |
39 | #include <gdk/gdk.h> | 39 | #include <gdk/gdk.h> |
40 | 40 | ||
41 | - #include <v3270.h> | 41 | + #include <pw3270/v3270.h> |
42 | #include "private.h" | 42 | #include "private.h" |
43 | 43 | ||
44 | #if GTK_CHECK_VERSION(3,0,0) | 44 | #if GTK_CHECK_VERSION(3,0,0) |
mouse.c
@@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
30 | #include <gtk/gtk.h> | 30 | #include <gtk/gtk.h> |
31 | #include <gdk/gdk.h> | 31 | #include <gdk/gdk.h> |
32 | #include <pw3270.h> | 32 | #include <pw3270.h> |
33 | - #include <v3270.h> | 33 | + #include <pw3270/v3270.h> |
34 | #include "private.h" | 34 | #include "private.h" |
35 | #include <lib3270/selection.h> | 35 | #include <lib3270/selection.h> |
36 | #include <lib3270/actions.h> | 36 | #include <lib3270/actions.h> |
@@ -40,7 +40,7 @@ | @@ -40,7 +40,7 @@ | ||
40 | #include <math.h> | 40 | #include <math.h> |
41 | #endif // HAVE_LIBM | 41 | #endif // HAVE_LIBM |
42 | 42 | ||
43 | - #include <v3270.h> | 43 | + #include <pw3270/v3270.h> |
44 | #include "private.h" | 44 | #include "private.h" |
45 | #include "accessible.h" | 45 | #include "accessible.h" |
46 | 46 | ||
@@ -505,9 +505,7 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me | @@ -505,9 +505,7 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me | ||
505 | #ifdef HAVE_PRINTER | 505 | #ifdef HAVE_PRINTER |
506 | { V3270_OIA_PRINTER, setup_single_char_right }, | 506 | { V3270_OIA_PRINTER, setup_single_char_right }, |
507 | #endif // HAVE_PRINTER | 507 | #endif // HAVE_PRINTER |
508 | -#ifdef HAVE_SCRIPT | ||
509 | { V3270_OIA_SCRIPT, setup_single_char_right }, | 508 | { V3270_OIA_SCRIPT, setup_single_char_right }, |
510 | -#endif // HAVE_SCRIPT | ||
511 | { V3270_OIA_INSERT, setup_insert_position }, | 509 | { V3270_OIA_INSERT, setup_insert_position }, |
512 | { V3270_OIA_TYPEAHEAD, setup_single_char_right }, | 510 | { V3270_OIA_TYPEAHEAD, setup_single_char_right }, |
513 | { V3270_OIA_SHIFT, setup_double_char_position }, | 511 | { V3270_OIA_SHIFT, setup_double_char_position }, |
@@ -858,10 +856,11 @@ void v3270_draw_shift_status(v3270 *terminal) | @@ -858,10 +856,11 @@ void v3270_draw_shift_status(v3270 *terminal) | ||
858 | 856 | ||
859 | } | 857 | } |
860 | 858 | ||
861 | -static void update_text_field(v3270 *terminal, gboolean flag, V3270_OIA_FIELD id, const gchar *text) | 859 | +static void update_text_field(v3270 *terminal, gboolean flag, V3270_OIA_FIELD id, const gchar chr) |
862 | { | 860 | { |
863 | - GdkRectangle *r; | ||
864 | - cairo_t *cr; | 861 | + GdkRectangle * r; |
862 | + cairo_t * cr; | ||
863 | + gchar text[] = { chr, 0 }; | ||
865 | 864 | ||
866 | if(!terminal->surface) | 865 | if(!terminal->surface) |
867 | return; | 866 | return; |
@@ -882,7 +881,7 @@ static void update_text_field(v3270 *terminal, gboolean flag, V3270_OIA_FIELD id | @@ -882,7 +881,7 @@ static void update_text_field(v3270 *terminal, gboolean flag, V3270_OIA_FIELD id | ||
882 | 881 | ||
883 | void v3270_draw_alt_status(v3270 *terminal) | 882 | void v3270_draw_alt_status(v3270 *terminal) |
884 | { | 883 | { |
885 | - update_text_field(terminal,terminal->keyflags & KEY_FLAG_ALT,V3270_OIA_ALT,"A"); | 884 | + update_text_field(terminal,terminal->keyflags & KEY_FLAG_ALT,V3270_OIA_ALT,'A'); |
886 | } | 885 | } |
887 | 886 | ||
888 | void v3270_draw_ins_status(v3270 *terminal) | 887 | void v3270_draw_ins_status(v3270 *terminal) |
@@ -1050,23 +1049,76 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) | @@ -1050,23 +1049,76 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) | ||
1050 | break; | 1049 | break; |
1051 | 1050 | ||
1052 | case LIB3270_FLAG_TYPEAHEAD: | 1051 | case LIB3270_FLAG_TYPEAHEAD: |
1053 | - update_text_field(terminal,on,V3270_OIA_TYPEAHEAD,"T"); | 1052 | + update_text_field(terminal,on,V3270_OIA_TYPEAHEAD,'T'); |
1054 | break; | 1053 | break; |
1055 | 1054 | ||
1056 | #ifdef HAVE_PRINTER | 1055 | #ifdef HAVE_PRINTER |
1057 | case LIB3270_FLAG_PRINTER: | 1056 | case LIB3270_FLAG_PRINTER: |
1058 | - update_text_field(terminal,on,V3270_OIA_PRINTER,"P"); | 1057 | + update_text_field(terminal,on,V3270_OIA_PRINTER,'P'); |
1059 | break; | 1058 | break; |
1060 | #endif // HAVE_PRINTER | 1059 | #endif // HAVE_PRINTER |
1061 | 1060 | ||
1062 | -#ifdef HAVE_SCRIPT | 1061 | +/* |
1063 | case LIB3270_FLAG_SCRIPT: | 1062 | case LIB3270_FLAG_SCRIPT: |
1064 | - update_text_field(terminal,on,V3270_OIA_SCRIPT,"S"); | 1063 | + update_text_field(terminal,on,V3270_OIA_SCRIPT,terminal->script_id); |
1065 | break; | 1064 | break; |
1066 | -#endif // HAVE_SCRIPT | 1065 | +*/ |
1067 | 1066 | ||
1068 | default: | 1067 | default: |
1069 | return; | 1068 | return; |
1070 | } | 1069 | } |
1071 | 1070 | ||
1072 | } | 1071 | } |
1072 | + | ||
1073 | +static gboolean blink_script(v3270 *widget) | ||
1074 | +{ | ||
1075 | + if(!widget->script.id) | ||
1076 | + return FALSE; | ||
1077 | + | ||
1078 | + update_text_field(widget,1,V3270_OIA_SCRIPT,widget->script.blink ? 'S' : ' '); | ||
1079 | + widget->script.blink = !widget->script.blink; | ||
1080 | + | ||
1081 | + return TRUE; | ||
1082 | +} | ||
1083 | + | ||
1084 | +static void release_script(v3270 *widget) | ||
1085 | +{ | ||
1086 | + widget->script.timer = NULL; | ||
1087 | + widget->script.id = 0; | ||
1088 | +} | ||
1089 | + | ||
1090 | +LIB3270_EXPORT int v3270_set_script(GtkWidget *widget, const gchar id, unsigned char on) | ||
1091 | +{ | ||
1092 | + v3270 *terminal; | ||
1093 | + g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL); | ||
1094 | + | ||
1095 | + terminal = GTK_V3270(widget); | ||
1096 | + | ||
1097 | + if(terminal->script.id && id != terminal->script.id) | ||
1098 | + return EBUSY; | ||
1099 | + | ||
1100 | + terminal->script.id = on ? id : 0; | ||
1101 | + update_text_field(terminal,on,V3270_OIA_SCRIPT,'S'); | ||
1102 | + | ||
1103 | + if(on) | ||
1104 | + { | ||
1105 | + if(!terminal->script.timer) | ||
1106 | + { | ||
1107 | + terminal->script.timer = g_timeout_source_new(500); | ||
1108 | + g_source_set_callback(terminal->script.timer,(GSourceFunc) blink_script, terminal, (GDestroyNotify) release_script); | ||
1109 | + | ||
1110 | + g_source_attach(terminal->script.timer, NULL); | ||
1111 | + g_source_unref(terminal->script.timer); | ||
1112 | + } | ||
1113 | + } | ||
1114 | + else if(terminal->script.timer) | ||
1115 | + { | ||
1116 | + if(terminal->script.timer->ref_count < 2) | ||
1117 | + g_source_destroy(terminal->script.timer); | ||
1118 | + | ||
1119 | + if(terminal->timer) | ||
1120 | + g_source_unref(terminal->script.timer); | ||
1121 | + } | ||
1122 | + | ||
1123 | + return 0; | ||
1124 | +} |
private.h
@@ -180,6 +180,14 @@ G_BEGIN_DECLS | @@ -180,6 +180,14 @@ G_BEGIN_DECLS | ||
180 | H3270 * host; /**< Related 3270 session */ | 180 | H3270 * host; /**< Related 3270 session */ |
181 | gchar * session_name; /**< Session name (for window title) */ | 181 | gchar * session_name; /**< Session name (for window title) */ |
182 | 182 | ||
183 | + // Scripting | ||
184 | + struct | ||
185 | + { | ||
186 | + int blink : 1; | ||
187 | + gchar id; /**< Script indicator */ | ||
188 | + GSource * timer; | ||
189 | + } script; | ||
190 | + | ||
183 | }; | 191 | }; |
184 | 192 | ||
185 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ | 193 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
selection.c
@@ -29,7 +29,7 @@ | @@ -29,7 +29,7 @@ | ||
29 | 29 | ||
30 | #include <gtk/gtk.h> | 30 | #include <gtk/gtk.h> |
31 | #include <pw3270.h> | 31 | #include <pw3270.h> |
32 | - #include <v3270.h> | 32 | + #include <pw3270/v3270.h> |
33 | #include "private.h" | 33 | #include "private.h" |
34 | #include <lib3270/selection.h> | 34 | #include <lib3270/selection.h> |
35 | #include <lib3270/log.h> | 35 | #include <lib3270/log.h> |
widget.c
@@ -39,7 +39,7 @@ | @@ -39,7 +39,7 @@ | ||
39 | #include <malloc.h> | 39 | #include <malloc.h> |
40 | #endif // HAVE_MALLOC_H | 40 | #endif // HAVE_MALLOC_H |
41 | 41 | ||
42 | - #include <v3270.h> | 42 | + #include <pw3270/v3270.h> |
43 | #include "private.h" | 43 | #include "private.h" |
44 | #include "accessible.h" | 44 | #include "accessible.h" |
45 | #include "marshal.h" | 45 | #include "marshal.h" |
@@ -892,6 +892,13 @@ static void v3270_destroy(GtkObject *widget) | @@ -892,6 +892,13 @@ static void v3270_destroy(GtkObject *widget) | ||
892 | g_source_unref(terminal->timer); | 892 | g_source_unref(terminal->timer); |
893 | } | 893 | } |
894 | 894 | ||
895 | + if(terminal->script.timer) | ||
896 | + { | ||
897 | + g_source_destroy(terminal->script.timer); | ||
898 | + while(terminal->script.timer) | ||
899 | + g_source_unref(terminal->script.timer); | ||
900 | + } | ||
901 | + | ||
895 | if(terminal->cursor.timer) | 902 | if(terminal->cursor.timer) |
896 | { | 903 | { |
897 | g_source_destroy(terminal->cursor.timer); | 904 | g_source_destroy(terminal->cursor.timer); |