Commit 2f02e4cd9dcaac66876ec018f415118fa0cee731
1 parent
06437083
Exists in
master
and in
1 other branch
Rômulo Silva Neiva
23 de agosto de 2012 08:18 Outra coisa, a configuração do Ctrl como "enter" não funcionou.
Showing
1 changed file
with
66 additions
and
38 deletions
Show diff stats
keyboard.c
... | ... | @@ -55,6 +55,42 @@ |
55 | 55 | #define GDK_NUMLOCK_MASK GDK_MOD2_MASK |
56 | 56 | #endif |
57 | 57 | |
58 | +/*--[ Globals ]--------------------------------------------------------------------------------------*/ | |
59 | + | |
60 | + static struct _keycode | |
61 | + { | |
62 | + guint keyval; | |
63 | + GdkModifierType state; | |
64 | + int (*exec)(H3270 *session); | |
65 | + GtkAction * action; | |
66 | + } keycode[] = | |
67 | + { | |
68 | + { GDK_Left, 0, lib3270_cursor_left, NULL }, | |
69 | + { GDK_Up, 0, lib3270_cursor_up, NULL }, | |
70 | + { GDK_Right, 0, lib3270_cursor_right, NULL }, | |
71 | + { GDK_Down, 0, lib3270_cursor_down, NULL }, | |
72 | + { GDK_Tab, 0, lib3270_nextfield, NULL }, | |
73 | + { GDK_ISO_Left_Tab, GDK_SHIFT_MASK, lib3270_previousfield, NULL }, | |
74 | + { GDK_KP_Left, 0, lib3270_cursor_left, NULL }, | |
75 | + { GDK_KP_Up, 0, lib3270_cursor_up, NULL }, | |
76 | + { GDK_KP_Right, 0, lib3270_cursor_right, NULL }, | |
77 | + { GDK_KP_Down, 0, lib3270_cursor_down, NULL }, | |
78 | + | |
79 | + { GDK_KP_Add, GDK_NUMLOCK_MASK, NULL, NULL }, | |
80 | + { GDK_KP_Subtract, GDK_NUMLOCK_MASK, NULL, NULL }, | |
81 | + | |
82 | + { GDK_3270_PrintScreen, 0, NULL, NULL }, | |
83 | + { GDK_Sys_Req, 0, lib3270_sysreq, NULL }, | |
84 | + | |
85 | + { GDK_Print, GDK_CONTROL_MASK, NULL, NULL }, | |
86 | + { GDK_Print, GDK_SHIFT_MASK, lib3270_sysreq, NULL }, | |
87 | + { GDK_Control_R, 0, NULL, NULL }, | |
88 | + { GDK_Control_L, 0, NULL, NULL }, | |
89 | + | |
90 | +#ifdef WIN32 | |
91 | + { GDK_Pause, 0, NULL, NULL }, | |
92 | +#endif | |
93 | + }; | |
58 | 94 | |
59 | 95 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
60 | 96 | |
... | ... | @@ -84,40 +120,6 @@ |
84 | 120 | |
85 | 121 | static gboolean check_keypress(v3270 *widget, GdkEventKey *event) |
86 | 122 | { |
87 | - static const struct _keycode | |
88 | - { | |
89 | - guint keyval; | |
90 | - GdkModifierType state; | |
91 | - int (*exec)(H3270 *session); | |
92 | - } keycode[] = | |
93 | - { | |
94 | - { GDK_Left, 0, lib3270_cursor_left }, | |
95 | - { GDK_Up, 0, lib3270_cursor_up }, | |
96 | - { GDK_Right, 0, lib3270_cursor_right }, | |
97 | - { GDK_Down, 0, lib3270_cursor_down }, | |
98 | - { GDK_Tab, 0, lib3270_nextfield }, | |
99 | - { GDK_ISO_Left_Tab, GDK_SHIFT_MASK, lib3270_previousfield }, | |
100 | - { GDK_KP_Left, 0, lib3270_cursor_left }, | |
101 | - { GDK_KP_Up, 0, lib3270_cursor_up }, | |
102 | - { GDK_KP_Right, 0, lib3270_cursor_right }, | |
103 | - { GDK_KP_Down, 0, lib3270_cursor_down }, | |
104 | - | |
105 | - { GDK_KP_Add, GDK_NUMLOCK_MASK, NULL }, | |
106 | - { GDK_KP_Subtract, GDK_NUMLOCK_MASK, NULL }, | |
107 | - | |
108 | - { GDK_3270_PrintScreen, 0, NULL }, | |
109 | - { GDK_Sys_Req, 0, lib3270_sysreq }, | |
110 | - | |
111 | - { GDK_Print, GDK_CONTROL_MASK, NULL }, | |
112 | - { GDK_Print, GDK_SHIFT_MASK, lib3270_sysreq }, | |
113 | - { GDK_Control_R, 0, NULL }, | |
114 | - { GDK_Control_L, 0, NULL }, | |
115 | - | |
116 | -#ifdef WIN32 | |
117 | - { GDK_Pause, 0, NULL }, | |
118 | -#endif | |
119 | - }; | |
120 | - | |
121 | 123 | int f; |
122 | 124 | int state = event->state & (GDK_SHIFT_MASK|GDK_CONTROL_MASK|GDK_ALT_MASK); |
123 | 125 | gboolean handled = FALSE; |
... | ... | @@ -153,17 +155,43 @@ |
153 | 155 | { |
154 | 156 | if(keycode[f].keyval == event->keyval && state == keycode[f].state) |
155 | 157 | { |
156 | - if(keycode[f].exec) | |
157 | - { | |
158 | + trace("%s: id=%d action=%p",__FUNCTION__,f,keycode[f].action); | |
159 | + if(keycode[f].action) | |
160 | + gtk_action_activate(keycode[f].action); | |
161 | + else if(keycode[f].exec) | |
158 | 162 | keycode[f].exec(widget->host); |
159 | - return TRUE; | |
160 | - } | |
163 | + else | |
164 | + return FALSE; | |
165 | + return TRUE; | |
166 | + | |
161 | 167 | } |
162 | 168 | } |
163 | 169 | |
164 | 170 | return FALSE; |
165 | 171 | } |
166 | 172 | |
173 | + gboolean v3270_set_keyboard_action(GtkWidget *widget, const gchar *key_name, GtkAction *action) | |
174 | + { | |
175 | + guint keyval; | |
176 | + GdkModifierType state; | |
177 | + int f; | |
178 | + | |
179 | + g_return_val_if_fail(GTK_IS_V3270(widget),FALSE); | |
180 | + | |
181 | + gtk_accelerator_parse(key_name,&keyval,&state); | |
182 | + | |
183 | + for(f=0; f < G_N_ELEMENTS(keycode);f++) | |
184 | + { | |
185 | + if(keycode[f].keyval == keyval && keycode[f].state == state) | |
186 | + { | |
187 | + keycode[f].action = action; | |
188 | + return TRUE; | |
189 | + } | |
190 | + } | |
191 | + | |
192 | + return FALSE; | |
193 | + } | |
194 | + | |
167 | 195 | gboolean v3270_key_press_event(GtkWidget *widget, GdkEventKey *event) |
168 | 196 | { |
169 | 197 | v3270 * terminal = GTK_V3270(widget); | ... | ... |