Commit 5db3f4951a2b189aacbd533d94b8958f82ea54b6

Authored by perry.werneck@gmail.com
1 parent 9a1f7f93

Comentando globais sem uso

src/include/lib3270.h
... ... @@ -763,14 +763,16 @@
763 763  
764 764 LIB3270_EXPORT void * lib3270_malloc(int len);
765 765 LIB3270_EXPORT void * lib3270_realloc(void *p, int len);
  766 + LIB3270_EXPORT void * lib3270_replace(void **p, void *ptr);
766 767  
767 768 /**
768 769 * Release allocated memory.
769 770 *
770 771 * @param p Memory block to release (can be NULL)
771 772 *
  773 + * @return NULL
772 774 */
773   - LIB3270_EXPORT void lib3270_free(void *p);
  775 + LIB3270_EXPORT void * lib3270_free(void *p);
774 776  
775 777  
776 778 /**
... ...
src/lib3270/actions.c
... ... @@ -134,44 +134,4 @@ check_usage(XtActionProc action, Cardinal nargs, Cardinal nargs_min,
134 134 return -1;
135 135 } */
136 136  
137   -/*
138   - * Wrapper for calling an action internally.
139   - */
140   - /*
141   -void
142   -action_internal(XtActionProc action, enum iaction cause, const char *parm1,
143   - const char *parm2)
144   -{
145   - Cardinal count = 0;
146   - String parms[2];
147   -
148   - // Duplicate the parms, because XtActionProc doesn't grok 'const'.
149   - if (parm1 != CN) {
150   - parms[0] = NewString(parm1);
151   - count++;
152   - if (parm2 != CN) {
153   - parms[1] = NewString(parm2);
154   - count++;
155   - }
156   - }
157   -
158   - ia_cause = cause;
159   - (*action)((Widget) NULL, (XEvent *) NULL,
160   - count ? parms : (String *) NULL,
161   - &count);
162   -
163   - // Free the parm copies.
164   - switch (count) {
165   - case 2:
166   - lib3270_free(parms[1]);
167   - // fall through...
168   - case 1:
169   - lib3270_free(parms[0]);
170   - break;
171   - default:
172   - break;
173   - }
174   -}
175   -*/
176   -
177 137  
... ...
src/lib3270/ctlrc.h
... ... @@ -78,6 +78,8 @@ enum dbcs_state {
78 78 #define IS_LEFT(d) ((d) == DBCS_LEFT || (d) == DBCS_LEFT_WRAP)
79 79 #define IS_RIGHT(d) ((d) == DBCS_RIGHT || (d) == DBCS_RIGHT_WRAP)
80 80 #define IS_DBCS(d) (IS_LEFT(d) || IS_RIGHT(d))
  81 +
  82 +/*
81 83 #define MAKE_LEFT(b) { \
82 84 if (((b) % COLS) == ((ROWS * COLS) - 1)) \
83 85 ea_buf[(b)].db = DBCS_LEFT_WRAP; \
... ... @@ -90,6 +92,8 @@ enum dbcs_state {
90 92 else \
91 93 ea_buf[(b)].db = DBCS_RIGHT; \
92 94 }
  95 +*/
  96 +
93 97 #define SOSI(c) (((c) == EBC_so)? EBC_si: EBC_so)
94 98  
95 99 enum dbcs_why { DBCS_FIELD, DBCS_SUBFIELD, DBCS_ATTRIBUTE };
... ...
src/lib3270/globals.h
... ... @@ -106,7 +106,6 @@
106 106 * Prerequisite #includes.
107 107 */
108 108 #include <stdio.h> /* Unix standard I/O library */
109   -// #include <stdlib.h> /* Other Unix library functions */
110 109 #include <unistd.h> /* Unix system calls */
111 110 #include <ctype.h> /* Character classes */
112 111 #include <string.h> /* String manipulations */
... ... @@ -123,33 +122,11 @@
123 122 #undef X3270_MENUS
124 123 #endif /*]*/
125 124  
126   -/* Local process (-e) header files. */ /*
127   -#if defined(X3270_LOCAL_PROCESS) && defined(HAVE_LIBUTIL)
128   - #define LOCAL_PROCESS 1
129   - #include <termios.h>
130   -
131   - #if defined(HAVE_PTY_H)
132   - #include <pty.h>
133   - #endif
134   -
135   - #if defined(HAVE_LIBUTIL_H)
136   - #include <libutil.h>
137   - #endif
138   -
139   - #if defined(HAVE_UTIL_H)
140   - #include <util.h>
141   - #endif
142   -#endif
143   -*/
144   -
145 125 /* Functions we may need to supply. */
146 126 #if defined(NEED_STRTOK_R) /*[*/
147 127 extern char *strtok_r(char *str, const char *sep, char **last);
148 128 #endif /*]*/
149 129  
150   -/* Stop conflicting with curses' COLS, even if we don't link with it. */
151   -// #define COLS cCOLS
152   -
153 130 #define CHECK_SESSION_HANDLE(x) if(!x) x = &h3270;
154 131  
155 132  
... ... @@ -162,9 +139,10 @@ enum iaction {
162 139 IA_IDLE
163 140 };
164 141  
165   -LIB3270_INTERNAL int COLS;
166   -LIB3270_INTERNAL int ROWS;
167   -extern H3270 h3270;
  142 +// LIB3270_INTERNAL int COLS;
  143 +// LIB3270_INTERNAL int ROWS;
  144 +
  145 +LIB3270_INTERNAL H3270 h3270;
168 146  
169 147 #if defined(X3270_DISPLAY) /*[*/
170 148 LIB3270_INTERNAL Atom a_3270, a_registry, a_encoding;
... ... @@ -232,14 +210,14 @@ LIB3270_INTERNAL Boolean exiting;
232 210 // LIB3270_INTERNAL int maxROWS;
233 211 // LIB3270_INTERNAL char *model_name;
234 212 // LIB3270_INTERNAL int model_num;
235   -LIB3270_INTERNAL Boolean no_login_host;
236   -LIB3270_INTERNAL Boolean non_tn3270e_host;
  213 +// LIB3270_INTERNAL Boolean no_login_host;
  214 +// LIB3270_INTERNAL Boolean non_tn3270e_host;
237 215 // LIB3270_INTERNAL int ov_cols, ov_rows;
238   - LIB3270_INTERNAL Boolean passthru_host;
239   -extern const char *programname;
240   -LIB3270_INTERNAL char *qualified_host;
241   -LIB3270_INTERNAL char *reconnect_host;
242   -LIB3270_INTERNAL int screen_depth;
  216 +// LIB3270_INTERNAL Boolean passthru_host;
  217 +// extern const char *programname;
  218 +// LIB3270_INTERNAL char *qualified_host;
  219 +// LIB3270_INTERNAL char *reconnect_host;
  220 +// LIB3270_INTERNAL int screen_depth;
243 221 LIB3270_INTERNAL Boolean scroll_initted;
244 222  
245 223 //#if defined(HAVE_LIBSSL) /*[*/
... ... @@ -247,13 +225,13 @@ LIB3270_INTERNAL Boolean scroll_initted;
247 225 //#endif /*]*/
248 226  
249 227 LIB3270_INTERNAL Boolean shifted;
250   -LIB3270_INTERNAL Boolean ssl_host;
  228 +// LIB3270_INTERNAL Boolean ssl_host;
251 229 LIB3270_INTERNAL Boolean *standard_font;
252   -LIB3270_INTERNAL Boolean std_ds_host;
253   -LIB3270_INTERNAL char *termtype;
254   -LIB3270_INTERNAL Widget toplevel;
  230 +// LIB3270_INTERNAL Boolean std_ds_host;
  231 +// LIB3270_INTERNAL char *termtype;
  232 +// LIB3270_INTERNAL Widget toplevel;
255 233 // LIB3270_INTERNAL Boolean visible_control;
256   -LIB3270_INTERNAL int *xtra_width;
  234 +// LIB3270_INTERNAL int *xtra_width;
257 235  
258 236 /*
259 237 #if defined(X3270_DISPLAY)
... ... @@ -318,7 +296,7 @@ LIB3270_INTERNAL struct trans_list *trans_list;
318 296  
319 297 #define CN ((char *) NULL)
320 298 #define PN ((XtPointer) NULL)
321   -#define Replace(var, value) { lib3270_free(var); var = (value); }
  299 +#define Replace(var, value) { lib3270_free(var); var = (value); };
322 300  
323 301 /* Configuration change masks. */
324 302 #define NO_CHANGE 0x0000 /* no change */
... ...
src/lib3270/util.c
... ... @@ -880,10 +880,11 @@ rpf_free(rpf_t *r)
880 880 r->cur_len = 0;
881 881 }
882 882  
883   -LIB3270_EXPORT void lib3270_free(void *p)
  883 +LIB3270_EXPORT void * lib3270_free(void *p)
