Commit d144f89f7f6708e451ae0f303446044b190077e1
1 parent
84d8d202
Exists in
master
and in
1 other branch
Updating print dialog.
Showing
3 changed files
with
51 additions
and
18 deletions
Show diff stats
src/dialogs/print/print.c
| @@ -136,14 +136,23 @@ | @@ -136,14 +136,23 @@ | ||
| 136 | 136 | ||
| 137 | V3270PrintOperation * operation = GTK_V3270_PRINT_OPERATION(object); | 137 | V3270PrintOperation * operation = GTK_V3270_PRINT_OPERATION(object); |
| 138 | 138 | ||
| 139 | - if(operation->contents.text) | ||
| 140 | - g_strfreev(operation->contents.text); | ||
| 141 | - | ||
| 142 | if(operation->font.info.scaled) | 139 | if(operation->font.info.scaled) |
| 143 | cairo_scaled_font_destroy(operation->font.info.scaled); | 140 | cairo_scaled_font_destroy(operation->font.info.scaled); |
| 144 | 141 | ||
| 145 | g_free(operation->font.name); | 142 | g_free(operation->font.name); |
| 146 | 143 | ||
| 144 | + if(operation->contents.text) | ||
| 145 | + { | ||
| 146 | + size_t row; | ||
| 147 | + | ||
| 148 | + for(row = 0; operation->contents.text[row]; row++) | ||
| 149 | + { | ||
| 150 | + g_free(operation->contents.text[row]); | ||
| 151 | + } | ||
| 152 | + g_free(operation->contents.text); | ||
| 153 | + | ||
| 154 | + } | ||
| 155 | + | ||
| 147 | } | 156 | } |
| 148 | 157 | ||
| 149 | static void V3270PrintOperation_class_init(V3270PrintOperationClass *klass) | 158 | static void V3270PrintOperation_class_init(V3270PrintOperationClass *klass) |
| @@ -191,7 +200,7 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT | @@ -191,7 +200,7 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT | ||
| 191 | operation->widget = GTK_V3270(widget); | 200 | operation->widget = GTK_V3270(widget); |
| 192 | operation->session = v3270_get_session(widget); | 201 | operation->session = v3270_get_session(widget); |
| 193 | 202 | ||
| 194 | - V3270PrintOperation_set_mode(operation, mode); | 203 | + V3270PrintOperation_set_text_by_mode(operation, mode); |
| 195 | 204 | ||
| 196 | return operation; | 205 | return operation; |
| 197 | } | 206 | } |
| @@ -223,16 +232,33 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT | @@ -223,16 +232,33 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT | ||
| 223 | v3270_print(widget,LIB3270_PRINT_COPY); | 232 | v3270_print(widget,LIB3270_PRINT_COPY); |
| 224 | } | 233 | } |
| 225 | 234 | ||
| 226 | - void V3270PrintOperation_set_mode(V3270PrintOperation * operation, LIB3270_PRINT_MODE mode) | 235 | + void V3270PrintOperation_set_text_by_mode(V3270PrintOperation * operation, LIB3270_PRINT_MODE mode) |
| 227 | { | 236 | { |
| 228 | operation->mode = mode; | 237 | operation->mode = mode; |
| 229 | 238 | ||
| 230 | - // Text rectangle (in characters). | ||
| 231 | switch(mode) | 239 | switch(mode) |
| 232 | { | 240 | { |
| 233 | case LIB3270_PRINT_ALL: | 241 | case LIB3270_PRINT_ALL: |
| 234 | - operation->contents.height = lib3270_get_height(operation->session); | ||
| 235 | - operation->contents.width = lib3270_get_width(operation->session); | 242 | + { |
| 243 | + size_t row, col; | ||
| 244 | + int baddr = 0; | ||
| 245 | + column * text; | ||
| 246 | + | ||
| 247 | + operation->contents.height = lib3270_get_height(operation->session); | ||
| 248 | + operation->contents.width = lib3270_get_width(operation->session); | ||
| 249 | + | ||
| 250 | + operation->contents.text = g_new0(column *, operation->contents.height+1); | ||
| 251 | + | ||
| 252 | + for(row = 0; row < operation->contents.height; row++) | ||
| 253 | + { | ||
| 254 | + operation->contents.text[row] = text = g_new0(column, operation->contents.width); | ||
| 255 | + for(col = 0; col < operation->contents.width; col++) | ||
| 256 | + { | ||
| 257 | + lib3270_get_element(operation->session,baddr++,&text[col].c,&text[col].attr); | ||
| 258 | + } | ||
| 259 | + } | ||
| 260 | + | ||
| 261 | + } | ||
| 236 | break; | 262 | break; |
| 237 | 263 | ||
| 238 | case LIB3270_PRINT_SELECTED: | 264 | case LIB3270_PRINT_SELECTED: |
| @@ -260,28 +286,29 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT | @@ -260,28 +286,29 @@ V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT | ||
| 260 | } | 286 | } |
| 261 | } | 287 | } |
| 262 | 288 | ||
| 263 | - operation->contents.height = rect.height; | ||
| 264 | - operation->contents.width = rect.width; | 289 | + operation->contents.height = rect.height - rect.y; |
| 290 | + operation->contents.width = rect.width - rect.x; | ||
| 265 | 291 | ||
| 266 | } | 292 | } |
| 267 | break; | 293 | break; |
| 268 | 294 | ||
| 269 | case LIB3270_PRINT_COPY: | 295 | case LIB3270_PRINT_COPY: |
| 270 | { | 296 | { |
| 271 | - lib3270_autoptr(char) text = v3270_get_copy(GTK_WIDGET(operation->widget)); | ||
| 272 | - if(text) | 297 | + lib3270_autoptr(char) copy = v3270_get_copy(GTK_WIDGET(operation->widget)); |
| 298 | + if(copy) | ||
| 273 | { | 299 | { |
| 274 | size_t r; | 300 | size_t r; |
| 275 | - | ||
| 276 | - operation->contents.text = g_strsplit(text,"\n",-1); | ||
| 277 | - operation->contents.height = g_strv_length(operation->contents.text); | 301 | + gchar ** text = g_strsplit(copy,"\n",-1); |
| 302 | + operation->contents.height = g_strv_length(text); | ||
| 278 | operation->contents.width = 0; | 303 | operation->contents.width = 0; |
| 279 | 304 | ||
| 280 | for(r=0;r < operation->contents.height;r++) | 305 | for(r=0;r < operation->contents.height;r++) |
| 281 | { | 306 | { |
| 282 | - operation->contents.width = MAX(operation->contents.width,strlen(operation->contents.text[r])); | 307 | + operation->contents.width = MAX(operation->contents.width,strlen(text[r])); |
| 283 | } | 308 | } |
| 284 | 309 | ||
| 310 | + g_strfreev(text); | ||
| 311 | + | ||
| 285 | } | 312 | } |
| 286 | } | 313 | } |
| 287 | break; | 314 | break; |
src/dialogs/print/private.h
| @@ -40,6 +40,12 @@ | @@ -40,6 +40,12 @@ | ||
| 40 | 40 | ||
| 41 | }; | 41 | }; |
| 42 | 42 | ||
| 43 | + typedef struct _column | ||
| 44 | + { | ||
| 45 | + unsigned char c; | ||
| 46 | + unsigned short attr; | ||
| 47 | + } column; | ||
| 48 | + | ||
| 43 | struct _V3270PrintOperation | 49 | struct _V3270PrintOperation |
| 44 | { | 50 | { |
| 45 | GtkPrintOperation parent; | 51 | GtkPrintOperation parent; |
| @@ -55,7 +61,7 @@ | @@ -55,7 +61,7 @@ | ||
| 55 | { | 61 | { |
| 56 | size_t width; ///< @brief Width of the contents (in columns); | 62 | size_t width; ///< @brief Width of the contents (in columns); |
| 57 | size_t height; ///< @brief Height of the contents (in rows); | 63 | size_t height; ///< @brief Height of the contents (in rows); |
| 58 | - gchar **text; ///< @brief Text contents; | 64 | + column **text; ///< @brief Report contents. |
| 59 | } contents; | 65 | } contents; |
| 60 | 66 | ||
| 61 | struct | 67 | struct |
src/include/v3270/print.h
| @@ -52,7 +52,7 @@ | @@ -52,7 +52,7 @@ | ||
| 52 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ | 52 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ |
| 53 | 53 | ||
| 54 | LIB3270_EXPORT V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT_MODE mode); | 54 | LIB3270_EXPORT V3270PrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_PRINT_MODE mode); |
| 55 | - LIB3270_EXPORT void V3270PrintOperation_set_mode(V3270PrintOperation * operation, LIB3270_PRINT_MODE mode); | 55 | + LIB3270_EXPORT void V3270PrintOperation_set_text_by_mode(V3270PrintOperation * operation, LIB3270_PRINT_MODE mode); |
| 56 | 56 | ||
| 57 | LIB3270_EXPORT GtkWidget * v3270_font_selection_new(const gchar *fontname); | 57 | LIB3270_EXPORT GtkWidget * v3270_font_selection_new(const gchar *fontname); |
| 58 | 58 |