Commit 36c9ac2af9df210d2caadfb98f71f1bd0eaf9121

Authored by Perry Werneck
1 parent 1985106c

Adding new action group for clipboard content availability.

Exporting action group notifier for use by the v3270 widget.
src/core/actions/actions.c
... ... @@ -105,7 +105,7 @@ LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name)
105 105 return lib3270_action_activate_by_name(name,hSession);
106 106 }
107 107  
108   -LIB3270_INTERNAL void lib3270_notify_actions(H3270 *hSession, LIB3270_ACTION_GROUP group)
  108 +LIB3270_EXPORT void lib3270_action_group_notify(H3270 *hSession, LIB3270_ACTION_GROUP group)
109 109 {
110 110  
111 111 if(group < (sizeof(hSession->listeners.actions)/sizeof(hSession->listeners.actions[0])))
... ...
src/core/actions/table.c
... ... @@ -687,7 +687,7 @@
687 687 .summary = N_("Print copy (if available)"),
688 688 .activate = lib3270_print_copy,
689 689  
690   - .group = LIB3270_ACTION_GROUP_ONLINE,
  690 + .group = LIB3270_ACTION_GROUP_COPY,
691 691 .activatable = lib3270_is_connected
692 692 },
693 693  
... ...
src/core/ctlr.c
... ... @@ -249,7 +249,7 @@ static void set_formatted(H3270 *hSession, int state)
249 249 if(state != hSession->formatted)
250 250 {
251 251 hSession->formatted = state;
252   - lib3270_notify_actions(hSession, LIB3270_ACTION_GROUP_LOCK_STATE);
  252 + lib3270_action_group_notify(hSession, LIB3270_ACTION_GROUP_LOCK_STATE);
253 253 }
254 254 }
255 255  
... ...
src/core/host.c
... ... @@ -138,12 +138,12 @@ int lib3270_set_cstate(H3270 *hSession, LIB3270_CSTATE cstate)
138 138  
139 139 if(connected != lib3270_is_connected(hSession)) {
140 140 // Online state has changed, fire LIB3270_ACTION_GROUP_ONLINE
141   - lib3270_notify_actions(hSession, LIB3270_ACTION_GROUP_ONLINE);
  141 + lib3270_action_group_notify(hSession, LIB3270_ACTION_GROUP_ONLINE);
142 142 }
143 143  
144 144 if(disconnected != lib3270_is_disconnected(hSession)) {
145 145 // Offline state has changed, fire LIB3270_ACTION_GROUP_OFFLINE
146   - lib3270_notify_actions(hSession, LIB3270_ACTION_GROUP_OFFLINE);
  146 + lib3270_action_group_notify(hSession, LIB3270_ACTION_GROUP_OFFLINE);
147 147 }
148 148  
149 149 return 1;
... ...
src/core/paste.c
... ... @@ -406,6 +406,7 @@ LIB3270_EXPORT int lib3270_paste_text(H3270 *hSession, const unsigned char *str)
406 406 if((int) strlen((char *) str) > sz)
407 407 {
408 408 hSession->paste_buffer = strdup((char *) (str+sz));
  409 + lib3270_action_group_notify(hSession, LIB3270_ACTION_GROUP_COPY);
409 410 return strlen(hSession->paste_buffer);
410 411 }
411 412  
... ... @@ -431,5 +432,9 @@ LIB3270_EXPORT int lib3270_paste_next(H3270 *hSession)
431 432 rc = lib3270_paste_text(hSession,(unsigned char *) ptr);
432 433  
433 434 lib3270_free(ptr);
  435 +
  436 + if(!hSession->paste_buffer)
  437 + lib3270_action_group_notify(hSession, LIB3270_ACTION_GROUP_COPY);
  438 +
