Commit bd4ed045200c18a69618b717ec89c2616c5fb77c
1 parent
60b8d5c8
Exists in
master
and in
3 other branches
Adjustments in action API.
Showing
3 changed files
with
128 additions
and
73 deletions
Show diff stats
src/core/actions/actions.c
@@ -48,17 +48,15 @@ LIB3270_EXPORT const LIB3270_ACTION * lib3270_get_action(const char *name) | @@ -48,17 +48,15 @@ LIB3270_EXPORT const LIB3270_ACTION * lib3270_get_action(const char *name) | ||
48 | return NULL; | 48 | return NULL; |
49 | } | 49 | } |
50 | 50 | ||
51 | -LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name) | 51 | +LIB3270_EXPORT int lib3270_action_is_activatable(const LIB3270_ACTION *action, H3270 *hSession) |
52 | { | 52 | { |
53 | - const LIB3270_ACTION *action = lib3270_get_action(name); | 53 | + return action->activatable(hSession); |
54 | +} | ||
54 | 55 | ||
55 | - if(!action) | ||
56 | - { | ||
57 | - lib3270_trace_event(hSession,"Unknown action \"%s\"\n",name); | ||
58 | - return errno; | ||
59 | - } | 56 | +LIB3270_EXPORT int lib3270_action_activate(const LIB3270_ACTION *action, H3270 *hSession) |
57 | +{ | ||
60 | 58 | ||
61 | - if(!action->enabled(hSession)) | 59 | + if(!action->activatable(hSession)) |
62 | { | 60 | { |
63 | lib3270_trace_event(hSession,"Action \"%s\" is disabled\n",action->name); | 61 | lib3270_trace_event(hSession,"Action \"%s\" is disabled\n",action->name); |
64 | return errno = EPERM; | 62 | return errno = EPERM; |
@@ -69,3 +67,21 @@ LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name) | @@ -69,3 +67,21 @@ LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name) | ||
69 | return action->activate(hSession); | 67 | return action->activate(hSession); |
70 | 68 | ||
71 | } | 69 | } |
70 | + | ||
71 | +LIB3270_EXPORT int lib3270_action_activate_by_name(const char *name, H3270 *hSession) | ||
72 | +{ | ||
73 | + const LIB3270_ACTION *action = lib3270_get_action(name); | ||
74 | + | ||
75 | + if(!action) | ||
76 | + { | ||
77 | + lib3270_trace_event(hSession,"Can't find action \"%s\"\n",name); | ||
78 | + return errno; | ||
79 | + } | ||
80 | + | ||
81 | + return lib3270_action_activate(action, hSession); | ||
82 | +} | ||
83 | + | ||
84 | +LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name) | ||
85 | +{ | ||
86 | + return lib3270_action_activate_by_name(name,hSession); | ||
87 | +} |
src/core/actions/table.c
@@ -83,7 +83,7 @@ | @@ -83,7 +83,7 @@ | ||
83 | .label = NULL, | 83 | .label = NULL, |
84 | .summary = N_( "Connect to host." ), | 84 | .summary = N_( "Connect to host." ), |
85 | .activate = connect_host, | 85 | .activate = connect_host, |
86 | - .enabled = lib3270_is_disconnected | 86 | + .activatable = lib3270_is_disconnected |
87 | }, | 87 | }, |
88 | 88 | ||
89 | { | 89 | { |
@@ -93,7 +93,7 @@ | @@ -93,7 +93,7 @@ | ||
93 | .label = NULL, | 93 | .label = NULL, |
94 | .summary = N_( "Disconnect from host." ), | 94 | .summary = N_( "Disconnect from host." ), |
95 | .activate = lib3270_disconnect, | 95 | .activate = lib3270_disconnect, |
96 | - .enabled = lib3270_is_connected | 96 | + .activatable = lib3270_is_connected |
97 | }, | 97 | }, |
98 | 98 | ||
99 | // | 99 | // |
@@ -106,7 +106,7 @@ | @@ -106,7 +106,7 @@ | ||
106 | .label = NULL, | 106 | .label = NULL, |
107 | .summary = N_( "Cursor up 1 position." ), | 107 | .summary = N_( "Cursor up 1 position." ), |
108 | .activate = lib3270_cursor_up, | 108 | .activate = lib3270_cursor_up, |
109 | - .enabled = lib3270_is_connected | 109 | + .activatable = lib3270_is_connected |
110 | }, | 110 | }, |
111 | 111 | ||
112 | { | 112 | { |
@@ -116,7 +116,7 @@ | @@ -116,7 +116,7 @@ | ||
116 | .label = NULL, | 116 | .label = NULL, |
117 | .summary = N_( "Cursor down 1 position." ), | 117 | .summary = N_( "Cursor down 1 position." ), |
118 | .activate = lib3270_cursor_down, | 118 | .activate = lib3270_cursor_down, |
119 | - .enabled = lib3270_is_connected | 119 | + .activatable = lib3270_is_connected |
120 | }, | 120 | }, |
121 | 121 | ||
122 | { | 122 | { |
@@ -126,7 +126,7 @@ | @@ -126,7 +126,7 @@ | ||
126 | .label = NULL, | 126 | .label = NULL, |
127 | .summary = N_( "Cursor left 1 position." ), | 127 | .summary = N_( "Cursor left 1 position." ), |
128 | .activate = lib3270_cursor_left, | 128 | .activate = lib3270_cursor_left, |
129 | - .enabled = lib3270_is_connected | 129 | + .activatable = lib3270_is_connected |
130 | }, | 130 | }, |
131 | 131 | ||
132 | { | 132 | { |
@@ -136,7 +136,7 @@ | @@ -136,7 +136,7 @@ | ||
136 | .label = NULL, | 136 | .label = NULL, |
137 | .summary = N_( "Cursor right 1 position." ), | 137 | .summary = N_( "Cursor right 1 position." ), |
138 | .activate = lib3270_cursor_right, | 138 | .activate = lib3270_cursor_right, |
139 | - .enabled = lib3270_is_connected | 139 | + .activatable = lib3270_is_connected |
140 | }, | 140 | }, |
141 | 141 | ||
142 | { | 142 | { |
@@ -146,7 +146,7 @@ | @@ -146,7 +146,7 @@ | ||
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 | .activate = lib3270_newline, | 148 | .activate = lib3270_newline, |
149 | - .enabled = lib3270_is_connected | 149 | + .activatable = lib3270_is_connected |
150 | }, | 150 | }, |
151 | 151 | ||
152 | { | 152 | { |
@@ -156,7 +156,7 @@ | @@ -156,7 +156,7 @@ | ||
156 | .label = NULL, | 156 | .label = NULL, |
157 | .summary = N_( "Cursor to previous word." ), | 157 | .summary = N_( "Cursor to previous word." ), |
158 | .activate = lib3270_previousword, | 158 | .activate = lib3270_previousword, |
159 | - .enabled = lib3270_is_connected | 159 | + .activatable = lib3270_is_connected |
160 | }, | 160 | }, |
161 | 161 | ||
162 | { | 162 | { |
@@ -166,7 +166,7 @@ | @@ -166,7 +166,7 @@ | ||
166 | .label = NULL, | 166 | .label = NULL, |
167 | .summary = N_( "Cursor to next unprotected word." ), | 167 | .summary = N_( "Cursor to next unprotected word." ), |
168 | .activate = lib3270_nextword, | 168 | .activate = lib3270_nextword, |
169 | - .enabled = lib3270_is_connected | 169 | + .activatable = lib3270_is_connected |
170 | }, | 170 | }, |
171 | 171 | ||
172 | // | 172 | // |
@@ -179,7 +179,7 @@ | @@ -179,7 +179,7 @@ | ||
179 | .label = NULL, | 179 | .label = NULL, |
180 | .summary = N_( "Save screen." ), | 180 | .summary = N_( "Save screen." ), |
181 | .activate = save_all, | 181 | .activate = save_all, |
182 | - .enabled = lib3270_is_connected | 182 | + .activatable = lib3270_is_connected |
183 | }, | 183 | }, |
184 | 184 | ||
185 | { | 185 | { |
@@ -189,7 +189,7 @@ | @@ -189,7 +189,7 @@ | ||
189 | .label = NULL, | 189 | .label = NULL, |
190 | .summary = N_( "Save selected area." ), | 190 | .summary = N_( "Save selected area." ), |
191 | .activate = save_selected, | 191 | .activate = save_selected, |
192 | - .enabled = lib3270_has_selection | 192 | + .activatable = lib3270_has_selection |
193 | }, | 193 | }, |
194 | 194 | ||
195 | { | 195 | { |
@@ -199,7 +199,7 @@ | @@ -199,7 +199,7 @@ | ||
199 | .label = NULL, | 199 | .label = NULL, |
200 | .summary = NULL, | 200 | .summary = NULL, |
201 | .activate = save_copy, | 201 | .activate = save_copy, |
202 | - .enabled = lib3270_is_connected | 202 | + .activatable = lib3270_is_connected |
203 | }, | 203 | }, |
204 | 204 | ||
205 | { | 205 | { |
@@ -209,7 +209,7 @@ | @@ -209,7 +209,7 @@ | ||
209 | .label = NULL, | 209 | .label = NULL, |
210 | .summary = N_( "Paste file." ), | 210 | .summary = N_( "Paste file." ), |
211 | .activate = paste_file, | 211 | .activate = paste_file, |
212 | - .enabled = lib3270_is_connected | 212 | + .activatable = lib3270_is_connected |
213 | }, | 213 | }, |
214 | 214 | ||
215 | // | 215 | // |
@@ -222,7 +222,7 @@ | @@ -222,7 +222,7 @@ | ||
222 | .label = NULL, | 222 | .label = NULL, |
223 | .summary = NULL, | 223 | .summary = NULL, |
224 | .activate = lib3270_select_all, | 224 | .activate = lib3270_select_all, |
225 | - .enabled = lib3270_is_connected | 225 | + .activatable = lib3270_is_connected |
226 | }, | 226 | }, |
227 | 227 | ||
228 | { | 228 | { |
@@ -232,7 +232,7 @@ | @@ -232,7 +232,7 @@ | ||
232 | .label = NULL, | 232 | .label = NULL, |
233 | .summary = N_( "Remove selection" ), | 233 | .summary = N_( "Remove selection" ), |
234 | .activate = lib3270_unselect, | 234 | .activate = lib3270_unselect, |
235 | - .enabled = lib3270_has_selection | 235 | + .activatable = lib3270_has_selection |
236 | }, | 236 | }, |
237 | 237 | ||
238 | { | 238 | { |
@@ -242,7 +242,7 @@ | @@ -242,7 +242,7 @@ | ||
242 | .label = NULL, | 242 | .label = NULL, |
243 | .summary = N_( "Reselect"), | 243 | .summary = N_( "Reselect"), |
244 | .activate = lib3270_reselect, | 244 | .activate = lib3270_reselect, |
245 | - .enabled = lib3270_is_connected | 245 | + .activatable = lib3270_is_connected |
246 | }, | 246 | }, |
247 | 247 | ||
248 | // | 248 | // |
@@ -255,7 +255,7 @@ | @@ -255,7 +255,7 @@ | ||
255 | .label = NULL, | 255 | .label = NULL, |
256 | .summary = N_( "Select Field" ), | 256 | .summary = N_( "Select Field" ), |
257 | .activate = lib3270_select_field, | 257 | .activate = lib3270_select_field, |
258 | - .enabled = lib3270_is_formatted | 258 | + .activatable = lib3270_is_formatted |
259 | }, | 259 | }, |
260 | 260 | ||
261 | 261 | ||
@@ -266,7 +266,7 @@ | @@ -266,7 +266,7 @@ | ||
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 | .activate = lib3270_fieldend, | 268 | .activate = lib3270_fieldend, |
269 | - .enabled = lib3270_is_formatted | 269 | + .activatable = lib3270_is_formatted |
270 | }, | 270 | }, |
271 | 271 | ||
272 | { | 272 | { |
@@ -276,7 +276,7 @@ | @@ -276,7 +276,7 @@ | ||
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 | .activate = lib3270_firstfield, | 278 | .activate = lib3270_firstfield, |
279 | - .enabled = lib3270_is_formatted | 279 | + .activatable = lib3270_is_formatted |
280 | }, | 280 | }, |
281 | 281 | ||
282 | { | 282 | { |
@@ -286,7 +286,7 @@ | @@ -286,7 +286,7 @@ | ||
286 | .label = NULL, | 286 | .label = NULL, |
287 | .summary = N_( "Tab forward to next field." ), | 287 | .summary = N_( "Tab forward to next field." ), |
288 | .activate = lib3270_nextfield, | 288 | .activate = lib3270_nextfield, |
289 | - .enabled = lib3270_is_formatted | 289 | + .activatable = lib3270_is_formatted |
290 | }, | 290 | }, |
291 | 291 | ||
292 | { | 292 | { |
@@ -296,7 +296,7 @@ | @@ -296,7 +296,7 @@ | ||
296 | .label = NULL, | 296 | .label = NULL, |
297 | .summary = N_( "Tab backward to previous field." ), | 297 | .summary = N_( "Tab backward to previous field." ), |
298 | .activate = lib3270_previousfield, | 298 | .activate = lib3270_previousfield, |
299 | - .enabled = lib3270_is_formatted | 299 | + .activatable = lib3270_is_formatted |
300 | }, | 300 | }, |
301 | 301 | ||
302 | 302 | ||
@@ -310,7 +310,7 @@ | @@ -310,7 +310,7 @@ | ||
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 | .activate = lib3270_deleteword, | 312 | .activate = lib3270_deleteword, |
313 | - .enabled = lib3270_is_connected | 313 | + .activatable = lib3270_is_connected |
314 | }, | 314 | }, |
315 | 315 | ||
316 | { | 316 | { |
@@ -320,7 +320,7 @@ | @@ -320,7 +320,7 @@ | ||
320 | .label = NULL, | 320 | .label = NULL, |
321 | .summary = N_( "Delete field" ), | 321 | .summary = N_( "Delete field" ), |
322 | .activate = lib3270_deletefield, | 322 | .activate = lib3270_deletefield, |
323 | - .enabled = lib3270_is_formatted | 323 | + .activatable = lib3270_is_formatted |
324 | }, | 324 | }, |
325 | 325 | ||
326 | 326 | ||
@@ -331,7 +331,7 @@ | @@ -331,7 +331,7 @@ | ||
331 | .label = NULL, | 331 | .label = NULL, |
332 | .summary = NULL, | 332 | .summary = NULL, |
333 | .activate = lib3270_eraseinput, | 333 | .activate = lib3270_eraseinput, |
334 | - .enabled = lib3270_is_connected | 334 | + .activatable = lib3270_is_connected |
335 | }, | 335 | }, |
336 | 336 | ||
337 | { | 337 | { |
@@ -341,7 +341,7 @@ | @@ -341,7 +341,7 @@ | ||
341 | .label = NULL, | 341 | .label = NULL, |
342 | .summary = N_( "Erase End Of Field Key." ), | 342 | .summary = N_( "Erase End Of Field Key." ), |
343 | .activate = lib3270_eraseeof, | 343 | .activate = lib3270_eraseeof, |
344 | - .enabled = lib3270_is_formatted | 344 | + .activatable = lib3270_is_formatted |
345 | }, | 345 | }, |
346 | 346 | ||
347 | { | 347 | { |
@@ -351,7 +351,7 @@ | @@ -351,7 +351,7 @@ | ||
351 | .label = NULL, | 351 | .label = NULL, |
352 | .summary = N_( "Erase End Of Line Key." ), | 352 | .summary = N_( "Erase End Of Line Key." ), |
353 | .activate = lib3270_eraseeol, | 353 | .activate = lib3270_eraseeol, |
354 | - .enabled = lib3270_is_connected | 354 | + .activatable = lib3270_is_connected |
355 | }, | 355 | }, |
356 | 356 | ||
357 | { | 357 | { |
@@ -361,7 +361,7 @@ | @@ -361,7 +361,7 @@ | ||
361 | .label = NULL, | 361 | .label = NULL, |
362 | .summary = NULL, | 362 | .summary = NULL, |
363 | .activate = lib3270_erase, | 363 | .activate = lib3270_erase, |
364 | - .enabled = lib3270_is_connected | 364 | + .activatable = lib3270_is_connected |
365 | }, | 365 | }, |
366 | 366 | ||
367 | // | 367 | // |
@@ -374,7 +374,7 @@ | @@ -374,7 +374,7 @@ | ||
374 | .label = NULL, | 374 | .label = NULL, |
375 | .summary = N_( "Send an \"Enter\" action." ), | 375 | .summary = N_( "Send an \"Enter\" action." ), |
376 | .activate = lib3270_enter, | 376 | .activate = lib3270_enter, |
377 | - .enabled = lib3270_is_connected | 377 | + .activatable = lib3270_is_connected |
378 | }, | 378 | }, |
379 | 379 | ||
380 | 380 | ||
@@ -385,7 +385,7 @@ | @@ -385,7 +385,7 @@ | ||
385 | .label = NULL, | 385 | .label = NULL, |
386 | .summary = NULL, | 386 | .summary = NULL, |
387 | .activate = lib3270_kybdreset, | 387 | .activate = lib3270_kybdreset, |
388 | - .enabled = lib3270_is_connected | 388 | + .activatable = lib3270_is_connected |
389 | }, | 389 | }, |
390 | 390 | ||
391 | { | 391 | { |
@@ -395,7 +395,7 @@ | @@ -395,7 +395,7 @@ | ||
395 | .label = NULL, | 395 | .label = NULL, |
396 | .summary = N_( "Clear AID key" ), | 396 | .summary = N_( "Clear AID key" ), |
397 | .activate = lib3270_clear, | 397 | .activate = lib3270_clear, |
398 | - .enabled = lib3270_is_connected | 398 | + .activatable = lib3270_is_connected |
399 | }, | 399 | }, |
400 | 400 | ||
401 | 401 | ||
@@ -406,7 +406,7 @@ | @@ -406,7 +406,7 @@ | ||
406 | .label = NULL, | 406 | .label = NULL, |
407 | .summary = NULL, | 407 | .summary = NULL, |
408 | .activate = lib3270_delete, | 408 | .activate = lib3270_delete, |
409 | - .enabled = lib3270_is_connected | 409 | + .activatable = lib3270_is_connected |
410 | }, | 410 | }, |
411 | 411 | ||
412 | { | 412 | { |
@@ -416,7 +416,7 @@ | @@ -416,7 +416,7 @@ | ||
416 | .label = NULL, | 416 | .label = NULL, |
417 | .summary = N_( "DUP key" ), | 417 | .summary = N_( "DUP key" ), |
418 | .activate = lib3270_dup, | 418 | .activate = lib3270_dup, |
419 | - .enabled = lib3270_is_connected | 419 | + .activatable = lib3270_is_connected |
420 | }, | 420 | }, |
421 | 421 | ||
422 | { | 422 | { |
@@ -426,7 +426,7 @@ | @@ -426,7 +426,7 @@ | ||
426 | .label = NULL, | 426 | .label = NULL, |
427 | .summary = N_( "FM key" ), | 427 | .summary = N_( "FM key" ), |
428 | .activate = lib3270_fieldmark, | 428 | .activate = lib3270_fieldmark, |
429 | - .enabled = lib3270_is_connected | 429 | + .activatable = lib3270_is_connected |
430 | }, | 430 | }, |
431 | 431 | ||
432 | { | 432 | { |
@@ -436,7 +436,7 @@ | @@ -436,7 +436,7 @@ | ||
436 | .label = NULL, | 436 | .label = NULL, |
437 | .summary = N_( "3270-style backspace." ), | 437 | .summary = N_( "3270-style backspace." ), |
438 | .activate = lib3270_backspace, | 438 | .activate = lib3270_backspace, |
439 | - .enabled = lib3270_is_connected | 439 | + .activatable = lib3270_is_connected |
440 | }, | 440 | }, |
441 | 441 | ||
442 | { | 442 | { |
@@ -446,7 +446,7 @@ | @@ -446,7 +446,7 @@ | ||
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 | .activate = lib3270_attn, | 448 | .activate = lib3270_attn, |
449 | - .enabled = lib3270_is_connected | 449 | + .activatable = lib3270_is_connected |
450 | }, | 450 | }, |
451 | 451 | ||
452 | { | 452 | { |
@@ -456,7 +456,7 @@ | @@ -456,7 +456,7 @@ | ||
456 | .label = NULL, | 456 | .label = NULL, |
457 | .summary = NULL, | 457 | .summary = NULL, |
458 | .activate = lib3270_break, | 458 | .activate = lib3270_break, |
459 | - .enabled = lib3270_is_connected | 459 | + .activatable = lib3270_is_connected |
460 | }, | 460 | }, |
461 | 461 | ||
462 | { | 462 | { |
@@ -466,7 +466,7 @@ | @@ -466,7 +466,7 @@ | ||
466 | .label = NULL, | 466 | .label = NULL, |
467 | .summary = NULL, | 467 | .summary = NULL, |
468 | .activate = lib3270_paste_next, | 468 | .activate = lib3270_paste_next, |
469 | - .enabled = lib3270_is_connected | 469 | + .activatable = lib3270_is_connected |
470 | }, | 470 | }, |
471 | 471 | ||
472 | { | 472 | { |
@@ -476,7 +476,7 @@ | @@ -476,7 +476,7 @@ | ||
476 | .label = NULL, | 476 | .label = NULL, |
477 | .summary = NULL, | 477 | .summary = NULL, |
478 | .activate = lib3270_sysreq, | 478 | .activate = lib3270_sysreq, |
479 | - .enabled = lib3270_is_connected | 479 | + .activatable = lib3270_is_connected |
480 | }, | 480 | }, |
481 | 481 | ||
482 | // | 482 | // |
@@ -490,7 +490,7 @@ | @@ -490,7 +490,7 @@ | ||
490 | .summary = N_("Send to print"), | 490 | .summary = N_("Send to print"), |
491 | .description = N_("If the terminal has selected area print it, if not, print all contents."), | 491 | .description = N_("If the terminal has selected area print it, if not, print all contents."), |
492 | .activate = lib3270_print, | 492 | .activate = lib3270_print, |
493 | - .enabled = lib3270_is_connected | 493 | + .activatable = lib3270_is_connected |
494 | }, | 494 | }, |
495 | 495 | ||
496 | { | 496 | { |
@@ -500,7 +500,7 @@ | @@ -500,7 +500,7 @@ | ||
500 | .label = NULL, | 500 | .label = NULL, |
501 | .summary = N_("Print screen contents"), | 501 | .summary = N_("Print screen contents"), |
502 | .activate = lib3270_print_all, | 502 | .activate = lib3270_print_all, |
503 | - .enabled = lib3270_is_connected | 503 | + .activatable = lib3270_is_connected |
504 | }, | 504 | }, |
505 | 505 | ||
506 | { | 506 | { |
@@ -510,7 +510,7 @@ | @@ -510,7 +510,7 @@ | ||
510 | .label = NULL, | 510 | .label = NULL, |
511 | .summary = N_( "Print selected area." ), | 511 | .summary = N_( "Print selected area." ), |
512 | .activate = lib3270_print_selected, | 512 | .activate = lib3270_print_selected, |
513 | - .enabled = lib3270_has_selection | 513 | + .activatable = lib3270_has_selection |
514 | }, | 514 | }, |
515 | 515 | ||
516 | { | 516 | { |
@@ -520,7 +520,7 @@ | @@ -520,7 +520,7 @@ | ||
520 | .label = NULL, | 520 | .label = NULL, |
521 | .summary = N_("Print copy (if available)"), | 521 | .summary = N_("Print copy (if available)"), |
522 | .activate = lib3270_print_copy, | 522 | .activate = lib3270_print_copy, |
523 | - .enabled = lib3270_is_connected | 523 | + .activatable = lib3270_is_connected |
524 | }, | 524 | }, |
525 | 525 | ||
526 | // | 526 | // |
@@ -534,7 +534,7 @@ | @@ -534,7 +534,7 @@ | ||
534 | .label = NULL, | 534 | .label = NULL, |
535 | .summary = NULL, | 535 | .summary = NULL, |
536 | .activate = lib3270_testpattern, | 536 | .activate = lib3270_testpattern, |
537 | - .enabled = lib3270_is_disconnected | 537 | + .activatable = lib3270_is_disconnected |
538 | }, | 538 | }, |
539 | 539 | ||
540 | { | 540 | { |
@@ -544,7 +544,7 @@ | @@ -544,7 +544,7 @@ | ||
544 | .label = NULL, | 544 | .label = NULL, |
545 | .summary = NULL, | 545 | .summary = NULL, |
546 | .activate = lib3270_charsettable, | 546 | .activate = lib3270_charsettable, |
547 | - .enabled = lib3270_is_disconnected | 547 | + .activatable = lib3270_is_disconnected |
548 | }, | 548 | }, |
549 | 549 | ||
550 | { | 550 | { |
@@ -554,7 +554,7 @@ | @@ -554,7 +554,7 @@ | ||
554 | .label = NULL, | 554 | .label = NULL, |
555 | .summary = NULL, | 555 | .summary = NULL, |
556 | .activate = NULL, | 556 | .activate = NULL, |
557 | - .enabled = NULL | 557 | + .activatable = NULL |
558 | } | 558 | } |
559 | }; | 559 | }; |
560 | 560 |
src/include/lib3270/actions.h
@@ -37,17 +37,71 @@ | @@ -37,17 +37,71 @@ | ||
37 | { | 37 | { |
38 | LIB3270_PROPERTY_HEAD | 38 | LIB3270_PROPERTY_HEAD |
39 | 39 | ||
40 | - int (*activate)(H3270 *hSession); ///< @brief lib3270 associated method. | ||
41 | - int (*enabled)(const H3270 *hSession); ///< @brief Is the action enabled? | 40 | + int (*activate)(H3270 *hSession); ///< @brief lib3270 associated method. |
41 | + int (*activatable)(const H3270 *hSession); ///< @brief Is the action activatable? | ||
42 | 42 | ||
43 | - const char *key; ///< @brief Default key (or NULL if no default). | ||
44 | - const char *icon; ///< @brief Icon name (from https://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html) | ||
45 | - const char *label; ///< @brief Button label (or NULL). | 43 | + const char *key; ///< @brief Default key (or NULL if no default). |
44 | + const char *icon; ///< @brief Icon name (from https://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html) | ||
45 | + const char *label; ///< @brief Button label (or NULL). | ||
46 | 46 | ||
47 | } LIB3270_ACTION; | 47 | } LIB3270_ACTION; |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * | 50 | * |
51 | + * @brief Call lib3270 action by name. | ||
52 | + * | ||
53 | + * @param hSession TN3270 Session handle. | ||
54 | + * @param name Name of the action to call. | ||
55 | + * | ||
56 | + * @return The action return code. | ||
57 | + * | ||
58 | + * @retval EPERM Action is disabled. | ||
59 | + * @retval ENOTSUP Action name is invalid. | ||
60 | + * | ||
61 | + */ | ||
62 | + LIB3270_EXPORT int LIB3270_DEPRECATED(lib3270_action(H3270 *hSession, const char *name)); | ||
63 | + | ||
64 | +/** | ||
65 | + * | ||
66 | + * @brief Call lib3270 action by name. | ||
67 | + * | ||
68 | + * @param hSession TN3270 Session handle. | ||
69 | + * @param name Name of the action to call. | ||
70 | + * | ||
71 | + * @return The action return code. | ||
72 | + * | ||
73 | + * @retval EPERM Action is disabled. | ||
74 | + * @retval ENOTSUP Action name is invalid. | ||
75 | + * | ||
76 | + */ | ||
77 | + LIB3270_EXPORT int lib3270_action_activate_by_name(const char *name, H3270 *hSession); | ||
78 | + | ||
79 | +/** | ||
80 | + * @brief activate an action. | ||
81 | + * | ||
82 | + * @param action Pointer to the action descriptor | ||
83 | + * @param hSession TN3270 Session handle. | ||
84 | + * | ||
85 | + * @return The action return code. | ||
86 | + * | ||
87 | + * @retval EPERM Action is disabled. | ||
88 | + * | ||
89 | + */ | ||
90 | + LIB3270_EXPORT int lib3270_action_activate(const LIB3270_ACTION *action, H3270 *hSession); | ||
91 | + | ||
92 | +/** | ||
93 | + * @brief Check if the action is activatable | ||
94 | + * | ||
95 | + * @param action Pointer to the action descriptor | ||
96 | + * @param hSession TN3270 Session handle. | ||
97 | + * | ||
98 | + * @return Non zero if action is activatable. | ||
99 | + * | ||
100 | + */ | ||
101 | + LIB3270_EXPORT int lib3270_action_is_activatable(const LIB3270_ACTION *action, H3270 *hSession); | ||
102 | + | ||
103 | +/** | ||
104 | + * | ||
51 | * @brief Send an "Enter" action. | 105 | * @brief Send an "Enter" action. |
52 | * | 106 | * |
53 | * @param hSession TN3270 Session handle. | 107 | * @param hSession TN3270 Session handle. |
@@ -460,21 +514,6 @@ | @@ -460,21 +514,6 @@ | ||
460 | */ | 514 | */ |
461 | LIB3270_EXPORT const LIB3270_ACTION * lib3270_get_actions(); | 515 | LIB3270_EXPORT const LIB3270_ACTION * lib3270_get_actions(); |
462 | 516 | ||
463 | -/** | ||
464 | - * | ||
465 | - * @brief Call lib3270 action by name. | ||
466 | - * | ||
467 | - * @param hSession TN3270 Session handle. | ||
468 | - * @param name Name of the action to call. | ||
469 | - * | ||
470 | - * @return The action return code. | ||
471 | - * | ||
472 | - * @retval EPERM Action is disabled. | ||
473 | - * @retval ENOTSUP Action name is invalid. | ||
474 | - * | ||
475 | - */ | ||
476 | - LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name); | ||
477 | - | ||
478 | #ifdef __cplusplus | 517 | #ifdef __cplusplus |
479 | } | 518 | } |
480 | #endif | 519 | #endif |