Commit efac1ab2bb04223c1fcf0c6a7b2eb991e0f8e343

Authored by Perry Werneck
1 parent 475489c7
Exists in master and in 1 other branch develop

Refactoring keytable management.

src/include/v3270/actions.h
@@ -54,11 +54,10 @@ @@ -54,11 +54,10 @@
54 54
55 V3270_ACTION_FLAGS flags; ///< @brief (The flags for activation). 55 V3270_ACTION_FLAGS flags; ///< @brief (The flags for activation).
56 56
57 - guint key;  
58 - GdkModifierType mods;  
59 -  
60 int (*activate)(GtkWidget *widget, const V3270_ACTION *action); 57 int (*activate)(GtkWidget *widget, const V3270_ACTION *action);
61 58
  59 + const char *keys; ///< @brief Default accelerators (or NULL if no default).
  60 +
62 }; 61 };
63 62
64 63
src/terminal/actions/internal.c 0 → 100644
@@ -0,0 +1,131 @@ @@ -0,0 +1,131 @@
  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 <internals.h>
  32 + #include <terminal.h>
  33 + #include <lib3270/actions.h>
  34 + #include <gdk/gdkkeysyms-compat.h>
  35 + #include <v3270/actions.h>
  36 +
  37 + #ifndef GDK_NUMLOCK_MASK
  38 + #define GDK_NUMLOCK_MASK GDK_MOD2_MASK
  39 + #endif
  40 +
  41 + #ifndef GDK_ALT_MASK
  42 + #define GDK_ALT_MASK GDK_MOD1_MASK
  43 + #endif
  44 +
  45 + #define LIB3270_TYPE_V3270_INTERNAL_ACTION (V270InternalAction_get_type())
  46 + #define V3270_INTERNAL_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), LIB3270_TYPE_V3270_INTERNAL_ACTION, V270InternalAction))
  47 +
  48 + #define GET_DESCRIPTOR(obj) ((const V3270_ACTION *) V3270_INTERNAL_ACTION(obj)->definition)
  49 +
  50 + typedef struct _V270InternalActionClass {
  51 + V3270ActionClass parent_class;
  52 + } V270InternalActionClass;
  53 +
  54 + typedef struct _V270InternalAction {
  55 + V3270Action parent;
  56 + const V3270_ACTION * definition;
  57 + } V270InternalAction;
  58 +
  59 + static void V270InternalAction_class_init(V270InternalActionClass *klass);
  60 + static void V270InternalAction_init(V270InternalAction *action);
  61 +
  62 + G_DEFINE_TYPE(V270InternalAction, V270InternalAction, V3270_TYPE_ACTION);
  63 +
  64 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  65 +
  66 + static const gchar * get_icon_name(GAction *action) {
  67 + return GET_DESCRIPTOR(action)->icon;
  68 + }
  69 +
  70 + static const gchar * get_label(GAction *action) {
  71 + return GET_DESCRIPTOR(action)->label;
  72 + }
  73 +
  74 + static const gchar * get_tooltip(GAction *action) {
  75 + return GET_DESCRIPTOR(action)->summary;
  76 + }
  77 +
  78 + static const gchar * get_name(GAction *action) {
  79 + return GET_DESCRIPTOR(action)->name;
  80 + }
  81 +
  82 + static void activate(GAction *action, GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) {
  83 +
  84 + debug("Activating action \"%s\"",g_action_get_name(action));
  85 +
  86 + const V3270_ACTION *descriptor = GET_DESCRIPTOR(action);
  87 +
  88 + descriptor->activate(terminal,descriptor);
  89 +
  90 + }
  91 +
  92 + static LIB3270_ACTION_GROUP get_action_group(GAction *action) {
  93 + return GET_DESCRIPTOR(action)->group;
  94 + }
  95 +
  96 + static void V270InternalAction_class_init(V270InternalActionClass *klass) {
  97 +
  98 + klass->parent_class.get_name = get_name;
  99 + klass->parent_class.get_icon_name = get_icon_name;
  100 + klass->parent_class.get_label = get_label;
  101 + klass->parent_class.get_tooltip = get_tooltip;
  102 + klass->parent_class.activate = activate;
  103 + klass->parent_class.get_action_group = get_action_group;
  104 +
  105 + }
  106 +
  107 + static void V270InternalAction_init(V270InternalAction G_GNUC_UNUSED(*action)) {
  108 + }
  109 +
  110 + void g_action_map_add_v3270_actions(GActionMap *action_map) {
  111 +
  112 + const V3270_ACTION * actions = v3270_get_actions();
  113 + size_t ix;
  114 +
  115 + for(ix = 0; actions[ix].name; ix++) {
  116 +
  117 + V270InternalAction * action = V3270_INTERNAL_ACTION(g_object_new(LIB3270_TYPE_V3270_INTERNAL_ACTION, NULL));
  118 +
  119 + action->definition = &actions[ix];
  120 + action->parent.translation_domain = GETTEXT_PACKAGE;
  121 +
  122 + if(!g_action_get_name(G_ACTION(action))) {
  123 + g_warning("Action \"%s\" is invalid",actions[ix].name);
  124 + } else {
  125 + g_action_map_add_action(action_map,G_ACTION(action));
  126 + }
  127 +
  128 + }
  129 +
  130 + }
  131 +