434 439 return rc;
435 440 }
... ...
src/core/screen.c
... ... @@ -839,7 +839,7 @@ void mcursor_set(H3270 *hSession,LIB3270_POINTER m)
839 839 hSession->cbk.cursor(hSession,m & 0x03);
840 840  
841 841 // Notify lock state change.
842   - lib3270_notify_actions(hSession, LIB3270_ACTION_GROUP_FORMATTED);
  842 + lib3270_action_group_notify(hSession, LIB3270_ACTION_GROUP_FORMATTED);
843 843  
844 844 }
845 845 }
... ...
src/include/internals.h
... ... @@ -877,5 +877,3 @@ LIB3270_INTERNAL int non_blocking(H3270 *session, Boolean on);
877 877 /// @brief Fire CState change.
878 878 LIB3270_INTERNAL int lib3270_set_cstate(H3270 *hSession, LIB3270_CSTATE cstate);
879 879  
880   - /// @brief Notify actions.
881   - LIB3270_INTERNAL void lib3270_notify_actions(H3270 *hSession, LIB3270_ACTION_GROUP group);
... ...
src/include/lib3270.h
... ... @@ -368,6 +368,7 @@
368 368 LIB3270_ACTION_GROUP_SELECTION, ///< @brief Action depends on selection.
369 369 LIB3270_ACTION_GROUP_LOCK_STATE, ///< @brief Action depends on keyboard lock state.
370 370 LIB3270_ACTION_GROUP_FORMATTED, ///< @brief Action depends on a formatted screen.
  371 + LIB3270_ACTION_GROUP_COPY, ///< @brief Action depends on stored string.
371 372  
372 373 LIB3270_ACTION_GROUP_CUSTOM ///< @brief Custom group/Number of groups.
373 374 } LIB3270_ACTION_GROUP;
... ... @@ -1627,6 +1628,12 @@
1627 1628 */
1628 1629 LIB3270_EXPORT int lib3270_wait_for_string_at_address(H3270 *hSession, int baddr, const char *key, int seconds);
1629 1630  
  1631 + /**
  1632 + * @brief Notify action group.
  1633 + *
  1634 + */
  1635 + LIB3270_EXPORT void lib3270_action_group_notify(H3270 *hSession, LIB3270_ACTION_GROUP group);
  1636 +
1630 1637 #ifdef __cplusplus
1631 1638 }
1632 1639 #endif
... ...
src/selection/actions.c
... ... @@ -64,7 +64,7 @@ LIB3270_EXPORT int lib3270_unselect(H3270 *hSession)
64 64 hSession->cbk.set_selection(hSession,0);
65 65 hSession->cbk.update_selection(hSession,-1,-1);
66 66  
67   - lib3270_notify_actions(hSession,LIB3270_ACTION_GROUP_SELECTION);
  67 + lib3270_action_group_notify(hSession,LIB3270_ACTION_GROUP_SELECTION);
68 68  
69 69 }
70 70  
... ...
src/selection/selection.c
... ... @@ -193,7 +193,7 @@ void do_select(H3270 *hSession, unsigned int start, unsigned int end, unsigned i
193 193 {
194 194 hSession->selected = 1;
195 195 hSession->cbk.set_selection(hSession,1);
196   - lib3270_notify_actions(hSession,LIB3270_ACTION_GROUP_SELECTION);
  196 + lib3270_action_group_notify(hSession,LIB3270_ACTION_GROUP_SELECTION);
197 197 }
198 198  
199 199 hSession->cbk.update_selection(hSession,start,end);
... ...
src/testprogram/testprogram.c
... ... @@ -36,15 +36,6 @@ static void online_group_state_changed(H3270 GNUC_UNUSED(*hSession), void GNUC_U
36 36 int main(int argc, char *argv[])
37 37 {
38 38  
39   - {
40   - LIB3270_ICONV *converter = lib3270_iconv_new("iso-8859-1","utf-8");
41   -
42   - lib3270_autoptr(char) text = lib3270_iconv_to_host(converter,"teste",-1);
43   -
44   - lib3270_iconv_free(converter);
45   - return 0;
46   - }
47   -
48 39 // #pragma GCC diagnostic push
49 40 // #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
50 41 static struct option options[] = {
... ...