Commit 06f4b00a3546162c12fe77edc6665200d6f2287a
1 parent
e8267e35
Exists in
master
and in
1 other branch
Implementing keyboard actions.
Showing
7 changed files
with
164 additions
and
23 deletions
Show diff stats
src/selection/linux/paste.c
... | ... | @@ -240,11 +240,13 @@ LIB3270_EXPORT void v3270_clipboard_get_from_url(GtkWidget *widget, const gchar |
240 | 240 | |
241 | 241 | LIB3270_EXPORT void v3270_paste(GtkWidget *widget) |
242 | 242 | { |
243 | + debug("%s",__FUNCTION__); | |
243 | 244 | v3270_clipboard_get_from_url(widget,NULL); |
244 | 245 | } |
245 | 246 | |
246 | 247 | LIB3270_EXPORT void v3270_paste_text(GtkWidget *widget) |
247 | 248 | { |
249 | + debug("%s",__FUNCTION__); | |
248 | 250 | v3270_clipboard_get_from_url(widget,"text://"); |
249 | 251 | } |
250 | 252 | ... | ... |
src/terminal/keyboard/accelerator.c
... | ... | @@ -81,16 +81,8 @@ |
81 | 81 | { |
82 | 82 | GSList * ix; |
83 | 83 | |
84 | - debug("%s: %u %u",__FUNCTION__,(unsigned int) keyval, (unsigned int) state); | |
85 | - | |
86 | 84 | for(ix = GTK_V3270(widget)->accelerators; ix; ix = g_slist_next(ix)) |
87 | 85 | { |
88 | - debug( | |
89 | - "%s: %u %u", | |
90 | - v3270_accelerator_get_name((V3270Accelerator *) ix->data), | |
91 | - (unsigned int) ((V3270Accelerator *) ix->data)->key, | |
92 | - (unsigned int) ((V3270Accelerator *) ix->data)->mods | |
93 | - ); | |
94 | 86 | if(v3270_accelerator_compare((V3270Accelerator *) ix->data, keyval, state)) |
95 | 87 | return (V3270Accelerator *) ix->data; |
96 | 88 | } |
... | ... | @@ -119,7 +111,10 @@ |
119 | 111 | switch(accel->type) |
120 | 112 | { |
121 | 113 | case V3270_ACCELERATOR_TYPE_LIB3270_ACTION: |
122 | - return gettext(((LIB3270_ACTION *) accel->arg)->name); | |
114 | + return ((LIB3270_ACTION *) accel->arg)->name; | |
115 | + | |
116 | + case V3270_ACCELERATOR_TYPE_INTERNAL: | |
117 | + return ((struct InternalAction *) accel->arg)->name; | |
123 | 118 | |
124 | 119 | case V3270_ACCELERATOR_TYPE_CUSTOM: |
125 | 120 | return ((V3270CustomAccelerator *) accel)->name; | ... | ... |
... | ... | @@ -0,0 +1,74 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como properties.c e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | + #include "private.h" | |
31 | + #include <v3270.h> | |
32 | + #include <lib3270/trace.h> | |
33 | + #include <lib3270/log.h> | |
34 | + | |
35 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
36 | + | |
37 | + int fire_copy_accelerator(GtkWidget *widget, const struct InternalAction * action) { | |
38 | + | |
39 | + debug("%s",__FUNCTION__); | |
40 | + | |
41 | + v3270_clipboard_set( | |
42 | + widget, | |
43 | + (action->operation & 0x0F), | |
44 | + (action->operation & ACCEL_OPERATION_CUT) != 0 | |
45 | + ); | |
46 | + | |
47 | + return EINVAL; | |
48 | + } | |
49 | + | |
50 | + int fire_paste_accelerator(GtkWidget *widget, const struct InternalAction * action) { | |
51 | + | |
52 | + | |
53 | + switch(action->operation) | |
54 | + { | |
55 | + case 0: // Default paste. | |
56 | + v3270_clipboard_get_from_url(widget,NULL); | |
57 | + break; | |
58 | + | |
59 | + case 1: // Text paste. | |
60 | + v3270_clipboard_get_from_url(widget,"text://"); | |
61 | + break; | |
62 | + | |
63 | + case 2: // File paste. | |
64 | + v3270_clipboard_get_from_url(widget,"file://"); | |
65 | + break; | |
66 | + | |
67 | + default: | |
68 | + g_warning("Unexpected paste operation %u",(unsigned int) action->operation); | |
69 | + } | |
70 | + | |
71 | + return 0; | |
72 | + } | |
73 | + | |
74 | + | ... | ... |
src/terminal/keyboard/init.c
... | ... | @@ -46,15 +46,71 @@ |
46 | 46 | static const struct InternalAction InternalActions[] = |
47 | 47 | { |
48 | 48 | { |
49 | - GDK_KP_Add, | |
50 | - GDK_NUMLOCK_MASK, | |
51 | - G_CALLBACK(fire_keypad_action) | |
49 | + .name = "keypad-add", | |
50 | + .key = GDK_KP_Add, | |
51 | + .mods = GDK_NUMLOCK_MASK, | |
52 | + .activate = G_CALLBACK(fire_keypad_action) | |
52 | 53 | }, |
53 | 54 | { |
54 | - GDK_KP_Subtract, | |
55 | - GDK_NUMLOCK_MASK, | |
56 | - G_CALLBACK(fire_keypad_action) | |
57 | - } | |
55 | + .name = "keypad-subtract", | |
56 | + .key = GDK_KP_Subtract, | |
57 | + .mods = GDK_NUMLOCK_MASK, | |
58 | + .activate = G_CALLBACK(fire_keypad_action) | |
59 | + }, | |
60 | + | |
61 | + // Standard Clipboard actions | |
62 | + { | |
63 | + .operation = V3270_COPY_DEFAULT, | |
64 | + .name = "copy", | |
65 | + .key = 'c', | |
66 | + .mods = GDK_CONTROL_MASK, | |
67 | + .activate = G_CALLBACK(fire_copy_accelerator) | |
68 | + }, | |
69 | + | |
70 | + /* | |
71 | + { | |
72 | + .operation = V3270_COPY_APPEND, | |
73 | + .name = "copy-append", | |
74 | + .key = 'c', | |
75 | + .mods = GDK_CONTROL_MASK|GDK_ALT_MASK, | |
76 | + .activate = G_CALLBACK(fire_copy_accelerator) | |
77 | + }, | |
78 | + */ | |
79 | + | |
80 | + { | |
81 | + .operation = V3270_COPY_TEXT, | |
82 | + .name = "copy-text", | |
83 | + .key = 'c', | |
84 | + .mods = GDK_SHIFT_MASK|GDK_CONTROL_MASK, | |
85 | + .activate = G_CALLBACK(fire_copy_accelerator) | |
86 | + }, | |
87 | + | |
88 | + { | |
89 | + .operation = ACCEL_OPERATION_CUT|V3270_COPY_DEFAULT, | |
90 | + .name = "cut", | |
91 | + .key = 'x', | |
92 | + .mods = GDK_CONTROL_MASK, | |
93 | + .activate = G_CALLBACK(fire_copy_accelerator) | |
94 | + }, | |
95 | + | |
96 | + /* | |
97 | + { | |
98 | + .operation = ACCEL_OPERATION_CUT|V3270_COPY_APPEND, | |
99 | + .name = "cut-append", | |
100 | + .key = 0, | |
101 | + .mods = 0, | |
102 | + .activate = G_CALLBACK(fire_copy_accelerator) | |
103 | + }, | |
104 | + */ | |
105 | + | |
106 | + { | |
107 | + .operation = ACCEL_OPERATION_DEFAULT, | |
108 | + .name = "paste", | |
109 | + .key = 'v', | |
110 | + .mods = GDK_CONTROL_MASK, | |
111 | + .activate = G_CALLBACK(fire_paste_accelerator) | |
112 | + }, | |
113 | + | |
58 | 114 | }; |
59 | 115 | |
60 | 116 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
... | ... | @@ -160,5 +216,3 @@ |
160 | 216 | |
161 | 217 | } |
162 | 218 | |
163 | - | |
164 | - | ... | ... |
src/terminal/keyboard/private.h
... | ... | @@ -32,12 +32,25 @@ |
32 | 32 | #include <v3270/actions.h> |
33 | 33 | #include <internals.h> |
34 | 34 | |
35 | + enum | |
36 | + { | |
37 | + ACCEL_OPERATION_DEFAULT = 0x00000000, | |
38 | + ACCEL_OPERATION_CUT = 0x10000000, | |
39 | + }; | |
40 | + | |
41 | + #define ACCEL_OPERATION_MASK (ACCEL_OPERATION_CUT|ACCEL_OPERATION_APPEND) | |
42 | + | |
35 | 43 | struct InternalAction |
36 | 44 | { |
37 | - guint key; | |
38 | - GdkModifierType mods; | |
39 | - GCallback activate; | |
45 | + unsigned int operation; | |
46 | + const gchar * name; | |
47 | + guint key; | |
48 | + GdkModifierType mods; | |
49 | + GCallback activate; | |
40 | 50 | }; |
41 | 51 | |
42 | 52 | G_GNUC_INTERNAL void v3270_accelerator_map_sort(v3270 *widget); |
43 | 53 | |
54 | + G_GNUC_INTERNAL int fire_copy_accelerator(GtkWidget *widget, const struct InternalAction * action); | |
55 | + G_GNUC_INTERNAL int fire_paste_accelerator(GtkWidget *widget, const struct InternalAction * action); | |
56 | + | ... | ... |
src/testprogram/testprogram.c
... | ... | @@ -174,8 +174,8 @@ |
174 | 174 | } |
175 | 175 | |
176 | 176 | // Set accelerators |
177 | - v3270_accelerator_map_add_entry(terminal, "copy", 'c', GDK_CONTROL_MASK, G_CALLBACK(accel_copy), window); | |
178 | - v3270_accelerator_map_add_entry(terminal, "paste", 'v', GDK_CONTROL_MASK, G_CALLBACK(accel_paste), window); | |
177 | + // v3270_accelerator_map_add_entry(terminal, "copy", 'c', GDK_CONTROL_MASK, G_CALLBACK(accel_copy), window); | |
178 | + // v3270_accelerator_map_add_entry(terminal, "paste", 'v', GDK_CONTROL_MASK, G_CALLBACK(accel_paste), window); | |
179 | 179 | |
180 | 180 | // Create trace window |
181 | 181 | v3270_set_trace(terminal,TRUE); | ... | ... |
v3270.cbp
... | ... | @@ -271,6 +271,9 @@ |
271 | 271 | <Unit filename="src/terminal/keyboard/accelerator.c"> |
272 | 272 | <Option compilerVar="CC" /> |
273 | 273 | </Unit> |
274 | + <Unit filename="src/terminal/keyboard/clipboard.c"> | |
275 | + <Option compilerVar="CC" /> | |
276 | + </Unit> | |
274 | 277 | <Unit filename="src/terminal/keyboard/init.c"> |
275 | 278 | <Option compilerVar="CC" /> |
276 | 279 | </Unit> | ... | ... |