Commit 60b8d5c8db4c27b82c03e17b7f8c5a914174eb50
1 parent
1a1e8112
Exists in
master
and in
3 other branches
Refactoring actions as properties (easier for language bindings).
Showing
4 changed files
with
90 additions
and
74 deletions
Show diff stats
src/core/actions/actions.c
@@ -33,34 +33,39 @@ | @@ -33,34 +33,39 @@ | ||
33 | 33 | ||
34 | /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ | 34 | /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ |
35 | 35 | ||
36 | -/** | ||
37 | - * @brief Launch an action by name. | ||
38 | - * | ||
39 | - * @param name Name of the action to launch. | ||
40 | - * | ||
41 | - * @return 0 if ok, error code if not (sets errno). | ||
42 | - * | ||
43 | - */ | ||
44 | -LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name) | 36 | +LIB3270_EXPORT const LIB3270_ACTION * lib3270_get_action(const char *name) |
45 | { | 37 | { |
46 | - const LIB3270_ACTION_ENTRY *actions = lib3270_get_action_table(); | 38 | + const LIB3270_ACTION * actions = lib3270_get_actions(); |
47 | size_t f; | 39 | size_t f; |
48 | 40 | ||
49 | for(f=0; actions[f].name; f++) | 41 | for(f=0; actions[f].name; f++) |
50 | { | 42 | { |
51 | if(!strcasecmp(name,actions[f].name)) | 43 | if(!strcasecmp(name,actions[f].name)) |
52 | - { | ||
53 | - lib3270_trace_event(hSession,"Action(%s): %s\n",actions[f].name, (actions[f].label ? actions[f].label : "")); | 44 | + return actions+f; |
45 | + } | ||
46 | + | ||
47 | + errno = ENOTSUP; | ||
48 | + return NULL; | ||
49 | +} | ||
54 | 50 | ||
55 | - if(!actions[f].enabled(hSession)) | ||
56 | - return errno = EPERM; | 51 | +LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name) |
52 | +{ | ||
53 | + const LIB3270_ACTION *action = lib3270_get_action(name); | ||
57 | 54 | ||
58 | - return actions[f].call(hSession); | ||
59 | - } | 55 | + if(!action) |
56 | + { | ||
57 | + lib3270_trace_event(hSession,"Unknown action \"%s\"\n",name); | ||
58 | + return errno; | ||
59 | + } | ||
60 | 60 | ||
61 | + if(!action->enabled(hSession)) | ||
62 | + { | ||
63 | + lib3270_trace_event(hSession,"Action \"%s\" is disabled\n",action->name); | ||
64 | + return errno = EPERM; | ||
61 | } | 65 | } |
62 | 66 | ||
63 | - lib3270_trace_event(hSession,"Unknown action %s\n",name); | ||
64 | - return errno = ENOENT; | 67 | + lib3270_trace_event(hSession,"Activating action \"%s\"\n",action->name); |
68 | + | ||
69 | + return action->activate(hSession); | ||
65 | 70 | ||
66 | } | 71 | } |
src/core/actions/table.c
@@ -68,10 +68,10 @@ | @@ -68,10 +68,10 @@ | ||
68 | * @brief Get LIB3270 action table; | 68 | * @brief Get LIB3270 action table; |
69 | * | 69 | * |
70 | */ | 70 | */ |
71 | - LIB3270_EXPORT const LIB3270_ACTION_ENTRY * lib3270_get_action_table() | 71 | + LIB3270_EXPORT const LIB3270_ACTION * lib3270_get_actions() |
72 | { | 72 | { |
73 | 73 | ||
74 | - static const LIB3270_ACTION_ENTRY actions[] = | 74 | + static const LIB3270_ACTION actions[] = |
75 | { | 75 | { |
76 | // | 76 | // |
77 | // Network actions | 77 | // Network actions |
@@ -82,7 +82,7 @@ | @@ -82,7 +82,7 @@ | ||
82 | .icon = "connect", | 82 | .icon = "connect", |
83 | .label = NULL, | 83 | .label = NULL, |
84 | .summary = N_( "Connect to host." ), | 84 | .summary = N_( "Connect to host." ), |
85 | - .call = connect_host, | 85 | + .activate = connect_host, |
86 | .enabled = lib3270_is_disconnected | 86 | .enabled = lib3270_is_disconnected |
87 | }, | 87 | }, |
88 | 88 | ||
@@ -92,7 +92,7 @@ | @@ -92,7 +92,7 @@ | ||
92 | .icon = "disconnect", | 92 | .icon = "disconnect", |
93 | .label = NULL, | 93 | .label = NULL, |
94 | .summary = N_( "Disconnect from host." ), | 94 | .summary = N_( "Disconnect from host." ), |
95 | - .call = lib3270_disconnect, | 95 | + .activate = lib3270_disconnect, |
96 | .enabled = lib3270_is_connected | 96 | .enabled = lib3270_is_connected |
97 | }, | 97 | }, |
98 | 98 | ||
@@ -105,7 +105,7 @@ | @@ -105,7 +105,7 @@ | ||
105 | .icon = NULL, | 105 | .icon = NULL, |
106 | .label = NULL, | 106 | .label = NULL, |
107 | .summary = N_( "Cursor up 1 position." ), | 107 | .summary = N_( "Cursor up 1 position." ), |
108 | - .call = lib3270_cursor_up, | 108 | + .activate = lib3270_cursor_up, |
109 | .enabled = lib3270_is_connected | 109 | .enabled = lib3270_is_connected |
110 | }, | 110 | }, |
111 | 111 | ||
@@ -115,7 +115,7 @@ | @@ -115,7 +115,7 @@ | ||
115 | .icon = NULL, | 115 | .icon = NULL, |
116 | .label = NULL, | 116 | .label = NULL, |
117 | .summary = N_( "Cursor down 1 position." ), | 117 | .summary = N_( "Cursor down 1 position." ), |
118 | - .call = lib3270_cursor_down, | 118 | + .activate = lib3270_cursor_down, |
119 | .enabled = lib3270_is_connected | 119 | .enabled = lib3270_is_connected |
120 | }, | 120 | }, |
121 | 121 | ||
@@ -125,7 +125,7 @@ | @@ -125,7 +125,7 @@ | ||
125 | .icon = NULL, | 125 | .icon = NULL, |
126 | .label = NULL, | 126 | .label = NULL, |
127 | .summary = N_( "Cursor left 1 position." ), | 127 | .summary = N_( "Cursor left 1 position." ), |
128 | - .call = lib3270_cursor_left, | 128 | + .activate = lib3270_cursor_left, |
129 | .enabled = lib3270_is_connected | 129 | .enabled = lib3270_is_connected |
130 | }, | 130 | }, |
131 | 131 | ||
@@ -135,7 +135,7 @@ | @@ -135,7 +135,7 @@ | ||
135 | .icon = NULL, | 135 | .icon = NULL, |
136 | .label = NULL, | 136 | .label = NULL, |
137 | .summary = N_( "Cursor right 1 position." ), | 137 | .summary = N_( "Cursor right 1 position." ), |
138 | - .call = lib3270_cursor_right, | 138 | + .activate = lib3270_cursor_right, |
139 | .enabled = lib3270_is_connected | 139 | .enabled = lib3270_is_connected |
140 | }, | 140 | }, |
141 | 141 | ||
@@ -145,7 +145,7 @@ | @@ -145,7 +145,7 @@ | ||
145 | .icon = NULL, | 145 | .icon = NULL, |
146 | .label = NULL, | 146 | .label = NULL, |
147 | .summary = N_( "Cursor to first field on next line or any lines after that." ), | 147 | .summary = N_( "Cursor to first field on next line or any lines after that." ), |
148 | - .call = lib3270_newline, | 148 | + .activate = lib3270_newline, |
149 | .enabled = lib3270_is_connected | 149 | .enabled = lib3270_is_connected |
150 | }, | 150 | }, |
151 | 151 | ||
@@ -155,7 +155,7 @@ | @@ -155,7 +155,7 @@ | ||
155 | .icon = NULL, | 155 | .icon = NULL, |
156 | .label = NULL, | 156 | .label = NULL, |
157 | .summary = N_( "Cursor to previous word." ), | 157 | .summary = N_( "Cursor to previous word." ), |
158 | - .call = lib3270_previousword, | 158 | + .activate = lib3270_previousword, |
159 | .enabled = lib3270_is_connected | 159 | .enabled = lib3270_is_connected |
160 | }, | 160 | }, |
161 | 161 | ||
@@ -165,7 +165,7 @@ | @@ -165,7 +165,7 @@ | ||
165 | .icon = NULL, | 165 | .icon = NULL, |
166 | .label = NULL, | 166 | .label = NULL, |
167 | .summary = N_( "Cursor to next unprotected word." ), | 167 | .summary = N_( "Cursor to next unprotected word." ), |
168 | - .call = lib3270_nextword, | 168 | + .activate = lib3270_nextword, |
169 | .enabled = lib3270_is_connected | 169 | .enabled = lib3270_is_connected |
170 | }, | 170 | }, |
171 | 171 | ||
@@ -178,7 +178,7 @@ | @@ -178,7 +178,7 @@ | ||
178 | .icon = "document-save", | 178 | .icon = "document-save", |
179 | .label = NULL, | 179 | .label = NULL, |
180 | .summary = N_( "Save screen." ), | 180 | .summary = N_( "Save screen." ), |
181 | - .call = save_all, | 181 | + .activate = save_all, |
182 | .enabled = lib3270_is_connected | 182 | .enabled = lib3270_is_connected |
183 | }, | 183 | }, |
184 | 184 | ||
@@ -188,7 +188,7 @@ | @@ -188,7 +188,7 @@ | ||
188 | .icon = NULL, | 188 | .icon = NULL, |
189 | .label = NULL, | 189 | .label = NULL, |
190 | .summary = N_( "Save selected area." ), | 190 | .summary = N_( "Save selected area." ), |
191 | - .call = save_selected, | 191 | + .activate = save_selected, |
192 | .enabled = lib3270_has_selection | 192 | .enabled = lib3270_has_selection |
193 | }, | 193 | }, |
194 | 194 | ||
@@ -198,7 +198,7 @@ | @@ -198,7 +198,7 @@ | ||
198 | .icon = NULL, | 198 | .icon = NULL, |
199 | .label = NULL, | 199 | .label = NULL, |
200 | .summary = NULL, | 200 | .summary = NULL, |
201 | - .call = save_copy, | 201 | + .activate = save_copy, |
202 | .enabled = lib3270_is_connected | 202 | .enabled = lib3270_is_connected |
203 | }, | 203 | }, |
204 | 204 | ||
@@ -208,7 +208,7 @@ | @@ -208,7 +208,7 @@ | ||
208 | .icon = "document-load", | 208 | .icon = "document-load", |
209 | .label = NULL, | 209 | .label = NULL, |
210 | .summary = N_( "Paste file." ), | 210 | .summary = N_( "Paste file." ), |
211 | - .call = paste_file, | 211 | + .activate = paste_file, |
212 | .enabled = lib3270_is_connected | 212 | .enabled = lib3270_is_connected |
213 | }, | 213 | }, |
214 | 214 | ||
@@ -221,7 +221,7 @@ | @@ -221,7 +221,7 @@ | ||
221 | .icon = "edit-select-all", | 221 | .icon = "edit-select-all", |
222 | .label = NULL, | 222 | .label = NULL, |
223 | .summary = NULL, | 223 | .summary = NULL, |
224 | - .call = lib3270_select_all, | 224 | + .activate = lib3270_select_all, |
225 | .enabled = lib3270_is_connected | 225 | .enabled = lib3270_is_connected |
226 | }, | 226 | }, |
227 | 227 | ||
@@ -231,7 +231,7 @@ | @@ -231,7 +231,7 @@ | ||
231 | .icon = NULL, | 231 | .icon = NULL, |
232 | .label = NULL, | 232 | .label = NULL, |
233 | .summary = N_( "Remove selection" ), | 233 | .summary = N_( "Remove selection" ), |
234 | - .call = lib3270_unselect, | 234 | + .activate = lib3270_unselect, |
235 | .enabled = lib3270_has_selection | 235 | .enabled = lib3270_has_selection |
236 | }, | 236 | }, |
237 | 237 | ||
@@ -241,7 +241,7 @@ | @@ -241,7 +241,7 @@ | ||
241 | .icon = NULL, | 241 | .icon = NULL, |
242 | .label = NULL, | 242 | .label = NULL, |
243 | .summary = N_( "Reselect"), | 243 | .summary = N_( "Reselect"), |
244 | - .call = lib3270_reselect, | 244 | + .activate = lib3270_reselect, |
245 | .enabled = lib3270_is_connected | 245 | .enabled = lib3270_is_connected |
246 | }, | 246 | }, |
247 | 247 | ||
@@ -254,7 +254,7 @@ | @@ -254,7 +254,7 @@ | ||
254 | .icon = NULL, | 254 | .icon = NULL, |
255 | .label = NULL, | 255 | .label = NULL, |
256 | .summary = N_( "Select Field" ), | 256 | .summary = N_( "Select Field" ), |
257 | - .call = lib3270_select_field, | 257 | + .activate = lib3270_select_field, |
258 | .enabled = lib3270_is_formatted | 258 | .enabled = lib3270_is_formatted |
259 | }, | 259 | }, |
260 | 260 | ||
@@ -265,7 +265,7 @@ | @@ -265,7 +265,7 @@ | ||
265 | .icon = NULL, | 265 | .icon = NULL, |
266 | .label = NULL, | 266 | .label = NULL, |
267 | .summary = N_( "Move the cursor to the first blank after the last nonblank in the field." ), | 267 | .summary = N_( "Move the cursor to the first blank after the last nonblank in the field." ), |
268 | - .call = lib3270_fieldend, | 268 | + .activate = lib3270_fieldend, |
269 | .enabled = lib3270_is_formatted | 269 | .enabled = lib3270_is_formatted |
270 | }, | 270 | }, |
271 | 271 | ||
@@ -275,7 +275,7 @@ | @@ -275,7 +275,7 @@ | ||
275 | .icon = "go-first", | 275 | .icon = "go-first", |
276 | .label = NULL, | 276 | .label = NULL, |
277 | .summary = N_( "Move to first unprotected field on screen." ), | 277 | .summary = N_( "Move to first unprotected field on screen." ), |
278 | - .call = lib3270_firstfield, | 278 | + .activate = lib3270_firstfield, |
279 | .enabled = lib3270_is_formatted | 279 | .enabled = lib3270_is_formatted |
280 | }, | 280 | }, |
281 | 281 | ||
@@ -285,7 +285,7 @@ | @@ -285,7 +285,7 @@ | ||
285 | .icon = "go-next", | 285 | .icon = "go-next", |
286 | .label = NULL, | 286 | .label = NULL, |
287 | .summary = N_( "Tab forward to next field." ), | 287 | .summary = N_( "Tab forward to next field." ), |
288 | - .call = lib3270_nextfield, | 288 | + .activate = lib3270_nextfield, |
289 | .enabled = lib3270_is_formatted | 289 | .enabled = lib3270_is_formatted |
290 | }, | 290 | }, |
291 | 291 | ||
@@ -295,7 +295,7 @@ | @@ -295,7 +295,7 @@ | ||
295 | .icon = "go-previous", | 295 | .icon = "go-previous", |
296 | .label = NULL, | 296 | .label = NULL, |
297 | .summary = N_( "Tab backward to previous field." ), | 297 | .summary = N_( "Tab backward to previous field." ), |
298 | - .call = lib3270_previousfield, | 298 | + .activate = lib3270_previousfield, |
299 | .enabled = lib3270_is_formatted | 299 | .enabled = lib3270_is_formatted |
300 | }, | 300 | }, |
301 | 301 | ||
@@ -309,7 +309,7 @@ | @@ -309,7 +309,7 @@ | ||
309 | .icon = NULL, | 309 | .icon = NULL, |
310 | .label = NULL, | 310 | .label = NULL, |
311 | .summary = N_( "Backspaces the cursor until it hits the front of a word." ), | 311 | .summary = N_( "Backspaces the cursor until it hits the front of a word." ), |
312 | - .call = lib3270_deleteword, | 312 | + .activate = lib3270_deleteword, |
313 | .enabled = lib3270_is_connected | 313 | .enabled = lib3270_is_connected |
314 | }, | 314 | }, |
315 | 315 | ||
@@ -319,7 +319,7 @@ | @@ -319,7 +319,7 @@ | ||
319 | .icon = NULL, | 319 | .icon = NULL, |
320 | .label = NULL, | 320 | .label = NULL, |
321 | .summary = N_( "Delete field" ), | 321 | .summary = N_( "Delete field" ), |
322 | - .call = lib3270_deletefield, | 322 | + .activate = lib3270_deletefield, |
323 | .enabled = lib3270_is_formatted | 323 | .enabled = lib3270_is_formatted |
324 | }, | 324 | }, |
325 | 325 | ||
@@ -330,7 +330,7 @@ | @@ -330,7 +330,7 @@ | ||
330 | .icon = NULL, | 330 | .icon = NULL, |
331 | .label = NULL, | 331 | .label = NULL, |
332 | .summary = NULL, | 332 | .summary = NULL, |
333 | - .call = lib3270_eraseinput, | 333 | + .activate = lib3270_eraseinput, |
334 | .enabled = lib3270_is_connected | 334 | .enabled = lib3270_is_connected |
335 | }, | 335 | }, |
336 | 336 | ||
@@ -340,7 +340,7 @@ | @@ -340,7 +340,7 @@ | ||
340 | .icon = NULL, | 340 | .icon = NULL, |
341 | .label = NULL, | 341 | .label = NULL, |
342 | .summary = N_( "Erase End Of Field Key." ), | 342 | .summary = N_( "Erase End Of Field Key." ), |
343 | - .call = lib3270_eraseeof, | 343 | + .activate = lib3270_eraseeof, |
344 | .enabled = lib3270_is_formatted | 344 | .enabled = lib3270_is_formatted |
345 | }, | 345 | }, |
346 | 346 | ||
@@ -350,7 +350,7 @@ | @@ -350,7 +350,7 @@ | ||
350 | .icon = NULL, | 350 | .icon = NULL, |
351 | .label = NULL, | 351 | .label = NULL, |
352 | .summary = N_( "Erase End Of Line Key." ), | 352 | .summary = N_( "Erase End Of Line Key." ), |
353 | - .call = lib3270_eraseeol, | 353 | + .activate = lib3270_eraseeol, |
354 | .enabled = lib3270_is_connected | 354 | .enabled = lib3270_is_connected |
355 | }, | 355 | }, |
356 | 356 | ||
@@ -360,7 +360,7 @@ | @@ -360,7 +360,7 @@ | ||
360 | .icon = NULL, | 360 | .icon = NULL, |
361 | .label = NULL, | 361 | .label = NULL, |
362 | .summary = NULL, | 362 | .summary = NULL, |
363 | - .call = lib3270_erase, | 363 | + .activate = lib3270_erase, |
364 | .enabled = lib3270_is_connected | 364 | .enabled = lib3270_is_connected |
365 | }, | 365 | }, |
366 | 366 | ||
@@ -373,7 +373,7 @@ | @@ -373,7 +373,7 @@ | ||
373 | .icon = NULL, | 373 | .icon = NULL, |
374 | .label = NULL, | 374 | .label = NULL, |
375 | .summary = N_( "Send an \"Enter\" action." ), | 375 | .summary = N_( "Send an \"Enter\" action." ), |
376 | - .call = lib3270_enter, | 376 | + .activate = lib3270_enter, |
377 | .enabled = lib3270_is_connected | 377 | .enabled = lib3270_is_connected |
378 | }, | 378 | }, |
379 | 379 | ||
@@ -384,7 +384,7 @@ | @@ -384,7 +384,7 @@ | ||
384 | .icon = NULL, | 384 | .icon = NULL, |
385 | .label = NULL, | 385 | .label = NULL, |
386 | .summary = NULL, | 386 | .summary = NULL, |
387 | - .call = lib3270_kybdreset, | 387 | + .activate = lib3270_kybdreset, |
388 | .enabled = lib3270_is_connected | 388 | .enabled = lib3270_is_connected |
389 | }, | 389 | }, |
390 | 390 | ||
@@ -394,7 +394,7 @@ | @@ -394,7 +394,7 @@ | ||
394 | .icon = NULL, | 394 | .icon = NULL, |
395 | .label = NULL, | 395 | .label = NULL, |
396 | .summary = N_( "Clear AID key" ), | 396 | .summary = N_( "Clear AID key" ), |
397 | - .call = lib3270_clear, | 397 | + .activate = lib3270_clear, |
398 | .enabled = lib3270_is_connected | 398 | .enabled = lib3270_is_connected |
399 | }, | 399 | }, |
400 | 400 | ||
@@ -405,7 +405,7 @@ | @@ -405,7 +405,7 @@ | ||
405 | .icon = NULL, | 405 | .icon = NULL, |
406 | .label = NULL, | 406 | .label = NULL, |
407 | .summary = NULL, | 407 | .summary = NULL, |
408 | - .call = lib3270_delete, | 408 | + .activate = lib3270_delete, |
409 | .enabled = lib3270_is_connected | 409 | .enabled = lib3270_is_connected |
410 | }, | 410 | }, |
411 | 411 | ||
@@ -415,7 +415,7 @@ | @@ -415,7 +415,7 @@ | ||
415 | .icon = NULL, | 415 | .icon = NULL, |
416 | .label = NULL, | 416 | .label = NULL, |
417 | .summary = N_( "DUP key" ), | 417 | .summary = N_( "DUP key" ), |
418 | - .call = lib3270_dup, | 418 | + .activate = lib3270_dup, |
419 | .enabled = lib3270_is_connected | 419 | .enabled = lib3270_is_connected |
420 | }, | 420 | }, |
421 | 421 | ||
@@ -425,7 +425,7 @@ | @@ -425,7 +425,7 @@ | ||
425 | .icon = NULL, | 425 | .icon = NULL, |
426 | .label = NULL, | 426 | .label = NULL, |
427 | .summary = N_( "FM key" ), | 427 | .summary = N_( "FM key" ), |
428 | - .call = lib3270_fieldmark, | 428 | + .activate = lib3270_fieldmark, |
429 | .enabled = lib3270_is_connected | 429 | .enabled = lib3270_is_connected |
430 | }, | 430 | }, |
431 | 431 | ||
@@ -435,7 +435,7 @@ | @@ -435,7 +435,7 @@ | ||
435 | .icon = NULL, | 435 | .icon = NULL, |
436 | .label = NULL, | 436 | .label = NULL, |
437 | .summary = N_( "3270-style backspace." ), | 437 | .summary = N_( "3270-style backspace." ), |
438 | - .call = lib3270_backspace, | 438 | + .activate = lib3270_backspace, |
439 | .enabled = lib3270_is_connected | 439 | .enabled = lib3270_is_connected |
440 | }, | 440 | }, |
441 | 441 | ||
@@ -445,7 +445,7 @@ | @@ -445,7 +445,7 @@ | ||
445 | .icon = NULL, | 445 | .icon = NULL, |
446 | .label = NULL, | 446 | .label = NULL, |
447 | .summary = N_( "ATTN key, per RFC 2355. Sends IP, regardless." ), | 447 | .summary = N_( "ATTN key, per RFC 2355. Sends IP, regardless." ), |
448 | - .call = lib3270_attn, | 448 | + .activate = lib3270_attn, |
449 | .enabled = lib3270_is_connected | 449 | .enabled = lib3270_is_connected |
450 | }, | 450 | }, |
451 | 451 | ||
@@ -455,7 +455,7 @@ | @@ -455,7 +455,7 @@ | ||
455 | .icon = NULL, | 455 | .icon = NULL, |
456 | .label = NULL, | 456 | .label = NULL, |
457 | .summary = NULL, | 457 | .summary = NULL, |
458 | - .call = lib3270_break, | 458 | + .activate = lib3270_break, |
459 | .enabled = lib3270_is_connected | 459 | .enabled = lib3270_is_connected |
460 | }, | 460 | }, |
461 | 461 | ||
@@ -465,7 +465,7 @@ | @@ -465,7 +465,7 @@ | ||
465 | .icon = NULL, | 465 | .icon = NULL, |
466 | .label = NULL, | 466 | .label = NULL, |
467 | .summary = NULL, | 467 | .summary = NULL, |
468 | - .call = lib3270_paste_next, | 468 | + .activate = lib3270_paste_next, |
469 | .enabled = lib3270_is_connected | 469 | .enabled = lib3270_is_connected |
470 | }, | 470 | }, |
471 | 471 | ||
@@ -475,7 +475,7 @@ | @@ -475,7 +475,7 @@ | ||
475 | .icon = NULL, | 475 | .icon = NULL, |
476 | .label = NULL, | 476 | .label = NULL, |
477 | .summary = NULL, | 477 | .summary = NULL, |
478 | - .call = lib3270_sysreq, | 478 | + .activate = lib3270_sysreq, |
479 | .enabled = lib3270_is_connected | 479 | .enabled = lib3270_is_connected |
480 | }, | 480 | }, |
481 | 481 | ||
@@ -487,8 +487,9 @@ | @@ -487,8 +487,9 @@ | ||
487 | .key = "Print", | 487 | .key = "Print", |
488 | .icon = "document-print", | 488 | .icon = "document-print", |
489 | .label = NULL, | 489 | .label = NULL, |
490 | - .summary = N_("If the terminal has selected area print it, if not, print all contents."), | ||
491 | - .call = lib3270_print, | 490 | + .summary = N_("Send to print"), |
491 | + .description = N_("If the terminal has selected area print it, if not, print all contents."), | ||
492 | + .activate = lib3270_print, | ||
492 | .enabled = lib3270_is_connected | 493 | .enabled = lib3270_is_connected |
493 | }, | 494 | }, |
494 | 495 | ||
@@ -498,7 +499,7 @@ | @@ -498,7 +499,7 @@ | ||
498 | .icon = NULL, | 499 | .icon = NULL, |
499 | .label = NULL, | 500 | .label = NULL, |
500 | .summary = N_("Print screen contents"), | 501 | .summary = N_("Print screen contents"), |
501 | - .call = lib3270_print_all, | 502 | + .activate = lib3270_print_all, |
502 | .enabled = lib3270_is_connected | 503 | .enabled = lib3270_is_connected |
503 | }, | 504 | }, |
504 | 505 | ||
@@ -508,7 +509,7 @@ | @@ -508,7 +509,7 @@ | ||
508 | .icon = NULL, | 509 | .icon = NULL, |
509 | .label = NULL, | 510 | .label = NULL, |
510 | .summary = N_( "Print selected area." ), | 511 | .summary = N_( "Print selected area." ), |
511 | - .call = lib3270_print_selected, | 512 | + .activate = lib3270_print_selected, |
512 | .enabled = lib3270_has_selection | 513 | .enabled = lib3270_has_selection |
513 | }, | 514 | }, |
514 | 515 | ||
@@ -518,7 +519,7 @@ | @@ -518,7 +519,7 @@ | ||
518 | .icon = NULL, | 519 | .icon = NULL, |
519 | .label = NULL, | 520 | .label = NULL, |
520 | .summary = N_("Print copy (if available)"), | 521 | .summary = N_("Print copy (if available)"), |
521 | - .call = lib3270_print_copy, | 522 | + .activate = lib3270_print_copy, |
522 | .enabled = lib3270_is_connected | 523 | .enabled = lib3270_is_connected |
523 | }, | 524 | }, |
524 | 525 | ||
@@ -532,7 +533,7 @@ | @@ -532,7 +533,7 @@ | ||
532 | .icon = NULL, | 533 | .icon = NULL, |
533 | .label = NULL, | 534 | .label = NULL, |
534 | .summary = NULL, | 535 | .summary = NULL, |
535 | - .call = lib3270_testpattern, | 536 | + .activate = lib3270_testpattern, |
536 | .enabled = lib3270_is_disconnected | 537 | .enabled = lib3270_is_disconnected |
537 | }, | 538 | }, |
538 | 539 | ||
@@ -542,7 +543,7 @@ | @@ -542,7 +543,7 @@ | ||
542 | .icon = NULL, | 543 | .icon = NULL, |
543 | .label = NULL, | 544 | .label = NULL, |
544 | .summary = NULL, | 545 | .summary = NULL, |
545 | - .call = lib3270_charsettable, | 546 | + .activate = lib3270_charsettable, |
546 | .enabled = lib3270_is_disconnected | 547 | .enabled = lib3270_is_disconnected |
547 | }, | 548 | }, |
548 | 549 | ||
@@ -552,7 +553,7 @@ | @@ -552,7 +553,7 @@ | ||
552 | .icon = NULL, | 553 | .icon = NULL, |
553 | .label = NULL, | 554 | .label = NULL, |
554 | .summary = NULL, | 555 | .summary = NULL, |
555 | - .call = NULL, | 556 | + .activate = NULL, |
556 | .enabled = NULL | 557 | .enabled = NULL |
557 | } | 558 | } |
558 | }; | 559 | }; |
src/include/lib3270/actions.h
@@ -33,16 +33,18 @@ | @@ -33,16 +33,18 @@ | ||
33 | extern "C" { | 33 | extern "C" { |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | - typedef struct _lib3270_action_entry | 36 | + typedef struct _lib3270_action |
37 | { | 37 | { |
38 | - const char *name; ///< @brief Action name. | 38 | + LIB3270_PROPERTY_HEAD |
39 | + | ||
40 | + int (*activate)(H3270 *hSession); ///< @brief lib3270 associated method. | ||
41 | + int (*enabled)(const H3270 *hSession); ///< @brief Is the action enabled? | ||
42 | + | ||
39 | const char *key; ///< @brief Default key (or NULL if no default). | 43 | const char *key; ///< @brief Default key (or NULL if no default). |
40 | const char *icon; ///< @brief Icon name (from https://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html) | 44 | const char *icon; ///< @brief Icon name (from https://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html) |
41 | const char *label; ///< @brief Button label (or NULL). | 45 | const char *label; ///< @brief Button label (or NULL). |
42 | - const char *summary; ///< @brief Short description (or NULL). | ||
43 | - int (*call)(H3270 *hSession); ///< @brief lib3270 associated method. | ||
44 | - int (*enabled)(const H3270 *hSession); ///< @brief Is the action enabled? | ||
45 | - } LIB3270_ACTION_ENTRY; | 46 | + |
47 | + } LIB3270_ACTION; | ||
46 | 48 | ||
47 | /** | 49 | /** |
48 | * | 50 | * |
@@ -442,6 +444,13 @@ | @@ -442,6 +444,13 @@ | ||
442 | */ | 444 | */ |
443 | LIB3270_EXPORT int lib3270_charsettable(H3270 *hSession); | 445 | LIB3270_EXPORT int lib3270_charsettable(H3270 *hSession); |
444 | 446 | ||
447 | +/** | ||
448 | + * @brief Get lib3270 action by name. | ||
449 | + * | ||
450 | + * @return Action descriptor or NULL if failed (sets errno). | ||
451 | + * | ||
452 | + */ | ||
453 | + LIB3270_EXPORT const LIB3270_ACTION * lib3270_get_action(const char *name); | ||
445 | 454 | ||
446 | /** | 455 | /** |
447 | * | 456 | * |
@@ -449,7 +458,7 @@ | @@ -449,7 +458,7 @@ | ||
449 | * | 458 | * |
450 | * @return Array with all the supported actions. | 459 | * @return Array with all the supported actions. |
451 | */ | 460 | */ |
452 | - LIB3270_EXPORT const LIB3270_ACTION_ENTRY * lib3270_get_action_table(); | 461 | + LIB3270_EXPORT const LIB3270_ACTION * lib3270_get_actions(); |
453 | 462 | ||
454 | /** | 463 | /** |
455 | * | 464 | * |
@@ -461,6 +470,7 @@ | @@ -461,6 +470,7 @@ | ||
461 | * @return The action return code. | 470 | * @return The action return code. |
462 | * | 471 | * |
463 | * @retval EPERM Action is disabled. | 472 | * @retval EPERM Action is disabled. |
473 | + * @retval ENOTSUP Action name is invalid. | ||
464 | * | 474 | * |
465 | */ | 475 | */ |
466 | LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name); | 476 | LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name); |
src/mkactions/mkactions.c
@@ -189,7 +189,7 @@ int main(int argc, char *argv[]) { | @@ -189,7 +189,7 @@ int main(int argc, char *argv[]) { | ||
189 | " *\n" | 189 | " *\n" |
190 | " * @return Array with all the supported actions.\n" | 190 | " * @return Array with all the supported actions.\n" |
191 | " */\n" | 191 | " */\n" |
192 | - " LIB3270_EXPORT const LIB3270_ACTION_ENTRY * lib3270_get_action_table();\n" | 192 | + " LIB3270_EXPORT const LIB3270_ACTION_ENTRY * lib3270_get_actions();\n" |
193 | "\n" | 193 | "\n" |
194 | "/**\n" | 194 | "/**\n" |
195 | " *\n" | 195 | " *\n" |