Commit c051366cf31f31f4a028fa94542462d618c8d486

Authored by Perry Werneck
1 parent 6c5ac017

Adding signals for save/print copy actions.

src/core/actions/table.c
@@ -39,27 +39,6 @@ @@ -39,27 +39,6 @@
39 39
40 /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ 40 /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
41 41
42 - /*  
43 - static int save_all(H3270 *hSession)  
44 - {  
45 - return lib3270_save_all(hSession,NULL);  
46 - }  
47 - */  
48 -  
49 - /*  
50 - static int save_selected(H3270 *hSession)  
51 - {  
52 - return lib3270_save_selected(hSession,NULL);  
53 - }  
54 - */  
55 -  
56 - /*  
57 - static int save_copy(H3270 *hSession)  
58 - {  
59 - return lib3270_save_copy(hSession,NULL);  
60 - }  
61 - */  
62 -  
63 static int paste_file(H3270 *hSession) 42 static int paste_file(H3270 *hSession)
64 { 43 {
65 return lib3270_load(hSession,NULL); 44 return lib3270_load(hSession,NULL);
@@ -211,55 +190,6 @@ @@ -211,55 +190,6 @@
211 .activatable = lib3270_is_connected 190 .activatable = lib3270_is_connected
212 }, 191 },
213 192
214 - /*  
215 -  
216 - No need here; this actions are better when implemented on the widget or main application.  
217 - //  
218 - // Save/load actions  
219 - //  
220 - {  
221 - .name = "save-all",  
222 - .type = LIB3270_ACTION_TYPE_FILE,  
223 -  
224 - .keys = NULL,  
225 - .icon = "document-save",  
226 - .label = NULL,  
227 - .summary = N_( "Save screen to file" ),  
228 - .activate = save_all,  
229 -  
230 - .group = LIB3270_ACTION_GROUP_ONLINE,  
231 - .activatable = lib3270_is_connected  
232 - },  
233 -  
234 - {  
235 - .name = "save-selected",  
236 - .type = LIB3270_ACTION_TYPE_FILE,  
237 -  
238 - .keys = NULL,  
239 - .icon = "document-save",  
240 - .label = NULL,  
241 - .summary = N_( "Save selected area to file" ),  
242 - .activate = save_selected,  
243 -  
244 - .group = LIB3270_ACTION_GROUP_SELECTION,  
245 - .activatable = lib3270_has_selection  
246 - },  
247 -  
248 - {  
249 - .name = "save-copy",  
250 - .type = LIB3270_ACTION_TYPE_FILE,  
251 -  
252 - .keys = NULL,  
253 - .icon = "document-save",  
254 - .label = NULL,  
255 - .summary = NULL,  
256 - .activate = save_copy,  
257 -  
258 - .group = LIB3270_ACTION_GROUP_ONLINE,  
259 - .activatable = lib3270_is_connected  
260 - },  
261 - */  
262 -  
263 { 193 {
264 .name = "paste-from-file", 194 .name = "paste-from-file",
265 .type = LIB3270_ACTION_TYPE_FILE, 195 .type = LIB3270_ACTION_TYPE_FILE,
@@ -642,71 +572,6 @@ @@ -642,71 +572,6 @@
642 }, 572 },
643 573
644 // 574 //
645 - // Misc actions  
646 - //  
647 - /*  
648 -  
649 - No need here; this actions are better when implemented on the widget or main application.  
650 -  
651 - {  
652 - .name = "print",  
653 - .type = LIB3270_ACTION_TYPE_PRINTER,  
654 -  
655 - .keys = "Print",  
656 - .icon = "document-print",  
657 - .label = N_("Print"),  
658 - .summary = N_("Send to printer"),  
659 - .description = N_("If the terminal has selected area print it, if not, print all contents"),  
660 - .activate = lib3270_print,  
661 -  
662 - .group = LIB3270_ACTION_GROUP_ONLINE,  
663 - .activatable = lib3270_is_connected  
664 - },  
665 -  
666 - {  
667 - .name = "print-all",  
668 - .type = LIB3270_ACTION_TYPE_PRINTER,  
669 -  
670 - .keys = NULL,  
671 - .icon = "document-print",  
672 - .label = N_("Print screen"),  
673 - .summary = N_("Print screen contents"),  
674 - .activate = lib3270_print_all,  
675 -  
676 - .group = LIB3270_ACTION_GROUP_ONLINE,  
677 - .activatable = lib3270_is_connected  
678 - },  
679 -  
680 - {  
681 - .name = "print-selected",  
682 - .type = LIB3270_ACTION_TYPE_PRINTER,  
683 -  
684 - .keys = NULL,  
685 - .icon = "document-print",  
686 - .label = N_("Print selection"),  
687 - .summary = N_( "Print selected area" ),  
688 - .activate = lib3270_print_selected,  
689 -  
690 - .group = LIB3270_ACTION_GROUP_SELECTION,  
691 - .activatable = lib3270_has_selection  
692 - },  
693 -  
694 - {  
695 - .name = "print-copy",  
696 - .type = LIB3270_ACTION_TYPE_PRINTER,  
697 -  
698 - .keys = NULL,  
699 - .icon = "document-print",  
700 - .label = N_("Print copy"),  
701 - .summary = N_("Print copy (if available)"),  
702 - .activate = lib3270_print_copy,  
703 -  
704 - .group = LIB3270_ACTION_GROUP_COPY,  
705 - .activatable = lib3270_is_connected  
706 - },  
707 - */  
708 -  
709 - //  
710 // Test actions 575 // Test actions
711 // 576 //
712 577
@@ -751,19 +616,18 @@ @@ -751,19 +616,18 @@
751 return hSession == NULL ? 0 : 1; 616 return hSession == NULL ? 0 : 1;
752 } 617 }
753 618
754 - LIB3270_EXPORT int lib3270_action_group_get_activatable(const H3270 *hSession, const LIB3270_ACTION_GROUP group)  
755 - {  
756 - static const struct  
757 - { 619 + LIB3270_EXPORT int lib3270_action_group_get_activatable(const H3270 *hSession, const LIB3270_ACTION_GROUP group) {
  620 +
  621 + static const struct {
758 int (*get)(const H3270 *); 622 int (*get)(const H3270 *);
759 - } activatable[LIB3270_ACTION_CUSTOM] =  
760 - {  
761 - { default_activatable_state }, // LIB3270_ACTION_GROUP_NONE  
762 - { lib3270_is_connected }, // LIB3270_ACTION_GROUP_ONLINE  
763 - { lib3270_is_disconnected }, // LIB3270_ACTION_GROUP_OFFLINE  
764 - { lib3270_has_selection }, // LIB3270_ACTION_GROUP_SELECTION  
765 - { lib3270_is_unlocked }, // LIB3270_ACTION_GROUP_LOCK_STATE  
766 - { lib3270_is_formatted }, // LIB3270_ACTION_GROUP_FORMATTED 623 + } activatable[LIB3270_ACTION_CUSTOM] = {
  624 + { default_activatable_state }, // LIB3270_ACTION_GROUP_NONE
  625 + { lib3270_is_connected }, // LIB3270_ACTION_GROUP_ONLINE
  626 + { lib3270_is_disconnected }, // LIB3270_ACTION_GROUP_OFFLINE
  627 + { lib3270_get_has_selection }, // LIB3270_ACTION_GROUP_SELECTION
  628 + { lib3270_is_unlocked }, // LIB3270_ACTION_GROUP_LOCK_STATE
  629 + { lib3270_is_formatted }, // LIB3270_ACTION_GROUP_FORMATTED
  630 + { lib3270_get_has_copy }, // LIB3270_ACTION_GROUP_COPY
767 }; 631 };
768 632
769 if(group < (sizeof(activatable)/sizeof(activatable[0]))) { 633 if(group < (sizeof(activatable)/sizeof(activatable[0]))) {
src/include/internals.h
@@ -353,6 +353,7 @@ struct _h3270 @@ -353,6 +353,7 @@ struct _h3270
353 LIB3270_HOST_TYPE host_type; ///< @brief Host type. 353 LIB3270_HOST_TYPE host_type; ///< @brief Host type.
354 354
355 int selected : 1; ///< @brief Has selected region? 355 int selected : 1; ///< @brief Has selected region?
  356 + int has_copy : 1; ///< @brief Has copy?
356 int rectsel : 1; ///< @brief Selected region is a rectangle ? 357 int rectsel : 1; ///< @brief Selected region is a rectangle ?
357 int vcontrol : 1; ///< @brief Visible control ? 358 int vcontrol : 1; ///< @brief Visible control ?
358 int modified_sel : 1; 359 int modified_sel : 1;
src/include/lib3270.h
@@ -1162,7 +1162,22 @@ @@ -1162,7 +1162,22 @@
1162 * @return Greater than zero if the terminal has selected area, 0 if not. 1162 * @return Greater than zero if the terminal has selected area, 0 if not.
1163 * 1163 *
1164 */ 1164 */
1165 - LIB3270_EXPORT int lib3270_has_selection(const H3270 *hSession); 1165 + LIB3270_EXPORT int lib3270_get_has_selection(const H3270 *hSession);
  1166 +
  1167 + LIB3270_EXPORT int LIB3270_DEPRECATED(lib3270_has_selection(const H3270 *hSession));
  1168 +
  1169 + /**
  1170 + * @brief Check if the terminal has stored clipboard contents.
  1171 + *
  1172 + * @param hSession Session handle.
  1173 + *
  1174 + * @return Greater than zero if the terminal has copy, 0 if not.
  1175 + *
  1176 + */
  1177 + LIB3270_EXPORT int lib3270_get_has_copy(const H3270 *hSession);
  1178 +
  1179 + LIB3270_EXPORT void lib3270_set_has_copy(H3270 *hSession, int has_copy);
  1180 +
1166 1181
1167 /** 1182 /**
1168 * @brief Get all text inside the terminal. 1183 * @brief Get all text inside the terminal.
src/selection/selection.c
@@ -393,7 +393,7 @@ LIB3270_EXPORT char * lib3270_get_field_string_at(H3270 *session, int baddr) @@ -393,7 +393,7 @@ LIB3270_EXPORT char * lib3270_get_field_string_at(H3270 *session, int baddr)
393 return lib3270_get_string_at_address(session,first,lib3270_field_length(session,first)+1,0); 393 return lib3270_get_string_at_address(session,first,lib3270_field_length(session,first)+1,0);
394 } 394 }
395 395
396 -LIB3270_EXPORT int lib3270_has_selection(const H3270 *hSession) 396 +LIB3270_EXPORT int lib3270_get_has_selection(const H3270 *hSession)
397 { 397 {
398 errno = 0; 398 errno = 0;
399 if(check_online_session(hSession)) 399 if(check_online_session(hSession))
@@ -402,6 +402,26 @@ LIB3270_EXPORT int lib3270_has_selection(const H3270 *hSession) @@ -402,6 +402,26 @@ LIB3270_EXPORT int lib3270_has_selection(const H3270 *hSession)
402 return hSession->selected ? 1 : 0; 402 return hSession->selected ? 1 : 0;
403 } 403 }
404 404
  405 +LIB3270_EXPORT int lib3270_has_selection(const H3270 *hSession) {
  406 + return lib3270_get_has_selection(hSession);
  407 +}
  408 +
  409 +LIB3270_EXPORT int lib3270_get_has_copy(const H3270 *hSession)
  410 +{
  411 + errno = 0;
  412 + if(check_online_session(hSession))
  413 + return 0;
  414 +
  415 + return hSession->has_copy ? 1 : 0;
  416 +}
  417 +
  418 +LIB3270_EXPORT void lib3270_set_has_copy(H3270 *hSession, int has_copy) {
  419 + hSession->has_copy = has_copy ? 1 : 0;
  420 + lib3270_action_group_notify(hSession,LIB3270_ACTION_GROUP_COPY);
  421 +}
  422 +
  423 +
  424 +
405 LIB3270_EXPORT int lib3270_get_selection_rectangle(H3270 *hSession, unsigned int *row, unsigned int *col, unsigned int *width, unsigned int *height) 425 LIB3270_EXPORT int lib3270_get_selection_rectangle(H3270 *hSession, unsigned int *row, unsigned int *col, unsigned int *width, unsigned int *height)
406 { 426 {
407 unsigned int r, c, minRow, minCol, maxRow, maxCol, baddr, count; 427 unsigned int r, c, minRow, minCol, maxRow, maxCol, baddr, count;