src/terminal/actions/table.c
@@ -28,404 +28,317 @@ @@ -28,404 +28,317 @@
28 */ 28 */
29 29
30 #include "private.h" 30 #include "private.h"
31 - #include <internals.h>  
32 - #include <terminal.h>  
33 #include <lib3270/actions.h> 31 #include <lib3270/actions.h>
34 - #include <gdk/gdkkeysyms-compat.h>  
35 #include <v3270/actions.h> 32 #include <v3270/actions.h>
  33 + #include <v3270/selection.h>
  34 + #include <terminal.h>
36 35
37 - #ifndef GDK_NUMLOCK_MASK  
38 - #define GDK_NUMLOCK_MASK GDK_MOD2_MASK  
39 - #endif  
40 -  
41 - #ifndef GDK_ALT_MASK  
42 - #define GDK_ALT_MASK GDK_MOD1_MASK  
43 - #endif  
44 -  
45 - #define LIB3270_TYPE_V3270_INTERNAL_ACTION (V270InternalAction_get_type())  
46 - #define V3270_INTERNAL_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), LIB3270_TYPE_V3270_INTERNAL_ACTION, V270InternalAction))  
47 -  
48 - #define GET_DESCRIPTOR(obj) ((const V3270_ACTION *) V3270_INTERNAL_ACTION(obj)->definition)  
49 -  
50 - typedef struct _V270InternalActionClass {  
51 - V3270ActionClass parent_class;  
52 - } V270InternalActionClass;  
53 -  
54 - typedef struct _V270InternalAction {  
55 - V3270Action parent;  
56 - const V3270_ACTION * definition;  
57 - } V270InternalAction;  
58 -  
59 - static void V270InternalAction_class_init(V270InternalActionClass *klass);  
60 - static void V270InternalAction_init(V270InternalAction *action);  
61 -  
62 - G_DEFINE_TYPE(V270InternalAction, V270InternalAction, V3270_TYPE_ACTION);  
63 -  
64 -/*--[ Globals ]--------------------------------------------------------------------------------------*/  
65 -  
66 - static const V3270_ACTION actions[] =  
67 - {  
68 - {  
69 - .name = "keypad-add",  
70 - .group = LIB3270_ACTION_GROUP_ONLINE,  
71 - .key = GDK_KP_Add,  
72 - .mods = GDK_NUMLOCK_MASK,  
73 - .activate = fire_keypad_action  
74 - },  
75 - {  
76 - .name = "keypad-subtract",  
77 - .group = LIB3270_ACTION_GROUP_ONLINE,  
78 - .key = GDK_KP_Subtract,  
79 - .mods = GDK_NUMLOCK_MASK,  
80 - .activate = fire_keypad_action  
81 - },  
82 -  
83 - // Standard Clipboard actions  
84 - {  
85 - .flags = V3270_COPY_SMART,  
86 - .name = "copy",  
87 - .group = LIB3270_ACTION_GROUP_SELECTION,  
88 - .icon = "edit-copy",  
89 - .label = N_( "Copy" ),  
90 - .summary = N_("Copy selection to clipboard"),  
91 - .description = N_("Replace current clipboard contents with the selected area"),  
92 - .key = 'c',  
93 - .mods = GDK_CONTROL_MASK,  
94 - .activate = fire_copy_accelerator  
95 - },  
96 -  
97 - {  
98 - .flags = V3270_COPY_APPEND,  
99 - .group = LIB3270_ACTION_GROUP_SELECTION,  
100 - .name = "copy-append",  
101 - .label = N_( "Add to copy" ),  
102 - .summary = N_("Append selection to clipboard"),  
103 - .description = N_("Append selected area to current clipboard contents"),  
104 - .key = 'c',  
105 - .mods = GDK_ALT_MASK,  
106 - .activate = fire_copy_accelerator  
107 - },  
108 -  
109 - {  
110 - .flags = V3270_COPY_TEXT,  
111 - .group = LIB3270_ACTION_GROUP_SELECTION,  
112 - .name = "copy-text",  
113 - .icon = "edit-copy",  
114 - .label = N_( "Copy" ),  
115 - .summary = N_( "Copy as plain text" ),  
116 - .key = 'c',  
117 - .mods = GDK_SHIFT_MASK|GDK_CONTROL_MASK,  
118 - .activate = fire_copy_accelerator  
119 - },  
120 -  
121 - {  
122 - .flags = V3270_COPY_TABLE,  
123 - .group = LIB3270_ACTION_GROUP_SELECTION,  
124 - .name = "copy-table",  
125 - .icon = "edit-copy",  
126 - .label = N_( "Copy as table" ),  
127 - .summary = N_( "Copy as table" ),  
128 - .key = 'c',  
129 - .mods = GDK_SHIFT_MASK|GDK_ALT_MASK,  
130 - .activate = fire_copy_accelerator  
131 - },  
132 -  
133 - {  
134 - .flags = V3270_ACTION_FLAG_CUT|V3270_COPY_SMART,  
135 - .group = LIB3270_ACTION_GROUP_SELECTION,  
136 - .name = "cut",  
137 - .icon = "edit-cut",  
138 - .label = N_( "Cut" ),  
139 - .key = 'x',  
140 - .mods = GDK_CONTROL_MASK,  
141 - .activate = fire_copy_accelerator  
142 - },  
143 -  
144 - {  
145 - .flags = V3270_ACTION_FLAG_CUT|V3270_COPY_APPEND,  
146 - .group = LIB3270_ACTION_GROUP_SELECTION,  
147 - .name = "cut-append",  
148 - .label = N_( "Cut" ),  
149 - .summary = N_( "Cut and append to copy" ),  
150 - .key = 'x',  
151 - .mods = GDK_ALT_MASK,  
152 - .activate = fire_copy_accelerator  
153 - },  
154 -  
155 - {  
156 - .flags = V3270_ACTION_FLAG_CUT|V3270_COPY_TEXT,  
157 - .group = LIB3270_ACTION_GROUP_SELECTION,  
158 - .name = "cut-text",  
159 - .icon = "edit-cut",  
160 - .label = N_( "Cut" ),  
161 - .summary = N_( "Cut as plain text" ),  
162 - .key = 'x',  
163 - .mods = GDK_SHIFT_MASK|GDK_CONTROL_MASK,  
164 - .activate = fire_copy_accelerator  
165 - },  
166 -  
167 - {  
168 - .flags = V3270_ACTION_FLAG_CUT|V3270_COPY_TABLE,  
169 - .group = LIB3270_ACTION_GROUP_SELECTION,  
170 - .name = "cut-table",  
171 - .icon = "edit-cut",  
172 - .label = N_( "Cut as table" ),  
173 - .summary = N_( "Cut as table" ),  
174 - .key = 'x',  
175 - .mods = GDK_SHIFT_MASK|GDK_ALT_MASK,  
176 - .activate = fire_copy_accelerator  
177 - },  
178 -  
179 - {  
180 - .flags = 0,  
181 - .group = LIB3270_ACTION_GROUP_ONLINE,  
182 - .name = "paste",  
183 - .icon = "edit-paste",  
184 - .label = N_("Paste"),  
185 - .summary = N_("Paste clipboard contents"),  
186 - .description = N_("Input current clipboard contents to screen"),  
187 - .key = 'v',  
188 - .mods = GDK_CONTROL_MASK,  
189 - .activate = fire_paste_accelerator  
190 - },  
191 -  
192 - {  
193 - .flags = 1,  
194 - .group = LIB3270_ACTION_GROUP_ONLINE,  
195 - .name = "paste-text",  
196 - .icon = "edit-paste",  
197 - .label = N_("Paste"),  
198 - .summary = N_("Paste as plain text"),  
199 - .key = 'v',  
200 - .mods = GDK_SHIFT_MASK|GDK_CONTROL_MASK,  
201 - .activate = fire_paste_accelerator  
202 - },  
203 -  
204 - {  
205 - .flags = 2,  
206 - .group = LIB3270_ACTION_GROUP_ONLINE,  
207 - .name = "paste-file",  
208 - .label = N_("Paste file"),  
209 - .summary = N_("Paste from text file"),  
210 - .key = 'v',  
211 - .mods = GDK_ALT_MASK,  
212 - .activate = fire_paste_accelerator  
213 - },  
214 -  
215 - {  
216 - .flags = 3,  
217 - .group = LIB3270_ACTION_GROUP_ONLINE,  
218 - .name = "paste-screen",  
219 - .label = N_("Paste formatted screen"),  
220 - .summary = N_("Paste similar screen from clipboard"),  
221 - .description = N_("Search clipboard for a similar screen, if found paste unprotected fields and restore cursor position"),  
222 - .key = 'v',  
223 - .mods = GDK_SHIFT_MASK|GDK_CONTROL_MASK|GDK_ALT_MASK,  
224 - .activate = fire_paste_accelerator  
225 - },  
226 -  
227 - {  
228 - .flags = 0,  
229 - .group = LIB3270_ACTION_GROUP_ONLINE,  
230 - .name = "zoom-in",  
231 - .icon = "zoom-in",  
232 - .label = N_("Zoom in"),  
233 - .summary = N_("Increase the font size"),  
234 - .key = GDK_KP_Add,  
235 - .mods = GDK_CONTROL_MASK,  
236 - .activate = fire_zoom_action  
237 - },  
238 -  
239 - {  
240 - .flags = 1,  
241 - .group = LIB3270_ACTION_GROUP_ONLINE,  
242 - .name = "zoom-out",  
243 - .label = N_("Zoom out"),  
244 - .summary = N_("decrease the font size"),  
245 - .icon = "zoom-out",  
246 - .key = GDK_KP_Subtract,  
247 - .mods = GDK_CONTROL_MASK,  
248 - .activate = fire_zoom_action  
249 - },  
250 -  
251 - {  
252 - .flags = 2,  
253 - .group = LIB3270_ACTION_GROUP_ONLINE,  
254 - .name = "zoom-fit-best",  
255 - .label = N_("Fit best"),  
256 - .summary = N_("Set the font to the best size for window"),  
257 - .icon = "zoom-fit-best",  
258 - .key = '0',  
259 - .mods = GDK_CONTROL_MASK,  
260 - .activate = fire_zoom_action  
261 - },  
262 -  
263 - //  
264 - // Save actions  
265 - //  
266 - {  
267 - .flags = -1,  
268 - .group = LIB3270_ACTION_GROUP_ONLINE,  
269 - .name = "save",  
270 - .icon = "document-save-as",  
271 - .label = N_("Save"),  
272 - .summary = N_("Save screen or selection"),  
273 - .activate = fire_save_action  
274 -  
275 - },  
276 -  
277 - {  
278 - .flags = LIB3270_CONTENT_ALL,  
279 - .group = LIB3270_ACTION_GROUP_ONLINE,  
280 - .name = "save-all",  
281 - .label = N_("Save all"),  
282 - .icon = "document-save-as",  
283 - .summary = N_("Save screen"),  
284 - .activate = fire_save_action  
285 -  
286 - },  
287 -  
288 - {  
289 - .flags = LIB3270_CONTENT_SELECTED,  
290 - .group = LIB3270_ACTION_GROUP_SELECTION,  
291 - .name = "save-selected",  
292 - .label = N_("Save selected"),  
293 - .icon = "document-save-as",  
294 - .summary = N_("Save selected area"),  
295 - .activate = fire_save_action  
296 -  
297 - },  
298 -  
299 - {  
300 - .flags = LIB3270_CONTENT_COPY,  
301 - .group = LIB3270_ACTION_GROUP_COPY,  
302 - .name = "save-copy",  
303 - .label = N_("Save copy"),  
304 - .icon = "document-save-as",  
305 - .summary = N_("Save Copy"),  
306 - .activate = fire_save_action  
307 -  
308 - },  
309 -  
310 - //  
311 - // Print actions  
312 - //  
313 - {  
314 - .flags = -1,  
315 - .group = LIB3270_ACTION_GROUP_ONLINE,  
316 - .name = "print",  
317 - .icon = "document-print",  
318 - .label = N_("Print"),  
319 - .summary = N_("Print screen or selection"),  
320 - .activate = fire_print_action  
321 -  
322 - },  
323 -  
324 - {  
325 - .flags = LIB3270_CONTENT_ALL,  
326 - .group = LIB3270_ACTION_GROUP_ONLINE,  
327 - .name = "print-all",  
328 - .icon = "document-print",  
329 - .label = N_("Print screen"),  
330 - .summary = N_("Print the entire screen"),  
331 - .activate = fire_print_action  
332 -  
333 - },  
334 -  
335 - {  
336 - .flags = LIB3270_CONTENT_SELECTED,  
337 - .group = LIB3270_ACTION_GROUP_SELECTION,  
338 - .name = "print-selected",  
339 - .icon = "document-print",  
340 - .label = N_("Print selected"),  
341 - .summary = N_("Print selected area"),  
342 - .activate = fire_print_action  
343 -  
344 - },  
345 -  
346 - {  
347 - .flags = LIB3270_CONTENT_COPY,  
348 - .group = LIB3270_ACTION_GROUP_COPY,  
349 - .name = "print-copy",  
350 - .icon = "document-print",  
351 - .label = N_("Print Copy"),  
352 - .activate = fire_print_action  
353 -  
354 - },  
355 -  
356 - {  
357 - .name = NULL  
358 - }  
359 - };  
360 -  
361 - LIB3270_EXPORT const V3270_ACTION * v3270_get_actions()  
362 - {  
363 - return actions;  
364 - }  
365 -  
366 - static const gchar * get_icon_name(GAction *action) {  
367 - return GET_DESCRIPTOR(action)->icon;  
368 - }  
369 -  
370 - static const gchar * get_label(GAction *action) {  
371 - return GET_DESCRIPTOR(action)->label;  
372 - }  
373 -  
374 - static const gchar * get_tooltip(GAction *action) {  
375 - return GET_DESCRIPTOR(action)->summary;  
376 - }  
377 -  
378 - static const gchar * get_name(GAction *action) {  
379 - return GET_DESCRIPTOR(action)->name;  
380 - }  
381 -  
382 - static void activate(GAction *action, GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) {  
383 -  
384 - debug("Activating action \"%s\"",g_action_get_name(action));  
385 -  
386 - const V3270_ACTION *descriptor = GET_DESCRIPTOR(action); 36 + static int fire_kp_add_action(GtkWidget *widget, const struct _v3270_action * action);
  37 + static int fire_kp_sub_action(GtkWidget *widget, const struct _v3270_action * action);
  38 +
  39 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  40 +
  41 + LIB3270_EXPORT const V3270_ACTION * v3270_get_actions() {
  42 +
  43 + static const V3270_ACTION actions[] = {
  44 + {
  45 + .name = "keypad-add",
  46 + .keys = "<Mod2>KP_Add",
  47 + .group = LIB3270_ACTION_GROUP_ONLINE,
  48 + .activate = fire_kp_add_action
  49 + },
  50 + {
  51 + .name = "keypad-subtract",
  52 + .keys = "<Mod2>KP_Subtract",
  53 + .group = LIB3270_ACTION_GROUP_ONLINE,
  54 + .activate = fire_kp_sub_action
  55 + },
  56 +
  57 + // Standard Clipboard actions
  58 + {
  59 + .flags = V3270_COPY_SMART,
  60 + .name = "copy",
  61 + .keys = "<Primary>c",
  62 + .group = LIB3270_ACTION_GROUP_SELECTION,
  63 + .icon = "edit-copy",
  64 + .label = N_( "Copy" ),
  65 + .summary = N_("Copy selection to clipboard"),
  66 + .description = N_("Replace current clipboard contents with the selected area"),
  67 + .activate = fire_copy_accelerator
  68 + },
  69 +
  70 + {
  71 + .name = "copy-append",
  72 + .keys = "<Alt>c",
  73 + .flags = V3270_COPY_APPEND,
  74 + .group = LIB3270_ACTION_GROUP_SELECTION,
  75 + .label = N_( "Add to copy" ),
  76 + .summary = N_("Append selection to clipboard"),
  77 + .description = N_("Append selected area to current clipboard contents"),
  78 + .activate = fire_copy_accelerator
  79 + },
  80 +
  81 + {
  82 + .name = "copy-text",
  83 + .keys = "<Primary><Shift>c",
  84 + .flags = V3270_COPY_TEXT,
  85 + .group = LIB3270_ACTION_GROUP_SELECTION,
  86 + .icon = "edit-copy",
  87 + .label = N_( "Copy" ),
  88 + .summary = N_( "Copy as plain text" ),
  89 + .activate = fire_copy_accelerator
  90 + },
  91 +
  92 + {
  93 + .name = "copy-table",
  94 + .keys = "<Shift><Alt>c",
  95 + .flags = V3270_COPY_TABLE,
  96 + .group = LIB3270_ACTION_GROUP_SELECTION,
  97 + .icon = "edit-copy",
  98 + .label = N_( "Copy as table" ),
  99 + .summary = N_( "Copy as table" ),
  100 + .activate = fire_copy_accelerator
  101 + },
  102 +
  103 + {
  104 + .name = "cut",
  105 + .keys = "<Primary>x",
  106 + .flags = V3270_ACTION_FLAG_CUT|V3270_COPY_SMART,
  107 + .group = LIB3270_ACTION_GROUP_SELECTION,
  108 + .icon = "edit-cut",
  109 + .label = N_( "Cut" ),
  110 + .activate = fire_copy_accelerator
  111 + },
  112 +
  113 + {
  114 + .name = "cut-append",
  115 + .keys = "<Alt>x",
  116 + .flags = V3270_ACTION_FLAG_CUT|V3270_COPY_APPEND,
  117 + .group = LIB3270_ACTION_GROUP_SELECTION,
  118 + .label = N_( "Cut" ),
  119 + .summary = N_( "Cut and append to copy" ),
  120 + .activate = fire_copy_accelerator
  121 + },
  122 +
  123 + {
  124 + .name = "cut-text",
  125 + .keys = "<Primary><Shift>x",
  126 + .flags = V3270_ACTION_FLAG_CUT|V3270_COPY_TEXT,
  127 + .group = LIB3270_ACTION_GROUP_SELECTION,
  128 + .icon = "edit-cut",
  129 + .label = N_( "Cut" ),
  130 + .summary = N_( "Cut as plain text" ),
  131 + .activate = fire_copy_accelerator
  132 + },
  133 +
  134 + {
  135 + .name = "cut-table",
  136 + .keys = "<Shift><Alt>x",
  137 + .flags = V3270_ACTION_FLAG_CUT|V3270_COPY_TABLE,
  138 + .group = LIB3270_ACTION_GROUP_SELECTION,
  139 + .icon = "edit-cut",
  140 + .label = N_( "Cut as table" ),
  141 + .summary = N_( "Cut as table" ),
  142 + .activate = fire_copy_accelerator
  143 + },
  144 +
  145 + {
  146 + .name = "paste",
  147 + .keys = "<Primary>v",
  148 + .flags = 0,
  149 + .group = LIB3270_ACTION_GROUP_ONLINE,
  150 + .icon = "edit-paste",
  151 + .label = N_("Paste"),
  152 + .summary = N_("Paste clipboard contents"),
  153 + .description = N_("Input current clipboard contents to screen"),
  154 + .activate = fire_paste_accelerator
  155 + },
  156 +
  157 + {
  158 + .name = "paste-text",
  159 + .keys = "<Primary><Shift>v",
  160 + .flags = 1,
  161 + .group = LIB3270_ACTION_GROUP_ONLINE,
  162 + .icon = "edit-paste",
  163 + .label = N_("Paste"),
  164 + .summary = N_("Paste as plain text"),
  165 + .activate = fire_paste_accelerator
  166 + },
  167 +
  168 + {
  169 + .name = "paste-file",
  170 + .keys = "<Alt>v",
  171 + .flags = 2,
  172 + .group = LIB3270_ACTION_GROUP_ONLINE,
  173 + .label = N_("Paste file"),
  174 + .summary = N_("Paste from text file"),
  175 + .activate = fire_paste_accelerator
  176 + },
  177 +
  178 + {
  179 + .name = "paste-screen",
  180 + .keys = "<Primary><Shift><Alt>v",
  181 + .flags = 3,
  182 + .group = LIB3270_ACTION_GROUP_ONLINE,
  183 + .label = N_("Paste formatted screen"),
  184 + .summary = N_("Paste similar screen from clipboard"),
  185 + .description = N_("Search clipboard for a similar screen, if found paste unprotected fields and restore cursor position"),
  186 + .activate = fire_paste_accelerator
  187 + },
  188 +
  189 + {
  190 + .name = "zoom-in",
  191 + .keys = "<Primary><Shift><Alt>v",
  192 + .flags = 0,
  193 + .group = LIB3270_ACTION_GROUP_ONLINE,
  194 + .icon = "zoom-in",
  195 + .label = N_("Zoom in"),
  196 + .summary = N_("Increase the font size"),
  197 + .activate = fire_zoom_action
  198 + },
  199 +
  200 + {
  201 + .name = "zoom-out",
  202 + .keys = "<Primary>KP_Subtract",
  203 + .flags = 1,
  204 + .group = LIB3270_ACTION_GROUP_ONLINE,
  205 + .label = N_("Zoom out"),
  206 + .summary = N_("decrease the font size"),
  207 + .icon = "zoom-out",
  208 + .activate = fire_zoom_action
  209 + },
  210 +
  211 + {
  212 + .name = "zoom-fit-best",
  213 + .keys = "<Primary>0",
  214 + .flags = 2,
  215 + .group = LIB3270_ACTION_GROUP_ONLINE,
  216 + .label = N_("Fit best"),
  217 + .summary = N_("Set the font to the best size for window"),
  218 + .icon = "zoom-fit-best",
  219 + .activate = fire_zoom_action
  220 + },
  221 +
  222 + //
  223 + // Save actions
  224 + //
  225 + {
  226 + .flags = -1,
  227 + .group = LIB3270_ACTION_GROUP_ONLINE,
  228 + .name = "save",
  229 + .icon = "document-save-as",
  230 + .label = N_("Save"),
  231 + .summary = N_("Save screen or selection"),
  232 + .activate = fire_save_action
  233 +
  234 + },
  235 +
  236 + {
  237 + .flags = LIB3270_CONTENT_ALL,
  238 + .group = LIB3270_ACTION_GROUP_ONLINE,
  239 + .name = "save-all",
  240 + .label = N_("Save all"),
  241 + .icon = "document-save-as",
  242 + .summary = N_("Save screen"),
  243 + .activate = fire_save_action
  244 +
  245 + },
  246 +
  247 + {
  248 + .flags = LIB3270_CONTENT_SELECTED,
  249 + .group = LIB3270_ACTION_GROUP_SELECTION,
  250 + .name = "save-selected",
  251 + .label = N_("Save selected"),
  252 + .icon = "document-save-as",
  253 + .summary = N_("Save selected area"),
  254 + .activate = fire_save_action
  255 +
  256 + },
  257 +
  258 + {
  259 + .flags = LIB3270_CONTENT_COPY,
  260 + .group = LIB3270_ACTION_GROUP_COPY,
  261 + .name = "save-copy",
  262 + .label = N_("Save copy"),
  263 + .icon = "document-save-as",
  264 + .summary = N_("Save Copy"),
  265 + .activate = fire_save_action
  266 +
  267 + },
  268 +
  269 + //
  270 + // Print actions
  271 + //
  272 + {
  273 + .flags = -1,
  274 + .group = LIB3270_ACTION_GROUP_ONLINE,
  275 + .name = "print",
  276 + .icon = "document-print",
  277 + .label = N_("Print"),
  278 + .summary = N_("Print screen or selection"),
  279 + .activate = fire_print_action
  280 +
  281 + },
  282 +
  283 + {
  284 + .flags = LIB3270_CONTENT_ALL,
  285 + .group = LIB3270_ACTION_GROUP_ONLINE,
  286 + .name = "print-all",
  287 + .icon = "document-print",
  288 + .label = N_("Print screen"),
  289 + .summary = N_("Print the entire screen"),
  290 + .activate = fire_print_action
  291 +
  292 + },
  293 +
  294 + {
  295 + .flags = LIB3270_CONTENT_SELECTED,
  296 + .group = LIB3270_ACTION_GROUP_SELECTION,
  297 + .name = "print-selected",
  298 + .icon = "document-print",
  299 + .label = N_("Print selected"),
  300 + .summary = N_("Print selected area"),
  301 + .activate = fire_print_action
  302 +
  303 + },
  304 +
  305 + {
  306 + .flags = LIB3270_CONTENT_COPY,
  307 + .group = LIB3270_ACTION_GROUP_COPY,
  308 + .name = "print-copy",
  309 + .icon = "document-print",
  310 + .label = N_("Print Copy"),
  311 + .activate = fire_print_action
  312 +
  313 + },
  314 +
  315 + {
  316 + .name = NULL
  317 + }
  318 + };
387 319
388 - descriptor->activate(terminal,descriptor); 320 + return actions;
389 321
390 } 322 }
391 323
392 - static LIB3270_ACTION_GROUP get_action_group(GAction *action) {  
393 - return GET_DESCRIPTOR(action)->group;  
394 - } 324 + int fire_kp_add_action(GtkWidget *widget, const struct _v3270_action G_GNUC_UNUSED(* action)) {
395 325
396 - static void V270InternalAction_class_init(V270InternalActionClass *klass) { 326 + if(v3270_get_toggle(widget,LIB3270_TOGGLE_KP_ALTERNATIVE))
  327 + return lib3270_nextfield(GTK_V3270(widget)->host);
397 328
398 - klass->parent_class.get_name = get_name;  
399 - klass->parent_class.get_icon_name = get_icon_name;  
400 - klass->parent_class.get_label = get_label;  
401 - klass->parent_class.get_tooltip = get_tooltip;  
402 - klass->parent_class.activate = activate;  
403 - klass->parent_class.get_action_group = get_action_group; 329 + v3270_set_string(widget, "+");
404 330
405 - } 331 + return 0;
406 332
407 - static void V270InternalAction_init(V270InternalAction G_GNUC_UNUSED(*action)) {  
408 } 333 }
409 334
410 - void g_action_map_add_v3270_actions(GActionMap *action_map) {  
411 -  
412 - const V3270_ACTION * actions = v3270_get_actions();  
413 - size_t ix;  
414 -  
415 - for(ix = 0; actions[ix].name; ix++) { 335 + int fire_kp_sub_action(GtkWidget *widget, const struct _v3270_action G_GNUC_UNUSED(* action)) {
416 336
417 - V270InternalAction * action = V3270_INTERNAL_ACTION(g_object_new(LIB3270_TYPE_V3270_INTERNAL_ACTION, NULL)); 337 + if(v3270_get_toggle(widget,LIB3270_TOGGLE_KP_ALTERNATIVE))
  338 + return lib3270_previousfield(GTK_V3270(widget)->host);
418 339
419 - action->definition = &actions[ix];  
420 - action->parent.translation_domain = GETTEXT_PACKAGE; 340 + v3270_set_string(widget, "-");
421 341
422 - if(!g_action_get_name(G_ACTION(action))) {  
423 - g_warning("Action \"%s\" is invalid",actions[ix].name);  
424 - } else {  
425 - g_action_map_add_action(action_map,G_ACTION(action));  
426 - }  
427 -  
428 - } 342 + return 0;
429 343
430 } 344 }
431 -  
src/terminal/keyboard/init.c
@@ -68,27 +68,6 @@ @@ -68,27 +68,6 @@
68 return lib3270_toggle(v3270_get_session(widget),action->id); 68 return lib3270_toggle(v3270_get_session(widget),action->id);
69 } 69 }
70 70
71 - int fire_keypad_action(GtkWidget *widget, const struct _v3270_action * action)  
72 - {  
73 - int rc = 0;  
74 - debug("%s",__FUNCTION__);  
75 -  
76 - if(v3270_get_toggle(widget,LIB3270_TOGGLE_KP_ALTERNATIVE))  
77 - {  
78 - if(action->key == GDK_KP_Add)  
79 - rc = lib3270_nextfield(GTK_V3270(widget)->host);  
80 - else  
81 - rc = lib3270_previousfield(GTK_V3270(widget)->host);  
82 - }  
83 - else  
84 - {  
85 - v3270_set_string(widget, action->key == GDK_KP_Add ? "+" : "-");  
86 - }  
87 -  
88 - return rc;  
89 -  
90 - }  
91 -  
92 static int fire_pfkey_action(GtkWidget *widget, V3270PFKeyAccelerator *accel) 71 static int fire_pfkey_action(GtkWidget *widget, V3270PFKeyAccelerator *accel)
93 { 72 {
94 debug("%s accel=%p",__FUNCTION__,accel); 73 debug("%s accel=%p",__FUNCTION__,accel);
@@ -175,17 +154,42 @@ @@ -175,17 +154,42 @@
175 154
176 for(ix = 0 ; actions[ix].name; ix++) 155 for(ix = 0 ; actions[ix].name; ix++)
177 { 156 {
178 - V3270Accelerator * accelerator = g_new0(V3270Accelerator,1); 157 + if(actions[ix].keys && *actions[ix].keys)
  158 + {
  159 + size_t key;
179 160
180 - accelerator->type = V3270_ACCELERATOR_TYPE_INTERNAL;  
181 - accelerator->arg = (gconstpointer) &actions[ix];  
182 - accelerator->activate = G_CALLBACK(actions[ix].activate);  
183 - accelerator->key = actions[ix].key;  
184 - accelerator->mods = actions[ix].mods; 161 + gchar ** keys = g_strsplit(actions[ix].keys,",",-1);
185 162
186 - widget->accelerators = g_slist_prepend(widget->accelerators,accelerator); 163 + for(key = 0; keys[key]; key++)
  164 + {
  165 + V3270Accelerator * accelerator = g_new0(V3270Accelerator,1);
187 166
  167 + accelerator->type = V3270_ACCELERATOR_TYPE_INTERNAL;
  168 + accelerator->arg = (gconstpointer) &actions[ix];
  169 + accelerator->activate = G_CALLBACK(actions[ix].activate);
  170 +
  171 + gtk_accelerator_parse(keys[key],&accelerator->key,&accelerator->mods);
  172 +
  173 + widget->accelerators = g_slist_prepend(widget->accelerators,accelerator);
  174 +
  175 + }
  176 +
  177 + g_strfreev(keys);
  178 +
  179 + }
  180 + else
  181 + {
  182 + V3270Accelerator * accelerator = g_new0(V3270Accelerator,1);
  183 +
  184 + accelerator->type = V3270_ACCELERATOR_TYPE_INTERNAL;
  185 + accelerator->arg = (gconstpointer) &actions[ix];
  186 + accelerator->activate = G_CALLBACK(actions[ix].activate);
  187 +
  188 + widget->accelerators = g_slist_prepend(widget->accelerators,accelerator);
  189 +
  190 + }
188 } 191 }
  192 +
189 } 193 }
190 194
191 // Create PF-Key accelerators 195 // Create PF-Key accelerators
src/testprogram/testprogram.c
@@ -40,6 +40,7 @@ @@ -40,6 +40,7 @@
40 #include <v3270/settings.h> 40 #include <v3270/settings.h>
41 #include <v3270/trace.h> 41 #include <v3270/trace.h>
42 #include <lib3270/log.h> 42 #include <lib3270/log.h>
  43 + #include <lib3270/properties.h>