884 884 {
885 885 if(p)
886 886 free(p);
  887 + return NULL;
887 888 }
888 889  
889 890 LIB3270_EXPORT void * lib3270_realloc(void *p, int len)
... ...
src/pw3270/print.c
... ... @@ -49,12 +49,15 @@
49 49 int rows;
50 50 int cols;
51 51 int pages;
  52 + int lpp; /**< Lines per page */
52 53 cairo_font_extents_t extents;
53 54 double left;
54   - double width;
55   - double height;
  55 + double width; /**< Report width */
  56 + double height; /**< Report height (all pages) */
56 57 cairo_scaled_font_t * font_scaled;
57 58  
  59 + gchar **text;
  60 +
58 61 } PRINT_INFO;
59 62  
60 63 /*--[ Implement ]------------------------------------------------------------------------------------*/
... ... @@ -83,10 +86,16 @@
83 86 static void begin_print(GtkPrintOperation *prt, GtkPrintContext *context, PRINT_INFO *info)
84 87 {
85 88 setup_font(context,info);
86   - gtk_print_operation_set_n_pages(prt,1);
  89 +
  90 + info->lpp = (gtk_print_context_get_height(context) / (info->extents.height + info->extents.descent));
  91 + info->pages = (info->rows / info->lpp)+1;
  92 +
  93 + trace("%d lines per page, %d pages to print",info->lpp,info->pages);
  94 +
  95 + gtk_print_operation_set_n_pages(prt,info->pages);
87 96 }
88 97  
89   - static void draw_page(GtkPrintOperation *prt, GtkPrintContext *context, gint pg, PRINT_INFO *info)
  98 + static void draw_screen(GtkPrintOperation *prt, GtkPrintContext *context, gint pg, PRINT_INFO *info)
