Commit 4baad403775c49eb7fafd4957ace935effe51545
1 parent
3d6d26cd
Exists in
master
and in
5 other branches
Implementando macros no widget do emulador
Showing
4 changed files
with
56 additions
and
4 deletions
Show diff stats
pw3270.cbp
| ... | ... | @@ -291,9 +291,13 @@ |
| 291 | 291 | <Unit filename="src/pw3270/uiparser/action.c"> |
| 292 | 292 | <Option compilerVar="CC" /> |
| 293 | 293 | </Unit> |
| 294 | + <Unit filename="src/pw3270/uiparser/button.c"> | |
| 295 | + <Option compilerVar="CC" /> | |
| 296 | + </Unit> | |
| 294 | 297 | <Unit filename="src/pw3270/uiparser/keypad.c"> |
| 295 | 298 | <Option compilerVar="CC" /> |
| 296 | 299 | </Unit> |
| 300 | + <Unit filename="src/pw3270/uiparser/keypad.h" /> | |
| 297 | 301 | <Unit filename="src/pw3270/uiparser/menu.c"> |
| 298 | 302 | <Option compilerVar="CC" /> |
| 299 | 303 | </Unit> | ... | ... |
src/include/pw3270/v3270.h
| ... | ... | @@ -157,6 +157,7 @@ |
| 157 | 157 | |
| 158 | 158 | LIB3270_EXPORT const gchar * v3270_copy(GtkWidget *widget, V3270_SELECT_FORMAT mode, gboolean cut); |
| 159 | 159 | LIB3270_EXPORT const gchar * v3270_copy_append(GtkWidget *widget); |
| 160 | + LIB3270_EXPORT int v3270_run_script(GtkWidget *widget, const gchar *script); | |
| 160 | 161 | |
| 161 | 162 | LIB3270_EXPORT const gchar * v3270_get_selected_text(GtkWidget *widget, gboolean cut); |
| 162 | 163 | LIB3270_EXPORT const gchar * v3270_get_copy(GtkWidget *widget); | ... | ... |
src/pw3270/actions.c
| ... | ... | @@ -861,10 +861,15 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash |
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | static void action_text_script(GtkAction *action, GtkWidget *widget) |
| 864 | -{ | |
| 864 | +{ | |
| 865 | + v3270_run_script(widget,g_object_get_data(G_OBJECT(action),"script_text")); | |
| 866 | + | |
| 867 | +/* | |
| 865 | 868 | gchar **ln = g_strsplit(g_object_get_data(G_OBJECT(action),"script_text"),"\n",-1); |
| 866 | 869 | int f; |
| 867 | 870 | H3270 * hSession = v3270_get_session(widget); |
| 871 | + | |
| 872 | + lib3270_trace_event(v3270_get_session(widget),"Action %s activated on widget %p\n",gtk_action_get_name(action),widget); | |
| 868 | 873 | |
| 869 | 874 | for(f=0;ln[f];f++) |
| 870 | 875 | { |
| ... | ... | @@ -893,7 +898,8 @@ static void action_text_script(GtkAction *action, GtkWidget *widget) |
| 893 | 898 | } |
| 894 | 899 | |
| 895 | 900 | |
| 896 | - g_strfreev(ln); | |
| 901 | + g_strfreev(ln); | |
| 902 | +*/ | |
| 897 | 903 | } |
| 898 | 904 | |
| 899 | 905 | void ui_connect_text_script(GtkWidget *widget, GtkAction *action, const gchar *script_text, GError **error) |
| ... | ... | @@ -902,8 +908,6 @@ void ui_connect_text_script(GtkWidget *widget, GtkAction *action, const gchar *s |
| 902 | 908 | gchar *text = g_strdup(base); |
| 903 | 909 | g_free(base); |
| 904 | 910 | |
| 905 | - lib3270_trace_event(v3270_get_session(widget),"Action %s activated on widget %p\n",gtk_action_get_name(action),widget); | |
| 906 | - | |
| 907 | 911 | gtk_action_set_sensitive(action,TRUE); |
| 908 | 912 | g_object_set_data_full(G_OBJECT(action),"script_text",text,g_free); |
| 909 | 913 | g_signal_connect(action,"activate",G_CALLBACK(action_text_script),widget); | ... | ... |
src/pw3270/v3270/widget.c
| ... | ... | @@ -33,6 +33,7 @@ |
| 33 | 33 | #include <lib3270/session.h> |
| 34 | 34 | #include <lib3270/actions.h> |
| 35 | 35 | #include <lib3270/log.h> |
| 36 | + #include <lib3270/macros.h> | |
| 36 | 37 | #include <errno.h> |
| 37 | 38 | |
| 38 | 39 | #ifdef HAVE_MALLOC_H |
| ... | ... | @@ -1542,3 +1543,45 @@ gboolean v3270_is_connected(GtkWidget *widget) |
| 1542 | 1543 | g_return_val_if_fail(GTK_IS_V3270(widget),FALSE); |
| 1543 | 1544 | return lib3270_connected(GTK_V3270(widget)->host) ? TRUE : FALSE; |
| 1544 | 1545 | } |
| 1546 | + | |
| 1547 | +int v3270_run_script(GtkWidget *widget, const gchar *script) | |
| 1548 | +{ | |
| 1549 | + gchar **ln; | |
| 1550 | + int f; | |
| 1551 | + H3270 * hSession; | |
| 1552 | + | |
| 1553 | + if(!script) | |
| 1554 | + return 0; | |
| 1555 | + | |
| 1556 | + g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL); | |
| 1557 | + | |
| 1558 | + hSession = v3270_get_session(widget); | |
| 1559 | + ln = g_strsplit(script,"\n",-1); | |
| 1560 | + | |
| 1561 | + for(f=0;ln[f];f++) | |
| 1562 | + { | |
| 1563 | + GError * error = NULL; | |
| 1564 | + gint argc = 0; | |
| 1565 | + gchar **argv = NULL; | |
| 1566 | + | |
| 1567 | + if(g_shell_parse_argv(g_strstrip(ln[f]),&argc,&argv,&error)) | |
| 1568 | + { | |
| 1569 | + gchar *rsp = lib3270_run_macro(hSession,(const gchar **) argv); | |
| 1570 | + if(rsp) | |
| 1571 | + g_free(rsp); | |
| 1572 | + } | |
| 1573 | + else | |
| 1574 | + { | |
| 1575 | + g_warning("Error parsing \"%s\": %s",g_strstrip(ln[f]),error->message); | |
| 1576 | + g_error_free(error); | |
| 1577 | + } | |
| 1578 | + | |
| 1579 | + if(argv) | |
| 1580 | + g_strfreev(argv); | |
| 1581 | + | |
| 1582 | + } | |
| 1583 | + | |
| 1584 | + g_strfreev(ln); | |
| 1585 | + | |
| 1586 | + return 0; | |
| 1587 | +} | ... | ... |