Commit 3414cdc23c5d734690abb864232860cf6c05dc53
1 parent
a6878485
Exists in
master
and in
5 other branches
Incluindo ícone extra no indicador de SSL quando a conexão não está assinada
Showing
2 changed files
with
42 additions
and
31 deletions
Show diff stats
src/pw3270/v3270/oia.c
... | ... | @@ -53,6 +53,7 @@ static void draw_cursor_position(cairo_t *cr, GdkRectangle *rect, struct v3270_m |
53 | 53 | #include "locked.xbm" |
54 | 54 | #include "unlocked.xbm" |
55 | 55 | #include "negotiated.xbm" |
56 | + #include "warning.xbm" | |
56 | 57 | |
57 | 58 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
58 | 59 | |
... | ... | @@ -306,15 +307,29 @@ void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metri |
306 | 307 | |
307 | 308 | } |
308 | 309 | |
309 | -void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect) | |
310 | +static void draw_xbm(cairo_t *cr, GdkRectangle *rect, int width, int height, unsigned char *bits) | |
310 | 311 | { |
311 | - cairo_surface_t * icon; | |
312 | - double sz = rect->width < rect->height ? rect->width : rect->height; | |
313 | -// int idx = 0; // lib3270_get_ssl_state(host) ? 1 : 0; | |
314 | - unsigned short width; | |
315 | - unsigned short height; | |
316 | - unsigned char * bits; | |
312 | + double sz = rect->width < rect->height ? rect->width : rect->height; | |
313 | + cairo_surface_t * icon = cairo_image_surface_create_for_data( | |
314 | + bits, | |
315 | + CAIRO_FORMAT_A1, | |
316 | + width,height, | |
317 | + cairo_format_stride_for_width(CAIRO_FORMAT_A1,width)); | |
318 | + | |
319 | + cairo_save(cr); | |
320 | + | |
321 | + cairo_scale(cr, sz / ((double) width), | |
322 | + sz / ((double) height)); | |
323 | + | |
324 | + cairo_mask_surface(cr,icon,(rect->width-sz)/2,(rect->height-sz)/2); | |
325 | + | |
326 | + cairo_surface_destroy(icon); | |
327 | + | |
328 | + cairo_restore(cr); | |
329 | +} | |
317 | 330 | |
331 | +void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect) | |
332 | +{ | |
318 | 333 | #ifdef DEBUG |
319 | 334 | cairo_set_source_rgb(cr,0.1,0.1,0.1); |
320 | 335 | #else |
... | ... | @@ -322,7 +337,6 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri |
322 | 337 | #endif |
323 | 338 | |
324 | 339 | cairo_translate(cr, rect->x, rect->y); |
325 | - | |
326 | 340 | cairo_rectangle(cr, 0, 0, rect->width, rect->height); |
327 | 341 | cairo_fill(cr); |
328 | 342 | |
... | ... | @@ -330,30 +344,24 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri |
330 | 344 | { |
331 | 345 | case LIB3270_SSL_UNSECURE: /**< No secure connection */ |
332 | 346 | gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_FOREGROUND); |
333 | - width = unlocked_width; | |
334 | - height = unlocked_height; | |
335 | - bits = (unsigned char *) unlocked_bits; | |
347 | + draw_xbm(cr,rect,unlocked_width,unlocked_height,unlocked_bits); | |
336 | 348 | break; |
337 | 349 | |
338 | 350 | case LIB3270_SSL_NEGOTIATING: /**< Negotiating SSL */ |
339 | 351 | gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_WARNING); |
340 | - width = unlocked_width; | |
341 | - height = unlocked_height; | |
342 | - bits = (unsigned char *) unlocked_bits; | |
352 | + draw_xbm(cr,rect,unlocked_width,unlocked_height,unlocked_bits); | |
343 | 353 | break; |
344 | 354 | |
345 | 355 | case LIB3270_SSL_NEGOTIATED: /**< Connection secure, no CA or self-signed */ |
356 | + gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_OK); | |
357 | + draw_xbm(cr,rect,negotiated_width,negotiated_height,negotiated_bits); | |
346 | 358 | gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_WARNING); |
347 | - width = negotiated_width; | |
348 | - height = negotiated_height; | |
349 | - bits = (unsigned char *) negotiated_bits; | |
359 | + draw_xbm(cr,rect,warning_width,warning_height,warning_bits); | |
350 | 360 | break; |
351 | 361 | |
352 | 362 | case LIB3270_SSL_SECURE: /**< Connection secure with CA check */ |
353 | 363 | gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_OK); |
354 | - width = locked_width; | |
355 | - height = locked_height; | |
356 | - bits = (unsigned char *) locked_bits; | |
364 | + draw_xbm(cr,rect,locked_width,locked_height,locked_bits); | |
357 | 365 | break; |
358 | 366 | |
359 | 367 | default: |
... | ... | @@ -361,17 +369,6 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri |
361 | 369 | |
362 | 370 | } |
363 | 371 | |
364 | - icon = cairo_image_surface_create_for_data( bits, | |
365 | - CAIRO_FORMAT_A1, | |
366 | - width,height, | |
367 | - cairo_format_stride_for_width(CAIRO_FORMAT_A1,locked_width)); | |
368 | - | |
369 | - cairo_scale(cr, sz / ((double) width), | |
370 | - sz / ((double) height)); | |
371 | - | |
372 | - cairo_mask_surface(cr,icon,(rect->width-sz)/2,(rect->height-sz)/2); | |
373 | - | |
374 | - cairo_surface_destroy(icon); | |
375 | 372 | |
376 | 373 | } |
377 | 374 | ... | ... |
... | ... | @@ -0,0 +1,14 @@ |
1 | +#define warning_width 32 | |
2 | +#define warning_height 32 | |
3 | +static unsigned char warning_bits[] = { | |
4 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
5 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
6 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
7 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0xe0, 0x00, | |
8 | + 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0xf0, 0x01, | |
9 | + 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0xfc, 0x07, | |
10 | + 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, 0xfe, 0x0f, | |
11 | + 0x00, 0x00, 0xff, 0x1f, 0x00, 0x00, 0xff, 0x1f, 0x00, 0x80, 0xff, 0x3f, | |
12 | + 0x00, 0x80, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
13 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
14 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ... | ... |