Commit c5066fd55d5785e9f9302043fa9eee3f9c9bcbda
1 parent
06041c11
Exists in
master
and in
3 other branches
Adding method to get the "activatable" state of an action group.
Showing
2 changed files
with
37 additions
and
0 deletions
Show diff stats
src/core/actions/table.c
| ... | ... | @@ -731,3 +731,30 @@ |
| 731 | 731 | return actions; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | + static int default_activatable_state(const H3270 *hSession) | |
| 735 | + { | |
| 736 | + return hSession == NULL ? 0 : 1; | |
| 737 | + } | |
| 738 | + | |
| 739 | + LIB3270_EXPORT int lib3270_action_group_get_activatable(const H3270 *hSession, const LIB3270_ACTION_GROUP group) | |
| 740 | + { | |
| 741 | + static const struct | |
| 742 | + { | |
| 743 | + int (*get)(const H3270 *); | |
| 744 | + } activatable[LIB3270_ACTION_CUSTOM] = | |
| 745 | + { | |
| 746 | + { default_activatable_state }, // LIB3270_ACTION_GROUP_NONE | |
| 747 | + { lib3270_is_connected }, // LIB3270_ACTION_GROUP_ONLINE | |
| 748 | + { lib3270_is_disconnected }, // LIB3270_ACTION_GROUP_OFFLINE | |
| 749 | + { lib3270_has_selection }, // LIB3270_ACTION_GROUP_SELECTION | |
| 750 | + { lib3270_is_unlocked }, // LIB3270_ACTION_GROUP_LOCK_STATE | |
| 751 | + { lib3270_is_formatted }, // LIB3270_ACTION_GROUP_FORMATTED | |
| 752 | + }; | |
| 753 | + | |
| 754 | + if(group < (sizeof(activatable)/sizeof(activatable[0]))) { | |
| 755 | + return activatable[group].get(hSession); | |
| 756 | + } | |
| 757 | + | |
| 758 | + return default_activatable_state(hSession); | |
| 759 | + | |
| 760 | + } | ... | ... |
src/include/lib3270/actions.h
| ... | ... | @@ -73,6 +73,16 @@ |
| 73 | 73 | |
| 74 | 74 | } LIB3270_ACTION; |
| 75 | 75 | |
| 76 | +/** | |
| 77 | + * @brief Query if the action group can be activated. | |
| 78 | + * | |
| 79 | + * @param hSession TN3270 Session handle. | |
| 80 | + * @param group The group to listen. | |
| 81 | + * | |
| 82 | + * @return The current state of the group. | |
| 83 | + * | |
| 84 | + */ | |
| 85 | + LIB3270_EXPORT int lib3270_action_group_get_activatable(const H3270 *hSession, const LIB3270_ACTION_GROUP group); | |
| 76 | 86 | |
| 77 | 87 | /** |
| 78 | 88 | * @brief Register an action group listener. | ... | ... |