90 99 {
91 100 int row;
92 101 int col;
... ... @@ -101,6 +110,7 @@
101 110 rect.height = (info->extents.height + info->extents.descent);
102 111 rect.width = info->extents.max_x_advance;
103 112  
  113 + // Clear page
104 114 gdk_cairo_set_source_color(cr,info->color+V3270_COLOR_BACKGROUND);
105 115 cairo_rectangle(cr, info->left-2, 0, (rect.width*info->cols)+4, (rect.height*info->rows)+4);
106 116 cairo_fill(cr);
... ... @@ -244,6 +254,9 @@ static gchar * enum_to_string(GType type, guint enum_value)
244 254 if(info->font)
245 255 g_free(info->font);
246 256  
  257 + if(info->text)
  258 + g_strfreev(info->text);
  259 +
247 260 g_free(info);
248 261 }
249 262  
... ... @@ -478,13 +491,15 @@ static gchar * enum_to_string(GType type, guint enum_value)
478 491 PRINT_INFO * info = NULL;
479 492 GtkPrintOperation * print = begin_print_operation(action,widget,&info);
480 493  
481   - trace("Action %s activated on widget %p print=%p",gtk_action_get_name(action),widget,print);
  494 + #ifdef X3270_TRACE
  495 + lib3270_trace_event(NULL,"Action %s activated on widget %p\n",gtk_action_get_name(action),widget);
  496 + #endif