43 #include <v3270/actions.h> 44 #include <v3270/actions.h>
44 #include <stdlib.h> 45 #include <stdlib.h>
45 #include <gdk/gdkkeysyms-compat.h> 46 #include <gdk/gdkkeysyms-compat.h>
@@ -130,6 +131,9 @@ @@ -130,6 +131,9 @@
130 GtkWidget * vBox = gtk_box_new(GTK_ORIENTATION_VERTICAL,2); 131 GtkWidget * vBox = gtk_box_new(GTK_ORIENTATION_VERTICAL,2);
131 GtkWidget * notebook = gtk_notebook_new(); 132 GtkWidget * notebook = gtk_notebook_new();
132 133
  134 + // Hack to speed up the tests.
  135 +// lib3270_disable_crl_download(v3270_get_session(terminal));
  136 +
133 gtk_box_pack_start(GTK_BOX(vBox),create_toolbar(terminal),FALSE,TRUE,0); 137 gtk_box_pack_start(GTK_BOX(vBox),create_toolbar(terminal),FALSE,TRUE,0);
134 gtk_box_pack_start(GTK_BOX(vBox),notebook,TRUE,TRUE,0); 138 gtk_box_pack_start(GTK_BOX(vBox),notebook,TRUE,TRUE,0);
135 139
@@ -250,6 +250,9 @@ @@ -250,6 +250,9 @@
250 <Unit filename="src/terminal/actions/dialog.c"> 250 <Unit filename="src/terminal/actions/dialog.c">
251 <Option compilerVar="CC" /> 251 <Option compilerVar="CC" />
252 </Unit> 252 </Unit>
  253 + <Unit filename="src/terminal/actions/internal.c">
  254 + <Option compilerVar="CC" />
  255 + </Unit>
253 <Unit filename="src/terminal/actions/lib3270.c"> 256 <Unit filename="src/terminal/actions/lib3270.c">
254 <Option compilerVar="CC" /> 257 <Option compilerVar="CC" />
255 </Unit> 258 </Unit>