Commit e286960d98bbfd3da198d9da67fbb76be0b017ee
1 parent
751252f6
Exists in
master
and in
5 other branches
Updating v3270 widget.
Showing
5 changed files
with
107 additions
and
3 deletions
Show diff stats
src/include/pw3270.h
@@ -93,6 +93,9 @@ | @@ -93,6 +93,9 @@ | ||
93 | 93 | ||
94 | LIB3270_EXPORT int pw3270_print(GtkWidget *widget, GObject *action, GtkPrintOperationAction oper, LIB3270_PRINT_MODE src); | 94 | LIB3270_EXPORT int pw3270_print(GtkWidget *widget, GObject *action, GtkPrintOperationAction oper, LIB3270_PRINT_MODE src); |
95 | 95 | ||
96 | + LIB3270_EXPORT gboolean pw3270_set_keyboard_action(GtkWidget *widget, const gchar *key_name, GtkAction *action); | ||
97 | + | ||
98 | + | ||
96 | #ifdef HAVE_GTKMAC | 99 | #ifdef HAVE_GTKMAC |
97 | #include <gtk-mac-bundle.h> | 100 | #include <gtk-mac-bundle.h> |
98 | LIB3270_EXPORT GtkMacBundle * pw3270_get_bundle(void); | 101 | LIB3270_EXPORT GtkMacBundle * pw3270_get_bundle(void); |
src/pw3270/actions.c
@@ -36,14 +36,26 @@ | @@ -36,14 +36,26 @@ | ||
36 | #include <v3270/filetransfer.h> | 36 | #include <v3270/filetransfer.h> |
37 | 37 | ||
38 | #include <pw3270/plugin.h> | 38 | #include <pw3270/plugin.h> |
39 | - // #include "filetransfer.h" | ||
40 | #include <lib3270/actions.h> | 39 | #include <lib3270/actions.h> |
41 | #include <lib3270/selection.h> | 40 | #include <lib3270/selection.h> |
42 | #include <lib3270/trace.h> | 41 | #include <lib3270/trace.h> |
43 | -// #include <lib3270/macros.h> | ||
44 | #include <lib3270/log.h> | 42 | #include <lib3270/log.h> |
45 | #include <stdlib.h> | 43 | #include <stdlib.h> |
46 | 44 | ||
45 | + #if GTK_CHECK_VERSION(3,0,0) | ||
46 | + #include <gdk/gdkkeysyms-compat.h> | ||
47 | + #else | ||
48 | + #include <gdk/gdkkeysyms.h> | ||
49 | + #endif | ||
50 | + | ||
51 | + #ifndef GDK_ALT_MASK | ||
52 | + #define GDK_ALT_MASK GDK_MOD1_MASK | ||
53 | + #endif | ||
54 | + | ||
55 | + #ifndef GDK_NUMLOCK_MASK | ||
56 | + #define GDK_NUMLOCK_MASK GDK_MOD2_MASK | ||
57 | + #endif | ||
58 | + | ||
47 | #ifdef DEBUG | 59 | #ifdef DEBUG |
48 | #include <lib3270/html.h> | 60 | #include <lib3270/html.h> |
49 | #endif | 61 | #endif |
@@ -58,6 +70,46 @@ | @@ -58,6 +70,46 @@ | ||
58 | #define trace_action(a,w) /* */ | 70 | #define trace_action(a,w) /* */ |
59 | #endif // X3270_TRACE | 71 | #endif // X3270_TRACE |
60 | 72 | ||
73 | +/*--[ Keyboard Actions ]-----------------------------------------------------------------------------*/ | ||
74 | + | ||
75 | + static struct _keyboard_actions | ||
76 | + { | ||
77 | + guint keyval; | ||
78 | + GdkModifierType state; | ||
79 | + GtkAction * action; | ||
80 | + } keyboard_actions[] = | ||
81 | + { | ||
82 | + { GDK_Left, 0, NULL }, | ||
83 | + { GDK_Up, 0, NULL }, | ||
84 | + { GDK_Right, 0, NULL }, | ||
85 | + { GDK_Down, 0, NULL }, | ||
86 | + { GDK_Tab, 0, NULL }, | ||
87 | + { GDK_ISO_Left_Tab, GDK_SHIFT_MASK, NULL }, | ||
88 | + { GDK_KP_Left, 0, NULL }, | ||
89 | + { GDK_KP_Up, 0, NULL }, | ||
90 | + { GDK_KP_Right, 0, NULL }, | ||
91 | + { GDK_KP_Down, 0, NULL }, | ||
92 | + | ||
93 | + { GDK_KP_Add, GDK_NUMLOCK_MASK, NULL }, | ||
94 | + { GDK_KP_Subtract, GDK_NUMLOCK_MASK, NULL }, | ||
95 | + | ||
96 | + { GDK_3270_PrintScreen, 0, NULL }, | ||
97 | + { GDK_P, GDK_CONTROL_MASK, NULL }, | ||
98 | + | ||
99 | + { GDK_Sys_Req, 0, NULL }, | ||
100 | + | ||
101 | + { GDK_Print, GDK_CONTROL_MASK, NULL }, | ||
102 | + { GDK_Print, GDK_SHIFT_MASK, NULL }, | ||
103 | + { GDK_Control_R, 0, NULL }, | ||
104 | + { GDK_Control_L, 0, NULL }, | ||
105 | + | ||
106 | + | ||
107 | +#ifdef WIN32 | ||
108 | + { GDK_Pause, 0, NULL }, | ||
109 | + | ||
110 | +#endif | ||
111 | +}; | ||
112 | + | ||
61 | 113 | ||
62 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 114 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
63 | 115 | ||
@@ -953,3 +1005,47 @@ void ui_set_scroll_actions(GtkWidget *widget, GtkAction *action[UI_ATTR_DIRECTIO | @@ -953,3 +1005,47 @@ void ui_set_scroll_actions(GtkWidget *widget, GtkAction *action[UI_ATTR_DIRECTIO | ||
953 | } | 1005 | } |
954 | 1006 | ||
955 | } | 1007 | } |
1008 | + | ||
1009 | +gboolean pw3270_set_keyboard_action(GtkWidget *widget, const gchar *key_name, GtkAction *action) | ||
1010 | +{ | ||
1011 | + guint keyval; | ||
1012 | + GdkModifierType state; | ||
1013 | + int f; | ||
1014 | + | ||
1015 | + g_return_val_if_fail(GTK_IS_V3270(widget),FALSE); | ||
1016 | + | ||
1017 | + debug("keyboard_action.%s=%p",key_name,action); | ||
1018 | + | ||
1019 | + gtk_accelerator_parse(key_name,&keyval,&state); | ||
1020 | + | ||
1021 | + for(f=0; f < (int) G_N_ELEMENTS(keyboard_actions);f++) | ||
1022 | + { | ||
1023 | + if(keyboard_actions[f].keyval == keyval && keyboard_actions[f].state == state) | ||
1024 | + { | ||
1025 | + keyboard_actions[f].action = action; | ||
1026 | + return TRUE; | ||
1027 | + } | ||
1028 | + } | ||
1029 | + | ||
1030 | + return FALSE; | ||
1031 | +} | ||
1032 | + | ||
1033 | +gboolean handle_keypress(GtkWidget *terminal, guint keyval, GdkModifierType state, GtkWidget *window) | ||
1034 | +{ | ||
1035 | + size_t f; | ||
1036 | + | ||
1037 | + debug("pw3270::%s keyval=%u state=%u",__FUNCTION__,(unsigned int) keyval, (unsigned int) state); | ||
1038 | + | ||
1039 | + for(f=0; f < (int) G_N_ELEMENTS(keyboard_actions);f++) | ||
1040 | + { | ||
1041 | + if(keyboard_actions[f].keyval == keyval && keyboard_actions[f].state == state && keyboard_actions[f].action) | ||
1042 | + { | ||
1043 | + debug("Activating action %s",gtk_action_get_name(keyboard_actions[f].action)); | ||
1044 | + gtk_action_activate(keyboard_actions[f].action); | ||
1045 | + return TRUE; | ||
1046 | + } | ||
1047 | + } | ||
1048 | + | ||
1049 | + return FALSE; | ||
1050 | +} | ||
1051 | + |
src/pw3270/globals.h
@@ -80,6 +80,9 @@ | @@ -80,6 +80,9 @@ | ||
80 | G_GNUC_INTERNAL void download_action(GtkAction *action, GtkWidget *widget); | 80 | G_GNUC_INTERNAL void download_action(GtkAction *action, GtkWidget *widget); |
81 | G_GNUC_INTERNAL void upload_action(GtkAction *action, GtkWidget *widget); | 81 | G_GNUC_INTERNAL void upload_action(GtkAction *action, GtkWidget *widget); |
82 | G_GNUC_INTERNAL void print_settings_action(GtkAction *action, GtkWidget *widget); | 82 | G_GNUC_INTERNAL void print_settings_action(GtkAction *action, GtkWidget *widget); |
83 | + G_GNUC_INTERNAL gboolean handle_keypress(GtkWidget *terminal, guint keyval, GdkModifierType state, GtkWidget *window); | ||
84 | + | ||
85 | + | ||
83 | 86 | ||
84 | 87 | ||
85 | 88 |
src/pw3270/uiparser/parser.c
@@ -31,6 +31,7 @@ | @@ -31,6 +31,7 @@ | ||
31 | 31 | ||
32 | #include "private.h" | 32 | #include "private.h" |
33 | #include <v3270.h> | 33 | #include <v3270.h> |
34 | + #include <pw3270.h> | ||
34 | 35 | ||
35 | #ifdef HAVE_GTKMAC | 36 | #ifdef HAVE_GTKMAC |
36 | #include <gtkmacintegration/gtk-mac-menu.h> | 37 | #include <gtkmacintegration/gtk-mac-menu.h> |
@@ -146,7 +147,7 @@ static void action_group_setup(gpointer key, GtkAction *action, struct action_in | @@ -146,7 +147,7 @@ static void action_group_setup(gpointer key, GtkAction *action, struct action_in | ||
146 | const gchar * key_name = g_object_get_data(G_OBJECT(action),"accel_attr"); | 147 | const gchar * key_name = g_object_get_data(G_OBJECT(action),"accel_attr"); |
147 | GSList * child = gtk_action_get_proxies(action); | 148 | GSList * child = gtk_action_get_proxies(action); |
148 | 149 | ||
149 | - if(key_name && !v3270_set_keyboard_action(info->widget,key_name,action)) | 150 | + if(key_name && !pw3270_set_keyboard_action(info->widget,key_name,action)) |
150 | { | 151 | { |
151 | gtk_action_group_add_action_with_accel(info->group[group_id],action,key_name); | 152 | gtk_action_group_add_action_with_accel(info->group[group_id],action,key_name); |
152 | gtk_action_connect_accelerator(action); | 153 | gtk_action_connect_accelerator(action); |
src/pw3270/window.c
@@ -773,6 +773,7 @@ static GtkWidget * trace_window = NULL; | @@ -773,6 +773,7 @@ static GtkWidget * trace_window = NULL; | ||
773 | g_signal_connect(widget->terminal,"selecting",G_CALLBACK(selecting),group); | 773 | g_signal_connect(widget->terminal,"selecting",G_CALLBACK(selecting),group); |
774 | g_signal_connect(widget->terminal,"popup",G_CALLBACK(popup_menu),popup); | 774 | g_signal_connect(widget->terminal,"popup",G_CALLBACK(popup_menu),popup); |
775 | g_signal_connect(widget->terminal,"has_text",G_CALLBACK(has_text),group); | 775 | g_signal_connect(widget->terminal,"has_text",G_CALLBACK(has_text),group); |
776 | + g_signal_connect(widget->terminal,"keypress",G_CALLBACK(handle_keypress),NULL); | ||
776 | 777 | ||
777 | } | 778 | } |
778 | 779 |