482 497  
483 498 lib3270_get_screen_size(info->session,&info->rows,&info->cols);
484 499  
485 500 info->all = 1;
486 501 g_signal_connect(print,"begin_print",G_CALLBACK(begin_print),info);
487   - g_signal_connect(print,"draw_page",G_CALLBACK(draw_page),info);
  502 + g_signal_connect(print,"draw_page",G_CALLBACK(draw_screen),info);
488 503  
489 504 // Run Print dialog
490 505 gtk_print_operation_run(print,GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,GTK_WINDOW(gtk_widget_get_toplevel(widget)),NULL);
... ... @@ -499,7 +514,9 @@ static gchar * enum_to_string(GType type, guint enum_value)
499 514 int start, end, rows;
500 515 GtkPrintOperation * print = begin_print_operation(action,widget,&info);;
501 516  
502   - trace("Action %s activated on widget %p",gtk_action_get_name(action),widget);
  517 + #ifdef X3270_TRACE
  518 + lib3270_trace_event(NULL,"Action %s activated on widget %p\n",gtk_action_get_name(action),widget);
  519 + #endif
503 520  
504 521 if(!lib3270_get_selection_bounds(info->session,&start,&end))
505 522 {
... ... @@ -517,18 +534,55 @@ static gchar * enum_to_string(GType type, guint enum_value)
517 534  
518 535 info->all = 0;
519 536 g_signal_connect(print,"begin_print",G_CALLBACK(begin_print),info);
520   - g_signal_connect(print,"draw_page",G_CALLBACK(draw_page),info);
  537 + g_signal_connect(print,"draw_page",G_CALLBACK(draw_screen),info);
521 538  
522 539 // Run Print dialog
523 540 gtk_print_operation_run(print,GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,GTK_WINDOW(gtk_widget_get_toplevel(widget)),NULL);
524 541  
525   -
526 542 g_object_unref(print);
527 543 }
528 544  
  545 + static void draw_text(GtkPrintOperation *prt, GtkPrintContext *context, gint pg, PRINT_INFO *info)
  546 + {
  547 + cairo_t * cr = gtk_print_context_get_cairo_context(context);
  548 +
  549 + cairo_set_scaled_font(cr,info->font_scaled);
  550 +
  551 +
  552 +
  553 + }
  554 +
529 555 void print_copy_action(GtkAction *action, GtkWidget *widget)
530 556 {
531   - trace("Action %s activated on widget %p",gtk_action_get_name(action),widget);
  557 + PRINT_INFO * info = NULL;
  558 + GtkPrintOperation * print;
  559 + const gchar * text = v3270_get_copy(widget);
  560 + int r;
  561 +
  562 + #ifdef X3270_TRACE
  563 + lib3270_trace_event(NULL,"Action %s activated on widget %p\n",gtk_action_get_name(action),widget);
  564 + #endif
  565 +
  566 + if(!text)
  567 + return;
  568 +
  569 + print = begin_print_operation(action,widget,&info);
  570 + info->text = g_strsplit(text,"\n",-1);
  571 + info->rows = g_strv_length(info->text);
  572 +
  573 + for(r=0;r < info->rows;r++)
  574 + {
  575 + size_t sz = strlen(info->text[r]);
  576 + if(sz > info->cols)
  577 + info->cols = sz;
  578 + }
  579 +
  580 + g_signal_connect(print,"begin_print",G_CALLBACK(begin_print),info);
  581 + g_signal_connect(print,"draw_page",G_CALLBACK(draw_text),info);
532 582  
  583 + // Run Print dialog
  584 + gtk_print_operation_run(print,GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,GTK_WINDOW(gtk_widget_get_toplevel(widget)),NULL);
  585 +
  586 + g_object_unref(print);
533 587 }
534 588  
... ...